| 8 | |
| 9 | == CouchDB Views == |
| 10 | |
| 11 | All views are in Javascript. |
| 12 | |
| 13 | === `_design/posts` === |
| 14 | |
| 15 | ==== `by_month` ==== |
| 16 | {{{ |
| 17 | #!text/javascript |
| 18 | function(doc) { |
| 19 | if (doc.type == 'Post') { |
| 20 | var year = parseInt(doc.published.substr(0, 4), 10); |
| 21 | var month = parseInt(doc.published.substr(5, 2), 10); |
| 22 | emit([year, month, doc.published], { |
| 23 | slug: doc.slug, title: doc.title, author: doc.author, summary: doc.summary, |
| 24 | published: doc.published, updated: doc.updated, tags: doc.tags |
| 25 | }); |
| 26 | } |
| 27 | } |
| 28 | }}} |
| 29 | |
| 30 | ==== `by_slug` ==== |
| 31 | {{{ |
| 32 | #!text/javascript |
| 33 | function(doc) { |
| 34 | if (doc.type == 'Post') { |
| 35 | var year = parseInt(doc.published.substr(0, 4), 10); |
| 36 | var month = parseInt(doc.published.substr(5, 2), 10); |
| 37 | emit([year, month, doc.slug], doc); |
| 38 | } |
| 39 | } |
| 40 | |
| 41 | }}} |
| 42 | |
| 43 | ==== `by_time` ==== |
| 44 | {{{ |
| 45 | #!text/javascript |
| 46 | function(doc) { |
| 47 | if (doc.type == 'Post') { |
| 48 | emit([doc.published], { |
| 49 | slug: doc.slug, title: doc.title, author: doc.author, summary: doc.summary, |
| 50 | body: doc.body, published: doc.published, updated: doc.updated, extended: doc.extended != '' ? '…' : null, |
| 51 | tags: doc.tags, allow_comments: doc.allow_comments, num_comments: doc.num_comments, |
| 52 | allow_pings: doc.allow_pings, num_pings: doc.num_pings}); |
| 53 | } |
| 54 | } |
| 55 | |
| 56 | }}} |
| 57 | |
| 58 | |
| 59 | === `_design/comments` === |
| 60 | |
| 61 | === `_design/pings` === |
| 62 | |
| 63 | === `_design/reactions` === |
| 64 | |
| 65 | |