Space separators in tags are optional.
[gruta.git] / examples / g.pl
blob83f9f3c9876e005398d9f1125fdbf3096167e54f
1 use Gruta;
3 use Gruta::Data;
5 use Gruta::Source::DBI;
6 use Gruta::Source::FS;
7 use Gruta::Source::Mbox;
8 use Gruta::Renderer::Grutatxt;
9 use Gruta::Renderer::HTML;
10 use Gruta::Template::Artemus;
11 use Gruta::Template::TT;
13 use Gruta::CGI;
15 my $base = '/var/www/webon';
17 my $src = Gruta::Source::DBI->new(
18 string => "dbi:SQLite:g.db",
19 user => 'coco',
20 passwd => 'caca'
23 my $src2 = Gruta::Source::FS->new(
24 path => 'var'
27 my $src3 = Gruta::Source::Mbox->new(
28 file => './url.mbox',
29 topic_id => 'links',
30 topic_name => 'Links',
31 index_file => '/tmp/url.mbox.idx'
34 my $rndr = Gruta::Renderer::Grutatxt->new();
35 my $rndr2 = Gruta::Renderer::HTML->new();
36 my $rndr3 = Gruta::Renderer::HTML->new( valid_tags => undef );
38 my $tmpl = Gruta::Template::Artemus->new(
39 path => "./templates/artemus"
42 my $tmpl2 = Gruta::Template::TT->new(
43 path => "./templates/tt"
46 my $w = Gruta->new(
47 # base => $base,
48 # upload => [ "${base}/img" ],
49 # templates => [ "${base}/templates" ],
50 sources => [ $src2, $src3 ],
51 renderers => [ $rndr, $rndr2, $rndr3 ],
52 template => $tmpl,
53 cgi => Gruta::CGI->new()
56 $w->login('angel', 'test');
57 $w->logout();
59 $w->template->cgi_vars( { t => 'LOGIN', topic => 'alimentos', userid => 'angel', pass => 'test' } );
61 #my $str = $w->template->process("{-story_part|alimentos|200609200001|content}");
62 #my $str = $w->template->process("{-loop_topics|_topics_as_option|\n}");
63 #$str = $w->template->process("{-story_loop_by_date|noticias|10|0|_story_link_as_item_with_hits|\n}");
64 #$str = $w->template->process("{-loop_renderers||\n}");
66 my @t = $w->tags();
67 my @sbt = $w->stories_by_tag('primeros');
69 my $str = $w->template->process('LOGIN');
71 my @ts = $w->topics();
73 my $topic = $w->topic('pruebas');
74 my $topic2 = $w->topic('art');
75 my $topic3 = $w->topic('links');
77 $topic->set('editors', 'coco');
78 $topic->save( );
80 my $u = $w->user('basurilla');
82 my @ss = $w->stories_by_date( 'noticias', num => 10 );
84 @ss = $w->stories('links');
85 my $story_n = $w->story('links', $ss[0]);
86 my @t = $story_n->tags();
88 my $story = $w->story('alimentos', '200609200001');
89 my @tags = $story->tags();
90 $story = $w->story('art', '200210040002');
91 $story = $w->story('art', '200210040002');
92 $story = $w->story('rec', '200209020002');
94 $story = $w->story('pruebas', '200707250001');
96 $story = $w->story('tbl', '200202270001');
98 my $hits = $story->get('hits');
99 $story->set('hits', $hits + 1);
100 $story->save( );
102 my $story = Gruta::Data::Story->new( topic_id => 'pruebas',
103 title => 'Testing', format => 'raw_html' );
104 $w->insert_story($story);
106 @ss = $w->search_stories('noticias', 'dieta');
108 #my $data = Gruta::Data->new(
109 # sources => [
110 # Gruta::Source::DBI->new(
111 # string => "dbi:SQLite:${base}/blabla.db",
112 # user => 'coco',
113 # passwd => 'caca'
114 # ),
118 #my $src2 = Webon::Source::FS->new(
119 # path => "${base}/var"
122 my @l = $w->stories_top_ten(10);
124 $w->run();