/[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.13 - (hide annotations) (download)
Thu Jun 3 06:38:48 2004 UTC (20 years, 10 months ago) by wakaba
Branch: MAIN
CVS Tags: release-3-0-0
Changes since 1.12: +45 -4 lines
Static output of stylesheet implemented; Use of simple HTML serializer (new to manakai) if text/html output

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

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24