mirror of
https://github.com/klaussilveira/gitlist.git
synced 2025-11-18 03:30:55 +01:00
Adding support to syntax highlighting for custom extensions, fixes #34. Thanks @attiks
This commit is contained in:
@@ -15,6 +15,7 @@ require_once __DIR__.'/vendor/silex.phar';
|
||||
|
||||
$app = new Silex\Application();
|
||||
$app['baseurl'] = $config['app']['baseurl'];
|
||||
$app['filetypes'] = $config['filetypes'];
|
||||
|
||||
// Register Git and Twig libraries
|
||||
$app['autoloader']->registerNamespace('Git', __DIR__.'/lib');
|
||||
|
||||
@@ -2,11 +2,20 @@
|
||||
|
||||
namespace Application;
|
||||
|
||||
use Silex\Application;
|
||||
|
||||
/**
|
||||
* General helper class, mostly used for string parsing inside the application controllers
|
||||
*/
|
||||
class Utils
|
||||
{
|
||||
protected $app;
|
||||
|
||||
public function __construct(Application $app)
|
||||
{
|
||||
$this->app = $app;
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds a breadcrumb array based on a path spec
|
||||
*
|
||||
@@ -209,8 +218,14 @@ class Utils
|
||||
return 'image';
|
||||
case 'bmp':
|
||||
return 'image';
|
||||
default:
|
||||
return 'text';
|
||||
}
|
||||
|
||||
if (!empty($this->app['filetypes'])) {
|
||||
foreach ($this->app['filetypes'] as $ext => $type) {
|
||||
if ($fileType == $ext) {
|
||||
return $type;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ class UtilsServiceProvider implements ServiceProviderInterface
|
||||
public function register(Application $app)
|
||||
{
|
||||
$app['utils'] = function () use ($app) {
|
||||
return new Utils;
|
||||
return new Utils($app);
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user