Merge remote-tracking branch 'upstream/master'

Conflicts:
	web/css/style.css
This commit is contained in:
Lukas Domnick
2013-03-30 21:51:05 +01:00
22 changed files with 1093 additions and 243 deletions

View File

@@ -1,14 +1,14 @@
{
"require": {
"silex/silex": "1.0.*",
"twig/twig": "1.9.*",
"symfony/twig-bridge": "2.1.*",
"symfony/filesystem": "2.1.*",
"klaussilveira/gitter": "dev-master"
"silex/silex": "1.0.*@dev",
"twig/twig": "1.12.*",
"symfony/twig-bridge": "2.2.*",
"symfony/filesystem": "2.2.*",
"klaussilveira/gitter": "0.1.3"
},
"require-dev": {
"symfony/browser-kit": "2.1.*",
"symfony/css-selector": "2.1.*",
"symfony/browser-kit": "2.2.*",
"symfony/css-selector": "2.2.*",
"phpunit/phpunit": "3.7.*",
"phpmd/phpmd": "1.4.*",
"phploc/phploc": "1.7.*"

225
composer.lock generated
View File

@@ -1,27 +1,27 @@
{
"hash": "23b42eb82a97fc586f9c703879c08ac9",
"hash": "4d7bf1d32c612b74b8e7afdb6a9ada2d",
"packages": [
{
"name": "klaussilveira/gitter",
"version": "dev-master",
"version": "0.1.3",
"source": {
"type": "git",
"url": "https://github.com/klaussilveira/gitter.git",
"reference": "9e30a927d1edf28c3ee844b7d0657c4a9535cd12"
"reference": "0.1.3"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/klaussilveira/gitter/zipball/9e30a927d1edf28c3ee844b7d0657c4a9535cd12",
"reference": "9e30a927d1edf28c3ee844b7d0657c4a9535cd12",
"url": "https://api.github.com/repos/klaussilveira/gitter/zipball/0.1.3",
"reference": "0.1.3",
"shasum": ""
},
"require": {
"php": ">=5.3.0",
"symfony/process": ">=2.1"
"symfony/process": ">=2.2"
},
"require-dev": {
"phpunit/phpunit": ">=3.7.1",
"symfony/filesystem": ">=2.1"
"symfony/filesystem": ">=2.2"
},
"type": "library",
"autoload": {
@@ -47,7 +47,7 @@
"git",
"vcs"
],
"time": "2013-02-19 13:59:07"
"time": "2013-03-29 01:18:34"
},
{
"name": "pimple/pimple",
@@ -139,12 +139,12 @@
"source": {
"type": "git",
"url": "https://github.com/fabpot/Silex.git",
"reference": "59e7dbd338b5caba9879ae11524da4a5905f80c1"
"reference": "a5cb55ced63ece76550de1599ddcc60719373594"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/fabpot/Silex/zipball/59e7dbd338b5caba9879ae11524da4a5905f80c1",
"reference": "59e7dbd338b5caba9879ae11524da4a5905f80c1",
"url": "https://api.github.com/repos/fabpot/Silex/zipball/a5cb55ced63ece76550de1599ddcc60719373594",
"reference": "a5cb55ced63ece76550de1599ddcc60719373594",
"shasum": ""
},
"require": {
@@ -212,7 +212,7 @@
"keywords": [
"microframework"
],
"time": "2013-03-08 16:56:52"
"time": "2013-03-27 09:31:32"
},
{
"name": "symfony/event-dispatcher",
@@ -270,26 +270,31 @@
},
{
"name": "symfony/filesystem",
"version": "2.1.x-dev",
"version": "2.2.x-dev",
"target-dir": "Symfony/Component/Filesystem",
"source": {
"type": "git",
"url": "https://github.com/symfony/Filesystem.git",
"reference": "v2.1.8"
"reference": "v2.2.0-RC3"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/Filesystem/zipball/v2.1.8",
"reference": "v2.1.8",
"url": "https://api.github.com/repos/symfony/Filesystem/zipball/v2.2.0-RC3",
"reference": "v2.2.0-RC3",
"shasum": ""
},
"require": {
"php": ">=5.3.3"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "2.2-dev"
}
},
"autoload": {
"psr-0": {
"Symfony\\Component\\Filesystem": ""
"Symfony\\Component\\Filesystem\\": ""
}
},
"notification-url": "https://packagist.org/downloads/",
@@ -308,7 +313,7 @@
],
"description": "Symfony Filesystem Component",
"homepage": "http://symfony.com",
"time": "2013-01-09 08:51:07"
"time": "2013-01-17 15:25:59"
},
{
"name": "symfony/http-foundation",
@@ -317,12 +322,12 @@
"source": {
"type": "git",
"url": "https://github.com/symfony/HttpFoundation.git",
"reference": "d154b0d9a6b5dac26413a314df1846abe197aaef"
"reference": "6af424d4fee81987e76bc76aa4e811859ca70bac"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/HttpFoundation/zipball/d154b0d9a6b5dac26413a314df1846abe197aaef",
"reference": "d154b0d9a6b5dac26413a314df1846abe197aaef",
"url": "https://api.github.com/repos/symfony/HttpFoundation/zipball/6af424d4fee81987e76bc76aa4e811859ca70bac",
"reference": "6af424d4fee81987e76bc76aa4e811859ca70bac",
"shasum": ""
},
"require": {
@@ -358,7 +363,7 @@
],
"description": "Symfony HttpFoundation Component",
"homepage": "http://symfony.com",
"time": "2013-03-01 10:42:10"
"time": "2013-03-23 07:49:54"
},
{
"name": "symfony/http-kernel",
@@ -367,12 +372,12 @@
"source": {
"type": "git",
"url": "https://github.com/symfony/HttpKernel.git",
"reference": "2a354f11ea59f58024b087c371dd1d4f9246dc86"
"reference": "3bfc8fda577fb671b2d9395a59fbc87f449fa61f"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/HttpKernel/zipball/2a354f11ea59f58024b087c371dd1d4f9246dc86",
"reference": "2a354f11ea59f58024b087c371dd1d4f9246dc86",
"url": "https://api.github.com/repos/symfony/HttpKernel/zipball/3bfc8fda577fb671b2d9395a59fbc87f449fa61f",
"reference": "3bfc8fda577fb671b2d9395a59fbc87f449fa61f",
"shasum": ""
},
"require": {
@@ -427,7 +432,7 @@
],
"description": "Symfony HttpKernel Component",
"homepage": "http://symfony.com",
"time": "2013-03-11 17:23:12"
"time": "2013-03-23 10:43:44"
},
{
"name": "symfony/process",
@@ -436,12 +441,12 @@
"source": {
"type": "git",
"url": "https://github.com/symfony/Process.git",
"reference": "6ebe4ba544cfc0dd25bfe49402da4d5267ee1b43"
"reference": "46b24c5905096914d467b769027e36433c7b5421"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/Process/zipball/6ebe4ba544cfc0dd25bfe49402da4d5267ee1b43",
"reference": "6ebe4ba544cfc0dd25bfe49402da4d5267ee1b43",
"url": "https://api.github.com/repos/symfony/Process/zipball/46b24c5905096914d467b769027e36433c7b5421",
"reference": "46b24c5905096914d467b769027e36433c7b5421",
"shasum": ""
},
"require": {
@@ -474,7 +479,7 @@
],
"description": "Symfony Process Component",
"homepage": "http://symfony.com",
"time": "2013-02-18 21:28:20"
"time": "2013-03-23 08:06:49"
},
{
"name": "symfony/routing",
@@ -483,12 +488,12 @@
"source": {
"type": "git",
"url": "https://github.com/symfony/Routing.git",
"reference": "3a97436e581bae44d0eec454a74bbb4f93593e78"
"reference": "a8599d5735c5f1f994cfbf91f59851add9c9f627"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/Routing/zipball/3a97436e581bae44d0eec454a74bbb4f93593e78",
"reference": "3a97436e581bae44d0eec454a74bbb4f93593e78",
"url": "https://api.github.com/repos/symfony/Routing/zipball/a8599d5735c5f1f994cfbf91f59851add9c9f627",
"reference": "a8599d5735c5f1f994cfbf91f59851add9c9f627",
"shasum": ""
},
"require": {
@@ -532,47 +537,54 @@
],
"description": "Symfony Routing Component",
"homepage": "http://symfony.com",
"time": "2013-03-06 19:31:19"
"time": "2013-03-14 09:39:13"
},
{
"name": "symfony/twig-bridge",
"version": "2.1.x-dev",
"version": "2.2.x-dev",
"target-dir": "Symfony/Bridge/Twig",
"source": {
"type": "git",
"url": "https://github.com/symfony/TwigBridge.git",
"reference": "083b7b93d43315f6d23b049f76527da2d64d92c6"
"reference": "50bbc4a10d34a71325b58940c4887726b8a30841"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/TwigBridge/zipball/083b7b93d43315f6d23b049f76527da2d64d92c6",
"reference": "083b7b93d43315f6d23b049f76527da2d64d92c6",
"url": "https://api.github.com/repos/symfony/TwigBridge/zipball/50bbc4a10d34a71325b58940c4887726b8a30841",
"reference": "50bbc4a10d34a71325b58940c4887726b8a30841",
"shasum": ""
},
"require": {
"php": ">=5.3.3",
"twig/twig": ">=1.9.1,<2.0-dev"
"twig/twig": ">=1.11.0,<2.0"
},
"require-dev": {
"symfony/form": "2.1.*",
"symfony/routing": "2.1.*",
"symfony/security": "2.1.*",
"symfony/templating": "2.1.*",
"symfony/translation": "2.1.*",
"symfony/yaml": "2.1.*"
"symfony/form": "2.2.*",
"symfony/http-kernel": ">=2.2,<2.3-dev",
"symfony/routing": ">=2.2,<2.3-dev",
"symfony/security": ">=2.0,<2.3-dev",
"symfony/templating": ">=2.1,<3.0",
"symfony/translation": ">=2.0,<2.3-dev",
"symfony/yaml": ">=2.0,<3.0"
},
"suggest": {
"symfony/form": "2.1.*",
"symfony/routing": "2.1.*",
"symfony/security": "2.1.*",
"symfony/templating": "2.1.*",
"symfony/translation": "2.1.*",
"symfony/yaml": "2.1.*"
"symfony/form": "2.2.*",
"symfony/http-kernel": "2.2.*",
"symfony/routing": "2.2.*",
"symfony/security": "2.2.*",
"symfony/templating": "2.2.*",
"symfony/translation": "2.2.*",
"symfony/yaml": "2.2.*"
},
"type": "symfony-bridge",
"extra": {
"branch-alias": {
"dev-master": "2.2-dev"
}
},
"autoload": {
"psr-0": {
"Symfony\\Bridge\\Twig": ""
"Symfony\\Bridge\\Twig\\": ""
}
},
"notification-url": "https://packagist.org/downloads/",
@@ -591,20 +603,20 @@
],
"description": "Symfony Twig Bridge",
"homepage": "http://symfony.com",
"time": "2013-03-12 10:55:49"
"time": "2013-03-15 10:14:31"
},
{
"name": "twig/twig",
"version": "v1.9.2",
"version": "dev-master",
"source": {
"type": "git",
"url": "git://github.com/fabpot/Twig.git",
"reference": "v1.9.2"
"url": "https://github.com/fabpot/Twig.git",
"reference": "e8991cc2f9c84b2b5c782203904898717d46e56a"
},
"dist": {
"type": "zip",
"url": "https://github.com/fabpot/Twig/zipball/v1.9.2",
"reference": "v1.9.2",
"url": "https://api.github.com/repos/fabpot/Twig/zipball/e8991cc2f9c84b2b5c782203904898717d46e56a",
"reference": "e8991cc2f9c84b2b5c782203904898717d46e56a",
"shasum": ""
},
"require": {
@@ -613,7 +625,7 @@
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.9-dev"
"dev-master": "1.12-dev"
}
},
"autoload": {
@@ -640,7 +652,7 @@
"keywords": [
"templating"
],
"time": "2012-08-25 10:32:57"
"time": "2013-03-25 07:43:31"
}
],
"packages-dev": [
@@ -979,12 +991,12 @@
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/phpunit.git",
"reference": "2c67e52445416bb7c14046b432acd7eb79e4e612"
"reference": "3.7.19"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/2c67e52445416bb7c14046b432acd7eb79e4e612",
"reference": "2c67e52445416bb7c14046b432acd7eb79e4e612",
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/3.7.19",
"reference": "3.7.19",
"shasum": ""
},
"require": {
@@ -998,7 +1010,7 @@
"phpunit/php-text-template": ">=1.1.1",
"phpunit/php-timer": ">=1.0.2,<1.1.0",
"phpunit/phpunit-mock-objects": ">=1.2.0,<1.3.0",
"symfony/yaml": ">=2.2.0"
"symfony/yaml": ">=2.0.0,<2.3.0"
},
"require-dev": {
"pear-pear/pear": "1.9.4"
@@ -1045,7 +1057,7 @@
"testing",
"xunit"
],
"time": "2013-03-11 07:06:05"
"time": "2013-03-25 11:45:06"
},
{
"name": "phpunit/phpunit-mock-objects",
@@ -1098,34 +1110,39 @@
},
{
"name": "symfony/browser-kit",
"version": "2.1.x-dev",
"version": "2.2.x-dev",
"target-dir": "Symfony/Component/BrowserKit",
"source": {
"type": "git",
"url": "https://github.com/symfony/BrowserKit.git",
"reference": "v2.1.8"
"reference": "d55e7ffd7f10bead48adb03b208bc67bd53926bb"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/BrowserKit/zipball/v2.1.8",
"reference": "v2.1.8",
"url": "https://api.github.com/repos/symfony/BrowserKit/zipball/d55e7ffd7f10bead48adb03b208bc67bd53926bb",
"reference": "d55e7ffd7f10bead48adb03b208bc67bd53926bb",
"shasum": ""
},
"require": {
"php": ">=5.3.3",
"symfony/dom-crawler": "2.1.*"
"symfony/dom-crawler": ">=2.0,<3.0"
},
"require-dev": {
"symfony/css-selector": "2.1.*",
"symfony/process": "2.1.*"
"symfony/css-selector": ">=2.0,<3.0",
"symfony/process": ">=2.0,<3.0"
},
"suggest": {
"symfony/process": "2.1.*"
"symfony/process": "2.2.*"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "2.2-dev"
}
},
"autoload": {
"psr-0": {
"Symfony\\Component\\BrowserKit": ""
"Symfony\\Component\\BrowserKit\\": ""
}
},
"notification-url": "https://packagist.org/downloads/",
@@ -1144,30 +1161,35 @@
],
"description": "Symfony BrowserKit Component",
"homepage": "http://symfony.com",
"time": "2013-02-22 06:39:07"
"time": "2013-03-15 10:14:31"
},
{
"name": "symfony/css-selector",
"version": "2.1.x-dev",
"version": "2.2.x-dev",
"target-dir": "Symfony/Component/CssSelector",
"source": {
"type": "git",
"url": "https://github.com/symfony/CssSelector.git",
"reference": "v2.1.8"
"reference": "v2.2.0-RC3"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/CssSelector/zipball/v2.1.8",
"reference": "v2.1.8",
"url": "https://api.github.com/repos/symfony/CssSelector/zipball/v2.2.0-RC3",
"reference": "v2.2.0-RC3",
"shasum": ""
},
"require": {
"php": ">=5.3.3"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "2.2-dev"
}
},
"autoload": {
"psr-0": {
"Symfony\\Component\\CssSelector": ""
"Symfony\\Component\\CssSelector\\": ""
}
},
"notification-url": "https://packagist.org/downloads/",
@@ -1186,36 +1208,41 @@
],
"description": "Symfony CssSelector Component",
"homepage": "http://symfony.com",
"time": "2013-01-09 08:51:07"
"time": "2013-01-17 15:25:59"
},
{
"name": "symfony/dom-crawler",
"version": "2.1.x-dev",
"version": "dev-master",
"target-dir": "Symfony/Component/DomCrawler",
"source": {
"type": "git",
"url": "https://github.com/symfony/DomCrawler.git",
"reference": "227204697da76258a3f7f8d91d72568f4c55e31c"
"reference": "c9698b3b5b93d18250f627a9001c88fe5bc87908"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/DomCrawler/zipball/227204697da76258a3f7f8d91d72568f4c55e31c",
"reference": "227204697da76258a3f7f8d91d72568f4c55e31c",
"url": "https://api.github.com/repos/symfony/DomCrawler/zipball/c9698b3b5b93d18250f627a9001c88fe5bc87908",
"reference": "c9698b3b5b93d18250f627a9001c88fe5bc87908",
"shasum": ""
},
"require": {
"php": ">=5.3.3"
},
"require-dev": {
"symfony/css-selector": "2.1.*"
"symfony/css-selector": ">=2.0,<3.0"
},
"suggest": {
"symfony/css-selector": "2.1.*"
"symfony/css-selector": "2.2.*"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "2.3-dev"
}
},
"autoload": {
"psr-0": {
"Symfony\\Component\\DomCrawler": ""
"Symfony\\Component\\DomCrawler\\": ""
}
},
"notification-url": "https://packagist.org/downloads/",
@@ -1234,7 +1261,7 @@
],
"description": "Symfony DomCrawler Component",
"homepage": "http://symfony.com",
"time": "2013-03-02 15:23:18"
"time": "2013-03-23 07:35:36"
},
{
"name": "symfony/finder",
@@ -1243,12 +1270,12 @@
"source": {
"type": "git",
"url": "https://github.com/symfony/Finder.git",
"reference": "69858f868c0caabe3d859c448f98d249541c0489"
"reference": "v2.1.9"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/Finder/zipball/69858f868c0caabe3d859c448f98d249541c0489",
"reference": "69858f868c0caabe3d859c448f98d249541c0489",
"url": "https://api.github.com/repos/symfony/Finder/zipball/v2.1.9",
"reference": "v2.1.9",
"shasum": ""
},
"require": {
@@ -1280,17 +1307,17 @@
},
{
"name": "symfony/yaml",
"version": "dev-master",
"version": "2.2.x-dev",
"target-dir": "Symfony/Component/Yaml",
"source": {
"type": "git",
"url": "https://github.com/symfony/Yaml.git",
"reference": "f198ac28048eeceae852419c076123aaee59cd1c"
"reference": "3f6d4ab3fd8226ab4ba0be9fc8a238f4338b79ab"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/Yaml/zipball/f198ac28048eeceae852419c076123aaee59cd1c",
"reference": "f198ac28048eeceae852419c076123aaee59cd1c",
"url": "https://api.github.com/repos/symfony/Yaml/zipball/3f6d4ab3fd8226ab4ba0be9fc8a238f4338b79ab",
"reference": "3f6d4ab3fd8226ab4ba0be9fc8a238f4338b79ab",
"shasum": ""
},
"require": {
@@ -1299,7 +1326,7 @@
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "2.3-dev"
"dev-master": "2.2-dev"
}
},
"autoload": {
@@ -1323,7 +1350,7 @@
],
"description": "Symfony Yaml Component",
"homepage": "http://symfony.com",
"time": "2013-01-31 21:39:01"
"time": "2013-03-23 07:49:54"
},
{
"name": "zetacomponents/base",
@@ -1460,7 +1487,7 @@
],
"minimum-stability": "dev",
"stability-flags": {
"klaussilveira/gitter": 20
"silex/silex": 20
},
"platform": [

View File

@@ -6,11 +6,13 @@ class Config
{
protected $data;
public static function fromFile($file) {
public static function fromFile($file)
{
if (!file_exists($file)) {
die(sprintf('Please, create the %1$s file.', $file));
}
$data = parse_ini_file($file, true);
return new static($data);
}

View File

@@ -12,11 +12,11 @@ class BlobController implements ControllerProviderInterface
{
$route = $app['controllers_factory'];
$route->get('{repo}/blob/{commitish_path}', function($repo, $commitish_path) use ($app) {
$route->get('{repo}/blob/{commitishPath}', function ($repo, $commitishPath) use ($app) {
$repository = $app['git']->getRepository($app['git.repos'] . $repo);
list($branch, $file) = $app['util.routing']
->parseCommitishPathParam($commitish_path, $repo);
->parseCommitishPathParam($commitishPath, $repo);
list($branch, $file) = $app['util.repository']->extractRef($repository, $branch, $file);
@@ -43,14 +43,14 @@ class BlobController implements ControllerProviderInterface
'tags' => $repository->getTags(),
));
})->assert('repo', $app['util.routing']->getRepositoryRegex())
->assert('commitish_path', '.+')
->assert('commitishPath', '.+')
->bind('blob');
$route->get('{repo}/raw/{commitish_path}', function($repo, $commitish_path) use ($app) {
$route->get('{repo}/raw/{commitishPath}', function ($repo, $commitishPath) use ($app) {
$repository = $app['git']->getRepository($app['git.repos'] . $repo);
list($branch, $file) = $app['util.routing']
->parseCommitishPathParam($commitish_path, $repo);
->parseCommitishPathParam($commitishPath, $repo);
list($branch, $file) = $app['util.repository']->extractRef($repository, $branch, $file);
@@ -67,7 +67,7 @@ class BlobController implements ControllerProviderInterface
return new Response($blob, 200, $headers);
})->assert('repo', $app['util.routing']->getRepositoryRegex())
->assert('commitish_path', $app['util.routing']->getCommitishPathRegex())
->assert('commitishPath', $app['util.routing']->getCommitishPathRegex())
->bind('blob_raw');
return $route;

View File

@@ -12,15 +12,15 @@ class CommitController implements ControllerProviderInterface
{
$route = $app['controllers_factory'];
$route->get('{repo}/commits/{commitish_path}', function($repo, $commitish_path) use ($app) {
$route->get('{repo}/commits/{commitishPath}', function ($repo, $commitishPath) use ($app) {
$repository = $app['git']->getRepository($app['git.repos'] . $repo);
if ($commitish_path === null) {
$commitish_path = $repository->getHead();
if ($commitishPath === null) {
$commitishPath = $repository->getHead();
}
list($branch, $file) = $app['util.routing']
->parseCommitishPathParam($commitish_path, $repo);
->parseCommitishPathParam($commitishPath, $repo);
list($branch, $file) = $app['util.repository']->extractRef($repository, $branch, $file);
@@ -48,8 +48,8 @@ class CommitController implements ControllerProviderInterface
'file' => $file,
));
})->assert('repo', $app['util.routing']->getRepositoryRegex())
->assert('commitish_path', $app['util.routing']->getCommitishPathRegex())
->value('commitish_path', null)
->assert('commitishPath', $app['util.routing']->getCommitishPathRegex())
->value('commitishPath', null)
->bind('commits');
$route->post('{repo}/commits/{branch}/search', function (Request $request, $repo, $branch = '') use ($app) {
@@ -91,11 +91,11 @@ class CommitController implements ControllerProviderInterface
->assert('commit', '[a-f0-9^]+')
->bind('commit');
$route->get('{repo}/blame/{commitish_path}', function($repo, $commitish_path) use ($app) {
$route->get('{repo}/blame/{commitishPath}', function ($repo, $commitishPath) use ($app) {
$repository = $app['git']->getRepository($app['git.repos'] . $repo);
list($branch, $file) = $app['util.routing']
->parseCommitishPathParam($commitish_path, $repo);
->parseCommitishPathParam($commitishPath, $repo);
list($branch, $file) = $app['util.repository']->extractRef($repository, $branch, $file);
@@ -110,7 +110,7 @@ class CommitController implements ControllerProviderInterface
'blames' => $blames,
));
})->assert('repo', $app['util.routing']->getRepositoryRegex())
->assert('commitish_path', $app['util.routing']->getCommitishPathRegex())
->assert('commitishPath', $app['util.routing']->getCommitishPathRegex())
->bind('blame');
return $route;

View File

@@ -13,13 +13,13 @@ class TreeController implements ControllerProviderInterface
{
$route = $app['controllers_factory'];
$route->get('{repo}/tree/{commitish_path}/', $treeController = function($repo, $commitish_path = '') use ($app) {
$route->get('{repo}/tree/{commitishPath}/', $treeController = function ($repo, $commitishPath = '') use ($app) {
$repository = $app['git']->getRepository($app['git.repos'] . $repo);
if (!$commitish_path) {
$commitish_path = $repository->getHead();
if (!$commitishPath) {
$commitishPath = $repository->getHead();
}
list($branch, $tree) = $app['util.routing']->parseCommitishPathParam($commitish_path, $repo);
list($branch, $tree) = $app['util.routing']->parseCommitishPathParam($commitishPath, $repo);
list($branch, $tree) = $app['util.repository']->extractRef($repository, $branch, $tree);
$files = $repository->getTree($tree ? "$branch:\"$tree\"/" : $branch);
@@ -44,7 +44,7 @@ class TreeController implements ControllerProviderInterface
'readme' => $app['util.repository']->getReadme($repo, $branch),
));
})->assert('repo', $app['util.routing']->getRepositoryRegex())
->assert('commitish_path', $app['util.routing']->getCommitishPathRegex())
->assert('commitishPath', $app['util.routing']->getCommitishPathRegex())
->bind('tree');
$route->post('{repo}/tree/{branch}/search', function (Request $request, $repo, $branch = '', $tree = '') use ($app) {
@@ -68,13 +68,13 @@ class TreeController implements ControllerProviderInterface
'tags' => $repository->getTags(),
));
})->assert('repo', $app['util.routing']->getRepositoryRegex())
->assert('branch', '[\w-._\/]+')
->assert('branch', $app['util.routing']->getBranchRegex())
->bind('search');
$route->get('{repo}/{branch}/', function ($repo, $branch) use ($app, $treeController) {
return $treeController($repo, $branch);
})->assert('repo', $app['util.routing']->getRepositoryRegex())
->assert('branch', '[\w-._\/]+')
->assert('branch', $app['util.routing']->getBranchRegex())
->bind('branch');
$route->get('{repo}/', function ($repo) use ($app, $treeController) {
@@ -111,7 +111,7 @@ class TreeController implements ControllerProviderInterface
));
})->assert('format', '(zip|tar)')
->assert('repo', $app['util.routing']->getRepositoryRegex())
->assert('branch', '[\w-._\/]+')
->assert('branch', $app['util.routing']->getBranchRegex())
->bind('archive');
return $route;

View File

@@ -11,7 +11,7 @@ use Symfony\Component\Filesystem\Filesystem;
class Repository extends BaseRepository
{
/**
* Return TRUE if the repo contains this commit.
* Return true if the repo contains this commit.
*
* @param $commitHash Hash of commit whose existence we want to check
* @return boolean Whether or not the commit exists in this repo
@@ -27,7 +27,7 @@ class Repository extends BaseRepository
/**
* Get the current branch, returning a default value when HEAD is detached.
*/
public function getHead()
public function getHead($default = null)
{
$client = $this->getClient();
@@ -42,12 +42,16 @@ class Repository extends BaseRepository
*/
public function getCommit($commitHash)
{
$logs = $this->getClient()->run($this, "show --pretty=format:\"<item><hash>%H</hash><short_hash>%h</short_hash><tree>%T</tree><parents>%P</parents><author>%an</author><author_email>%ae</author_email><date>%at</date><commiter>%cn</commiter><commiter_email>%ce</commiter_email><commiter_date>%ct</commiter_date><message><![CDATA[%s]]></message></item>\" $commitHash");
$logs = explode("\n", $logs);
$logs = $this->getClient()->run($this, "show --pretty=format:\"<item><hash>%H</hash><short_hash>%h</short_hash><tree>%T</tree><parents>%P</parents><author>%an</author><author_email>%ae</author_email><date>%at</date><commiter>%cn</commiter><commiter_email>%ce</commiter_email><commiter_date>%ct</commiter_date><message><![CDATA[%s]]></message><body><![CDATA[%b]]></body></item>\" $commitHash");
$xmlEnd = strpos($logs, '</item>') + 7;
$commitInfo = substr($logs, 0, $xmlEnd);
$commitData = substr($logs, $xmlEnd);
$logs = explode("\n", $commitData);
array_shift($logs);
// Read commit metadata
$format = new PrettyFormat;
$data = $format->parse($logs[0]);
$data = $format->parse($commitInfo);
$commit = new Commit;
$commit->importData($data[0]);
@@ -313,8 +317,12 @@ class Repository extends BaseRepository
$data['size'] += $file[3];
}
if (($pos = strrpos($file[4], '.')) !== FALSE) {
$data['extensions'][] = substr($file[4], $pos);
if (($pos = strrpos($file[4], '.')) !== false) {
$extension = substr($file[4], $pos);
if (($pos = strrpos($extension, '/')) === false) {
$data['extensions'][] = $extension;
}
}
}
@@ -339,7 +347,7 @@ class Repository extends BaseRepository
}
/**
* Return TRUE if $path exists in $branch; return FALSE otherwise.
* Return true if $path exists in $branch; return false otherwise.
*
* @param string $commitish Commitish reference; branch, tag, SHA1, etc.
* @param string $path Path whose existence we want to verify.
@@ -347,13 +355,14 @@ class Repository extends BaseRepository
* GRIPE Arguably belongs in Gitter, as it's generally useful functionality.
* Also, this really may not be the best way to do this.
*/
public function pathExists($commitish, $path) {
$output = $this->getClient()->run($this, "ls-tree $commitish $path");
public function pathExists($commitish, $path)
{
$output = $this->getClient()->run($this, "ls-tree $commitish '$path'");
if (strlen($output) > 0) {
return TRUE;
return true;
}
return FALSE;
return false;
}
}

View File

@@ -219,5 +219,4 @@ class Repository
return array($branch, $tree);
}
}

View File

@@ -1,6 +1,6 @@
<?php
namespace Gitlist\Util;
namespace GitList\Util;
use Silex\Application;
@@ -13,26 +13,27 @@ class Routing
$this->app = $app;
}
/* @brief Return $commitish, $path parsed from $commitish_path, based on
/* @brief Return $commitish, $path parsed from $commitishPath, based on
* what's in $repo. Raise a 404 if $branchpath does not represent a
* valid branch and path.
*
* A helper for parsing routes that use commit-ish names and paths
* separated by /, since route regexes are not enough to get that right.
*/
public function parseCommitishPathParam($commitish_path, $repo) {
public function parseCommitishPathParam($commitishPath, $repo)
{
$app = $this->app;
$repository = $app['git']->getRepository($app['git.repos'] . $repo);
$commitish = null;
$path = null;
$slash_pos = strpos($commitish_path, '/');
if (strlen($commitish_path) >= 40 &&
($slash_pos === FALSE ||
$slash_pos === 40)) {
$slashPosition = strpos($commitishPath, '/');
if (strlen($commitishPath) >= 40 &&
($slashPosition === false ||
$slashPosition === 40)) {
// We may have a commit hash as our commitish.
$hash = substr($commitish_path, 0, 40);
$hash = substr($commitishPath, 0, 40);
if ($repository->hasCommit($hash)) {
$commitish = $hash;
}
@@ -48,56 +49,57 @@ class Routing
$branches = array_merge($branches, $tags);
}
$matched_branch = null;
$matched_branch_name_len = 0;
$matchedBranch = null;
$matchedBranchLength = 0;
foreach ($branches as $branch) {
if (strpos($commitish_path, $branch) === 0 &&
strlen($branch) > $matched_branch_name_len) {
$matched_branch = $branch;
$matched_branch_name_len = strlen($matched_branch);
if (strpos($commitishPath, $branch) === 0 &&
strlen($branch) > $matchedBranchLength) {
$matchedBranch = $branch;
$matchedBranchLength = strlen($matchedBranch);
}
}
$commitish = $matched_branch;
$commitish = $matchedBranch;
}
if ($commitish === null) {
$app->abort(404, "'$branch_path' does not appear to contain a " .
"commit-ish for '$repo.'");
$app->abort(404, "'$branch_path' does not appear to contain a commit-ish for '$repo'.");
}
$commitish_len = strlen($commitish);
$path = substr($commitish_path, $commitish_len);
$commitishLength = strlen($commitish);
$path = substr($commitishPath, $commitishLength);
if (strpos($path, '/') === 0) {
$path = substr($path, 1);
}
$commit_has_path = $repository->pathExists($commitish, $path);
if ($commit_has_path !== TRUE) {
$commitHasPath = $repository->pathExists($commitish, $path);
if ($commitHasPath !== true) {
$app->abort(404, "\"$path\" does not exist in \"$commitish\".");
}
return array($commitish, $path);
}
public function getBranchRegex() {
static $branch_regex = null;
public function getBranchRegex()
{
static $branchRegex = null;
if ($branch_regex === null) {
$branch_regex = '[\w-._\/]+';
if ($branchRegex === null) {
$branchRegex = '(?!/|.*([/.]\.|//|@\{|\\\\))[^\040\177 ~^:?*\[]+(?<!\.lock|[/.])';
}
return $branch_regex;
return $branchRegex;
}
public function getCommitishPathRegex() {
static $commitish_path_regex = null;
public function getCommitishPathRegex()
{
static $commitishPathRegex = null;
if ($commitish_path_regex === null) {
$commitish_path_regex = '.+';
if ($commitishPathRegex === null) {
$commitishPathRegex = '.+';
}
return $commitish_path_regex;
return $commitishPathRegex;
}
public function getRepositoryRegex()
@@ -112,7 +114,14 @@ class Routing
},
$this->app['git']->getRepositories($this->app['git.repos'])
);
usort($quotedPaths, function ($a, $b) { return strlen($b) - strlen($a); });
usort(
$quotedPaths,
function ($a, $b) {
return strlen($b) - strlen($a);
}
);
$regex = implode('|', $quotedPaths);
}
@@ -129,6 +138,7 @@ class Routing
{
if (strpos($repoPath, $this->app['git.repos']) === 0) {
$relativePath = substr($repoPath, strlen($this->app['git.repos']));
return ltrim(strtr($relativePath, '\\', '/'), '/');
} else {
throw new \InvalidArgumentException(

View File

@@ -148,8 +148,8 @@ class InterfaceTest extends WebTestCase
$this->assertTrue($client->getResponse()->isOk());
$this->assertCount(1, $crawler->filter('.tree tr:contains("README.md")'));
$this->assertCount(1, $crawler->filter('.tree tr:contains("test.php")'));
$this->assertCount(1, $crawler->filter('.readme-header:contains("README.md")'));
$this->assertEquals("## GitTest\nGitTest is a *test* repository!", $crawler->filter('#readme-content')->eq(0)->text());
$this->assertCount(1, $crawler->filter('.md-header:contains("README.md")'));
$this->assertEquals("## GitTest\nGitTest is a *test* repository!", $crawler->filter('#md-content')->eq(0)->text());
$this->assertEquals('/GitTest/blob/master/README.md', $crawler->filter('.tree tr td')->eq(0)->filter('a')->eq(0)->attr('href'));
$this->assertEquals('/GitTest/blob/master/test.php', $crawler->filter('.tree tr td')->eq(3)->filter('a')->eq(0)->attr('href'));
@@ -166,7 +166,7 @@ class InterfaceTest extends WebTestCase
$this->assertEquals('/foobar/tree/master/myfolder/', $crawler->filter('.tree tr td')->eq(0)->filter('a')->eq(0)->attr('href'));
$this->assertEquals('/foobar/tree/master/testfolder/', $crawler->filter('.tree tr td')->eq(3)->filter('a')->eq(0)->attr('href'));
$this->assertEquals('/foobar/blob/master/bar.json', $crawler->filter('.tree tr td')->eq(6)->filter('a')->eq(0)->attr('href'));
$this->assertCount(0, $crawler->filter('.readme-header'));
$this->assertCount(0, $crawler->filter('.md-header'));
$this->assertEquals('master', $crawler->filter('.dropdown-menu li')->eq(1)->text());
}

View File

@@ -2,7 +2,7 @@
<li><a href="{{ path('repository', {repo: repo}) }}">{{ repo }}</a></li>
{% for breadcrumb in breadcrumbs %}
<span class="divider">/</span>
<li{% if loop.last %} class="active"{% endif %}>{% if not loop.last %}<a href="{{ path('tree', {repo: repo, commitish_path: branch ~ '/' ~ breadcrumb.path}) }}">{{ breadcrumb.dir }}</a>{% endif %}{% if loop.last %}{{ breadcrumb.dir }}{% endif %}</li>
<li{% if loop.last %} class="active"{% endif %}>{% if not loop.last %}<a href="{{ path('tree', {repo: repo, commitishPath: branch ~ '/' ~ breadcrumb.path}) }}">{{ breadcrumb.dir }}</a>{% endif %}{% if loop.last %}{{ breadcrumb.dir }}{% endif %}</li>
{% endfor %}
{% block extra %}{% endblock %}

View File

@@ -13,6 +13,9 @@
<h4>{{ commit.message }}</h4>
</div>
<div class="commit-body">
{% if commit.body is not empty %}
<p>{{ commit.body | nl2br }}</p>
{% endif %}
<img src="https://gravatar.com/avatar/{{ commit.author.email | lower | md5 }}?s=32" class="pull-left space-right" />
<span><a href="mailto:{{ commit.author.email }}">{{ commit.author.name }}</a> authored on {{ commit.date | date('d/m/Y \\a\\t H:i:s') }}<br />Showing {{ commit.changedFiles }} changed files</span>
</div>
@@ -30,8 +33,8 @@
<div class="meta"><a name="{{ loop.index }}">{{ diff.file }}</div>
<div class="btn-group pull-right">
<a href="{{ path('commits', {repo: repo, commitish_path: commit.hash ~ '/' ~ diff.file}) }}" class="btn btn-small"><i class="icon-list-alt"></i> History</a>
<a href="{{ path('blob', {repo: repo, commitish_path: commit.hash ~'/' ~ diff.file}) }}" class="btn btn-small"><i class="icon-file"></i> View file @ {{ commit.shortHash }}</a>
<a href="{{ path('commits', {repo: repo, commitishPath: commit.hash ~ '/' ~ diff.file}) }}" class="btn btn-small"><i class="icon-list-alt"></i> History</a>
<a href="{{ path('blob', {repo: repo, commitishPath: commit.hash ~'/' ~ diff.file}) }}" class="btn btn-small"><i class="icon-file"></i> View file @ {{ commit.shortHash }}</a>
</div>
</div>

View File

@@ -12,16 +12,16 @@
<div class="meta"></div>
<div class="btn-group pull-right">
<a href="{{ path('blob_raw', {repo: repo, commitish_path: branch ~ '/' ~ file}) }}" class="btn btn-small"><i class="icon-file"></i> Raw</a>
<a href="{{ path('blame', {repo: repo, commitish_path: branch ~ '/' ~ file}) }}" class="btn btn-small"><i class="icon-bullhorn"></i> Blame</a>
<a href="{{ path('commits', {repo: repo, commitish_path: branch ~ '/' ~ file}) }}" class="btn btn-small"><i class="icon-list-alt"></i> History</a>
<a href="{{ path('blob_raw', {repo: repo, commitishPath: branch ~ '/' ~ file}) }}" class="btn btn-small"><i class="icon-file"></i> Raw</a>
<a href="{{ path('blame', {repo: repo, commitishPath: branch ~ '/' ~ file}) }}" class="btn btn-small"><i class="icon-bullhorn"></i> Blame</a>
<a href="{{ path('commits', {repo: repo, commitishPath: branch ~ '/' ~ file}) }}" class="btn btn-small"><i class="icon-list-alt"></i> History</a>
</div>
</div>
{% if fileType == 'image' %}
<center><img src="{{ path('blob_raw', {repo: repo, commitish_path: branch ~ '/' ~ file}) }}" alt="{{ file }}" class="image-blob" /></center>
<center><img src="{{ path('blob_raw', {repo: repo, commitishPath: branch ~ '/' ~ file}) }}" alt="{{ file }}" class="image-blob" /></center>
{% elseif fileType == 'markdown' %}
<div class="readme-view"><div id="readme-content">{{ blob }}</div></div>
<div class="md-view"><div id="md-content">{{ blob }}</div></div>
{% else %}
<pre id="sourcecode" language="{{ fileType }}">{{ blob|htmlentities|raw }}</pre>

View File

@@ -4,6 +4,7 @@
<meta charset="UTF-8" />
<title>{% block title %}Welcome!{% endblock %}</title>
<link rel="stylesheet" type="text/css" href="{{ app.request.basepath }}/web/css/style.css">
<link rel="shortcut icon" type="image/png" href="{{ app.request.basepath }}/web/img/favicon.png" />
<!--[if lt IE 9]>
<script src="{{ app.request.basepath }}/web/js/html5.js"></script>
<![endif]-->

View File

@@ -1,6 +1,6 @@
<ul class="nav nav-tabs">
<li{% if page == 'files' %} class="active"{% endif %}><a href="{{ path('branch', {repo: repo, branch: branch}) }}">Files</a></li>
<li{% if page in ['commits', 'searchcommits'] %} class="active"{% endif %}><a href="{{ path('commits', {repo: repo, commitish_path: branch}) }}">Commits</a></li>
<li{% if page in ['commits', 'searchcommits'] %} class="active"{% endif %}><a href="{{ path('commits', {repo: repo, commitishPath: branch}) }}">Commits</a></li>
<li{% if page == 'stats' %} class="active"{% endif %}><a href="{{ path('stats', {repo: repo, branch: branch}) }}">Stats</a></li>
<li{% if page == 'network' %} class="active"{% endif %}><a href="{{ path('network', {repo: repo, branch: branch}) }}">Network</a></li>
</ul>

View File

@@ -32,7 +32,7 @@
{% if not parent %}
<a href="{{ path('branch', {repo: repo, branch: branch}) }}">..</a>
{% else %}
<a href="{{ path('tree', {repo: repo, commitish_path: branch ~ '/' ~ parent}) }}">..</a>
<a href="{{ path('tree', {repo: repo, commitishPath: branch ~ '/' ~ parent}) }}">..</a>
{% endif %}
</td>
<td></td>
@@ -43,9 +43,9 @@
<tr>
<td><i class="{{ file.type == "folder" or file.type == "symlink" ? "icon-folder-open" : "icon-file" }} icon-spaced"></i> <a href="
{%- if file.type == "folder" or file.type == "symlink" -%}
{{ path('tree', {repo: repo, commitish_path: branch ~ '/' ~ path ~ (file.type == "symlink" ? file.path : file.name)}) }}
{{ path('tree', {repo: repo, commitishPath: branch ~ '/' ~ path ~ (file.type == "symlink" ? file.path : file.name)}) }}
{%- else -%}
{{ path('blob', {repo: repo, commitish_path: branch ~ '/' ~ path ~ (file.type == "symlink" ? file.path : file.name)}) }}
{{ path('blob', {repo: repo, commitishPath: branch ~ '/' ~ path ~ (file.type == "symlink" ? file.path : file.name)}) }}
{%- endif -%}
">{{ file.name }}</a></td>
<td>{{ file.mode }}</td>
@@ -56,10 +56,10 @@
</table>
{% if readme is defined and readme is not empty %}
<div class="readme-view">
<div class="readme-header">
<div class="md-header">
<div class="meta">{{ readme.filename }}</div>
</div>
<div id="readme-content">{{ readme.content }}</div>
<div id="md-content">{{ readme.content }}</div>
</div>
{% endif %}

File diff suppressed because one or more lines are too long

BIN
web/img/favicon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 884 B

View File

@@ -20,22 +20,23 @@ $(function () {
});
}
if ($('#readme-content').length) {
if ($('#md-content').length) {
var converter = new Showdown.converter();
$('#readme-content').html(converter.makeHtml($('#readme-content').text()));
$('#md-content').html(converter.makeHtml($('#md-content').text()));
}
function paginate() {
var $pager = $('.pager');
$pager.find('.next a').one('click', function (e) {
e.preventDefault();
$(this).css('pointer-events', 'none');
$.get(this.href, function (html) {
$pager.after(html);
$pager.remove();
paginate();
});
});
$pager.find('.previous').remove();
}
paginate();

View File

@@ -161,11 +161,15 @@
}
.readme-view {
border: 1px solid @treeHeaderBorder;
}
.md-view {
width: 100%;
margin-bottom: @baseLineHeight;
border: 1px solid @treeHeaderBorder;
}
.readme-header {
.md-header {
padding: 8px;
line-height: @baseLineHeight;
text-align: left;
@@ -183,8 +187,7 @@
}
}
#readme-content {
#md-content {
padding: 30px;
color: @black;
}
}