mirror of
https://github.com/klaussilveira/gitlist.git
synced 2026-05-07 11:55:34 +02:00
Figured out how use repository hash. Not fully implemented.
This commit is contained in:
4
boot.php
4
boot.php
@@ -18,16 +18,18 @@ foreach( $repositories as $repo ) {
|
||||
}
|
||||
$repositories = $tmp_arr;
|
||||
|
||||
$config->set('git', 'repositories', $repositories);
|
||||
|
||||
|
||||
// Startup and configure Silex application
|
||||
$app = new GitList\Application($config, __DIR__);
|
||||
|
||||
|
||||
// Mount the controllers
|
||||
$app->mount('', new GitList\Controller\MainController());
|
||||
$app->mount('', new GitList\Controller\BlobController());
|
||||
$app->mount('', new GitList\Controller\CommitController());
|
||||
$app->mount('', new GitList\Controller\TreeController());
|
||||
|
||||
|
||||
|
||||
return $app;
|
||||
|
||||
@@ -37,9 +37,17 @@ class Application extends SilexApplication
|
||||
'twig.path' => $root . DIRECTORY_SEPARATOR . 'views',
|
||||
'twig.options' => array('cache' => $root . DIRECTORY_SEPARATOR . 'cache' . DIRECTORY_SEPARATOR . 'views'),
|
||||
));
|
||||
|
||||
$repositories = $config->get('git', 'repositories');
|
||||
/*
|
||||
echo "doing this\n";
|
||||
$repositories = $app['git']->getRepositories($repositories);
|
||||
$config->set('git', 'repositories', $repositories);
|
||||
*/
|
||||
|
||||
$this->register(new GitServiceProvider(), array(
|
||||
'git.client' => $config->get('git', 'client'),
|
||||
'git.repos' => $config->get('git', 'repositories'),
|
||||
'git.repos' => $repositories,
|
||||
'git.hidden' => $config->get('git', 'hidden') ? $config->get('git', 'hidden') : array(),
|
||||
));
|
||||
$this->register(new ViewUtilServiceProvider());
|
||||
|
||||
@@ -13,7 +13,14 @@ class CommitController implements ControllerProviderInterface
|
||||
$route = $app['controllers_factory'];
|
||||
|
||||
$route->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);
|
||||
|
||||
# NOTE: this call is to the ONE Client!
|
||||
$repositories = $app['git']->getRepositories($app['git.repos']);
|
||||
$path = $repositories[ $repo ]['path'];
|
||||
|
||||
# NOTE: this call is to the OTHER Client!
|
||||
$repository = $app['git']->getRepository($path);
|
||||
|
||||
list($branch, $file) = $app['util.repository']->extractRef($repository, $branch, $file);
|
||||
|
||||
|
||||
@@ -24,6 +24,9 @@ class MainController implements ControllerProviderInterface
|
||||
*/
|
||||
|
||||
$repositories = $app['git']->getRepositories($app['git.repos']);
|
||||
echo "Doing that\n";
|
||||
#$repositories = $app['git.repos'];
|
||||
print_r( $repositories );
|
||||
|
||||
return $app['twig']->render('index.twig', array(
|
||||
'repositories' => $repositories,
|
||||
@@ -32,7 +35,14 @@ class MainController implements ControllerProviderInterface
|
||||
|
||||
$route->get('{repo}/stats/{branch}', function($repo, $branch) use ($app) {
|
||||
#$repository = $app['git']->getRepository($app['git.repos'][$repo]);
|
||||
$repository = $app['git']->getRepository($app['git.repos'] . $repo);
|
||||
|
||||
# NOTE: this call is to the ONE Client!
|
||||
$repositories = $app['git']->getRepositories($app['git.repos']);
|
||||
$path = $repositories[ $repo ]['path'];
|
||||
|
||||
# NOTE: this call is to the OTHER Client!
|
||||
$repository = $app['git']->getRepository($path);
|
||||
|
||||
$stats = $repository->getStatistics($branch);
|
||||
$authors = $repository->getAuthorStatistics();
|
||||
|
||||
@@ -50,7 +60,15 @@ class MainController implements ControllerProviderInterface
|
||||
->bind('stats');
|
||||
|
||||
$route->get('{repo}/{branch}/rss/', function($repo, $branch) use ($app) {
|
||||
$repository = $app['git']->getRepository($app['git.repos'] . $repo);
|
||||
#$repository = $app['git']->getRepository($app['git.repos'] );
|
||||
|
||||
# NOTE: this call is to the ONE Client!
|
||||
$repositories = $app['git']->getRepositories($app['git.repos']);
|
||||
$path = $repositories[ $repo ]['path'];
|
||||
|
||||
# NOTE: this call is to the OTHER Client!
|
||||
$repository = $app['git']->getRepository($path);
|
||||
|
||||
$commits = $repository->getPaginatedCommits($branch);
|
||||
|
||||
$html = $app['twig']->render('rss.twig', array(
|
||||
|
||||
@@ -14,7 +14,14 @@ class TreeController implements ControllerProviderInterface
|
||||
$route = $app['controllers_factory'];
|
||||
|
||||
$route->get('{repo}/tree/{branch}/{tree}/', $treeController = function($repo, $branch = '', $tree = '') use ($app) {
|
||||
$repository = $app['git']->getRepository($app['git.repos'] . $repo);
|
||||
|
||||
# NOTE: this call is to the ONE Client!
|
||||
$repositories = $app['git']->getRepositories($app['git.repos']);
|
||||
$path = $repositories[ $repo ]['path'];
|
||||
|
||||
# NOTE: this call is to the OTHER Client!
|
||||
$repository = $app['git']->getRepository($path);
|
||||
|
||||
if (!$branch) {
|
||||
$branch = $repository->getHead();
|
||||
}
|
||||
@@ -39,7 +46,7 @@ class TreeController implements ControllerProviderInterface
|
||||
'breadcrumbs' => $breadcrumbs,
|
||||
'branches' => $repository->getBranches(),
|
||||
'tags' => $repository->getTags(),
|
||||
'readme' => $app['util.repository']->getReadme($repo, $branch),
|
||||
'readme' => $app['util.repository']->getReadme($repository, $branch),
|
||||
));
|
||||
})->assert('repo', $app['util.routing']->getRepositoryRegex())
|
||||
->assert('branch', '[\w-._\/]+')
|
||||
@@ -47,7 +54,7 @@ class TreeController implements ControllerProviderInterface
|
||||
->bind('tree');
|
||||
|
||||
$route->post('{repo}/tree/{branch}/search', function(Request $request, $repo, $branch = '', $tree = '') use ($app) {
|
||||
$repository = $app['git']->getRepository($app['git.repos'] . $repo);
|
||||
$repository = $app['git']->getRepository($app['git.repos'][ $repo ]);
|
||||
|
||||
if (!$branch) {
|
||||
$branch = $repository->getHead();
|
||||
|
||||
@@ -31,6 +31,8 @@ class Client extends BaseClient
|
||||
*/
|
||||
public function getRepository($path)
|
||||
{
|
||||
echo "this getRepository2\n";
|
||||
|
||||
if (!file_exists($path) || !file_exists($path . '/.git/HEAD') && !file_exists($path . '/HEAD')) {
|
||||
throw new \RuntimeException('There is no GIT repository at ' . $path);
|
||||
}
|
||||
|
||||
@@ -160,9 +160,9 @@ class Repository
|
||||
return false;
|
||||
}
|
||||
|
||||
public function getReadme($repo, $branch = 'master')
|
||||
public function getReadme($repository, $branch = 'master')
|
||||
{
|
||||
$repository = $this->app['git']->getRepository($this->app['git.repos'] . $repo);
|
||||
#$repository = $this->app['git']->getRepository($this->app['git.repos'][$repo ]);
|
||||
$files = $repository->getTree($branch)->output();
|
||||
|
||||
foreach ($files as $file) {
|
||||
|
||||
@@ -23,8 +23,9 @@ class Routing
|
||||
#function ($repo) use ($app) {
|
||||
# return preg_quote($app['util.routing']->getRelativePath($repo['path']), '#');
|
||||
#},
|
||||
# TODO: return keys instead
|
||||
function ($repo) use ($app) {
|
||||
return $repo['path'];
|
||||
return $repo['name'];
|
||||
},
|
||||
$this->app['git']->getRepositories($this->app['git.repos'])
|
||||
);
|
||||
|
||||
@@ -9,8 +9,8 @@
|
||||
{% for repository in repositories %}
|
||||
<div class="repository">
|
||||
<div class="repository-header">
|
||||
<i class="icon-folder-open icon-spaced"></i> <a href="{{ path('repository', {repo: repository.relativePath}) }}">{{ repository.name }}</a>
|
||||
<a href="{{ path('rss', {repo: repository.relativePath, branch: 'master'}) }}"><i class="rss pull-right"></i></a>
|
||||
<i class="icon-folder-open icon-spaced"></i> <a href="{{ path('repository', {repo: repository.name}) }}">{{ repository.name }}</a>
|
||||
<a href="{{ path('rss', {repo: repository.name, branch: 'master'}) }}"><i class="rss pull-right"></i></a>
|
||||
</div>
|
||||
<div class="repository-body">
|
||||
<p>{{ repository.description }}</p>
|
||||
|
||||
Reference in New Issue
Block a user