update final for sandframework site-web with git-folder download
This commit is contained in:
parent
c0ab3e31ad
commit
2f89c46410
2222 changed files with 276304 additions and 130 deletions
|
|
@ -0,0 +1,77 @@
|
|||
<?php
|
||||
|
||||
namespace GitList\Controller;
|
||||
|
||||
use Silex\ControllerProviderInterface;
|
||||
use Silex\Application;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
class MainController implements ControllerProviderInterface
|
||||
{
|
||||
public function connect(Application $app)
|
||||
{
|
||||
$route = $app['controllers_factory'];
|
||||
|
||||
$route->get(MODULE_NAME.'/', function () use ($app) {
|
||||
$repositories = $app['git']->getRepositories($app['git.repos']);
|
||||
|
||||
return $app['twig']->render('index.twig', array(
|
||||
'repositories' => $repositories,
|
||||
));
|
||||
})->bind('homepage');
|
||||
|
||||
$route->get(MODULE_NAME.'/refresh', function (Request $request) use ($app) {
|
||||
// Go back to calling page
|
||||
return $app->redirect($request->headers->get('Referer'));
|
||||
})->bind('refresh');
|
||||
|
||||
$route->get(MODULE_NAME.'/{repo}/stats/{branch}', function ($repo, $branch) use ($app) {
|
||||
$repository = $app['git']->getRepositoryFromName($app['git.repos'], $repo);
|
||||
|
||||
if ($branch === null) {
|
||||
$branch = $repository->getHead();
|
||||
}
|
||||
|
||||
$stats = $repository->getBranchStatistics($branch);
|
||||
$authors = $repository->getAuthorStatistics($branch);
|
||||
|
||||
return $app['twig']->render('stats.twig', array(
|
||||
'repo' => $repo,
|
||||
'branch' => $branch,
|
||||
'branches' => $repository->getBranches(),
|
||||
'tags' => $repository->getTags(),
|
||||
'stats' => $stats,
|
||||
'authors' => $authors,
|
||||
));
|
||||
})->assert('repo', $app['util.routing']->getRepositoryRegex())
|
||||
->assert('branch', $app['util.routing']->getBranchRegex())
|
||||
->value('branch', null)
|
||||
->convert('branch', 'escaper.argument:escape')
|
||||
->bind('stats');
|
||||
|
||||
$route->get(MODULE_NAME.'/{repo}/{branch}/rss/', function ($repo, $branch) use ($app) {
|
||||
$repository = $app['git']->getRepositoryFromName($app['git.repos'], $repo);
|
||||
|
||||
if ($branch === null) {
|
||||
$branch = $repository->getHead();
|
||||
}
|
||||
|
||||
$commits = $repository->getPaginatedCommits($branch);
|
||||
|
||||
$html = $app['twig']->render('rss.twig', array(
|
||||
'repo' => $repo,
|
||||
'branch' => $branch,
|
||||
'commits' => $commits,
|
||||
));
|
||||
|
||||
return new Response($html, 200, array('Content-Type' => 'application/rss+xml'));
|
||||
})->assert('repo', $app['util.routing']->getRepositoryRegex())
|
||||
->assert('branch', $app['util.routing']->getBranchRegex())
|
||||
->value('branch', null)
|
||||
->convert('branch', 'escaper.argument:escape')
|
||||
->bind('rss');
|
||||
|
||||
return $route;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue