Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
klaussilveira committed May 18, 2012
0 parents commit df43c98
Show file tree
Hide file tree
Showing 244 changed files with 20,826 additions and 0 deletions.
28 changes: 28 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
cache/
*.diff
*.err
*.orig
*.log
*.rej
*.swo
*.swp
*.zip
*.vi
*~
*.sass-cache
.DS_Store
._*
Thumbs.db
.cache
.project
.settings
.tmproj
*.esproj
nbproject
*.sublime-project
*.sublime-workspace
.hg
.svn
.CVS
.idea
node_modules
7 changes: 7 additions & 0 deletions .htaccess
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<IfModule mod_rewrite.c>
Options -MultiViews

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
5 changes: 5 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
language: php
php:
- 5.3
- 5.4
script: phpunit
9 changes: 9 additions & 0 deletions LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Copyright (c) 2012, Klaus Silveira and contributors
All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
Neither the name of GitList nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
53 changes: 53 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# GitList: an elegant and modern git repository viewer
[![Build Status](https://secure.travis-ci.org/klaussilveira/GitList.png)](http://travis-ci.org/klaussilveira/GitList)

GitList is an elegant and modern web interface for interacting with multiple git repositories. It allows you to browse repositories using your favorite browser, viewing files under different revisions, commit history, diffs. It also generates RSS feeds for each repository, allowing you to stay up-to-date with the latest changes anytime, anywhere. GitList was written in PHP, on top of the [Silex](http://silex.sensiolabs.org/) microframework and powered by the Twig template engine. This means that GitList is easy to install and easy to customize. Also, the GitList gorgeous interface was made possible due to [Bootstrap](http://twitter.github.com/bootstrap/).

## Features
* Multiple repository support
* Multiple branch support
* Multiple tag support
* Commit history, blame, diff
* RSS feeds
* Syntax highlighting
* Repository statistics

## Authors and contributors
* [Klaus Silveira](http://www.klaussilveira.com) (Creator, developer)

## License
[New BSD license](http://www.opensource.org/licenses/bsd-license.php)

## Todo
* improve the current test code coverage
* test the interface
* error handling can be greatly improved during parsing
* submodule support
* multilanguage support

## Requirements
In order to run GitList on your server, you'll need:

* git
* Apache and mod_rewrite enabled
* PHP 5.3.3

## Installing
Download the GitList latest package and decompress to your `/var/www/gitlist` folder, or anywhere else you want to place GitList. You can also clone the repository:

```
git clone https://github.com/klaussilveira/gitlist.git /var/www/gitlist
```

Now open up the `config.ini` and configure your installation. You'll have to provide where your repositories are located and the base GitList URL (in our case, http://localhost/gitlist). Now, let's create the cache folder and give the correct permissions:

```
cd /var/www/gitlist
mkdir cache
chmod 777 cache
```

That's it, installation complete!

## Further information
If you want to know more about customizing GitList, check the [Customization](https://github.com/klaussilveira/gitlist/wiki/Customizing) page on the wiki. Also, if you're having problems with GitList, check the [Troubleshooting](https://github.com/klaussilveira/gitlist/wiki/Customizing) page. Don't forget to report issues and suggest new features! :)
6 changes: 6 additions & 0 deletions config.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[git]
client = '/usr/bin/git' ; Your git executable path
repositories = '/home/git/' ; Path to your repositories (with ending slash)

[app]
baseurl = 'http://localhost/gitlist' ; Base URL of the application (without ending slash)
32 changes: 32 additions & 0 deletions controllers/blobController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php

$app->get('{repo}/blob/{branch}/{file}/', function($repo, $branch, $file) use($app) {
$repository = $app['git']->getRepository($app['git.repos'] . $repo);
$blob = $repository->getBlob("$branch:$file");
$breadcrumbs = $app['utils']->getBreadcrumbs("$repo/tree/$branch/$file");
$fileType = $app['utils']->getFileType($file);

return $app['twig']->render('file.twig', array(
'baseurl' => $app['baseurl'],
'page' => 'files',
'file' => $file,
'fileType' => $fileType,
'blob' => $blob->output(),
'repo' => $repo,
'branch' => $branch,
'breadcrumbs' => $breadcrumbs,
'branches' => $repository->getBranches(),
'tags' => $repository->getTags(),
));
})->assert('file', '.+')
->assert('repo', '[\w-._]+')
->assert('branch', '[\w-._]+');

$app->get('{repo}/raw/{branch}/{file}', function($repo, $branch, $file) use($app) {
$repository = $app['git']->getRepository($app['git.repos'] . $repo);
$blob = $repository->getBlob("$branch:$file")->output();

return new Symfony\Component\HttpFoundation\Response($blob, 200, array('Content-Type' => 'text/plain'));
})->assert('file', '.+')
->assert('repo', '[\w-._]+')
->assert('branch', '[\w-._]+');
79 changes: 79 additions & 0 deletions controllers/commitController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
<?php

$app->get('{repo}/commits/{branch}', function($repo, $branch) use($app) {
$repository = $app['git']->getRepository($app['git.repos'] . $repo);
$commits = $repository->getCommits();

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',
'repo' => $repo,
'branch' => $branch,
'branches' => $repository->getBranches(),
'tags' => $repository->getTags(),
'commits' => $categorized,
));
})->assert('repo', '[\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);
$commits = $repository->getCommits($file);

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',
'repo' => $repo,
'branch' => $branch,
'branches' => $repository->getBranches(),
'tags' => $repository->getTags(),
'commits' => $categorized,
));
})->assert('repo', '[\w-._]+')
->assert('file', '.+')
->assert('branch', '[\w-._]+');

$app->get('{repo}/commit/{commit}/', function($repo, $commit) use($app) {
$repository = $app['git']->getRepository($app['git.repos'] . $repo);
$commit = $repository->getCommit($commit);

return $app['twig']->render('commit.twig', array(
'baseurl' => $app['baseurl'],
'page' => 'commits',
'branch' => 'master',
'repo' => $repo,
'commit' => $commit,
));
})->assert('repo', '[\w-._]+')
->assert('commit', '[a-f0-9]+');

$app->get('{repo}/blame/{branch}/{file}/', function($repo, $branch, $file) use($app) {
$repository = $app['git']->getRepository($app['git.repos'] . $repo);
$blames = $repository->getBlame($file);

return $app['twig']->render('blame.twig', array(
'baseurl' => $app['baseurl'],
'page' => 'commits',
'file' => $file,
'repo' => $repo,
'branch' => $branch,
'branches' => $repository->getBranches(),
'tags' => $repository->getTags(),
'blames' => $blames,
));
})->assert('repo', '[\w-._]+')
->assert('file', '.+')
->assert('branch', '[\w-._]+');
10 changes: 10 additions & 0 deletions controllers/indexController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

$app->get('/', function() use($app) {
$repositories = $app['git']->getRepositories($app['git.repos']);

return $app['twig']->render('index.twig', array(
'baseurl' => $app['baseurl'],
'repositories' => $repositories,
));
});
16 changes: 16 additions & 0 deletions controllers/rssController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

$app->get('{repo}/{branch}/rss/', function($repo, $branch) use($app) {
$repository = $app['git']->getRepository($app['git.repos'] . $repo);
$commits = $repository->getCommits();

$html = $app['twig']->render('rss.twig', array(
'baseurl' => $app['baseurl'],
'repo' => $repo,
'branch' => $branch,
'commits' => $commits,
));

return new Symfony\Component\HttpFoundation\Response($html, 200, array('Content-Type' => 'application/rss+xml'));
})->assert('repo', '[\w-._]+')
->assert('branch', '[\w-._]+');
20 changes: 20 additions & 0 deletions controllers/statsController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

$app->get('{repo}/stats/{branch}', function($repo, $branch) use($app) {
$repository = $app['git']->getRepository($app['git.repos'] . $repo);
$stats = $repository->getStatistics($branch);
$authors = $repository->getAuthorStatistics();

return $app['twig']->render('stats.twig', array(
'baseurl' => $app['baseurl'],
'page' => 'stats',
'repo' => $repo,
'branch' => $branch,
'branches' => $repository->getBranches(),
'tags' => $repository->getTags(),
'stats' => $stats,
'authors' => $authors,
));
})->assert('repo', '[\w-._]+')
->assert('branch', '[\w-._]+')
->value('branch', 'master');
67 changes: 67 additions & 0 deletions controllers/treeController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
<?php

$app->get('{repo}/', function($repo) use($app) {
$repository = $app['git']->getRepository($app['git.repos'] . $repo);
$tree = $repository->getTree('master');
$breadcrumbs = $app['utils']->getBreadcrumbs("$repo/");

return $app['twig']->render('tree.twig', array(
'baseurl' => $app['baseurl'],
'page' => 'files',
'files' => $tree->output(),
'repo' => $repo,
'branch' => 'master',
'path' => '',
'parent' => '',
'breadcrumbs' => $breadcrumbs,
'branches' => $repository->getBranches(),
'tags' => $repository->getTags(),
));
})->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,
'branch' => $branch,
'path' => '',
'parent' => '',
'breadcrumbs' => $breadcrumbs,
'branches' => $repository->getBranches(),
'tags' => $repository->getTags(),
));
})->assert('repo', '[\w-._]+')
->assert('branch', '[\w-._]+');

$app->get('{repo}/tree/{branch}/{tree}/', function($repo, $branch, $tree) use($app) {
$repository = $app['git']->getRepository($app['git.repos'] . $repo);
$files = $repository->getTree("$branch:$tree/");
$breadcrumbs = $app['utils']->getBreadcrumbs("$repo/tree/$branch/$tree");

if (($slash = strrpos($tree, '/')) !== false) {
$parent = '/' . substr($tree, 0, $slash);
} else {
$parent = '/';
}

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-._]+');
Loading

0 comments on commit df43c98

Please sign in to comment.