Adding support to syntax highlighting for custom extensions, fixes #34. Thanks @attiks

This commit is contained in:
Klaus Silveira
2012-06-07 00:55:56 -03:00
parent ab14e90cdd
commit 8ac31cdc93
3 changed files with 19 additions and 3 deletions

View File

@@ -15,6 +15,7 @@ require_once __DIR__.'/vendor/silex.phar';
$app = new Silex\Application(); $app = new Silex\Application();
$app['baseurl'] = $config['app']['baseurl']; $app['baseurl'] = $config['app']['baseurl'];
$app['filetypes'] = $config['filetypes'];
// Register Git and Twig libraries // Register Git and Twig libraries
$app['autoloader']->registerNamespace('Git', __DIR__.'/lib'); $app['autoloader']->registerNamespace('Git', __DIR__.'/lib');

View File

@@ -2,11 +2,20 @@
namespace Application; namespace Application;
use Silex\Application;
/** /**
* General helper class, mostly used for string parsing inside the application controllers * General helper class, mostly used for string parsing inside the application controllers
*/ */
class Utils class Utils
{ {
protected $app;
public function __construct(Application $app)
{
$this->app = $app;
}
/** /**
* Builds a breadcrumb array based on a path spec * Builds a breadcrumb array based on a path spec
* *
@@ -209,8 +218,14 @@ class Utils
return 'image'; return 'image';
case 'bmp': case 'bmp':
return 'image'; return 'image';
default: }
return 'text';
if (!empty($this->app['filetypes'])) {
foreach ($this->app['filetypes'] as $ext => $type) {
if ($fileType == $ext) {
return $type;
}
}
} }
} }

View File

@@ -16,7 +16,7 @@ class UtilsServiceProvider implements ServiceProviderInterface
public function register(Application $app) public function register(Application $app)
{ {
$app['utils'] = function () use ($app) { $app['utils'] = function () use ($app) {
return new Utils; return new Utils($app);
}; };
} }
} }