diff --git a/.htaccess b/.htaccess index efb9407..cd0335e 100644 --- a/.htaccess +++ b/.htaccess @@ -3,7 +3,7 @@ RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f - RewriteRule ^(.*)$ /index.php [L,NC] + RewriteRule ^(.*)$ index.php [L,NC] order allow,deny diff --git a/boot.php b/boot.php index 5e36efe..a7336b2 100644 --- a/boot.php +++ b/boot.php @@ -4,7 +4,22 @@ if (!isset($config)) { die("No configuration object provided."); } -$config->set('git', 'repositories', rtrim($config->get('git', 'repositories'), DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR); +$repositories = $config->get('git', 'repositories'); + +if ( !is_array( $repositories ) ) { + # Convert the single item to an array - this is the internal handling + $repositories = array( $repositories ); +} + +$tmp_arr = array(); +foreach( $repositories as $repo ) { + $tmp = rtrim($repo, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR; + $tmp_arr []= $tmp; +} +$repositories = $tmp_arr; + +$config->set('git', 'repositories', $repositories); + // Startup and configure Silex application $app = new GitList\Application($config, __DIR__); diff --git a/index.php b/index.php index 51eaaa6..76807cb 100644 --- a/index.php +++ b/index.php @@ -1,5 +1,7 @@ "; + /** * GitList 0.3 * https://github.com/klaussilveira/gitlist @@ -16,4 +18,7 @@ require 'vendor/autoload.php'; $config = GitList\Config::fromFile('config.ini'); $app = require 'boot.php'; + +echo ""; + $app->run(); diff --git a/src/GitList/Config.php b/src/GitList/Config.php index 33d5b39..31bb07b 100644 --- a/src/GitList/Config.php +++ b/src/GitList/Config.php @@ -49,8 +49,11 @@ class Config protected function validateOptions() { - if (!$this->get('git', 'repositories') || !is_dir($this->get('git', 'repositories'))) { - die("Please, edit the config file and provide your repositories directory"); + foreach ( $this->get('git', 'repositories') as $dir ) { + echo $dir; + if (!$dir || !is_dir($dir)) { + die("Please, edit the config file and provide your repositories directory"); + } } } } diff --git a/src/GitList/Controller/MainController.php b/src/GitList/Controller/MainController.php index 89b6f62..b99fafd 100644 --- a/src/GitList/Controller/MainController.php +++ b/src/GitList/Controller/MainController.php @@ -13,6 +13,7 @@ class MainController implements ControllerProviderInterface $route = $app['controllers_factory']; $route->get('/', function() use ($app) { +/* $repositories = array_map( function ($repo) use ($app) { $repo['relativePath'] = $app['util.routing']->getRelativePath($repo['path']); @@ -20,6 +21,9 @@ class MainController implements ControllerProviderInterface }, $app['git']->getRepositories($app['git.repos']) ); +*/ + + $repositories = $app['git']->getRepositories($app['git.repos']); return $app['twig']->render('index.twig', array( 'repositories' => $repositories, @@ -27,6 +31,7 @@ class MainController implements ControllerProviderInterface })->bind('homepage'); $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); $stats = $repository->getStatistics($branch); $authors = $repository->getAuthorStatistics(); diff --git a/src/GitList/Util/Routing.php b/src/GitList/Util/Routing.php index 884e251..f729435 100644 --- a/src/GitList/Util/Routing.php +++ b/src/GitList/Util/Routing.php @@ -20,8 +20,11 @@ class Routing if ($regex === null) { $app = $this->app; $quotedPaths = array_map( + #function ($repo) use ($app) { + # return preg_quote($app['util.routing']->getRelativePath($repo['path']), '#'); + #}, function ($repo) use ($app) { - return preg_quote($app['util.routing']->getRelativePath($repo['path']), '#'); + return $repo['path']; }, $this->app['git']->getRepositories($this->app['git.repos']) );