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.

Version 2 (modified by cmlenz, 16 years ago) (diff)

Added view definitions

Scratchpad

Scratchpad is a simple “nopaste” service that is included with Diva as an example application.

It uses CouchDB (via the CouchDB-Python library) for storage, and Pygments for syntax highlighting.

CouchDB Views

All views are in Javascript.

_design/snippets

by_author

function(doc) {
  if (doc.author) {
    emit([doc.author, doc.time], {
      title: doc.title,
      author: doc.author,
      time: doc.time,
      mimetype: doc.mimetype,
      description: doc.description,
      num_comments: doc.comments ? doc.comments.length : 0
    });
  }
}

by_time

function(doc) {
  emit([doc.time, doc.title], {
    title: doc.title, author: doc.author, time: doc.time,
    mimetype: doc.mimetype, description: doc.description,
    num_comments: doc.comments ? doc.comments.length : 0
  });
}

by_type

function(doc) {
  emit([doc.mimetype, doc.time], {
    title: doc.title, author: doc.author, time: doc.time,
    mimetype: doc.mimetype, description: doc.description,
    num_comments: doc.comments ? doc.comments.length : 0
  })
}