/[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.10 - (hide annotations) (download)
Mon Mar 29 03:22:30 2004 UTC (21 years ago) by wakaba
Branch: MAIN
Changes since 1.9: +40 -24 lines
+2004-03-29  Wakaba  <wakaba@suika.fam.cx>
+
+       * WikiEdit.wp2 (ViewDefinition[write]): Don't update content and
+       lastmodified if new content is actually not changed.
+
+       * WikiFormCore.wp2 (ViewDefinition[wikiform]): 'bbs__sage' parameter
+       implemented for WikiFormBBS WikiPlugin module.
+
+2004-03-24  Wakaba  <wakaba@suika.fam.cx>
+
+       * WikiFormCore.wp2 (ViewDefinition[wikiform]): Action name 'view'
+       is changed to 'ok'.
+       (required): Internal data structure is changed
+       from {form}->{require}->{ id } to {form}->{require}->{id}->{ id }.
+       * WikiFormText.wp2 (FormattingRule): s/{require}/{require}->{id}/g;
+
+2004-03-20  Wakaba  <wakaba@suika.fam.cx>
+
+       * WikiFormText.wp2 (FormattingRule[textarea]): Appends <br/> after
+       label.

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

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24