Skip to content
Snippets Groups Projects
Commit b7832487 authored by Camille Simiand's avatar Camille Simiand
Browse files

Remove dead code and code improvements

parent 0a7bb6f7
Branches
Tags
1 merge request!32tuleap-50-create-a-capsule-for-an-unexisting-project-in-the-legacy
......@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "b63b0363576a36d88b7d444dc9451ce5",
"content-hash": "9e0fb1d1270499adf1e3618f2c6abf83",
"packages": [
{
"name": "composer/package-versions-deprecated",
......@@ -7204,16 +7204,16 @@
},
{
"name": "symfony/uid",
"version": "v5.3.10",
"version": "v5.3.13",
"source": {
"type": "git",
"url": "https://github.com/symfony/uid.git",
"reference": "183336998e6b28c37ebf04ee18e6359dfb22084d"
"reference": "915b11b94a6a14627234f89696370d2db3e1b43b"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/uid/zipball/183336998e6b28c37ebf04ee18e6359dfb22084d",
"reference": "183336998e6b28c37ebf04ee18e6359dfb22084d",
"url": "https://api.github.com/repos/symfony/uid/zipball/915b11b94a6a14627234f89696370d2db3e1b43b",
"reference": "915b11b94a6a14627234f89696370d2db3e1b43b",
"shasum": ""
},
"require": {
......@@ -7254,10 +7254,11 @@
"homepage": "https://symfony.com",
"keywords": [
"UID",
"ulid",
"uuid"
],
"support": {
"source": "https://github.com/symfony/uid/tree/v5.3.10"
"source": "https://github.com/symfony/uid/tree/v5.3.13"
},
"funding": [
{
......@@ -7273,7 +7274,7 @@
"type": "tidelift"
}
],
"time": "2021-10-15T16:00:52+00:00"
"time": "2021-12-16T21:47:07+00:00"
},
{
"name": "symfony/validator",
......@@ -11964,6 +11965,8 @@
"ext-json": "*",
"ext-zip": "^1.15"
},
"platform-dev": [],
"platform-dev": {
"ext-dom": "*"
},
"plugin-api-version": "2.1.0"
}
......@@ -9,7 +9,7 @@
AllowOverride None
Require all granted
DirectoryIndex index1.php, index.html
DirectoryIndex index.php, index.html
</Directory>
# uncomment the following lines if you install assets as symlinks
......
<?php
// //Créé un projet Rekall
// function createProject($name, $videoUrl, $sha1password) {
// $retours = array("success" => 0, "error" => "", "value" => "");
// $name = sanitize($name);
//
// if($name == "")
// $name = sha1(rand());
//
// if(!file_exists($name)) {
// $zip = new ZipArchive;
// $res = $zip->open("create.zip");
// if ($res === TRUE) {
// $zip->extractTo($name);
// $zip->close();
// file_put_contents($name."/file/project.xml", str_replace("__video__", $videoUrl, file_get_contents($name."/file/project.xml")));
// file_put_contents($name."/file/projectPassword.txt", $sha1password);
// $retours["success"] = 1;
// } else {
// $retours["success"] = -1;
// $retours["error"] = "No seed found";
// }
// }
// else {
// $retours["success"] = 0;
// $retours["error"] = "Project already exists";
// }
// $retours["value"] = $name;
//
// echo json_encode($retours);
// }
//
// if((isset($_POST["create"])) && (isset($_POST["video"])) && (isset($_POST["p"]))) {
// createProject($_POST["create"], $_POST["video"], $_POST["p"]);
// exit();
// }
//?>
<!--<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">-->
<!--<html xmlns="http://www.w3.org/1999/xhtml">-->
<!--<head>-->
<!-- <meta http-equiv="Content-type" content="text/html; charset=UTF-8">-->
<!-- <meta http-equiv="Content-Language" content="fr">-->
<!-- <meta name="language" content="fr">-->
<!-- <meta name="designer" content="buzzing light"> -->
<!-- <meta name="copyright" content="buzzing light">-->
<!-- <meta name="HandheldFriendly" content="true" />-->
<!-- <meta name="viewport" content="width=device-width, user-scalable=no"><!--, minimum-scale=1.0, maximum-scale=1.0-->-->
<!-- <meta name="apple-mobile-web-app-capable" content="yes">-->
<!-- <meta name="apple-mobile-web-app-status-bar-style" content="black">-->
<!---->
<!-- <link rel="apple-touch-icon" href="favicon.png" />-->
<!-- <link rel="stylesheet" type="text/css" href="css/reset.css" />-->
<!---->
<!-- <title>Rekall</title>-->
<!-- -->
<!-- <script language="javascript" type='text/javascript' src='js/jquery.min.js'></script> -->
<!-- <script language="javascript" type='text/javascript' src='js/sha1.js'></script>-->
<!-- <link rel="stylesheet" type="text/css" href="css/create-theme.css" /> -->
<!-- -->
<!-- <script language="javascript" type='text/javascript'>-->
<!-- $(document).ready(function() {-->
<!-- $("#formCreate").submit(function(event) {-->
<!-- event.stopPropagation();-->
<!-- if(($("input[name=create]").val() != "") && ($("input[name=video]").val() != "") /*&& ($("input[name=password]").val() != "")*/) {-->
<!-- var passwordRaw = "000000"; //$("input[name=p]").val();-->
<!-- var password = (CryptoJS.SHA1(passwordRaw) + "").toUpperCase();-->
<!-- $("#submitCreate").hide();-->
<!-- $.ajax("index.php", {-->
<!-- type: "POST",-->
<!-- dataType: "json",-->
<!-- data: {"create": $("input[name=create]").val(), "video": $("input[name=video]").val(), "p": password},-->
<!-- success: function(retour) {-->
<!-- console.log(retour);-->
<!-- if(retour.success == 1) {-->
<!-- window.document.location = document.URL.substr(0,document.URL.lastIndexOf('/')) + "/" + retour.value + "/?p=" + password;-->
<!-- }-->
<!-- else {-->
<!-- alert(retour.error)-->
<!-- $("#submitCreate").show();-->
<!-- }-->
<!-- },-->
<!-- error: function(retour) {-->
<!-- $("#submitCreate").show();-->
<!-- }-->
<!-- }); -->
<!-- }-->
<!-- else-->
<!-- alert("Merci de saisir tous les champs");-->
<!-- return false;-->
<!-- }); -->
<!-- });-->
<!-- </script>-->
<!--</head>-->
<!--<body id="createProjectBody"> -->
<!-- <img id="createProjectLogo" src="css/images/logo.png" />-->
<!-- <br/><div class="col-md-12 row-title-box">-->
<!-- <div class="row-title">Create Capsule</div>-->
<!-- </div>-->
<!-- <form action="index.php" method="post" id='formCreate'>-->
<!-- <label>Name of the capsule</label>-->
<!-- <input type="text" name="create" placeholder="my-project-name" size="30"><br/>-->
<!-- <label>YouTube or Vimeo video URL</label>-->
<!-- <input type="text" name="video" placeholder="https://www.youtube.com/watch?v=4Rcw5GCXJnQ" size="30"><br/>-->
<!-- <!--<label>Edition password *</label>-->
<!-- <input type="password" name="p" placeholder="password" size="30"><br/>-->-->
<!---->
<!-- <input id="submitCreate" type="submit" value="Create a capsule" name="submit">-->
<!-- </form> -->
<!--</body>-->
<!--</html>-->
\ No newline at end of file
......@@ -4,13 +4,11 @@ namespace App\Controller;
use App\Entity\Capsule;
use App\Entity\User;
use App\Exception\CapsuleNotFoundException;
use App\Form\CreateCapsuleFormType;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Security\Core\Exception\UserNotFoundException;
use Symfony\Component\Uid\Uuid;
class CapsuleController extends AbstractController
......@@ -68,48 +66,4 @@ class CapsuleController extends AbstractController
'capsuleCreationForm' => $form->createView()
]);
}
// /**
// * @Route("/capsule/{edition_link}", name="edit_capsule")
// */
// public function edit(string $edition_link): Response
// {
// $current_user = $this->getUser();
//
// if (! $current_user instanceof User) {
// return $this->redirectToRoute('app_login');
// }
//
// $user_id = $current_user->getId();
// $capsule_repository = $this->getDoctrine()
// ->getRepository(Capsule::class);
// $capsule = $capsule_repository->findOneBy(['edition_link' => $edition_link]);
//
// if (! $capsule instanceof Capsule) {
// throw new CapsuleNotFoundException("The capsule was not found");
// }
// $author_capsule_creation = $capsule->getCreationAuthor();
//
// if (! $author_capsule_creation instanceof User) {
// throw new UserNotFoundException("The capsule author was not found");
// }
//
// $author_capsule_creation_id = $author_capsule_creation->getId();
//
// if ($user_id === $author_capsule_creation_id) {
// return $this->render("project/edit.html.twig", [
//// 'url' => $url
// ]);
// }
//
// return $this->render('capsule/no_edition_access.html.twig');
// }
// /**
// * @Route("/capsule/{preview_link}", name="display_capsule")
// */
// public function show(Capsule $capsule): Response
// {
// return $this->redirectToRoute('get_legacy_resource');
// }
}
......@@ -83,8 +83,7 @@ class FallbackController extends AbstractController
//$url = "{$path_to_legacy_code}{$originalController}";
$url = "{$originalController}";
try {
$legacy_helper = new LegacyHelper();
$mime = $legacy_helper->getMime($url, $extension);
$mime = LegacyHelper::getMime($url, $extension);
$response = new BinaryFileResponse($url);
$response->headers->set('Content-Type', $mime ?: 'application/octet-stream');
return $response;
......@@ -103,9 +102,8 @@ class FallbackController extends AbstractController
"{$originalController}{$separator}?{$originalQueryString}";
$url = preg_replace('(^https?:\/\/[^/]+(:\d+)?)', '', $url);
// TODO: fix regex
// $pattern = '/\/\//i';
// $url = preg_replace($pattern, '/', $url);
$pattern = '/\/\//i';
$url = preg_replace($pattern, '/', $url);
return $this->render("project/edit.html.twig", [
'url' => $url
......
......@@ -41,14 +41,7 @@ class ProjectController extends AbstractController
return $this->redirectToRoute('capsule_list');
}
$zip = new ZipArchive();
$zip_file_archive_is_open = $zip->open("create.zip");
if (! $zip_file_archive_is_open) {
throw new ZipArchiveNotOpeningException("Create Zip Archive could not be open");
}
$this->extractZipArchiveInNewCapsuleDirectory($zip, $capsule_name);
$this->extractZipArchiveInNewCapsuleDirectory($capsule_name);
$this->addProjectVideoUrlInXMLProjectFile($capsule_name, $video_url);
......@@ -63,17 +56,17 @@ class ProjectController extends AbstractController
);
return $this->redirectToRoute('capsule_list');
}
// $capsule_edition_link = $capsule->getEditionLink();
private function extractZipArchiveInNewCapsuleDirectory(string $capsule_name): void
{
$zip = new ZipArchive();
$zip_file_archive_is_open = $zip->open("create.zip");
// return $this->forward('App\Controller\CapsuleController::edit', [
//// 'video_url' => $video_url,
// 'edition_link' => $capsule_edition_link
// ]);
if (! $zip_file_archive_is_open) {
throw new ZipArchiveNotOpeningException("Create Zip Archive could not be open");
}
private function extractZipArchiveInNewCapsuleDirectory(ZipArchive $zip, string $capsule_name): void
{
$zip->extractTo($capsule_name);
$zip->close();
}
......
{% extends 'layout.html.twig' %}
{% block title %}
{{ 'project.edit_project'|trans }}
{% endblock %}
{% block body %}
{# <iframe src="{{ url }}"#}
<iframe src="https://www.youtube.com/watch?v=544DTGHIBM0&ab_channel=Vogue"
style="width:100%;height:100%;top:0;left:0;position:absolute"
{# width="1200"
height="600" #}
frameborder="0"
webkitallowfullscreen
mozallowfullscreen
allowfullscreen>
</iframe>
{% endblock %}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment