/[couchdb]/scripts/deploy/reblog.pl
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Contents of /scripts/deploy/reblog.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 23 - (show annotations)
Tue Feb 3 19:15:02 2009 UTC (15 years, 3 months ago) by dpavlin
File MIME type: text/plain
File size: 1778 byte(s)
use feed_link or feed_url
1 #!/usr/bin/perl
2
3 use warnings;
4 use strict;
5
6 use CouchDB::Deploy;
7
8 use strip;
9
10 my $reduce_count = qq|
11 function (Key, Values) {
12 var sum = 0;
13 for(var i in Values)
14 sum += Values[i];
15 return sum;
16 }
17 |;
18
19 my $reduce_join = qq|
20 function (k, v, c) {
21 if ( c ) {
22 a = v.shift();
23 //log( a ); log( v );
24 while ( v.length ) {
25 //log( v.length );
26 e = v.shift();
27 //log( e );
28 a.concat( e );
29 }
30 return a;
31 } else {
32 return v;
33 }
34 }
35 |;
36
37 db 'reblog/', containing {
38 # doc {
39 # _id => '_sync',
40 # key => '_sync',
41 # last_row_id => 0,
42 # };
43 design {
44 _id => '_design/count',
45 language => 'javascript',
46 views => {
47 'feed_items' => {
48 'map' => strip(qq|
49 function(doc) {
50 emit(doc.feed_title, 1);
51 }
52 |),
53 'reduce' => strip($reduce_count),
54 },
55 'tags' => {
56 'map' => strip(qq|
57 function(doc) {
58 var tags = doc.category.split(/[\\s\/]/);
59 for(var i in tags) {
60 emit(tags[i], 1);
61 }
62 }
63 |),
64 'reduce' => strip($reduce_count),
65 }
66 },
67 _id => '_design/items',
68 language => 'javascript',
69 views => {
70 'by_feed' => {
71 'map' => strip(q#
72 function(doc) {
73 emit(
74 [ doc.feed_title, doc.feed_link || doc.feed_url ],
75 [ doc.title, doc.link ]
76 );
77 }
78 #),
79 'reduce' => strip($reduce_join),
80 },
81 'by_feed_html' => {
82 'map' => strip(qq|
83 function(doc) {
84 emit(
85 [ doc.feed_title, doc.feed_link ],
86 '<a href="' + doc.link + '">' + doc.title + '</a>'
87 );
88 }
89 |),
90 'reduce' => strip($reduce_join),
91 },
92 'by_date' => {
93 'map' => strip(qq|
94 function(doc) {
95 emit(
96 [ doc.insert_timestamp, doc.feed_title, doc.feed_link ],
97 [ doc.title, doc.link ]
98 );
99 }
100 |),
101 }
102 },
103 };
104 };

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.26