Commit: 5d6feb2d48bd238f4a95913c62be850cf90066db

Author: alkemann | Date: 2009-11-19 02:49:55 +0100
Merge branch 'dev' into 0.3
diff --cc models/Paste.php index f7e142c,cb6dcd6..bb85545 --- a/models/Paste.php +++ b/models/Paste.php @@@ -3,8 -3,6 +3,7 @@@ namespace app\models; use \Geshi; +use \lithium\core\Libraries; - use \lithium\data\model\Document; use \lithium\util\Validator; /** @@@ -63,22 -72,19 +73,20 @@@ class Paste extends \lithium\data\Mode * Views Document */ public static $_views = array( - 'latest' => array( - 'id' => '_design/latest', - 'language' => 'javascript', + 'latest' => array('id' => '_design/latest', 'language' => 'javascript', 'views' => array( - 'all' => array('map' => 'function(doc) { - if (doc.permanent == "1") { - var preview = String.substring(doc.content, 0, 100); - emit(doc.created, { - author:doc.author, language:doc.language, - preview: preview, created: doc.created - }); - } - }'), + 'all' => array( + 'map' => 'function(doc) { + if (doc.permanent == "1") { + emit(doc.created, { + author: doc.author, language: doc.language, + preview: doc.preview, created: doc.created + }); + } + }' + ) ) - ) + ), ); /** @@@ -151,31 -142,7 +155,18 @@@ 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: - * {{{ - * Paste::createView()->save(); - * }}} - * - * @return Document - */ - public static function createView() { - return parent::create(static::$_views['latest']); - } - - /** * Sets default values and calls the parent create() * * @param array $data of field values to start with @@@ -200,22 -171,22 +197,22 @@@ * @return boolean */ public function validates($record, $options = array()) { - $success = true; $errors = array(); - if (!Validator::isAlphaNumeric($record->author)) { - $success = false; - $errors['author'] = 'This field can only be alphanumeric'; + $errors = static::$_errors; + + if (Validator::isAlphaNumeric($record->author)) { + unset($errors['author']); + } + if (Validator::isNotEmpty($record->content)) { + unset($errors['content']); } - if (!Validator::isNotEmpty($record->content)) { - $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())) { + unset($errors['language']); } - if (!in_array($record->language, static::languages())) { - $success = false; - $errors['language'] = 'You have messed with the HTML that is not valid language'; + if (empty($errors)){ + return true; } - if (!$success) - $record->set(array('errors' => $errors)); - return $success; + $record->set(array('errors' => $errors)); + return false; } } diff --cc webroot/css/bin.0.3.css index 99712ad,0000000..3730ea6 mode 100644,000000..100644 --- a/webroot/css/bin.0.3.css +++ b/webroot/css/bin.0.3.css @@@ -1,150 -1,0 +1,152 @@@ +* { + margin: 0; + padding: 0; +} + +html { + height:100%; +} +body { + min-height:101%; +} +html, body { + margin:0; + padding:0; + background:white url(../img/accent.png) no-repeat bottom right fixed; + color:#333; + font-family:Helvetica, Arial, sans-serif; +} +a { + color: #333; +} +p { + margin-top: 1em; +} +h1 { + margin: 0; + color: #555; +} +#menu { + float: right; + margin: 30px 50px 0 0; +} +#menu ul { + list-style: none; +} +#menu li { + display: inline; + padding: 5px 5px 2px; + background-color: white; +} +#menu a { +} + +div#content { + margin: 0 30px; +} +h2 { + font-size: 20px; +} +h3 { + font-size: 12px; + font-weight: normal; +} +ul.latest, ul.latest li { + margin: 1em; +} ++form { ++ margin-bottom: 40px; ++} +input[type=text] { + display: block; + width: 70%; + padding: 1px 3px; + font-size: 110%; +} +input[type=submit] { + display: block; + width: auto; + font-size: 110%; +} +input[type=checkbox] { + margin: 10px 0 0 0px; +} +select { + display:block; +} +textarea { + display: block; + width: 70%; + padding: 0 0 0 3px ; + font-size: 110%; +} +label { + font-size: 85%; +} +label.required, div.required label { + font-weight: bold; +} +div#paste, div#clean { + margin: 10px 0 10px 30px; + padding: 4px; + border-top: 2px solid #333333; + border-right: 2px solid #AAAAAA; + border-bottom: 2px solid #AAAAAA; + border-left: 2px solid #333333; + background-color: white; +} +a#toggle { + margin-left: 2em; +} +div#footer { - position: absolute; - padding: 30px 0 35px; ++ position: fixed; + text-align: center; + font-size: 70%; + bottom: 0; + right: 20px; +} + +pre.debug { + background-color: orange; + padding: 15px 5px; + display: block; +} +li.li1 { + background-color: white; +} +li.li2 { + background-color: #eee; +} +a { + text-decoration: underline; +} +.kw0, .kw1, .kw2, .kw3, .kw4 { + color: black; + font-weight: bold; +} +.kw5, .kw6, .kw7, .kw8 { + color: #449; + font-weight: bold; +} +.br0, .br1, .br2, .br3, .br4 { + font-weight: bold; + color: blue; +} +.re0, .re1, .re2, .re3, .re4{ + color: magenta; +} +.st_h, .st0, .st1, .st2, .st3, .st4 { + color:red; +} + +.me0, .me1, .me2, .me3, .me4 { + color: green; +} + +.sy0, .sy1, .sy2, .sy3, .sy4 { + font-weight: bold; +} +/* code comment */ +.co1, .co2, .co3, .co4 { + color: #888; +}