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