/[pub]/suikawiki/script/lib/SuikaWiki/Plugin/WikiEdit.wp2
Suika

Contents of /suikawiki/script/lib/SuikaWiki/Plugin/WikiEdit.wp2

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.9 - (hide annotations) (download)
Wed Feb 18 07:18:30 2004 UTC (21 years, 2 months ago) by wakaba
Branch: MAIN
Changes since 1.8: +30 -8 lines
WikiDB Error reporting bug fixed

1 wakaba 1.1 #?SuikaWikiConfig/2.0
2    
3     Plugin:
4     @Name: WikiEdit
5     @Description:
6     @@@: WikiPage editing components
7     @@lang:en
8 wakaba 1.9 @License: %%Perl%%
9 wakaba 1.1 @Author:
10     @@Name:
11     @@@@: Wakaba
12     @@@lang:ja
13     @@@script:Latn
14     @@Mail[list]: w@suika.fam.cx
15 wakaba 1.9 @Date.RCS:
16     $Date: 2004/02/08 08:52:03 $
17 wakaba 1.1 @RequiredModule[list]:
18     Digest::SHA1
19 wakaba 1.2 @RequiredPlugin[list]:
20     WikiView
21     WikiStruct
22     WikiLinking
23     WikiFormCore
24 wakaba 1.3 WikiFormText
25 wakaba 1.6 WikiResource
26 wakaba 1.2 HTML
27 wakaba 1.7 @Use:
28     use Message::Util::Error;
29 wakaba 1.1
30     PluginConst:
31     @NS_XHTML1:
32     http://www.w3.org/1999/xhtml
33    
34     ViewDefinition:
35     @Mode: edit
36     @Condition:
37     @@http-method[list]:
38     GET
39     HEAD
40     @Description:
41     @@@: Edit WikiPage content as whole, as a plaintext
42     @@lang: en
43     @template:
44     @@http-status-code: 200
45     @@media-type: text/html
46     @@use-media-type-charset: 1
47     @@expires: %%edit%%
48     @@body:
49     %html-document (
50     title => {%res(name=>{Edit:WebPageTitle});}p,
51 wakaba 1.2 link-meta => {%template (name => links);
52     %html-meta(name => ROBOTS, content => NOINDEX);}p,
53 wakaba 1.1 content => {
54     %template (
55     name => ws--page,
56 wakaba 1.2 -content => {%template (name => we--edit-body);},
57 wakaba 1.1 );
58     }p,
59     );
60    
61     ViewDefinition:
62     @Mode: write
63     @Condition:
64     @@http-method[list]:
65     POST
66     @Description:
67     @@@: Saving modified (new) WikiPage content
68     @@lang: en
69 wakaba 1.7 @Use:
70     use Message::Util::Error;
71 wakaba 1.1 @method:
72     @@@:
73     my $touch = $self->{view}->{wiki}->{input}->parameter ('we--touch');
74    
75     $self->{view}->{wiki}->{var}->{db}->{read_only}->{'content'} = 0;
76     $self->{view}->{wiki}->{var}->{db}->{read_only}->{'lastmodified'} = 0
77     if $touch;
78     $self->{view}->init_db;
79    
80     my $page = $self->{view}->{wiki}->{var}->{page};
81    
82     ## Check confliction
83 wakaba 1.7 my $current_content;
84     try {
85     $current_content = $self->{view}->{wiki}->{db}->get (content => $page);
86     } catch SuikaWiki::DB::Util::Error with {
87 wakaba 1.9 my $err = shift;
88     if ($err->{-type} eq 'ERROR_REPORTED') {
89     $err->throw;
90     } else {
91     $self->{view}->{wiki}->view_in_mode (mode => '-wdb--fatal-error');
92     throw SuikaWiki::DB::Util::Error -type => 'ERROR_REPORTED';
93     }
94 wakaba 1.7 };
95 wakaba 1.1 if (length $current_content) {
96 wakaba 1.5 my $current_digest = __FUNCPACK__->digest ($current_content,
97 wakaba 1.2 normalize => 1);
98 wakaba 1.1 my $prev_digest
99     = $self->{view}->{wiki}->{input}->parameter ('we--digest');
100     if ($current_digest ne $prev_digest) {
101 wakaba 1.2 return $self->{view}->{wiki}->view_in_mode
102     (mode => '-conflict');
103 wakaba 1.1 }
104     }
105    
106     my $new_content
107     = $self->{view}->{wiki}->{input}->parameter ('we--content');
108     if (length $new_content) {
109 wakaba 1.7 try {
110     $self->{view}->{wiki}->{db}->set (content => $page => $new_content);
111     } catch SuikaWiki::DB::Util::Error with {
112 wakaba 1.9 my $err = shift;
113     if ($err->{-type} eq 'ERROR_REPORTED') {
114     $err->throw;
115     } else {
116     $self->{view}->{wiki}->view_in_mode (mode => '-wdb--fatal-error');
117     throw SuikaWiki::DB::Util::Error -type => 'ERROR_REPORTED';
118     }
119 wakaba 1.7 };
120 wakaba 1.1 if ($touch) {
121 wakaba 1.7 try {
122     $self->{view}->{wiki}->{db}->set (lastmodified => $page => time);
123     } catch SuikaWiki::DB::Util::Error with {
124 wakaba 1.9 my $err = shift;
125     $err->throw if $err->{-type} eq 'ERROR_REPORTED';
126 wakaba 1.7 };
127 wakaba 1.1 }
128 wakaba 1.5
129 wakaba 1.1 my $new_mode = $self->{view}->{wiki}->{input}->parameter
130     ('we--mode-modified');
131     $new_mode =~ s/[^0-9A-Za-z._-]+//g;
132 wakaba 1.5 my $uri = $self->{view}->{wiki}->uri_reference
133     (page => $page,
134     mode => $new_mode,
135     up_to_date => 1,
136     param => {we__mode_modified => $new_mode});
137 wakaba 1.1
138     require SuikaWiki::Output::HTTP;
139     my $output = SuikaWiki::Output::HTTP->new
140     (wiki => $self->{view}->{wiki});
141     $output->set_redirect (uri => $uri, status_code => 303);
142     $output->output (output => 'http-cgi');
143     } else {
144 wakaba 1.7 try {
145     $self->{view}->{wiki}->{db}->delete (content => $page);
146     $self->{view}->{wiki}->{db}->delete (lastmodified => $page) if $touch;
147     } catch SuikaWiki::DB::Util::Error with {
148 wakaba 1.9 my $err = shift;
149     if ($err->{-type} eq 'ERROR_REPORTED') {
150     $err->throw;
151     } else {
152     $self->{view}->{wiki}->view_in_mode (mode => '-wdb--fatal-error');
153     throw SuikaWiki::DB::Util::Error -type => 'ERROR_REPORTED';
154     }
155 wakaba 1.7 };
156 wakaba 1.2 $self->{view}->{wiki}->view_in_mode (mode => '-deleted');
157 wakaba 1.1 }
158     @@Name: main
159    
160     ViewDefinition:
161     @Mode: adminedit
162     @Condition:
163     @@http-method[list]:
164     GET
165     HEAD
166     @Description:
167     @@@: Edit WikiPage content as whole, as a plaintext (administrator mode)
168     @@lang: en
169     @template:
170     @@http-status-code: 200
171     @@media-type: application/xhtml+xml
172     @@use-media-type-charset: 1
173     @@expires: %%edit%%
174     @@body:
175 wakaba 1.2 %html-document (
176     title => {%res(name=>{Edit:Admin:WebPageTitle});}p,
177 wakaba 1.6 link-meta => {%template (name => links);
178 wakaba 1.2 %html-meta(name=>ROBOTS,content=>NOINDEX);}p,
179     content => {
180     %template (
181     name => ws--page,
182     -content => {%template (name => we--adminedit-body);},
183     );
184     }p,
185     );
186 wakaba 1.1
187 wakaba 1.2 ViewDefinition:
188 wakaba 1.1 @Mode: -conflict
189     @Condition:
190     @@http-method[list]:
191     GET
192     HEAD
193     @Description:
194     @@@: Confliction message
195     @@lang: en
196     @template:
197     @@http-status-code: 409
198     @@media-type: text/html
199     @@use-media-type-charset: 1
200     @@body:
201 wakaba 1.2 %html-document (
202     title => {%res(name=>{Edit:Conflict:WebPageTitle});}p,
203     link-meta => {%template(name=>links);
204     %html-meta(name=>ROBOTS,content=>NOINDEX);}p,
205     content => {
206     %template (
207     name => ws--page,
208     -content => {
209 wakaba 1.6 %section (
210 wakaba 1.2 title => {%res(name=>{Edit:Conflict:Title});}p, heading,
211     content => {%template (name => we--conflict-body);}p,
212     );
213     },
214     );
215     }p,
216     );
217    
218     ViewDefinition:
219     @Mode: -deleted
220     @Condition:
221     @@http-method[list]:
222     GET
223     HEAD
224     @Expires:%%view%%
225     @Description:
226     @@@: Confliction message
227     @@lang: en
228     @template:
229     @@http-status-code: 200
230     @@media-type: text/html
231     @@use-media-type-charset: 1
232     @@body:
233     %html-document (
234     title => {%res (name => {Edit:Deleted:WebPageTitle});}p,
235     link-meta => {%template (name => links);
236     %html-meta (name => ROBOTS, content => NOINDEX);}p,
237     content => {
238     %template (
239     name => ws--page,
240     -content => {
241 wakaba 1.6 %section (
242 wakaba 1.2 title => {%res(name=>{Edit:Deleted:Title});}p, heading,
243     content => {
244     %paragraph (content => {%res
245     (name => {Edit:Deleted:Description});}p);
246     }p,
247     );
248     },
249     );
250     }p,
251     );
252 wakaba 1.1
253     ViewFragment:
254     @Name: links
255     @Description:
256     @@@: Link to edit mode of the WikiPage
257     @@lang:en
258     @Formatting:
259 wakaba 1.6 %link-wiki(mode => edit, up-to-date,
260     rel => edit, class => wiki-cmd,
261     description => {%res(name=>{Link:Edit:Description});}p);
262     %link-wiki(mode => adminedit, up-to-date,
263     rel=>edit, class => wiki-cmd,
264     description => {%res(name=>{Link:AdminEdit:Description});}p);
265 wakaba 1.1
266     ViewFragment:
267     @Name: navbar
268     @Description:
269     @@@: Link to edit mode of the WikiPage
270     @Order: 10
271     @Formatting:
272 wakaba 1.3 %link-to-wikipage (
273     mode => edit,
274     rel => edit,
275     up-to-date,
276     label => {%link-to-it (
277     class => wiki-cmd,
278     label => {%res (name => EditThisPage);}p,
279     description => {%res (name => EditThisPageLong);}p,
280     );},
281     page-anchor-name => edit,
282     );
283 wakaba 1.2
284     ViewFragment:
285     @Template[list]:
286     we--conflict-body
287     @Order: 30
288     @Description:
289     @@@: Conflict report
290     @@lang:en
291     @Formatting:
292     %paragraph (content=>{%res(name=>{Edit:Conflict:Description});}p);
293     %we--conflict-modified-content;
294 wakaba 1.6 %section (
295 wakaba 1.2 id => edit-conflict-diff,
296     title => {%res(name=>{Edit:Conflict:Diff:Title});}p, heading,
297     content => {
298     %paragraph (
299     content => {%res(name=>{Edit:Conflict:Diff:Description});}p);
300     %conflict-diff;
301     }p,
302     );
303    
304     ViewFragment:
305     @Template[list]: we--edit-body
306     @Order:80
307     @Description:
308     @@@: Editing WikiPage form section
309     @@lang:en
310     @Formatting:
311 wakaba 1.6 %section (
312 wakaba 1.2 id => edit,
313     title => {%res (name => {Edit:Title});}p, heading,
314     content => {%edit-form;}p,
315     );
316    
317     ViewFragment:
318     @Template[list]: we--adminedit-body
319     @Order:80
320     @Description:
321     @@@: Editing WikiPage form section (Admin edit mode)
322     @@lang:en
323     @Formatting:
324 wakaba 1.6 %section (
325 wakaba 1.2 id => edit,
326     title => {%res(name=>{Edit:Title});}p, heading,
327     content => {%edit-form(admin);}p,
328     );
329    
330     ViewFragment:
331     @Template[list]: we--conflict-body
332     @Order: 80
333     @Description:
334     @@@: Editing-WikiPage-form section (conflict mode)
335     @@lang:en
336     @Formatting:
337 wakaba 1.6 %section (
338 wakaba 1.2 id => edit,
339     title => {%res(name=>{Edit:Title});}p, heading,
340     content => {
341     %paragraph(name=>{%res(name=>{Edit:Conflict:Edit:Description});}p);
342     %edit-form;
343     }p,
344     );
345 wakaba 1.1
346     ViewFragment:
347     @Name: we--edit
348     @Description:
349     @@@: Edit form --- main textarea
350     @@lang:en
351     @Order: 0
352     @Formatting:
353 wakaba 1.5 %textarea (id => we--content, size => {%res (name=>{Edit:Form:Size});}p,
354 wakaba 1.6 source => content, lines => {%res (name=>{Edit:Form:Lines});}p);
355 wakaba 1.1 ViewFragment:
356     @Name: we--edit
357     @Description:
358     @@@: Submit button
359     @@lang:en
360     @Order: 200
361     @Formatting:
362     %submit(label=>{%res(name=>{Edit:Save});}p);
363    
364     FormattingRule:
365     @Category[list]: view
366     @Name: edit-form
367     @Description:
368     @@@: Provides WikiPage editing form
369     @@lang: en
370     @Parameter:
371     @@Name: admin
372     @@Type: boolean
373     @@Default: {0}
374     @@Description:
375     @@@@: Whether administrator's editing mode or not
376     @@@lang:en
377 wakaba 1.5 @Parameter:
378     @@Name: page
379     @@Type: WikiName
380     @@Default: (auto)
381     @@Description:
382     @@@@: WikiPage that is editing
383     @@@lang:en
384 wakaba 1.1 @Formatting:
385 wakaba 1.5 __ATTRTEXT:%admin__;__ATTRTEXT:%page__;
386 wakaba 1.8 my $page = $o->{wiki}->name ($p->{page} || $o->{wiki}->{var}->{page});
387 wakaba 1.5 my $template = $o->{wiki}->{view}->assemble_template ('we__edit');
388     local $o->{var} = {
389 wakaba 1.1 #content
390     is_admin_mode => $p->{admin},
391     is_conflict_mode => 0,
392     #is_new_page_template
393     };
394 wakaba 1.5 $o->{var}->{content} = __FUNCPACK__->get_content ($o, $page);
395     SuikaWiki::Plugin->module_package ('WikiFormCore')
396     ->make_form_in_html
397     ($p->{-parent}, $template,
398     wiki => $o->{wiki},
399     o => $o,
400     index => -1,
401     output => {
402     mode => 'write',
403     page => $page,
404     hidden => sub {
405     my ($hidden, $o) = @_;
406 wakaba 1.3 for ($hidden->append_new_node (type => '#element',
407 wakaba 1.5 namespace_uri => $NS_XHTML1,
408     local_name => 'input')) {
409 wakaba 1.1 $_->set_attribute (type => 'hidden');
410     $_->set_attribute (name => 'we--digest');
411 wakaba 1.2 $_->set_attribute (value => ($o->{var}->{is_new_page_template}?'':
412 wakaba 1.5 __FUNCPACK__->digest ($o->{var}->{content},
413     normalize => 1)));
414 wakaba 1.1 $_->option (use_EmptyElemTag => 1);
415     }
416 wakaba 1.5 },
417     });
418    
419 wakaba 1.1
420     FormattingRule:
421     @Category[list]: view
422 wakaba 1.2 @Name: we--conflict-modified-content
423 wakaba 1.1 @Description:
424     @@@:
425 wakaba 1.2 Modified content that is conflicted with current content
426 wakaba 1.1 @@lang:en
427     @Formatting:
428 wakaba 1.3 $p->{-parent}->append_new_node (type => '#element',
429 wakaba 1.2 namespace_uri => $NS_XHTML1,
430 wakaba 1.3 local_name => 'pre')
431     ->append_text (scalar $o->{wiki}->{input}->parameter ('we--content'));
432 wakaba 1.1
433     FormattingRule:
434     @Category[list]:view
435     @Name: conflict-diff
436     @Description:
437     @@@:
438     Provides marked diff between latest WikiPage content and
439     submitted one
440     @@lang:en
441     @Formatting:
442 wakaba 1.6 my $before = scalar $o->{wiki}->{input}->parameter ('we--content');
443 wakaba 1.7 my $after;
444     try {
445     $after = $o->{wiki}->{db}->get (content => $o->{wiki}->{var}->{page});
446     } catch SuikaWiki::DB::Util::Error with {
447 wakaba 1.9 my $err = shift;
448     $err->throw if $err->{-type} eq 'ERROR_REPORTED';
449 wakaba 1.7 $after = undef;
450     };
451 wakaba 1.6 __FUNCPACK__->diff_in_html (\$before => \$after, $p->{-parent});
452    
453     Function:
454     @Name: diff_in_html
455     @Main:
456     my (undef, $before, $after, $parent, %opt) = @_;
457 wakaba 1.3 require Algorithm::Diff;
458 wakaba 1.6 my $diff = $parent->append_new_node (type => '#element',
459     namespace_uri => $NS_XHTML1,
460     local_name => 'pre');
461 wakaba 1.3 $diff->set_attribute (class => 'diff');
462 wakaba 1.6 for (Algorithm::Diff::diff
463     ([split /\x0D?\x0A/, $$before]=>[split /\x0D?\x0A/, $$after])) {
464 wakaba 1.1 for (@{$_}) {
465     my ($sign, $lineno, $text) = @{$_};
466 wakaba 1.3 my $line = $diff->append_new_node (type => '#element',
467 wakaba 1.2 namespace_uri => $NS_XHTML1,
468     local_name => ({qw/+ ins - del/}->{$sign}||'span'));
469    
470     $line->set_attribute (class => 'line');
471     for ($line->append_new_node (type => '#element',
472     namespace_uri => $NS_XHTML1,
473     local_name => 'span')) {
474     $_->set_attribute (class => 'lineno');
475     $_->append_text ($lineno);
476     }
477     $line->append_text (' ');
478     for ($line->append_new_node (type => '#element',
479     namespace_uri => $NS_XHTML1,
480     local_name => 'span')) {
481     $_->set_attribute (class => 'sign');
482     $_->append_text ($sign);
483     }
484     $line->append_text (' ');
485     for ($line->append_new_node (type => '#element',
486     namespace_uri => $NS_XHTML1,
487     local_name => 'span')) {
488     $_->set_attribute (class => 'content');
489     $_->append_text ($text);
490     }
491     $line->append_text ("\n");
492     } # diff lines
493 wakaba 1.1 }
494    
495     FormattingRule:
496     @Name:mode-after-edit-selection
497 wakaba 1.5 @Category[list]:form-input
498 wakaba 1.8 @Parameter:
499     @@Name: description
500     @@Type: text
501     @@Default: (none)
502     @@Description:
503     @@@@: Human readable description about this input
504     @@@lang: en
505 wakaba 1.1 @Formatting:
506 wakaba 1.8 ## TODO: media-type prop support
507 wakaba 1.1 my $magic = '';
508     $magic = $1 if $o->{var}->{content} =~ m/^([^\x0A\x0D]+)/s;
509    
510 wakaba 1.5 my $name = 'we--mode-modified';
511 wakaba 1.1 my $selected_mode = $o->{wiki}->{input}->parameter ($name);
512     unless ($selected_mode) {
513     if ($magic =~ /C(?:on(?:fig|st)|SS)/) {
514     $selected_mode = 'edit';
515     } else {
516     $selected_mode = 'default';
517     }
518     }
519    
520 wakaba 1.3 my $SELECT = $p->{-parent}->append_new_node (type => '#element',
521     namespace_uri => $NS_XHTML1,
522     local_name => 'select');
523 wakaba 1.1 $SELECT->set_attribute (name => $name);
524 wakaba 1.8 __ATTRTEXT:%description__;
525     $SELECT->set_attribute (title => $p->{description})
526     if length $p->{description};
527 wakaba 1.1 for (qw/default read edit/) {
528     for my $OPTION ($SELECT->append_new_node (type => '#element',
529     namespace_uri => $NS_XHTML1,
530     local_name => 'option')) {
531     $OPTION->set_attribute (value => $_);
532 wakaba 1.6 my $label = SuikaWiki::Plugin->module_package ('WikiResource')
533     ->append_node (name => 'Edit:SaveAnd:'.$_.':Label',
534     param => $o,
535     wiki => $o->{wiki});
536     $OPTION->set_attribute (label => $label->inner_text);
537     $OPTION->append_node ($label);
538 wakaba 1.1 $OPTION->set_attribute
539 wakaba 1.6 (title => SuikaWiki::Plugin->module_package ('WikiResource')
540     ->append_node (name => 'Edit:SaveAnd:'.$_.':Description',
541     param => $o,
542     wiki => $o->{wiki})->inner_text);
543 wakaba 1.1 $OPTION->set_attribute (selected => 'selected')
544     if $selected_mode eq $_;
545     }
546     }
547    
548 wakaba 1.5 FormattingRule:
549     @Category[list]:form-input
550     @Name:we--update-lastmodified-datetime
551     @Description:
552     @@@:
553     This direction force to update last-modified date-time
554     of the WikiPage modified.
555     \
556     Allowing user to select whether last-modified date-time should be
557     updated, use another formatting rule provided by WikiFormSelection
558     module.
559     \
560     WikiForm other that editing form might not be affected by this
561     parameter. See also "we--touch" parameter.
562     @@lang:en
563     @Formatting:
564     for ($p->{-parent}->append_new_node
565     (type => '#element',
566     namespace_uri => $NS_XHTML1,
567     local_name => 'input')) {
568     $_->set_attribute (type => 'hidden');
569     $_->set_attribute (name => 'we--touch');
570     $_->set_attribute (value => 'on');
571     $_->option (use_EmptyElemTag => 1);
572     }
573    
574    
575 wakaba 1.1 Resource:
576 wakaba 1.2 @Edit:Conflict:Title:
577     @@@:Confliction detected!
578     @@lang:en
579     @Edit:Conflict:WebPageTitle:
580     @@@:%page-name; (Edit : 409 CONFLICTION)
581     @@lang:en
582     @Edit:Deleted:Description:
583     @@@:Content of WikiPage %page-name; has been removed.
584     @@lang:en
585     @Edit:Deleted:Title:
586     @@@:WikiPage Deleted
587     @@lang:en
588     @Edit:Deleted:WebPageTitle:
589     @@@:%page-name; (Deleted)
590     @@lang:en
591 wakaba 1.1 @Edit:Form:Lines:15
592     @Edit:Form:Size:18
593     @Edit:Save:
594     @@@:Save
595     @@lang:en
596 wakaba 1.8 @Edit:SaveAnd:Description:
597     @@@: Select what to do after saving content
598     @@lang: en
599 wakaba 1.1 @Edit:SaveAnd:default:Description:
600     @@@: Save modified content and show content with your default view mode
601     @@lang:en
602     @Edit:SaveAnd:default:Label:
603     @@@: Default view
604     @@lang:en
605     @Edit:SaveAnd:edit:Description:
606     @@@: Save modified content and show content in the edit mode again
607     @@lang:en
608     @Edit:SaveAnd:edit:Label:
609     @@@: Edit again
610     @@lang:en
611     @Edit:SaveAnd:read:Description:
612     @@@: Save modified content and show content in the read mode
613     @@lang:en
614     @Edit:SaveAnd:read:Label:
615     @@@: Show content
616     @@lang:en
617     @EditThisPage:
618     @@@: Edit
619     @@lang:en
620     @EditThisPageLong:
621     @@@: Edit this WikiPage
622     @@lang:en
623     @Edit:WebPageTitle:
624     @@@: %page-name; (Modification)
625     @@lang:en
626     @Edit:Title:
627     @@@: Modification of the WikiPage
628     @@lang:en
629     @Link:AdminEdit:Description:
630     @@@: Edit this WikiPage (administrator's mode)
631     @@lang:en
632     @Link:Edit:Description:
633     @@@: Edit this WikiPage
634     @@lang:en
635 wakaba 1.8 @Mode:adminedit:
636     @@@: Editing (for administrator)
637     @@lang: en
638     @Mode:edit:
639     @@@: Editing
640     @@lang: en
641 wakaba 1.1
642     Function:
643 wakaba 1.2 @Name:digest
644     @Description:
645     @@@: Compute digest of given string
646     @@lang:en
647     @Main:
648 wakaba 1.5 my (undef, $s, %opt) = @_;
649 wakaba 1.2 require Digest::SHA1;
650     if ($opt{normalize}) {
651     $s =~ s/\x0D\x0A/\x0A/g;
652     $s =~ tr/\x0D/\x0A/;
653     }
654     Digest::SHA1::sha1_base64 ($s);
655    
656     Function:
657 wakaba 1.1 @Name:get_content
658     @Description:
659     @@@:Get WikiPage content to be modified. For new (currently not exist)
660     WikiPage, new page template content is returned.
661     @@lang:en
662     @Main:
663 wakaba 1.5 my (undef, $o, $page) = @_;
664 wakaba 1.1 my $content;
665 wakaba 1.7 try {
666     $content = $o->{wiki}->{db}->get (content => $page);
667    
668     unless (length $content) {
669     ## TODO: use namespaced template page
670     $content = $o->{wiki}->{db}->get
671     (content => $o->{wiki}->{config}->{page}->{NewPageTemplate});
672     $o->{var}->{is_new_page_template} = 1;
673     }
674     } catch SuikaWiki::DB::Util::Error with {
675 wakaba 1.9 my $err = shift;
676     $err->throw if $err->{-type} eq 'ERROR_REPORTED';
677 wakaba 1.7 $o->{wiki}->view_in_mode (mode => '-wdb--fatal-error');
678     throw SuikaWiki::DB::Util::Error -type => 'ERROR_REPORTED';
679     };
680 wakaba 1.1 $content;
681    
682     Parameter:
683 wakaba 1.2 @Name: we--content
684     @Type: text
685     @Default: ""
686     @Description:
687     @@@:
688     Content of WikiPage (to be)
689     @@lang:en
690    
691     Parameter:
692 wakaba 1.1 @Name: we--digest
693     @Type: "Base64ed SHA1"
694     @Default: {undef}
695     @Description:
696     @@@:
697     SHA1 digest value of the WikiPage content before the modification.
698     This value is used to detect confliction of modifying.
699     Empty value (undef or length-zero-string) means that
700     there were no WikiPage content.
701 wakaba 1.2 @@lang:en
702    
703     Parameter:
704     @Name: we--mode-modified
705     @Type: mode-name
706     @Default: "default"
707     @Description:
708     @@@:
709     WikiEngine running mode to be specified after modification is completed
710 wakaba 1.1 @@lang:en
711    
712     Parameter:
713     @Name: we--touch
714 wakaba 1.5 @Type:
715     form:checkbox-value
716 wakaba 1.1 @Default: "off"
717     @Description:
718     @@@:
719     Whether last-modified date-time of the WikiPage should be updated or not
720     when the WikiPage is modified.
721     @@lang:en

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24