/[couchdb]/scripts/socialtext2couch.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

Annotation of /scripts/socialtext2couch.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 18 - (hide annotations)
Tue Sep 30 18:20:47 2008 UTC (15 years, 7 months ago) by dpavlin
File MIME type: text/plain
File size: 975 byte(s)
Socialtext to CouchDB importer
1 dpavlin 18 #!/usr/bin/perl
2    
3     # st2couch.pl
4     #
5     # 09/30/08 20:07:10 CEST Dobrica Pavlinusic <dpavlin@rot13.org>
6    
7     use warnings;
8     use strict;
9    
10     use Socialtext::Resting;
11     use CouchDB::Client;
12    
13     my $database = 'razmjenavjestina';
14    
15     our %opts;
16     require "$ENV{HOME}/.st.pl";
17    
18    
19     my $c = CouchDB::Client->new(uri => 'http://localhost:5984/');
20     $c->testConnection or die "The server cannot be reached";
21     print "CouchDB version " . $c->serverInfo->{version} . "\n";
22     my $db = $c->newDB( $database );
23     $db->delete if $c->dbExists( $database );
24     $db->create;
25    
26     my $Rester = Socialtext::Resting->new(
27     username => $opts{username},
28     password => $opts{password},
29     server => $opts{server},
30     );
31    
32     $Rester->workspace( $database );
33    
34     foreach my $page ( $Rester->get_pages ) {
35     my $_id = $page;
36     $_id =~ s/\W/_/g;
37     my $doc = $db->newDoc( $_id );
38     my $row = {
39     title => $page,
40     tags => [ $Rester->get_pagetags( $page ) ],
41     wiki => $Rester->get_page( $page ),
42     };
43     $doc->{data} = $row;
44     $doc->create;
45     warn "<< $page\n";
46     }

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.26