File Coverage

blib/lib/CGI/Wiki/Simple/NoTemplates.pm
Criterion Covered Total %
statement 6 6 100.0
branch n/a
condition n/a
subroutine 2 2 100.0
pod n/a
total 8 8 100.0


line stmt bran cond sub pod time code
1             package CGI::Wiki::Simple::NoTemplates;
2 3     3   7802 use strict;
  3         6  
  3         125  
3 3     3   16 use base 'CGI::Wiki::Simple';
  3         5  
  3         864  
4            
5             use vars qw($VERSION);
6             $VERSION = 0.09;
7            
8             =head1 NAME
9            
10             CGI::Wiki::Simple::NoTemplates - A simple wiki without templates
11            
12             =head1 DESCRIPTION
13            
14             This is an instant wiki.
15            
16             =head1 SYNOPSIS
17            
18             It might be the case that you don't want to use HTML::Template,
19             and in fact, no templates at all. Then you can simple use the
20             following example as your wiki, which does not rely on
21             HTML::Template to prepare the content :
22            
23             =for example begin
24            
25             use strict;
26             use CGI::Wiki::Simple::NoTemplates;
27             use CGI::Wiki::Store::MySQL; # Change this to match your setup
28            
29             my $store = CGI::Wiki::Store::MySQL->new( dbname => "test",
30             dbuser => "master",
31             dbpass => "master" );
32            
33            
34             my $search = undef;
35             my $wiki = CGI::Wiki::Simple::NoTemplates
36             ->new( PARAMS => {
37             store => $store,
38             })->run;
39            
40             =for example end
41            
42             =cut
43            
44             sub make_edit_form {
45             my ($self,$raw_content,%actions) = @_;
46            
47             my ($url_title) = $self->param("url_node_title");
48             #my $prefix = $self->query->script_name;
49            
50             return "
"
52             . "
"
55             . $self->actions(node=>$url_title,%actions)
56             . "";
57             };
58            
59             sub make_header {
60             my ($self,$version) = @_;
61             $self->header_props( -title => $self->param("node_title"), -content_type => "text/html" );
62            
63             if ($version) {
64             $version = " (v $version)"
65             } else {
66             $version = "";
67             };
68            
69             return
70             "" . $self->param("node_title") . "".$self->param("cgi_wiki_simple_style").""
71             . "
" . $self->param("cgi_wiki_simple_header") . $self->param("html_node_title")
72             . "$version

";
73             };
74            
75             sub make_footer {
76             my ($self) = @_;
77            
78             my $template = $self->load_tmpl("footer.templ", die_on_bad_params => 0 );
79             return $self->param("cgi_wiki_simple_footer"),
80             };
81            
82             sub make_checksum {
83             my ($self) = @_;
84             return "";
85             };
86            
87             sub actions {
88             my ($self,%args) = @_;
89             #my $node = $self->param("url_node_title");
90             my $node = $self->param("node_title");
91             my $checksum = $self->make_checksum();
92            
93             my $prefix = $self->query->script_name;
94            
95             my @result;
96            
97             # First, make the "display" link
98             if (delete $args{display}) {
99             push @result, $self->inside_link( node => $node, mode => 'display', title => 'display' );
100             #push @result, "display";
101             };
102            
103             # and then the "preview" link
104             if (delete $args{preview}) {
105             push @result, $self->inside_link( node => $node, mode => 'preview', title => 'preview' );
106             #push @result, "edit";
107             };
108            
109             # and then the "save" link
110             if (delete $args{commit}) {
111             push @result, "$checksum";
112             };
113            
114             # Further actions will have to go here
115            
116             join " | ", @result;
117             };
118            
119             sub render_display {
120             my ($self) = @_;
121             my $node = $self->param("node_title");
122             my $html_node_title = $self->param("html_node_title");
123             return $self->make_header()
124             . $self->param('content')
125             . "
"
126             . $self->actions( preview => 1, node => $html_node_title )
127             . $self->param("cgi_wiki_simple_footer"),
128             . "";
129             };
130            
131             sub render_editform {
132             my ($self) = @_;
133             return $self->make_header()
134             . $self->param("content")
135             . "
"
136             . $self->make_edit_form($self->param("raw"),commit=>1,display=>1 )
137             . $self->param("cgi_wiki_simple_footer")
138             . ""
139             };
140            
141             sub render_conflict {
142             my ($self) = @_;
143             return $self->make_header()
144             . $self->param("content")
145             . "
"
146             . "

While you were editing this node, somebody else changed it already. Please integrate your changes into the changed node text to resolve the conflict.

"
147             . "
"
148             . "

Your content:

"
149             . "
"
 
150             . HTML::Entities::encode_entities($self->param("submitted_content"))
151             . ""
152             . "

Current node content:

"
153             . $self->make_edit_form($self->param("raw"),commit=>1,display=>1,preview=>1 )
154             . $self->{cgi_wiki_simple_footer}
155             . "";
156             };
157            
158             1;