Navigation Menu

Skip to content

Commit

Permalink
changed couch view latest to exclude temporary pastes and order by cr…
Browse files Browse the repository at this point in the history
…eated
  • Loading branch information
alkemann committed Oct 25, 2009
1 parent dc8ff21 commit f05e9b0
Showing 1 changed file with 13 additions and 15 deletions.
28 changes: 13 additions & 15 deletions models/Paste.php
Expand Up @@ -59,23 +59,25 @@ class Paste extends \lithium\core\StaticObject {
/**
* Views Document
*/
protected static $_views = array(
'latest' => array(
'_id' => '_design/latest',
'language' => 'javascript',
'views' => array(
'all' => array(
'map' => 'function(doc) {
protected static $_views = array(
'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.author, {
emit(Date.parse(doc.created), {
author:doc.author, language:doc.language,
preview: preview, created: doc.created
});
}'
)
}
}'
)
)
);
)
);

/*
* Validate the input data before saving to data
Expand All @@ -96,10 +98,6 @@ public static function validate($data) {
$data->errors['language'] =
'You have messed with the HTML that is not valid language';
}
if (!Validator::isBoolean($data->permanent)) {
$data->errors['permanent'] =
'You have messed with the HTML that is not a boolean';
}
return $data;
}

Expand Down

0 comments on commit f05e9b0

Please sign in to comment.