X-Git-Url: http://git.rot13.org/?p=ILL-Zotero-RT;a=blobdiff_plain;f=zotero.pl;fp=zotero.pl;h=2dac6e02f97ad0aa0fcc80c227a3b6745677506b;hp=1364606cfc8bd1cf9866911bb2616c85914c03d2;hb=c66001cf81a861e875ef6bb5f8f5dfe1a27bff1b;hpb=840cab65ee98ac0143c3b4c0d49101e2268b37a0;ds=sidebyside diff --git a/zotero.pl b/zotero.pl index 1364606..2dac6e0 100755 --- a/zotero.pl +++ b/zotero.pl @@ -18,6 +18,12 @@ my $FETCH = $ENV{FETCH} || 0; my $db = CouchDB->new('10.60.0.92', 5984); eval { $db->put("zotero_$UserID") }; # create user database +eval { + local $/ = undef; + my $view = ; + warn "# create $view"; + $db->put("zotero_$UserID/_design/zotero" => decode_json $view) +}; my @urls = map { "https://api.zotero.org/users/$UserID/$_?format=atom&content=json&order=dateModified&sort=desc" } qw( collections items ); # we don't need to fetch tags since we can generate using CouchDB views @@ -169,3 +175,6 @@ foreach my $nr ( keys %$ticket_items ) { } } + +__DATA__ +{"_id":"_design/zotero","language":"javascript","views":{"itemType":{"map":"function(doc) {\n emit(doc.zapi.itemType,1);\n}","reduce":"_count"},"updated":{"map":"function(doc) {\n emit(doc.updated,1);\n}","reduce":"_count"},"tags":{"map":"function(doc) {\n \n doc.content.tags.forEach( function(v) {\n emit(v, doc._id);\n });\n}","reduce":"_count"},"link_up":{"map":"function(doc) {\n if ( doc.link[1].rel == 'up' )\n emit( doc.link[1].key, doc._id );\n}","reduce":"_count"},"year,publisher":{"map":"function(doc) {\n if ( doc.zapi.year )\n emit([doc.zapi.year, doc.content.publisher], 1);\n}","reduce":"_count"}}}