close
Warning:
Can't synchronize with repository "(default)" (Unsupported version control system "svn": No module named svn). Look in the Trac log for more information.
- Timestamp:
-
Aug 26, 2008, 1:54:24 PM (16 years ago)
- Author:
-
cmlenz
- Comment:
-
Add map/reduce views for archive page
Legend:
- Unmodified
- Added
- Removed
- Modified
-
v6
|
v7
|
|
81 | 81 | }}} |
82 | 82 | |
| 83 | ==== `months` ==== |
| 84 | ''Map'': |
| 85 | {{{ |
| 86 | #!javascript |
| 87 | function(doc) { |
| 88 | if (doc.type == 'Post') { |
| 89 | var year = parseInt(doc.published.substr(0, 4), 10); |
| 90 | var month = parseInt(doc.published.substr(5, 2), 10); |
| 91 | emit([year, month], 1); |
| 92 | } |
| 93 | } |
| 94 | }}} |
| 95 | |
| 96 | ''Reduce'': |
| 97 | {{{ |
| 98 | #!javascript |
| 99 | function(keys, values) { |
| 100 | return sum(values); |
| 101 | } |
| 102 | }}} |
| 103 | |
| 104 | ==== `tags` ==== |
| 105 | ''Map'': |
| 106 | {{{ |
| 107 | #!javascript |
| 108 | function(doc) { |
| 109 | if (doc.type == 'Post' && doc.tags) { |
| 110 | for (var idx in doc.tags) { |
| 111 | emit(doc.tags[idx], 1); |
| 112 | } |
| 113 | } |
| 114 | } |
| 115 | }}} |
| 116 | |
| 117 | ''Reduce'': |
| 118 | {{{ |
| 119 | #!javascript |
| 120 | function(keys, values) { |
| 121 | return sum(values); |
| 122 | } |
| 123 | }}} |
| 124 | |
83 | 125 | === `_design/pings` === |
84 | 126 | |