Toggle navigation
P3X GitList Snapshot
GitHub
Repo
Changelog
To do
Releases
Themes
Change log
Loading change log ...
To do ...
Loading todo ...
browsing:
4591e5f08387da9a8bcd0d56437b16391527ee90
Branches
master
Tags
v2024.4.105
v2023.10.119
v2023.10.102
v2022.4.106
v2021.10.211
v2021.10.198
v2021.10.197
v2021.10.195
v2021.10.194
v2021.10.191
v2021.10.189
v2021.10.183
v2021.10.161
v2021.10.152
v2021.10.146
v2021.10.143
v2021.4.102
v2020.10.189
v2020.10.187
v2020.10.185
v2020.10.182
v2020.10.170
v2020.10.138
v2020.10.136
v2020.10.104
v2020.10.102
v2020.4.218
v2020.4.210
v2020.4.188
v2020.4.185
v2020.4.146
v2020.4.144
v2020.4.126
v2020.4.125
v2020.4.123
v2020.4.117
v2020.4.116
v2020.4.114
v2020.4.111
v2020.4.107
v2020.4.105
v2020.4.103
v2019.10.154
v2019.10.146
v2019.10.114
v2019.10.111
v2019.10.109
v2019.4.128
v2019.4.124
v2019.4.121
v2019.4.119
v2019.4.116
v2019.4.113
v2019.4.108
v2019.4.107
v2019.4.106
v2019.4.104
v2019.4.102
v2019.4.22
v2019.4.21
v2019.4.19
v2019.4.16
v2019.2.9-0
v2019.1.23-7
v2019.1.23-0
v2019.1.19-3
v2019.1.1-16
v2019.1.1-15
v2019.1.1-13
v2019.1.1-11
v2019.1.1-6
v2014.4.16
v2014.4.14
v1.1.18-573
p3x-gitlist-2.8.25-822
2019.4.8
2019.1.15-0
2019.1.12-3
2019.1.12-1
2019.1.10-5
2019.1.1-2
2018.12.31-3
2018.12.30-1
2018.12.22-6
2018.12.21-8
2018.12.21-7
2018.12.21-2
2018.12.14-3
2018.12.14-1
2018.12.14-0
2018.12.13-4
2018.12.13-3
2018.12.13-1
2018.12.13-0
2018.11.24-2
2018.11.19-0
2018.11.15-3
2018.11.15-1
2018.10.8-1
2018.9.20-0
2.12.10-1046
2.12.6-1040
2.12.4-1038
2.11.14-1031
2.10.83-1014
2.9.13-892
2.9.8-888
2.9.6-887
2.9.4-886
2.9.2-883
2.9.1-882
2.8.56-862
2.8.52-855
2.8.48-849
2.8.27-829
2.8.23-822
2.8.7-806
2.8.2-803
2.8.0
2.7.78-794
2.7.19-757
2.7.17-754
2.7.12-750
2.7.8-749
2.7.5-743
2.7.4-742
2.6.2-721
2.5.22-696
2.5.19-684
2.5.7-668
2.1.7-643
2.0.38-619
2.0.37-616
2.0.35-613
2.0.33-609
2.0.31-604
2.0.27-600
2.0.26-598
2.0.25-598
2.0.17-593
2.0.15-589
2.0.12-585
2.0.4-579
1.1.14
1.1.13
1.1.12
1.1.11
1.1.10
1.1.9
1.1.8
1.1.7
1.1.6
1.1.5
1.1.4
1.1.3
1.1.2
1.1.1
1.1.0
1.0.4-rc.3
1.0.4-rc.2
1.0.4-rc.1
1.0.3
1.0.2
1.0.1
1.0.0
0.5.6
0.5.5
0.5.4
0.5.0
0.4.0
0.3
0.2
0.1
Files
Commits
Log
Graph
Stats
gitlist.git
src
GitList
Application.php
RSS
Git
Fetch origin
Download
ZIP
TAR
Clone
Raw
View
History
Clone
SSH
HTTPS
Blames found: 113
Mode: php
Binary: false
Hang on, we reloading big blames...
5624c4bc
<?php namespace GitList; use Silex\Application as SilexApplication; use Silex\Provider\TwigServiceProvider;
09abf4bb
use Silex\Provider\UrlGeneratorServiceProvider;
5624c4bc
use GitList\Provider\GitServiceProvider; use GitList\Provider\RepositoryUtilServiceProvider; use GitList\Provider\ViewUtilServiceProvider;
ffe27b2a
use GitList\Provider\RoutingUtilServiceProvider;
bd695118
use Symfony\Component\Filesystem\Filesystem;
4591e5f0
use Twig\TwigFilter; use Twig\TwigFunction;
5624c4bc
/** * GitList application. */ class Application extends SilexApplication {
89bc96b4
protected $path;
5624c4bc
/** * Constructor initialize services. * * @param Config $config
ea3be972
* @param string $root Base path of the application files (views, cache)
5624c4bc
*/ public function __construct(Config $config, $root = null) { parent::__construct(); $app = $this;
89bc96b4
$this->path = realpath($root);
5624c4bc
c3ed23e3
$string = file_get_contents("../package.json"); $pkg = json_decode($string, true);
71cff41e
$this['url_subdir'] = str_replace('\\', '/', dirname($_SERVER['SCRIPT_NAME']));
ccaa04c8
if ($this['url_subdir'] === '/') { $this['url_subdir'] = ''; }
5624c4bc
$this['debug'] = $config->get('app', 'debug');
dbde52ca
$this['date.format'] = $config->get('date', 'format') ? $config->get('date', 'format') : 'd/m/Y H:i:s';
6722fb20
$this['theme'] = 'bootstrap';
f1e4d5b9
c3ed23e3
$this['title'] = $config->get('app', 'title') ? $config->get('app', 'title') : 'P3X GitList ' . $pkg['version'];
5624c4bc
$this['filetypes'] = $config->getSection('filetypes');
c8fcb7cd
$this['binary_filetypes'] = $config->getSection('binary_filetypes');
89bc96b4
$this['cache.archives'] = $this->getCachePath() . 'archives';
73c362fa
$this['avatar.url'] = $config->get('avatar', 'url'); $this['avatar.query'] = $config->get('avatar', 'query');
ecc8e971
$this['show_http_remote'] = $config->get('clone_button', 'show_http_remote'); $this['use_https'] = $config->get('clone_button', 'use_https');
bd3f48df
$this['ssh_clone_subdir'] = $config->get('clone_button', 'ssh_clone_subdir');
4bd3d6a7
$this['repo_paging'] = $config->get('app', 'repo_paging') ? $config->get('app', 'repo_paging') : 10;
d1efad81
4b092f88
if (!isset($_SERVER['PHP_AUTH_USER'])) { $_SERVER['PHP_AUTH_USER'] = ''; }
d1efad81
216aa7fd
$this['http_user'] = $config->get('clone_button', 'http_user_dynamic') ? $_SERVER['PHP_AUTH_USER'] : $config->get('clone_button', 'http_user');
d1efad81
216aa7fd
$this['show_ssh_remote'] = $config->get('clone_button', 'show_ssh_remote');
d1efad81
216aa7fd
$this['ssh_user'] = $config->get('clone_button', 'ssh_user_dynamic') ? $_SERVER['PHP_AUTH_USER'] : $config->get('clone_button', 'ssh_user');
4066d7b7
cb434802
$this['git_http_subdir_calculated'] = $config->get('clone_button', 'git_http_subdir_calculated') ? $config->get('clone_button', 'git_http_subdir_calculated') : true;
ea3be972
$this['git_http_subdir'] = $config->get('clone_button', 'git_http_subdir') ? $config->get('clone_button', 'git_http_subdir') : '';
cb434802
$this['fixed_navbar'] = $config->get('app', 'fixed_navbar') ? $config->get('app', 'fixed_navbar') : true;
5624c4bc
// Register services $this->register(new TwigServiceProvider(), array(
ea3be972
'twig.path' => array($this->getThemePath($this['theme'])), 'twig.options' => $config->get('app', 'cache') ? array('cache' => $this->getCachePath() . 'views') : array(),
5624c4bc
));
875d3c96
$repositories = $config->get('git', 'repositories');
8951074e
$this['git.projects'] = $config->get('git', 'project_list') ?
ea3be972
$this->parseProjectList($config->get('git', 'project_list')) : false;
875d3c96
5624c4bc
$this->register(new GitServiceProvider(), array(
ea3be972
'config' => $config, 'git.client' => $config->get('git', 'client'), 'git.repos' => $repositories, 'ini.file' => "config.ini", 'git.hidden' => $config->get('git', 'hidden') ? $config->get('git', 'hidden') : array(),
5122e91b
'git.default_branch' => $config->get('git', 'default_branch') ?
ea3be972
$config->get('git', 'default_branch') : 'master',
5624c4bc
));
8cb0ce62
5624c4bc
$this->register(new ViewUtilServiceProvider()); $this->register(new RepositoryUtilServiceProvider());
ffe27b2a
$this->register(new RoutingUtilServiceProvider());
5624c4bc
ea3be972
$this['twig'] = $this->extend('twig', function ($twig, $app) use ($pkg, $config) {
78824f19
4591e5f0
$twig->addFilter(new TwigFilter('to_id', function ($value) {
78824f19
$value = str_replace(['.', '/', '\\', ' '], '-', $value); $value = strtolower($value); return $value; }));
4591e5f0
$twig->addFilter(new TwigFilter('remove_extension', function ($string) {
4af1308b
return pathinfo($string, PATHINFO_FILENAME); }));
78824f19
4591e5f0
$twig->addFilter(new TwigFilter('htmlentities', 'htmlentities')); $twig->addFilter(new TwigFilter('md5', 'md5')); $twig->addFilter(new TwigFilter('format_date', array($app, 'formatDate'))); $twig->addFilter(new TwigFilter('format_size', array($app, 'formatSize'))); $twig->addFunction(new TwigFunction('avatar', array($app, 'getAvatar')));
5624c4bc
6f2153ac
$currentTheme = !isset($_COOKIE['gitlist-bootstrap-theme']) ? 'bootstrap-cosmo' : $_COOKIE['gitlist-bootstrap-theme']; $themeDark = [ 'cyborg', 'darkly', 'slate', 'superhero',
dd5784c6
'solar',
6f2153ac
];
f1e4d5b9
6f2153ac
$twig->addGlobal('theme_type', !in_array(substr($currentTheme, strlen('bootstrap-')), $themeDark) ? 'p3x-gitlist-light' : 'p3x-gitlist-dark'); $twig->addGlobal('theme', $currentTheme);
acb728d8
$query = isset($_REQUEST['query']) ? $_REQUEST['query'] : (isset($_COOKIE['p3x-gitlist-query']) ? $_COOKIE['p3x-gitlist-query'] : '');
ea3be972
setcookie('p3x-gitlist-query', $query, 0, '/' . $this['url_subdir']);
acb728d8
$_COOKIE['p3x-gitlist-query'] = $query; $twig->addGlobal('search_query', $query);
16e407a9
$twig->addGlobal('theme_postfix', $pkg['corifeus']['css-postfix']);
d049c45d
$twig->addGlobal('prod_dir', $pkg['corifeus']['prod-dir']);
6f2153ac
$twig->addGlobal('theme_dark', $themeDark);
f1e4d5b9
$twig->addGlobal('version', $pkg['version']);
a06111cb
$twig->addGlobal('gitlist_date_format', $this['date.format']);
f1e4d5b9
30923e92
$codemirror_full_limit = (int)$config->get('app', 'codemirror_full_limit'); if (!is_int($codemirror_full_limit) || $codemirror_full_limit < 32) { $codemirror_full_limit = 32; } $twig->addGlobal('codemirror_full_limit', $codemirror_full_limit);
5624c4bc
return $twig;
09abf4bb
});
5624c4bc
ea3be972
$this['escaper.argument'] = $this->factory(function () {
1bef1b96
return new Escaper\ArgumentEscaper(); });
5624c4bc
// Handle errors $this->error(function (\Exception $e, $code) use ($app) {
2f437193
if ($app['debug']) { return; }
90d9fd49
5624c4bc
return $app['twig']->render('error.twig', array( 'message' => $e->getMessage(), )); });
bd695118
$this->finish(function () use ($app, $config) { if (!$config->get('app', 'cache')) { $fs = new Filesystem(); $fs->remove($app['cache.archives']); } });
5624c4bc
}
89bc96b4
dbde52ca
public function formatDate($date) { return $date->format($this['date.format']); }
4591e5f0
public function formatSize($bytes, $precision = 0)
ff571bf3
{
4591e5f0
$size = ['B','kB','MB','GB','TB','PB','EB','ZB','YB']; $factor = floor((strlen($bytes) - 1) / 3); return sprintf("%.{$precision}f", $bytes / pow(1024, $factor)) . @$size[$factor];
ff571bf3
}
73c362fa
public function getAvatar($email, $size) { $url = $this['avatar.url'] ? $this['avatar.url'] : "//gravatar.com/avatar/"; $query = array("s=$size"); if (is_string($this['avatar.query'])) $query[] = $this['avatar.query']; else if (is_array($this['avatar.query'])) $query = array_merge($query, $this['avatar.query']); $id = md5(strtolower($email)); return $url . $id . "?" . implode('&', $query); }
89bc96b4
public function getPath() { return $this->path . DIRECTORY_SEPARATOR; }
f8b29db8
89bc96b4
public function setPath($path) { $this->path = $path;
f8b29db8
89bc96b4
return $this; } public function getCachePath() {
f8b29db8
return $this->path . DIRECTORY_SEPARATOR . 'cache' . DIRECTORY_SEPARATOR;
89bc96b4
}
f8b29db8
public function getThemePath($theme)
89bc96b4
{
f8b29db8
return $this->path
d049c45d
. DIRECTORY_SEPARATOR . 'src'
f8b29db8
. DIRECTORY_SEPARATOR . 'twig' . DIRECTORY_SEPARATOR;
89bc96b4
}
8951074e
public function parseProjectList($project_list) { $projects = array(); $file = fopen($project_list, "r"); while ($file && !feof($file)) $projects[] = trim(fgets($file)); fclose($file); return $projects; }
5624c4bc
}