Use Slim 3.3 (fixes #49)

This commit is contained in:
Pierre Rudloff 2016-03-30 01:39:47 +02:00
parent 0db96bad5d
commit 81f32c3e61
10 changed files with 234 additions and 234 deletions

View file

@ -7,9 +7,8 @@
"require": {
"smarty/smarty": "~3.1.29",
"rg3/youtube-dl": "2016.03.14",
"slim/slim": "~2.6.2",
"slim/views": "~0.1.3",
"rudloff/smarty-plugin-noscheme": "~0.1.0",
"slim/slim": "~3.3.0",
"mathmarques/smarty-view": "~1.0.0",
"symfony/yaml": "~3.0.0",
"ffmpeg/ffmpeg": "~2.8.2"
},

315
composer.lock generated
View file

@ -4,9 +4,36 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is @generated automatically"
],
"hash": "d4b9e76dbda3af97316a38bfe163ac00",
"content-hash": "6eb27104cc39af34f798d35fb3f381ac",
"hash": "22d65db5d1fd37d20bc4b2ad6736ab4a",
"content-hash": "bbf51588b3930e62a675a947d23aa6b0",
"packages": [
{
"name": "container-interop/container-interop",
"version": "1.1.0",
"source": {
"type": "git",
"url": "https://github.com/container-interop/container-interop.git",
"reference": "fc08354828f8fd3245f77a66b9e23a6bca48297e"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/container-interop/container-interop/zipball/fc08354828f8fd3245f77a66b9e23a6bca48297e",
"reference": "fc08354828f8fd3245f77a66b9e23a6bca48297e",
"shasum": ""
},
"type": "library",
"autoload": {
"psr-4": {
"Interop\\Container\\": "src/Interop/Container/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"description": "Promoting the interoperability of container objects (DIC, SL, etc.)",
"time": "2014-12-30 15:22:37"
},
{
"name": "ffmpeg/ffmpeg",
"version": "2.8.4",
@ -22,102 +49,123 @@
"type": "library"
},
{
"name": "jeremykendall/php-domain-parser",
"version": "3.0.0",
"name": "mathmarques/smarty-view",
"version": "1.0",
"source": {
"type": "git",
"url": "https://github.com/jeremykendall/php-domain-parser.git",
"reference": "896e7e70f02bd4fd77190052799bc61e4d779672"
"url": "https://github.com/mathmarques/Smarty-View.git",
"reference": "0e7e34611d78183efbf748fa351be3faf09bcbce"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/jeremykendall/php-domain-parser/zipball/896e7e70f02bd4fd77190052799bc61e4d779672",
"reference": "896e7e70f02bd4fd77190052799bc61e4d779672",
"url": "https://api.github.com/repos/mathmarques/Smarty-View/zipball/0e7e34611d78183efbf748fa351be3faf09bcbce",
"reference": "0e7e34611d78183efbf748fa351be3faf09bcbce",
"shasum": ""
},
"require": {
"ext-curl": "*",
"ext-intl": "*",
"ext-mbstring": "*",
"php": ">=5.3.0"
"php": ">=5.5.0",
"slim/slim": "^3.0",
"smarty/smarty": "~3.1"
},
"require-dev": {
"jeremykendall/debug-die": "0.0.1.*",
"mikey179/vfsstream": "~1.4",
"phpunit/phpunit": "~4.4"
"phpunit/phpunit": "^4.8.0"
},
"bin": [
"bin/parse",
"bin/update-psl"
],
"type": "library",
"autoload": {
"psr-0": {
"Pdp\\": "src/"
"psr-4": {
"Slim\\Views\\": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Matheus Marques",
"email": "matheusocmarques@gmail.com",
"homepage": "http://matheusmarques.com"
}
],
"description": "Slim Framework 3 view helper built on top of the Smarty templating component",
"keywords": [
"framework",
"slim",
"smarty",
"template",
"view"
],
"time": "2015-12-07 21:31:37"
},
{
"name": "nikic/fast-route",
"version": "v0.6.0",
"source": {
"type": "git",
"url": "https://github.com/nikic/FastRoute.git",
"reference": "31fa86924556b80735f98b294a7ffdfb26789f22"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/nikic/FastRoute/zipball/31fa86924556b80735f98b294a7ffdfb26789f22",
"reference": "31fa86924556b80735f98b294a7ffdfb26789f22",
"shasum": ""
},
"require": {
"php": ">=5.4.0"
},
"type": "library",
"autoload": {
"psr-4": {
"FastRoute\\": "src/"
},
"files": [
"src/pdp-parse-url.php"
"src/functions.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
"BSD-3-Clause"
],
"authors": [
{
"name": "Jeremy Kendall",
"homepage": "http://about.me/jeremykendall",
"role": "Developer"
},
{
"name": "Contributors",
"homepage": "https://github.com/jeremykendall/php-domain-parser/graphs/contributors"
"name": "Nikita Popov",
"email": "nikic@php.net"
}
],
"description": "Public Suffix List based URL parsing implemented in PHP.",
"homepage": "https://github.com/jeremykendall/php-domain-parser",
"description": "Fast request router for PHP",
"keywords": [
"Public Suffix List",
"domain parsing",
"url parsing"
"router",
"routing"
],
"time": "2015-03-30 12:49:45"
"time": "2015-06-18 19:15:47"
},
{
"name": "league/uri",
"version": "4.1.0",
"name": "pimple/pimple",
"version": "v3.0.2",
"source": {
"type": "git",
"url": "https://github.com/thephpleague/uri.git",
"reference": "a4f0ea3323745214c955af2f6451d7743f30a076"
"url": "https://github.com/silexphp/Pimple.git",
"reference": "a30f7d6e57565a2e1a316e1baf2a483f788b258a"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/thephpleague/uri/zipball/a4f0ea3323745214c955af2f6451d7743f30a076",
"reference": "a4f0ea3323745214c955af2f6451d7743f30a076",
"url": "https://api.github.com/repos/silexphp/Pimple/zipball/a30f7d6e57565a2e1a316e1baf2a483f788b258a",
"reference": "a30f7d6e57565a2e1a316e1baf2a483f788b258a",
"shasum": ""
},
"require": {
"ext-fileinfo": "*",
"ext-intl": "*",
"ext-mbstring": "*",
"jeremykendall/php-domain-parser": "^3.0",
"php": ">=5.5.9",
"psr/http-message": "^1.0"
},
"require-dev": {
"fabpot/php-cs-fixer": "^1.9",
"phpunit/phpunit": "^4.0"
"php": ">=5.3.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "4.1-dev"
"dev-master": "3.0.x-dev"
}
},
"autoload": {
"psr-4": {
"League\\Uri\\": "src"
"psr-0": {
"Pimple": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
@ -126,26 +174,17 @@
],
"authors": [
{
"name": "Ignace Nyamagana Butera",
"email": "nyamsprod@gmail.com",
"homepage": "https://nyamsprod.com"
"name": "Fabien Potencier",
"email": "fabien@symfony.com"
}
],
"description": "URI manipulation library",
"homepage": "http://url.thephpleague.com",
"description": "Pimple, a simple Dependency Injection Container",
"homepage": "http://pimple.sensiolabs.org",
"keywords": [
"data",
"data-uri",
"ftp",
"http",
"parse_url",
"psr-7",
"rfc3986",
"uri",
"url",
"ws"
"container",
"dependency injection"
],
"time": "2016-02-18 14:46:01"
"time": "2015-09-11 15:10:35"
},
{
"name": "psr/http-message",
@ -206,114 +245,35 @@
},
"type": "library"
},
{
"name": "rudloff/smarty-plugin-noscheme",
"version": "0.1.0",
"source": {
"type": "git",
"url": "https://github.com/Rudloff/smarty-plugin-noscheme.git",
"reference": "537bcb2f7576252af70d8f9f817bfe050d873072"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/Rudloff/smarty-plugin-noscheme/zipball/537bcb2f7576252af70d8f9f817bfe050d873072",
"reference": "537bcb2f7576252af70d8f9f817bfe050d873072",
"shasum": ""
},
"require": {
"league/uri": "~4.0"
},
"require-dev": {
"symfony/var-dumper": "~2.7.6"
},
"type": "library",
"notification-url": "https://packagist.org/downloads/",
"license": [
"GPL-3.0"
],
"authors": [
{
"name": "Pierre Rudloff",
"email": "contact@rudloff.pro",
"homepage": "https://rudloff.pro/",
"role": "Developer"
}
],
"description": "Smarty modifier that removes the scheme in URLs",
"time": "2015-10-31 10:25:47"
},
{
"name": "slim/slim",
"version": "2.6.2",
"version": "3.3.0",
"source": {
"type": "git",
"url": "https://github.com/slimphp/Slim.git",
"reference": "20a02782f76830b67ae56a5c08eb1f563c351a37"
"reference": "939f2e85d57508de9cff241d10091cd972f221c3"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/slimphp/Slim/zipball/20a02782f76830b67ae56a5c08eb1f563c351a37",
"reference": "20a02782f76830b67ae56a5c08eb1f563c351a37",
"url": "https://api.github.com/repos/slimphp/Slim/zipball/939f2e85d57508de9cff241d10091cd972f221c3",
"reference": "939f2e85d57508de9cff241d10091cd972f221c3",
"shasum": ""
},
"require": {
"php": ">=5.3.0"
"container-interop/container-interop": "^1.1",
"nikic/fast-route": "^0.6",
"php": ">=5.5.0",
"pimple/pimple": "^3.0",
"psr/http-message": "^1.0"
},
"suggest": {
"ext-mcrypt": "Required for HTTP cookie encryption"
},
"type": "library",
"autoload": {
"psr-0": {
"Slim": "."
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Josh Lockhart",
"email": "info@joshlockhart.com",
"homepage": "http://www.joshlockhart.com/"
}
],
"description": "Slim Framework, a PHP micro framework",
"homepage": "http://github.com/codeguy/Slim",
"keywords": [
"microframework",
"rest",
"router"
],
"time": "2015-03-08 18:41:17"
},
{
"name": "slim/views",
"version": "0.1.3",
"source": {
"type": "git",
"url": "https://github.com/slimphp/Slim-Views.git",
"reference": "8561c785e55a39df6cb6f95c3aba3281a60ed5b0"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/slimphp/Slim-Views/zipball/8561c785e55a39df6cb6f95c3aba3281a60ed5b0",
"reference": "8561c785e55a39df6cb6f95c3aba3281a60ed5b0",
"shasum": ""
},
"require": {
"php": ">=5.3.0",
"slim/slim": ">=2.4.0"
},
"suggest": {
"smarty/smarty": "Smarty templating system",
"twig/twig": "Twig templating system"
"require-dev": {
"phpunit/phpunit": "^4.0",
"squizlabs/php_codesniffer": "^2.5"
},
"type": "library",
"autoload": {
"psr-4": {
"Slim\\Views\\": "./"
"Slim\\": "Slim"
}
},
"notification-url": "https://packagist.org/downloads/",
@ -321,25 +281,36 @@
"MIT"
],
"authors": [
{
"name": "Rob Allen",
"email": "rob@akrabat.com",
"homepage": "http://akrabat.com"
},
{
"name": "Josh Lockhart",
"email": "info@joshlockhart.com",
"homepage": "http://www.joshlockhart.com/"
"email": "hello@joshlockhart.com",
"homepage": "https://joshlockhart.com"
},
{
"name": "Gabriel Manricks",
"email": "gmanricks@me.com",
"homepage": "http://gabrielmanricks.com"
},
{
"name": "Andrew Smith",
"email": "a.smith@silentworks.co.uk",
"homepage": "http://thoughts.silentworks.co.uk/"
"homepage": "http://silentworks.co.uk"
}
],
"description": "Smarty and Twig View Parser package for the Slim Framework",
"homepage": "http://github.com/codeguy/Slim-Views",
"description": "Slim is a PHP micro framework that helps you quickly write simple yet powerful web applications and APIs",
"homepage": "http://slimframework.com",
"keywords": [
"extensions",
"slimphp",
"templating"
"api",
"framework",
"micro",
"router"
],
"time": "2014-12-09 23:48:51"
"time": "2016-03-10 21:37:40"
},
{
"name": "smarty/smarty",

View file

@ -30,63 +30,77 @@ class FrontController
/**
* Display index page
*
* @param Request $request PSR-7 request
* @param Response $response PSR-7 response
*
* @return void
*/
static function index()
static function index($request, $response)
{
global $app;
global $container;
$config = Config::getInstance();
$app->render(
$container->view->render(
$response,
'head.tpl',
array(
'class'=>'index'
)
);
$app->render(
$container->view->render(
$response,
'header.tpl'
);
$app->render(
$container->view->render(
$response,
'index.tpl',
array(
'convert'=>$config->convert
)
);
$app->render('footer.tpl');
$container->view->render($response, 'footer.tpl');
}
/**
* Display a list of extractors
*
* @param Request $request PSR-7 request
* @param Response $response PSR-7 response
*
* @return void
*/
static function extractors()
static function extractors($request, $response)
{
global $app;
$app->render(
global $container;
$container->view->render(
$response,
'head.tpl',
array(
'class'=>'extractors'
)
);
$app->render('header.tpl');
$app->render('logo.tpl');
$app->render(
$container->view->render($response, 'header.tpl');
$container->view->render($response, 'logo.tpl');
$container->view->render(
$response,
'extractors.tpl',
array(
'extractors'=>VideoDownload::listExtractors()
)
);
$app->render('footer.tpl');
$container->view->render($response, 'footer.tpl');
}
/**
* Dislay information about the video
*
* @param Request $request PSR-7 request
* @param Response $response PSR-7 response
*
* @return void
*/
static function video()
static function video($request, $response)
{
global $app;
global $container;
$config = Config::getInstance();
if (isset($_GET["url"])) {
if (isset($_GET['audio'])) {
@ -147,56 +161,63 @@ class FrontController
} else {
try {
$video = VideoDownload::getJSON($_GET["url"]);
$app->render(
$container->view->render(
$response,
'head.tpl',
array(
'class'=>'video'
)
);
$app->render(
$container->view->render(
$response,
'video.tpl',
array(
'video'=>$video
)
);
$app->render('footer.tpl');
$container->view->render($response, 'footer.tpl');
} catch (\Exception $e) {
$error = $e->getMessage();
}
}
}
if (isset($error)) {
$app->render(
$container->view->render(
$response,
'head.tpl',
array(
'class'=>'video'
)
);
$app->render(
$container->view->render(
$response,
'error.tpl',
array(
'errors'=>$error
)
);
$app->render('footer.tpl');
$container->view->render($response, 'footer.tpl');
}
}
/**
* Redirect to video file
*
* @param Request $request PSR-7 request
* @param Response $response PSR-7 response
*
* @return void
*/
static function redirect()
static function redirect($request, $response)
{
global $app;
if (isset($_GET["url"])) {
try {
$video = VideoDownload::getURL($_GET["url"]);
$app->redirect($video['url']);
return $response->withRedirect($video['url']);
} catch (\Exception $e) {
$app->response->headers->set('Content-Type', 'text/plain');
echo $e->getMessage().PHP_EOL;
return $response->withHeader('Content-Type', 'text/plain');
}
}
}
@ -204,18 +225,22 @@ class FrontController
/**
* Output JSON info about the video
*
* @param Request $request PSR-7 request
* @param Response $response PSR-7 response
*
* @return void
*/
static function json()
static function json($request, $response)
{
global $app;
if (isset($_GET["url"])) {
$app->response->headers->set('Content-Type', 'application/json');
try {
$video = VideoDownload::getJSON($_GET["url"]);
echo json_encode($video);
return $response->withJson($video);
} catch (\Exception $e) {
echo json_encode(array('success'=>false, 'error'=>$e->getMessage()));
return $response->withJson(
array('success'=>false, 'error'=>$e->getMessage())
);
}
}
}

View file

@ -15,16 +15,16 @@
require_once __DIR__.'/vendor/autoload.php';
use Alltube\VideoDownload;
$app = new \Slim\Slim(
array(
'view' => new \Slim\Views\Smarty()
)
);
$view = $app->view();
$view->parserExtensions = array(
__DIR__.'/vendor/slim/views/SmartyPlugins',
__DIR__.'/vendor/rudloff/smarty-plugin-noscheme/'
);
$app = new \Slim\App();
$container = $app->getContainer();
$container['view'] = function ($c) {
$view = new \Slim\Views\Smarty(__DIR__.'/templates/');
$view->addSlimPlugins($c['router'], $c['request']->getUri());
return $view;
};
$app->get(
'/',
array('Alltube\Controller\FrontController', 'index')
@ -32,11 +32,11 @@ $app->get(
$app->get(
'/extractors',
array('Alltube\Controller\FrontController', 'extractors')
)->name('extractors');
)->setName('extractors');
$app->get(
'/video',
array('Alltube\Controller\FrontController', 'video')
)->name('video');
)->setName('video');
$app->get(
'/redirect',
array('Alltube\Controller\FrontController', 'redirect')

View file

@ -17,6 +17,6 @@
·
</div>
</footer>
<script src="{siteUrl|noscheme|replace:'index.php':'' url='dist/main.js'}"></script>
<script src="{base_url}/dist/main.js"></script>
</body>
</html>

View file

@ -4,21 +4,26 @@
<meta charset="UTF-8" />
<meta name=viewport content="width=device-width, initial-scale=1">
<meta name="description" content="Easily download videos from Youtube, Dailymotion, Vimeo and other websites." />
<link rel="stylesheet" href="{siteUrl|noscheme|replace:'index.php':'' url='dist/main.css'}" />
<link rel="stylesheet" href="{base_url}/dist/main.css" />
<link rel="author" href="https://plus.google.com/110403274854419000481?rel=author" />
<link rel="author" href="https://plus.google.com/103696815796116179392?rel=author" />
<link href="https://plus.google.com/108799967445657477255" rel="publisher" />
<title itemprop="name">AllTube Download</title>
<meta itemprop="url" content="{siteUrl}" />
<link rel="canonical" href="{currentUrl|replace:{siteUrl}:'http://www.alltubedownload.net/'}" />
<link rel="icon" href="{siteUrl|noscheme|replace:'index.php':'' url='img/favicon.png'}" />
<meta property="og:url" content="{siteUrl}" />
<meta itemprop="url" content="{base_url}" />
{if isset($smarty.server.HTTPS)}
{$scheme = "https://"}
{else}
{$scheme = "http://"}
{/if}
<link rel="canonical" href="{$scheme|cat:$smarty.server.HTTP_HOST|cat:$smarty.server.REQUEST_URI|replace:{base_url}:'http://www.alltubedownload.net'}" />
<link rel="icon" href="{base_url}/img/favicon.png" />
<meta property="og:url" content="{base_url}" />
<meta property="og:title" content="AllTube Download" />
<meta property="og:description" content="Easily download videos from Youtube, Dailymotion, Vimeo and other websites." />
<meta property="og:image" content="{siteUrl|replace:'index.php':'' url='img/logo.png'}" />
<meta property="og:image" content="{base_url}/img/logo.png" />
<meta name="twitter:card" content="summary" />
<meta name="twitter:title" content="AllTube Download" />
<meta name="twitter:image" content="{siteUrl|replace:'index.php':'' url='img/logo.png'}" />
<meta name="twitter:image" content="{base_url}/img/logo.png" />
<meta name="twitter:creator" content="@Tael67" />
<meta name="twitter:description" content="Easily download videos from Youtube, Dailymotion, Vimeo and other websites." />
<script type="text/javascript" src="https://www.gstatic.com/cv/js/sender/v1/cast_sender.js"></script>

View file

@ -1,8 +1,8 @@
<header>
<div class="social">
<a class="twitter" href="http://twitter.com/home?status={siteUrl|urlencode}" target="_blank">
<a class="twitter" href="http://twitter.com/home?status={base_url|urlencode}" target="_blank">
Share on Twitter<div class="twittermask"></div></a>
<a class="facebook" href="https://www.facebook.com/sharer/sharer.php?u={siteUrl|urlencode}" target="_blank">Share on Facebook<div class="facebookmask"></div></a>
<a class="facebook" href="https://www.facebook.com/sharer/sharer.php?u={base_url|urlencode}" target="_blank">Share on Facebook<div class="facebookmask"></div></a>
</div>
</header>
<div class="wrapper">

View file

@ -1,7 +1,7 @@
<div class="main">
<div><img itemprop="image" class="logo" src="{siteUrl|noscheme|replace:'index.php':'' url='img/logo.png'}"
<div><img itemprop="image" class="logo" src="{base_url}/img/logo.png"
alt="AllTube Download" width="328" height="284"></div>
<form action="{urlFor name="video"}">
<form action="{path_for name="video"}">
<label class="labelurl" for="url">
Copy here the URL of your video (Youtube, Dailymotion, etc.)
</label>
@ -20,10 +20,10 @@
{/if}
</div>
</form>
<a class="combatiblelink" href="{urlFor name="extractors"}">See all supported websites</a>
<a class="combatiblelink" href="{path_for name="extractors"}">See all supported websites</a>
<div id="bookmarklet">
<p> Drag this to your bookmarks bar: </p>
<a class="bookmarklet" href="javascript:window.location='{siteUrl withUri=false}{urlFor name='video'}?url='+encodeURIComponent(location.href);">Bookmarklet</a>
<a class="bookmarklet" href="javascript:window.location='{base_url}{path_for name='video'}?url='+encodeURIComponent(location.href);">Bookmarklet</a>
</div>
</div>

View file

@ -1,4 +1,4 @@
<h1 class="logobis">
<a class="logocompatible" href="{siteUrl}">
AllTube Download<span class="logocompatiblemask"><img src="{siteUrl|noscheme|replace:'index.php':'' url='img/logocompatiblemask.png'}" width="447" height="107" alt="" /></span>
<a class="logocompatible" href="{base_url}">
AllTube Download<span class="logocompatiblemask"><img src="{base_url}/img/logocompatiblemask.png" width="447" height="107" alt="" /></span>
</a></h1>

View file

@ -9,13 +9,13 @@
href="{$video->webpage_url}">
{$video->title}</a></i>.
<img class="cast_icon" id="cast_disabled"
src="{siteUrl|noscheme|replace:'index.php':'' url='img/ic_media_route_disabled_holo_light.png'}"
src="{base_url}/img/ic_media_route_disabled_holo_light.png"
alt="Google Cast™ is disabled"
title="Google Cast is not supported on this browser." />
<img class="cast_btn cast_hidden cast_icon" id="cast_btn_launch"
src="{siteUrl|noscheme|replace:'index.php':'' url='img/ic_media_route_off_holo_light.png'}"
src="{base_url}/img/ic_media_route_off_holo_light.png"
title="Cast to ChromeCast" alt="Google Cast™" />
<img src="{siteUrl|noscheme|replace:'index.php':'' url='img/ic_media_route_on_holo_light.png'}"
<img src="{base_url}/img/ic_media_route_on_holo_light.png"
alt="Casting to ChromeCast…" title="Stop casting"
id="cast_btn_stop" class="cast_btn cast_hidden cast_icon" /></p>
{if isset($video->thumbnail)}