Commit: 2b677e48c6a8522922b5b5b934713ab0e9ba9cb6
Author: alkemann | Date: 2009-11-19 01:15:48 +0100
diff --git a/controllers/PastesController.php b/controllers/PastesController.php
index 12c6386..1fdf9cf 100644
--- a/controllers/PastesController.php
+++ b/controllers/PastesController.php
@@ -70,7 +70,7 @@ class PastesController extends \lithium\action\Controller {
));
}
}
- $languages = Paste::$languages;
+ $languages = Paste::languages();
$this->set(compact('paste', 'languages'));
$this->render('form');
}
@@ -102,7 +102,7 @@ class PastesController extends \lithium\action\Controller {
));
}
}
- $languages = Paste::$languages;
+ $languages = Paste::languages();
$this->set(compact('paste', 'languages'));
$this->render('form');
}
diff --git a/models/Paste.php b/models/Paste.php
index ac37116..f7e142c 100644
--- a/models/Paste.php
+++ b/models/Paste.php
@@ -3,6 +3,7 @@
namespace app\models;
use \Geshi;
+use \lithium\core\Libraries;
use \lithium\data\model\Document;
use \lithium\util\Validator;
@@ -31,7 +32,7 @@ class Paste extends \lithium\data\Model {
*
* @var array
*/
- public static $languages = array('php','html','javascript','text');
+ public static $languages = null;
/**
* Metadata
@@ -119,7 +120,7 @@ class Paste extends \lithium\data\Model {
Paste::applyFilter('save', function($self, $params, $chain) {
if ($params['record']->id != '_design/latest') {
$document = $params['record'];
- if (in_array($document->language, Paste::$languages)) {
+ if (in_array($document->language, Paste::languages())) {
$document = Paste::parse($document);
}
$document->preview = rawurlencode(substr($document->content,0,100));
@@ -151,6 +152,16 @@ class Paste extends \lithium\data\Model {
return $doc;
}
+ public static function languages() {
+ if (static::$languages === null) {
+ static::$languages = Libraries::find('geshi', array(
+ 'path' => '/geshi', 'filter' => false, 'format' => function($class) {
+ return basename($class, '.php');
+ }
+ ));
+ }
+ return static::$languages;
+ }
/**
* Used to create and then save the design view 'latest' to couch, ie:
@@ -198,7 +209,7 @@ class Paste extends \lithium\data\Model {
$success = false;
$errors['content'] = 'This field can not be left empty';
}
- if (!in_array($record->language, static::$languages)) {
+ if (!in_array($record->language, static::languages())) {
$success = false;
$errors['language'] = 'You have messed with the HTML that is not valid language';
}
diff --git a/webroot/css/bin.0.3.css b/webroot/css/bin.0.3.css
index e69a1b8..99712ad 100644
--- a/webroot/css/bin.0.3.css
+++ b/webroot/css/bin.0.3.css
@@ -122,6 +122,10 @@ a {
color: black;
font-weight: bold;
}
+.kw5, .kw6, .kw7, .kw8 {
+ color: #449;
+ font-weight: bold;
+}
.br0, .br1, .br2, .br3, .br4 {
font-weight: bold;
color: blue;