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.

Changes between Version 6 and Version 7 of Divan


Ignore:
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
  • Divan

    v6 v7  
    8181}}}
    8282
     83==== `months` ====
     84''Map'':
     85{{{
     86#!javascript
     87function(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
     99function(keys, values) {
     100  return sum(values);
     101}
     102}}}
     103
     104==== `tags` ====
     105''Map'':
     106{{{
     107#!javascript
     108function(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
     120function(keys, values) {
     121  return sum(values);
     122}
     123}}}
     124
    83125=== `_design/pings` ===
    84126