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 13 and Version 14 of Divan


Ignore:
Timestamp:
Nov 10, 2008, 1:41:42 PM (15 years ago)
Author:
cmlenz
Comment:

View creation is now handled automatically

Legend:

Unmodified
Added
Removed
Modified
  • Divan

    v13 v14  
    11= Divan =
     2
    23Divan is a simple blogging platform that is [source:trunk/examples/divan included] with Diva as an example application.
    34
     
    56
    67It supports comments with [http://openid.net/ OpenID authentication], [http://hixie.ch/specs/pingback/pingback-1.0 pingbacks], [http://atomenabled.org/ Atom feeds] for the whole blog, individual categories, and comments, and the [http://atomenabled.org/developers/protocol/ Atom publishing protocol]. It does not provide a HTML-based interface for authoring entries, nor does it support the XML-RPC based !MetaWeblog API.
     8
     9== Setting Up ==
     10
     11You'll need Diva, [http://incubator.apache.org/couchdb/ CouchDB] (0.8 or later), and [http://code.google.com/p/couchdb-python/ CouchDB-Python] (trunk) installed. CouchDB needs to be running, and it needs to contain an empty database named "divan" (the name can be changed using a config option, see below).
     12
     13Change into the `examples/divan` directory in the Diva source, and run:
     14
     15{{{
     16$ PYTHONPATH=. ./divan/app.py -v
     17[INFO] diva.server: Serving <__main__.Blog object at 0x5c0290> on 127.0.0.1:8080
     18}}}
     19
     20This will install (or update) the view definitions in the database, and run the web application on `http://localhost:8080/`.
     21
     22See the DevelopmentServer page for more server options.
    723
    824== Configuration Options ==
     
    1733 `moderation_email_to`:: The email address that moderation notification mails should be sent to
    1834
    19 
    20 == CouchDB Views ==
    21 [[PageOutline(3-4, Views)]]
    22 
    23 All views are in Javascript.
    24 
    25 === `_design/posts` ===
    26 
    27 ==== `by_month` ====
    28 {{{
    29 #!javascript
    30 function(doc) {
    31   if (doc.type == 'Post') {
    32     var year = parseInt(doc.published.substr(0, 4), 10);
    33     var month = parseInt(doc.published.substr(5, 2), 10);
    34     emit([year, month, doc.published], {
    35       slug: doc.slug, title: doc.title, author: doc.author, summary: doc.summary,
    36       published: doc.published, updated: doc.updated, tags: doc.tags
    37     });
    38   }
    39 }
    40 }}}
    41 
    42 ==== `by_slug` ====
    43 {{{
    44 #!javascript
    45 function(doc) {
    46   if (doc.type == 'Post') {
    47     var year = parseInt(doc.published.substr(0, 4), 10);
    48     var month = parseInt(doc.published.substr(5, 2), 10);
    49     emit([year, month, doc.slug], doc);
    50   }
    51 }
    52 
    53 }}}
    54 
    55 ==== `by_tag` ====
    56 
    57 {{{
    58 #!javascript
    59 function(doc) {
    60   if (doc.type == 'Post' && doc.tags) {
    61     for (var idx in doc.tags) {
    62       emit([doc.tags[idx], doc.published], {
    63         slug: doc.slug, title: doc.title, author: doc.author, published: doc.published, updated: doc.updated,
    64         summary: doc.summary, body: doc.body, tags: doc.tags, extended: doc.extended != '' ? '…' : null
    65       });
    66     }
    67   }
    68 }
    69 }}}
    70 
    71 ==== `by_time` ====
    72 {{{
    73 #!javascript
    74 function(doc) {
    75   if (doc.type == 'Post') {
    76     emit([doc.published], {
    77       slug: doc.slug, title: doc.title, author: doc.author, summary: doc.summary,
    78       body: doc.body, published: doc.published, updated: doc.updated, extended: doc.extended != '' ? '…' : null,
    79       tags: doc.tags, allow_comments: doc.allow_comments, num_comments: doc.num_comments,
    80       allow_pings: doc.allow_pings, num_pings: doc.num_pings});
    81   }
    82 }
    83 }}}
    84 
    85 ==== `by_update` ====
    86 {{{
    87 #!javascript
    88 function(doc) {
    89   if (doc.type == 'Post') {
    90     emit([doc.updated], null);
    91   }
    92 }
    93 }}}
    94 
    95 ==== `months` ====
    96 ''Map'':
    97 {{{
    98 #!javascript
    99 function(doc) {
    100   if (doc.type == 'Post') {
    101     var year = parseInt(doc.published.substr(0, 4), 10);
    102     var month = parseInt(doc.published.substr(5, 2), 10);
    103     emit([year, month], 1);
    104   }
    105 }
    106 }}}
    107 
    108 ''Reduce'':
    109 {{{
    110 #!javascript
    111 function(keys, values) {
    112   return sum(values);
    113 }
    114 }}}
    115 
    116 ==== `tags` ====
    117 ''Map'':
    118 {{{
    119 #!javascript
    120 function(doc) {
    121   if (doc.type == 'Post' && doc.tags) {
    122     for (var idx in doc.tags) {
    123       emit(doc.tags[idx], 1);
    124     }
    125   }
    126 }
    127 }}}
    128 
    129 ''Reduce'':
    130 {{{
    131 #!javascript
    132 function(keys, values) {
    133   return sum(values);
    134 }
    135 }}}
    136 
    137 === `_design/comments` ===
    138 
    139 ==== `whitelist` ====
    140 
    141 ''Map'':
    142 {{{
    143 #!javascript
    144 function(doc) {
    145   if (doc.type == 'Comment' && doc.published) {
    146     emit(doc.openid, 1);
    147   }
    148 }
    149 }}}
    150 
    151 ''Reduce'':
    152 {{{
    153 #!javascript
    154 function(keys, values) {
    155   return sum(values);
    156 }
    157 }}}
    158 
    159 === `_design/pings` ===
    160 
    161 ==== `by_uri` ====
    162 
    163 {{{
    164 #!javascript
    165 function(doc) {
    166   if (doc.type == 'Ping') {
    167     emit([doc.post_id, doc.uri], null);
    168   }
    169 }
    170 }}}
    171 
    172 === `_design/reactions` ===
    173 
    174 ==== `by_post` ====
    175 
    176 {{{
    177 #!javascript
    178 function(doc) {
    179   if (doc.type == 'Ping' && doc.published) {
    180     emit([doc.post_id, doc.time], {
    181       type: doc.type, uri: doc.uri, title: doc.title,
    182       author: doc.author, excerpt: doc.excerpt,
    183       time: doc.time
    184     });
    185   } else if (doc.type == 'Comment' && doc.published) {
    186     emit([doc.post_id, doc.time], {
    187       type: doc.type, openid: doc.openid, author: doc.author,
    188       markup: doc.markup, time: doc.time
    189     });
    190   }
    191 }
    192 }}}
    193 
    194 ==== `by_time` ====
    195 
    196 {{{
    197 #!javascript
    198 function(doc) {
    199   if (doc.type == 'Ping' && !doc.published) {
    200     emit([doc.time, doc.type], doc);
    201   } else if (doc.type == 'Comment' && doc.authenticated && !doc.published) {
    202     emit([doc.time, doc.type], doc);
    203   }
    204 }
    205 }}}
    206