Merge pull request #74 from fabpot/refactoring

Refactoring
This commit is contained in:
Klaus Silveira
2012-07-07 19:41:13 -07:00
27 changed files with 201 additions and 293 deletions

View File

@@ -1,8 +1,10 @@
{ {
"require": { "require": {
"silex/silex": "1.0.*", "silex/silex": "1.0.*",
"twig/twig": "1.8.*" "twig/twig": "1.8.*",
"symfony/twig-bridge": "2.1.*"
}, },
"minimum-stability": "dev",
"autoload": { "autoload": {
"psr-0": { "psr-0": {
"Application": "lib/", "Application": "lib/",

22
composer.lock generated
View File

@@ -1,5 +1,5 @@
{ {
"hash": "3a86b6a3e837b125e3cebc503fd8cf38", "hash": "8909d5f3ac695303e7845fe5cb0658ad",
"packages": [ "packages": [
{ {
"package": "pimple/pimple", "package": "pimple/pimple",
@@ -22,8 +22,8 @@
{ {
"package": "silex/silex", "package": "silex/silex",
"version": "dev-master", "version": "dev-master",
"source-reference": "13eb2ba916e39d5b8b1d054aaa441cf8e1004d85", "source-reference": "23dc19c334e2f74ec4de037568f5426bceaff421",
"commit-date": "1341343086" "commit-date": "1341597562"
}, },
{ {
"package": "symfony/event-dispatcher", "package": "symfony/event-dispatcher",
@@ -74,16 +74,20 @@
"commit-date": "1341312726" "commit-date": "1341312726"
}, },
{ {
"package": "twig/twig", "package": "symfony/twig-bridge",
"version": "dev-master", "version": "dev-master",
"alias-pretty-version": "1.8.x-dev", "alias-pretty-version": "2.1.x-dev",
"alias-version": "1.8.9999999.9999999-dev" "alias-version": "2.1.9999999.9999999-dev"
},
{
"package": "symfony/twig-bridge",
"version": "dev-master",
"source-reference": "2a577b6cf0fe32f383acf4a972c1d5d8f48ae1e2",
"commit-date": "1340549862"
}, },
{ {
"package": "twig/twig", "package": "twig/twig",
"version": "dev-master", "version": "v1.8.3"
"source-reference": "73da773aaad0f97f2e967ec8241b8adf7b1e03d2",
"commit-date": "1340890758"
} }
], ],
"packages-dev": null, "packages-dev": null,

View File

@@ -6,7 +6,6 @@ repositories = '/var/www/projects/' ; Path to your repositories
; hidden[] = '/var/www/projects/BetaTest' ; hidden[] = '/var/www/projects/BetaTest'
[app] [app]
baseurl = 'http://localhost/git' ; Base URL of the application
; If you need to specify custom filetypes for certain extensions, do this here ; If you need to specify custom filetypes for certain extensions, do this here
[filetypes] [filetypes]

View File

@@ -1,14 +1,12 @@
<?php <?php
$app->get('{repo}/blob/{branch}/{file}/', function($repo, $branch, $file) use($app) { $app->get('{repo}/blob/{branch}/{file}', function($repo, $branch, $file) use($app) {
$repository = $app['git']->getRepository($app['git.repos'] . $repo); $repository = $app['git']->getRepository($app['git.repos'] . $repo);
$blob = $repository->getBlob("$branch:'$file'"); $blob = $repository->getBlob("$branch:'$file'");
$breadcrumbs = $app['utils']->getBreadcrumbs("$repo/tree/$branch/$file"); $breadcrumbs = $app['utils']->getBreadcrumbs($file);
$fileType = $app['utils']->getFileType($file); $fileType = $app['utils']->getFileType($file);
return $app['twig']->render('file.twig', array( return $app['twig']->render('file.twig', array(
'baseurl' => $app['baseurl'],
'page' => 'files',
'file' => $file, 'file' => $file,
'fileType' => $fileType, 'fileType' => $fileType,
'blob' => $blob->output(), 'blob' => $blob->output(),
@@ -20,7 +18,8 @@ $app->get('{repo}/blob/{branch}/{file}/', function($repo, $branch, $file) use($a
)); ));
})->assert('file', '.+') })->assert('file', '.+')
->assert('repo', '[\w-._]+') ->assert('repo', '[\w-._]+')
->assert('branch', '[\w-._]+'); ->assert('branch', '[\w-._]+')
->bind('blob');
$app->get('{repo}/raw/{branch}/{file}', function($repo, $branch, $file) use($app) { $app->get('{repo}/raw/{branch}/{file}', function($repo, $branch, $file) use($app) {
$repository = $app['git']->getRepository($app['git.repos'] . $repo); $repository = $app['git']->getRepository($app['git.repos'] . $repo);
@@ -29,4 +28,5 @@ $app->get('{repo}/raw/{branch}/{file}', function($repo, $branch, $file) use($app
return new Symfony\Component\HttpFoundation\Response($blob, 200, array('Content-Type' => 'text/plain')); return new Symfony\Component\HttpFoundation\Response($blob, 200, array('Content-Type' => 'text/plain'));
})->assert('file', '.+') })->assert('file', '.+')
->assert('repo', '[\w-._]+') ->assert('repo', '[\w-._]+')
->assert('branch', '[\w-._]+'); ->assert('branch', '[\w-._]+')
->bind('blob_raw');

View File

@@ -1,9 +1,10 @@
<?php <?php
$app->get('{repo}/commits/{branch}', function($repo, $branch) use($app) { $app->get('{repo}/commits/{branch}/{file}', function($repo, $branch, $file) use($app) {
$repository = $app['git']->getRepository($app['git.repos'] . $repo); $repository = $app['git']->getRepository($app['git.repos'] . $repo);
$pager = $app['utils']->getPager($app['request']->get('page'), $repository->getTotalCommits()); $type = $file ? "$branch -- $file" : $branch;
$commits = $repository->getCommits($branch, $pager['current']); $pager = $app['utils']->getPager($app['request']->get('page'), $repository->getTotalCommits($type));
$commits = $repository->getCommits($type, $pager['current']);
foreach ($commits as $commit) { foreach ($commits as $commit) {
$date = $commit->getDate(); $date = $commit->getDate();
@@ -12,65 +13,39 @@ $app->get('{repo}/commits/{branch}', function($repo, $branch) use($app) {
} }
return $app['twig']->render('commits.twig', array( return $app['twig']->render('commits.twig', array(
'baseurl' => $app['baseurl'],
'page' => 'commits',
'pager' => $pager, 'pager' => $pager,
'repo' => $repo, 'repo' => $repo,
'branch' => $branch, 'branch' => $branch,
'branches' => $repository->getBranches(), 'branches' => $repository->getBranches(),
'tags' => $repository->getTags(), 'tags' => $repository->getTags(),
'commits' => $categorized, 'commits' => $categorized,
'file' => $file,
)); ));
})->assert('repo', '[\w-._]+') })->assert('repo', '[\w-._]+')
->assert('branch', '[\w-._]+') ->assert('branch', '[\w-._]+')
->value('branch', 'master');
$app->get('{repo}/commits/{branch}/{file}/', function($repo, $branch, $file) use($app) {
$repository = $app['git']->getRepository($app['git.repos'] . $repo);
$pager = $app['utils']->getPager($app['request']->get('page'), $repository->getTotalCommits("$branch -- $file"));
$commits = $repository->getCommits("$branch -- $file", $pager['current']);
foreach ($commits as $commit) {
$date = $commit->getDate();
$date = $date->format('m/d/Y');
$categorized[$date][] = $commit;
}
return $app['twig']->render('commits.twig', array(
'baseurl' => $app['baseurl'],
'page' => 'commits',
'pager' => $pager,
'repo' => $repo,
'branch' => $branch,
'branches' => $repository->getBranches(),
'tags' => $repository->getTags(),
'commits' => $categorized,
));
})->assert('repo', '[\w-._]+')
->assert('file', '.+') ->assert('file', '.+')
->assert('branch', '[\w-._]+'); ->value('branch', 'master')
->value('file', '')
->bind('commits');
$app->get('{repo}/commit/{commit}/', function($repo, $commit) use($app) { $app->get('{repo}/commit/{commit}/', function($repo, $commit) use($app) {
$repository = $app['git']->getRepository($app['git.repos'] . $repo); $repository = $app['git']->getRepository($app['git.repos'] . $repo);
$commit = $repository->getCommit($commit); $commit = $repository->getCommit($commit);
return $app['twig']->render('commit.twig', array( return $app['twig']->render('commit.twig', array(
'baseurl' => $app['baseurl'],
'page' => 'commits',
'branch' => 'master', 'branch' => 'master',
'repo' => $repo, 'repo' => $repo,
'commit' => $commit, 'commit' => $commit,
)); ));
})->assert('repo', '[\w-._]+') })->assert('repo', '[\w-._]+')
->assert('commit', '[a-f0-9]+'); ->assert('commit', '[a-f0-9]+')
->bind('commit');
$app->get('{repo}/blame/{branch}/{file}/', function($repo, $branch, $file) use($app) { $app->get('{repo}/blame/{branch}/{file}', function($repo, $branch, $file) use($app) {
$repository = $app['git']->getRepository($app['git.repos'] . $repo); $repository = $app['git']->getRepository($app['git.repos'] . $repo);
$blames = $repository->getBlame("$branch -- $file"); $blames = $repository->getBlame("$branch -- $file");
return $app['twig']->render('blame.twig', array( return $app['twig']->render('blame.twig', array(
'baseurl' => $app['baseurl'],
'page' => 'commits',
'file' => $file, 'file' => $file,
'repo' => $repo, 'repo' => $repo,
'branch' => $branch, 'branch' => $branch,
@@ -80,4 +55,5 @@ $app->get('{repo}/blame/{branch}/{file}/', function($repo, $branch, $file) use($
)); ));
})->assert('repo', '[\w-._]+') })->assert('repo', '[\w-._]+')
->assert('file', '.+') ->assert('file', '.+')
->assert('branch', '[\w-._]+'); ->assert('branch', '[\w-._]+')
->bind('blame');

View File

@@ -4,7 +4,6 @@ $app->get('/', function() use($app) {
$repositories = $app['git']->getRepositories($app['git.repos']); $repositories = $app['git']->getRepositories($app['git.repos']);
return $app['twig']->render('index.twig', array( return $app['twig']->render('index.twig', array(
'baseurl' => $app['baseurl'],
'repositories' => $repositories, 'repositories' => $repositories,
)); ));
}); })->bind('homepage');

View File

@@ -5,7 +5,6 @@ $app->get('{repo}/{branch}/rss/', function($repo, $branch) use($app) {
$commits = $repository->getCommits($branch); $commits = $repository->getCommits($branch);
$html = $app['twig']->render('rss.twig', array( $html = $app['twig']->render('rss.twig', array(
'baseurl' => $app['baseurl'],
'repo' => $repo, 'repo' => $repo,
'branch' => $branch, 'branch' => $branch,
'commits' => $commits, 'commits' => $commits,
@@ -13,4 +12,5 @@ $app->get('{repo}/{branch}/rss/', function($repo, $branch) use($app) {
return new Symfony\Component\HttpFoundation\Response($html, 200, array('Content-Type' => 'application/rss+xml')); return new Symfony\Component\HttpFoundation\Response($html, 200, array('Content-Type' => 'application/rss+xml'));
})->assert('repo', '[\w-._]+') })->assert('repo', '[\w-._]+')
->assert('branch', '[\w-._]+'); ->assert('branch', '[\w-._]+')
->bind('rss');

View File

@@ -6,8 +6,6 @@ $app->get('{repo}/stats/{branch}', function($repo, $branch) use($app) {
$authors = $repository->getAuthorStatistics(); $authors = $repository->getAuthorStatistics();
return $app['twig']->render('stats.twig', array( return $app['twig']->render('stats.twig', array(
'baseurl' => $app['baseurl'],
'page' => 'stats',
'repo' => $repo, 'repo' => $repo,
'branch' => $branch, 'branch' => $branch,
'branches' => $repository->getBranches(), 'branches' => $repository->getBranches(),
@@ -17,4 +15,5 @@ $app->get('{repo}/stats/{branch}', function($repo, $branch) use($app) {
)); ));
})->assert('repo', '[\w-._]+') })->assert('repo', '[\w-._]+')
->assert('branch', '[\w-._]+') ->assert('branch', '[\w-._]+')
->value('branch', 'master'); ->value('branch', 'master')
->bind('stats');

View File

@@ -1,70 +1,43 @@
<?php <?php
$app->get('{repo}/', function($repo) use($app) { $app->get('{repo}/tree/{branch}/{tree}/', $treeController = function($repo, $branch = '', $tree = '') use($app) {
$repository = $app['git']->getRepository($app['git.repos'] . $repo); $repository = $app['git']->getRepository($app['git.repos'] . $repo);
$defaultBranch = $repository->getHead(); if (!$branch) {
$tree = $repository->getTree($defaultBranch); $branch = $repository->getHead();
$breadcrumbs = $app['utils']->getBreadcrumbs("$repo/"); }
$files = $repository->getTree($tree ? "$branch:'$tree'/" : $branch);
$breadcrumbs = $app['utils']->getBreadcrumbs($tree);
$parent = null;
if (($slash = strrpos($tree, '/')) !== false) {
$parent = substr($tree, 0, $slash);
} elseif (!empty($tree)) {
$parent = '';
}
return $app['twig']->render('tree.twig', array( return $app['twig']->render('tree.twig', array(
'baseurl' => $app['baseurl'], 'files' => $files->output(),
'page' => 'files',
'files' => $tree->output(),
'repo' => $repo,
'branch' => $defaultBranch,
'path' => '',
'parent' => '',
'breadcrumbs' => $breadcrumbs,
'branches' => $repository->getBranches(),
'tags' => $repository->getTags(),
'readme' => $app['utils']->getReadme($repo, $defaultBranch),
));
})->assert('repo', '[\w-._]+');
$app->get('{repo}/tree/{branch}/', function($repo, $branch) use($app) {
$repository = $app['git']->getRepository($app['git.repos'] . $repo);
$tree = $repository->getTree($branch);
$breadcrumbs = $app['utils']->getBreadcrumbs("$repo/");
return $app['twig']->render('tree.twig', array(
'baseurl' => $app['baseurl'],
'page' => 'files',
'files' => $tree->output(),
'repo' => $repo, 'repo' => $repo,
'branch' => $branch, 'branch' => $branch,
'path' => '', 'path' => $tree ? $tree.'/' : $tree,
'parent' => '', 'parent' => $parent,
'breadcrumbs' => $breadcrumbs, 'breadcrumbs' => $breadcrumbs,
'branches' => $repository->getBranches(), 'branches' => $repository->getBranches(),
'tags' => $repository->getTags(), 'tags' => $repository->getTags(),
'readme' => $app['utils']->getReadme($repo, $branch), 'readme' => $app['utils']->getReadme($repo, $branch),
)); ));
})->assert('repo', '[\w-._]+') })->assert('repo', '[\w-._]+')
->assert('branch', '[\w-._]+'); ->assert('branch', '[\w-._]+')
->assert('tree', '.+')
->bind('tree');
$app->get('{repo}/tree/{branch}/{tree}/', function($repo, $branch, $tree) use($app) { $app->get('{repo}/{branch}/', function($repo, $branch) use($app, $treeController) {
$repository = $app['git']->getRepository($app['git.repos'] . $repo); return $treeController($repo, $branch);
$files = $repository->getTree("$branch:'$tree'/"); })->assert('repo', '[\w-._]+')
$breadcrumbs = $app['utils']->getBreadcrumbs("$repo/tree/$branch/$tree"); ->assert('branch', '[\w-._]+')
->bind('branch');
if (($slash = strrpos($tree, '/')) !== false) { $app->get('{repo}/', function($repo) use($app, $treeController) {
$parent = '/' . substr($tree, 0, $slash); return $treeController($repo);
} else { })->assert('repo', '[\w-._]+')
$parent = '/'; ->bind('repository');
}
return $app['twig']->render('tree.twig', array(
'baseurl' => $app['baseurl'],
'page' => 'files',
'files' => $files->output(),
'repo' => $repo,
'branch' => $branch,
'path' => "$tree/",
'parent' => $parent,
'breadcrumbs' => $breadcrumbs,
'branches' => $repository->getBranches(),
'tags' => $repository->getTags(),
));
})->assert('tree', '.+')
->assert('repo', '[\w-._]+')
->assert('branch', '[\w-._]+');

View File

@@ -14,7 +14,6 @@ if (empty($config['git']['repositories']) || !is_dir($config['git']['repositorie
require 'vendor/autoload.php'; require 'vendor/autoload.php';
$app = new Silex\Application(); $app = new Silex\Application();
$app['baseurl'] = rtrim($config['app']['baseurl'], '/');
$app['filetypes'] = $config['filetypes']; $app['filetypes'] = $config['filetypes'];
$app['hidden'] = isset($config['git']['hidden']) ? $config['git']['hidden'] : array(); $app['hidden'] = isset($config['git']['hidden']) ? $config['git']['hidden'] : array();
$config['git']['repositories'] = rtrim($config['git']['repositories'], DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR; $config['git']['repositories'] = rtrim($config['git']['repositories'], DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR;
@@ -29,9 +28,14 @@ $app->register(new Git\GitServiceProvider(), array(
'git.repos' => $config['git']['repositories'], 'git.repos' => $config['git']['repositories'],
)); ));
$app->register(new Application\UtilsServiceProvider()); $app->register(new Application\UtilsServiceProvider());
$app->register(new Silex\Provider\UrlGeneratorServiceProvider());
// Add the md5() function to Twig scope $app['twig'] = $app->share($app->extend('twig', function($twig, $app) {
$app['twig']->addFilter('md5', new Twig_Filter_Function('md5')); // Add the md5() function to Twig scope
$twig->addFilter('md5', new Twig_Filter_Function('md5'));
return $twig;
}));
// Load controllers // Load controllers
include 'controllers/indexController.php'; include 'controllers/indexController.php';
@@ -44,8 +48,7 @@ include 'controllers/rssController.php';
// Error handling // Error handling
$app->error(function (\Exception $e, $code) use ($app) { $app->error(function (\Exception $e, $code) use ($app) {
return $app['twig']->render('error.twig', array( return $app['twig']->render('error.twig', array(
'baseurl' => $app['baseurl'], 'message' => $e->getMessage(),
'message' => $e->getMessage(),
)); ));
}); });

View File

@@ -24,21 +24,19 @@ class Utils
*/ */
public function getBreadcrumbs($spec) public function getBreadcrumbs($spec)
{ {
if (!$spec) {
return array();
}
$paths = explode('/', $spec); $paths = explode('/', $spec);
$last = '';
foreach ($paths as $path) { foreach ($paths as $i => $path) {
$dir['dir'] = $path; $breadcrumbs[] = array(
$dir['path'] = "$last/$path"; 'dir' => $path,
$breadcrumbs[] = $dir; 'path' => implode('/', array_slice($paths, 0, $i + 1)),
$last .= '/' . $path; );
} }
if (isset($paths[2])) {
$breadcrumbs[0]['path'] .= '/' . $paths[1] . '/' . $paths[2];
}
unset($breadcrumbs[1], $breadcrumbs[2]);
return $breadcrumbs; return $breadcrumbs;
} }

View File

@@ -11,13 +11,12 @@ class UtilsServiceProvider implements ServiceProviderInterface
* Register the Utils class on the Application ServiceProvider * Register the Utils class on the Application ServiceProvider
* *
* @param Application $app Silex Application * @param Application $app Silex Application
* @return Utils Instance of the Utils class
*/ */
public function register(Application $app) public function register(Application $app)
{ {
$app['utils'] = function () use ($app) { $app['utils'] = $app->share(function () use ($app) {
return new Utils($app); return new Utils($app);
}; });
} }
public function boot(Application $app) public function boot(Application $app)

View File

@@ -515,7 +515,7 @@ class Repository
continue; continue;
} }
preg_match_all("/([a-zA-Z0-9^]{8})[\s]+([0-9]+)\)(.+)/", $log, $match); preg_match_all("/([a-zA-Z0-9^]{8})\s+.*?([0-9]+)\)(.+)/", $log, $match);
$current_commit = $match[1][0]; $current_commit = $match[1][0];
if ($current_commit != $previous_commit) { if ($current_commit != $previous_commit) {

View File

@@ -1,20 +1,11 @@
{% extends 'layout.twig' %} {% extends 'layout_page.twig' %}
{% set page = 'commits' %}
{% block title %}GitList{% endblock %} {% block title %}GitList{% endblock %}
{% block body %} {% block content %}
{% include 'navigation.twig' %} {% include 'breadcrumb.twig' with {breadcrumbs: [{dir: 'Blame', path:''}]} %}
<div class="container">
<div class="row">
<div class="span12">
{% include 'menu.twig' %}
</div>
</div>
<ul class="breadcrumb">
<li><a href="{{ baseurl }}/{{ repo }}">{{ repo }}</a> <span class="divider">/</span></li>
<li>Blame</li>
</ul>
<div class="source-view"> <div class="source-view">
<div class="source-header"> <div class="source-header">
@@ -23,7 +14,7 @@
<table class="blame-view"> <table class="blame-view">
{% for blame in blames %} {% for blame in blames %}
<tr> <tr>
<td class="commit"><a href="{{ baseurl }}/{{ repo }}/commit/{{ blame.commit }}/">{{ blame.commit }}</a></td> <td class="commit"><a href="{{ path('commit', {repo: repo, commit: blame.commit}) }}">{{ blame.commit }}</a></td>
<td><pre>{{ blame.line }}</pre></td> <td><pre>{{ blame.line }}</pre></td>
</tr> </tr>
{% endfor %} {% endfor %}
@@ -31,7 +22,4 @@
</div> </div>
<hr> <hr>
{% include 'footer.twig' %}
</div>
{% endblock %} {% endblock %}

View File

@@ -3,12 +3,12 @@
<ul class="dropdown-menu"> <ul class="dropdown-menu">
<li class="dropdown-header">Branches</li> <li class="dropdown-header">Branches</li>
{% for item in branches %} {% for item in branches %}
<li><a href="{{ baseurl }}/{{ repo }}/tree/{{ item }}">{{ item }}</a></li> <li><a href="{{ path('branch', {repo: repo, branch: item}) }}">{{ item }}</a></li>
{% endfor %} {% endfor %}
{% if tags %} {% if tags %}
<li class="dropdown-header">Tags</li> <li class="dropdown-header">Tags</li>
{% for item in tags %} {% for item in tags %}
<li><a href="{{ baseurl }}/{{ repo }}/tree/{{ item }}">{{ item }}</a></li> <li><a href="{{ path('branch', {repo: repo, branch: item}) }}">{{ item }}</a></li>
{% endfor %} {% endfor %}
{% endif %} {% endif %}
</ul> </ul>

9
views/breadcrumb.twig Normal file
View File

@@ -0,0 +1,9 @@
<ul class="breadcrumb">
<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, branch: branch, tree: breadcrumb.path}) }}">{{ breadcrumb.dir }}</a>{% endif %}{% if loop.last %}{{ breadcrumb.dir }}{% endif %}</li>
{% endfor %}
{% block extra %}{% endblock %}
</ul>

View File

@@ -1,24 +1,15 @@
{% extends 'layout.twig' %} {% extends 'layout_page.twig' %}
{% set page = 'commits' %}
{% block title %}GitList{% endblock %} {% block title %}GitList{% endblock %}
{% block body %} {% block content %}
{% include 'navigation.twig' %} {% include 'breadcrumb.twig' with {breadcrumbs: [{dir: "Commit #{commit.getHash}", path:''}]} %}
<div class="container">
<div class="row">
<div class="span12">
{% include 'menu.twig' %}
</div>
</div>
<ul class="breadcrumb">
<li><a href="{{ baseurl }}/{{ repo }}">{{ repo }}</a> <span class="divider">/</span></li>
<li>Commit {{ commit.getHash}} </li>
</ul>
<div class="commit-view"> <div class="commit-view">
<div class="commit-header"> <div class="commit-header">
<span class="pull-right"><a class="btn btn-small" href="{{ baseurl }}/{{ repo }}/tree/{{ commit.getHash }}/" title="Browse code at this point in history"><i class="icon-list-alt"></i> Browse code</a></span> <span class="pull-right"><a class="btn btn-small" href="{{ path('branch', {repo: repo, branch: commit.getHash}) }}" title="Browse code at this point in history"><i class="icon-list-alt"></i> Browse code</a></span>
<h4>{{ commit.getMessage }}</h4> <h4>{{ commit.getMessage }}</h4>
</div> </div>
<div class="commit-body"> <div class="commit-body">
@@ -39,7 +30,7 @@
<div class="meta"><a name="{{ loop.index }}">{{ diff.getFile }}</div> <div class="meta"><a name="{{ loop.index }}">{{ diff.getFile }}</div>
<div class="btn-group pull-right"> <div class="btn-group pull-right">
<a href="{{ baseurl }}/{{ repo }}/blob/{{ commit.getHash }}/{{ diff.getFile }}" class="btn btn-small"><i class="icon-file"></i> View file @ {{ commit.getShortHash }}</a> <a href="{{ path('blob', {repo: repo, branch: commit.getHash, file: diff.getFile}) }}" class="btn btn-small"><i class="icon-file"></i> View file @ {{ commit.getShortHash }}</a>
</div> </div>
</div> </div>
@@ -52,7 +43,4 @@
{% endfor %} {% endfor %}
<hr> <hr>
{% include 'footer.twig' %}
</div>
{% endblock %} {% endblock %}

View File

@@ -1,21 +1,11 @@
{% extends 'layout.twig' %} {% extends 'layout_page.twig' %}
{% set page = 'commits' %}
{% block title %}GitList{% endblock %} {% block title %}GitList{% endblock %}
{% block body %} {% block content %}
{% include 'navigation.twig' %} {% include 'breadcrumb.twig' with {breadcrumbs: [{dir: 'Commit history', path:''}]} %}
<div class="container">
<div class="row">
<div class="span12">
{% include 'branch_menu.twig' %}
{% include 'menu.twig' %}
</div>
</div>
<ul class="breadcrumb">
<li><a href="{{ baseurl }}/{{ repo }}">{{ repo }}</a> <span class="divider">/</span></li>
<li>Commit history</li>
</ul>
{% for date, commit in commits %} {% for date, commit in commits %}
<table class="table table-striped table-bordered"> <table class="table table-striped table-bordered">
@@ -29,7 +19,7 @@
<tr> <tr>
<td width="5%"><img src="http://gravatar.com/avatar/{{ item.getAuthor.getEmail | md5 }}?s=40" /></td> <td width="5%"><img src="http://gravatar.com/avatar/{{ item.getAuthor.getEmail | md5 }}?s=40" /></td>
<td width="95%"> <td width="95%">
<span class="pull-right"><a class="btn btn-small" href="{{ baseurl }}/{{ repo }}/commit/{{ item.getShortHash }}"><i class="icon-list-alt"></i> View {{ item.getShortHash }}</a></span> <span class="pull-right"><a class="btn btn-small" href="{{ path('commit', {repo: repo, commit: item.getShortHash}) }}"><i class="icon-list-alt"></i> View {{ item.getShortHash }}</a></span>
<h4>{{ item.getMessage }}</h4> <h4>{{ item.getMessage }}</h4>
<span><a href="mailto:{{ item.getAuthor.getEmail }}">{{ item.getAuthor.getName }}</a> authored in {{ item.getDate | date('d/m/Y \\a\\t H:i:s') }}</span> <span><a href="mailto:{{ item.getAuthor.getEmail }}">{{ item.getAuthor.getName }}</a> authored in {{ item.getDate | date('d/m/Y \\a\\t H:i:s') }}</span>
</td> </td>
@@ -53,7 +43,4 @@
</ul> </ul>
<hr> <hr>
{% include 'footer.twig' %}
</div>
{% endblock %} {% endblock %}

View File

@@ -1,47 +1,28 @@
{% extends 'layout.twig' %} {% extends 'layout_page.twig' %}
{% set page = 'files' %}
{% block title %}GitList{% endblock %} {% block title %}GitList{% endblock %}
{% block body %} {% block content %}
{% include 'navigation.twig' %} {% include 'breadcrumb.twig' with {breadcrumbs: breadcrumbs} %}
<div class="container">
<div class="row">
<div class="span12">
{% include 'branch_menu.twig' %}
{% include 'menu.twig' %}
</div>
</div>
<ul class="breadcrumb">
{% for breadcrumb in breadcrumbs %}
<li{% if loop.last %} class="active"{% endif %}>{% if not loop.last %}<a href="{{ baseurl }}{{ breadcrumb.path }}">{{ breadcrumb.dir }}</a>{% endif %}{% if loop.last %}{{ breadcrumb.dir }}{% endif %}
{%- if not loop.last -%}
<span class="divider">/</span></li>
{%- else -%}
</li>
{%- endif -%}
{% endfor %}
</ul>
<div class="source-view"> <div class="source-view">
<div class="source-header"> <div class="source-header">
<div class="meta"></div> <div class="meta"></div>
<div class="btn-group pull-right"> <div class="btn-group pull-right">
<a href="{{ baseurl }}/{{ repo }}/raw/{{ branch }}/{{ file }}" class="btn btn-small"><i class="icon-file"></i> Raw</a> <a href="{{ path('blob_raw', {repo: repo, branch: branch, file: file}) }}" class="btn btn-small"><i class="icon-file"></i> Raw</a>
<a href="{{ baseurl }}/{{ repo }}/blame/{{ branch }}/{{ file }}" class="btn btn-small"><i class="icon-bullhorn"></i> Blame</a> <a href="{{ path('blame', {repo: repo, branch: branch, file: file}) }}" class="btn btn-small"><i class="icon-bullhorn"></i> Blame</a>
<a href="{{ baseurl }}/{{ repo }}/commits/{{ branch }}/{{ file }}" class="btn btn-small"><i class="icon-list-alt"></i> History</a> <a href="{{ path('commits', {repo: repo, branch: branch, file: file}) }}" class="btn btn-small"><i class="icon-list-alt"></i> History</a>
</div> </div>
</div> </div>
{% if fileType == 'image' %} {% if fileType == 'image' %}
<center><img src="{{ baseurl }}/{{ repo }}/raw/{{ branch }}/{{ file }}" alt="{{ file }}" class="image-blob" /></center> <center><img src="{{ path('blob_raw', {repo: repo, branch: branch, file: file}) }}" alt="{{ file }}" class="image-blob" /></center>
{% else %} {% else %}
<pre id="sourcecode" language="{{ fileType }}">{{ blob }}</pre> <pre id="sourcecode" language="{{ fileType }}">{{ blob }}</pre>
{% endif %} {% endif %}
</div> </div>
<hr> <hr>
{% include 'footer.twig' %}
</div>
{% endblock %} {% endblock %}

View File

@@ -9,8 +9,8 @@
{% for repository in repositories %} {% for repository in repositories %}
<div class="repository"> <div class="repository">
<div class="repository-header"> <div class="repository-header">
<i class="icon-folder-open icon-spaced"></i> <a href="{{ baseurl }}/{{ repository.name }}">{{ repository.name }}</a> <i class="icon-folder-open icon-spaced"></i> <a href="{{ path('repository', {repo: repository.name}) }}">{{ repository.name }}</a>
<a href="{{ baseurl }}/{{ repository.name }}/master/rss/"><i class="rss pull-right"></i></a> <a href="{{ path('rss', {repo: repository.name, branch: 'master'}) }}"><i class="rss pull-right"></i></a>
</div> </div>
<div class="repository-body"> <div class="repository-body">
<p>{{ repository.description }}</p> <p>{{ repository.description }}</p>

View File

@@ -3,18 +3,18 @@
<head> <head>
<meta charset="UTF-8" /> <meta charset="UTF-8" />
<title>{% block title %}Welcome!{% endblock %}</title> <title>{% block title %}Welcome!{% endblock %}</title>
<link rel="stylesheet" type="text/css" href="{{ baseurl }}/web/css/style.css"> <link rel="stylesheet" type="text/css" href="{{ app.request.basepath }}/web/css/style.css">
<!--[if lt IE 9]> <!--[if lt IE 9]>
<script src="{{ baseurl }}/web/js/html5.js"></script> <script src="{{ app.request.basepath }}/web/js/html5.js"></script>
<![endif]--> <![endif]-->
</head> </head>
<body> <body>
{% block body %}{% endblock %} {% block body %}{% endblock %}
<script src="{{ baseurl }}/web/js/jquery.js"></script> <script src="{{ app.request.basepath }}/web/js/jquery.js"></script>
<script src="{{ baseurl }}/web/js/bootstrap.js"></script> <script src="{{ app.request.basepath }}/web/js/bootstrap.js"></script>
<script src="{{ baseurl }}/web/js/codemirror.js"></script> <script src="{{ app.request.basepath }}/web/js/codemirror.js"></script>
<script src="{{ baseurl }}/web/js/showdown.js"></script> <script src="{{ app.request.basepath }}/web/js/showdown.js"></script>
<script src="{{ baseurl }}/web/js/main.js"></script> <script src="{{ app.request.basepath }}/web/js/main.js"></script>
</body> </body>
</html> </html>

22
views/layout_page.twig Normal file
View File

@@ -0,0 +1,22 @@
{% extends 'layout.twig' %}
{% block body %}
{% include 'navigation.twig' %}
<div class="container">
<div class="row">
<div class="span12">
{% if branches is defined %}
{% include 'branch_menu.twig' %}
{% endif %}
{% include 'menu.twig' %}
</div>
</div>
{% block content %}{% endblock %}
<hr>
{% include 'footer.twig' %}
</div>
{% endblock %}

View File

@@ -1,5 +1,5 @@
<ul class="nav nav-tabs"> <ul class="nav nav-tabs">
<li{% if page == 'files' %} class="active"{% endif %}><a href="{{ baseurl }}/{{ repo }}/tree/{{ branch }}">Files</a></li> <li{% if page == 'files' %} class="active"{% endif %}><a href="{{ path('branch', {repo: repo, branch: branch}) }}">Files</a></li>
<li{% if page == 'commits' %} class="active"{% endif %}><a href="{{ baseurl }}/{{ repo }}/commits/{{ branch }}">Commits</a></li> <li{% if page == 'commits' %} class="active"{% endif %}><a href="{{ path('commits', {repo: repo, branch: branch}) }}">Commits</a></li>
<li{% if page == 'stats' %} class="active"{% endif %}><a href="{{ baseurl }}/{{ repo }}/stats/{{ branch }}">Stats</a></li> <li{% if page == 'stats' %} class="active"{% endif %}><a href="{{ path('stats', {repo: repo, branch: branch}) }}">Stats</a></li>
</ul> </ul>

View File

@@ -6,7 +6,7 @@
<span class="icon-bar"></span> <span class="icon-bar"></span>
<span class="icon-bar"></span> <span class="icon-bar"></span>
</a> </a>
<a class="brand" href="{{ baseurl }}">GitList</a> <a class="brand" href="{{ path('homepage') }}">GitList</a>
<div class="nav-collapse"> <div class="nav-collapse">
<ul class="nav pull-right"> <ul class="nav pull-right">
<li><a href="http://gitlist.org/">About</a></li> <li><a href="http://gitlist.org/">About</a></li>

View File

@@ -3,13 +3,13 @@
<channel> <channel>
<title>Latest commits in {{ repo }}:{{ branch }}</title> <title>Latest commits in {{ repo }}:{{ branch }}</title>
<description>RSS provided by GitList</description> <description>RSS provided by GitList</description>
<link>{{ baseurl }}/</link> <link>{{ path('homepage') }}</link>
{% for commit in commits %} {% for commit in commits %}
<item> <item>
<title>{{ commit.getMessage }}</title> <title>{{ commit.getMessage }}</title>
<description>{{ commit.getAuthor.getName }} authored {{ commit.getShortHash }} in {{ commit.getDate | date('d/m/Y \\a\\t H:i:s') }}</description> <description>{{ commit.getAuthor.getName }} authored {{ commit.getShortHash }} in {{ commit.getDate | date('d/m/Y \\a\\t H:i:s') }}</description>
<link>{{ baseurl }}/{{ repo }}/commit/{{ commit.getShortHash }}</link> <link>{{ path('commit', {repo: repo, commit: commit.getShortHash}) }}</link>
<pubDate>{{ commit.getDate | date('r') }}</pubDate> <pubDate>{{ commit.getDate | date('r') }}</pubDate>
</item> </item>
{% endfor %} {% endfor %}

View File

@@ -1,21 +1,11 @@
{% extends 'layout.twig' %} {% extends 'layout_page.twig' %}
{% set page = 'stats' %}
{% block title %}GitList{% endblock %} {% block title %}GitList{% endblock %}
{% block body %} {% block content %}
{% include 'navigation.twig' %} {% include 'breadcrumb.twig' with {breadcrumbs: [{dir: 'Statistics', path:''}]} %}
<div class="container">
<div class="row">
<div class="span12">
{% include 'branch_menu.twig' %}
{% include 'menu.twig' %}
</div>
</div>
<ul class="breadcrumb">
<li><a href="{{ baseurl }}/{{ repo }}">{{ repo }}</a> <span class="divider">/</span></li>
<li>Statistics</li>
</ul>
<table class="table table-striped table-bordered"> <table class="table table-striped table-bordered">
<thead> <thead>
@@ -55,7 +45,4 @@
</table> </table>
<hr> <hr>
{% include 'footer.twig' %}
</div>
{% endblock %} {% endblock %}

View File

@@ -1,28 +1,15 @@
{% extends 'layout.twig' %} {% extends 'layout_page.twig' %}
{% set page = 'files' %}
{% block title %}GitList{% endblock %} {% block title %}GitList{% endblock %}
{% block body %} {% block content %}
{% include 'navigation.twig' %} {% embed 'breadcrumb.twig' with {breadcrumbs: breadcrumbs} %}
{% block extra %}
<div class="container"> <a href="{{ path('rss', {repo: repo, branch: branch}) }}"><i class="rss pull-right"></i></a>
<div class="row"> {% endblock %}
<div class="span12"> {% endembed %}
{% include 'branch_menu.twig' %}
{% include 'menu.twig' %}
</div>
</div>
<ul class="breadcrumb">
{% for breadcrumb in breadcrumbs %}
<li{% if loop.last %} class="active"{% endif %}>{% if not loop.last %}<a href="{{ baseurl }}{{ breadcrumb.path }}">{{ breadcrumb.dir }}</a>{% endif %}{% if loop.last %}{{ breadcrumb.dir }}{% endif %}
{%- if not loop.last -%}
<span class="divider">/</span></li>
{%- else -%}
</li>
{%- endif -%}
{% endfor %}
<a href="{{ baseurl }}/{{ repo }}/{{ branch }}/rss/"><i class="rss pull-right"></i></a>
</ul>
<table class="tree"> <table class="tree">
<thead> <thead>
@@ -33,16 +20,28 @@
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
{% if parent is not empty %} {% if parent is not null %}
<tr> <tr>
<td><i class="icon-spaced"></i> <a href="{{ baseurl }}/{{ repo }}/tree/{{ branch }}{{ parent }}">..</a></td> <td><i class="icon-spaced"></i>
{% if not parent %}
<a href="{{ path('branch', {repo: repo, branch: branch}) }}">..</a>
{% else %}
<a href="{{ path('tree', {repo: repo, branch: branch, tree: parent}) }}">..</a>
{% endif %}
</td>
<td></td> <td></td>
<td></td> <td></td>
</tr> </tr>
{% endif %} {% endif %}
{% for file in files %} {% for file in files %}
<tr> <tr>
<td><i class="{{ file.type == "folder" or file.type == "symlink" ? "icon-folder-open" : "icon-file" }} icon-spaced"></i> <a href="{{ baseurl }}/{{ repo }}/{{ file.type == "folder" or file.type == "symlink" ? "tree" : "blob" }}/{{ branch }}/{{ path }}{{ file.type == "symlink" ? file.path : file.name }}">{{ file.name }}</a></td> <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, branch: branch, tree: path ~ (file.type == "symlink" ? file.path : file.name)}) }}
{% else %}
{{ path('blob', {repo: repo, branch: branch, file: path ~ (file.type == "symlink" ? file.path : file.name)}) }}
{% endif -%}
">{{ file.name }}</a></td>
<td>{{ file.mode }}</td> <td>{{ file.mode }}</td>
<td>{% if file.size %}{{ (file.size / 1024) | number_format }} kb{% endif %}</td> <td>{% if file.size %}{{ (file.size / 1024) | number_format }} kb{% endif %}</td>
</tr> </tr>
@@ -57,9 +56,4 @@
<div id="readme-content">{{ readme.content }}</div> <div id="readme-content">{{ readme.content }}</div>
</div> </div>
{% endif %} {% endif %}
<hr>
{% include 'footer.twig' %}
</div>
{% endblock %} {% endblock %}