/[pub]/suikawiki/script/misc/plugins/view/paragraph.wp2
Suika

Contents of /suikawiki/script/misc/plugins/view/paragraph.wp2

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1.2.1 - (hide annotations) (download)
Wed Aug 11 00:05:02 2004 UTC (20 years, 11 months ago) by wakaba
Branch: paragraph-200404
Changes since 1.1: +376 -0 lines
Experimental paragraph-oriented wiki implementation

1 wakaba 1.1.2.1 #?SuikaWikiConfig/2.0
2    
3     Plugin:
4     @Name: Paragraph
5     @Description:
6     @@@: Paragraph-oriented wiki'ing
7     @@lang:en
8     @License: %%Perl%%
9     @Author:
10     @@Name:
11     @@@@: Wakaba
12     @@@lang:ja
13     @@@script:Latn
14     @@Mail[list]: w@suika.fam.cx
15     @Date.RCS:
16     $Date: 2004/04/25 07:06:50 $
17     @RequiredPlugin[list]:
18     WikiFormat
19     WikiStruct
20     WikiLinking
21     HTML
22     WikiRead
23     @Use:
24     require SuikaWiki::Format::Definition;
25     use Message::Util::Error;
26     my $WIKIFORMAT;
27     my $WIKIRESOURCE;
28    
29     ViewDefinition:
30     @Mode: para--read
31     @Condition:
32     @@http-method[list]:
33     GET
34     HEAD
35     POST
36     @Description:
37     @@@: Show WikiPage content as whole (paragraph-oriented)
38     @@lang: en
39     @template:
40     @@http-status-code: 200
41     @@media-type: text/html
42     @@use-media-type-charset: 1
43     @@expires: %%view%%
44     @@body:
45     %html-document (
46     title => {%res (name => {View:WebPageTitle});}p,
47     link-meta => {%template (name => links);}p,
48     content => {
49     %template (
50     name => ws--page,
51     -content => {
52     %block (
53     class => "bodytext",
54     content => {%template (name => para--read-body);}p,
55     );
56     },
57     );
58     }p,
59     );
60    
61     ViewFragment:
62     @Template[list]:para--read-body
63     @Order: 0
64     @Description:
65     @@@: "Read" mode body -- WikiPage main content (parahraph-oriented)
66     @@lang:en
67     @Formatting:
68     %para--read;
69     %section (
70     class => para--new,
71     title => {%res (name => {Paragraph:New:Title});}p, heading,
72     content => {%para--new-paragraph;}p,
73     );
74    
75     PluginConst:
76     @NS_XHTML1:
77     http://www.w3.org/1999/xhtml
78     @WIKIFORMAT:
79     {($WIKIFORMAT ||= SuikaWiki::Plugin->module_package ('WikiFormat'))}
80     @WIKIRESOURCE:
81     {($WIKIRESOURCE ||= SuikaWiki::Plugin->module_package ('WikiResource'))}
82    
83     FormattingRule:
84     @Category[list]: view
85     @Name: para--read
86     @Description:
87     @@@:
88     Show the WikiPage to be "read" (paragraph-oriented)
89     @@lang: en
90     @Parameter:
91     @@Name: page
92     @@Type: WikiName
93     @@Default: (current)
94     @@Description:
95     @@@@: WikiPage shown
96     @@@lang:en
97     @Parameter:
98     @@Name: comment
99     @@Type: boolean
100     @@Default: {0}
101     @@Description:
102     @@@@: Append comment form
103     @@@lang:en
104     @Parameter:
105     @@Name: IsFragment
106     @@Type: boolean
107     @@Default: (auto)
108     @@Description:
109     @@@@:
110     Specify whether convertion result should be "fragment" format.
111     (For example, "text/html" fragment will not have "html" element
112     as the root element.)
113     @@@lang: en
114     @Parameter:
115     @@Name: Name
116     @@Type: product-name-token
117     @@Default: (auto)
118     @@Description:
119     @@@@:
120     Media type name (product style).
121     @@@lang: en
122     @Parameter:
123     @@Name: Type
124     @@Type: internet-media-type-subtype
125     @@Default: (auto)
126     @@Description:
127     @@@@:
128     Internet media type (type/subtype pair) to which content should be
129     converted.
130     \
131     Note that media type parameters cannot be specified here.
132     Way to specify them are under consideration.
133     \
134     Neither Type nor Name is specified, defaulted to
135     (Type => {text/html}, IsFragment => 1).
136     @Parameter:
137     @@Name: Version
138     @@Type: product-version-token
139     @@Default: (auto)
140     @@Description:
141     @@@@:
142     Media type version (product style).
143     \
144     Name parameter should also be specified, otherwise Version makes
145     no mean.
146     @Parameter:
147     @@Name: when-no-converter
148     @@Type: token
149     @@Default: "exception"
150     @@Description:
151     @@@@:
152     Specify how behave if Converter not found.
153     \
154     'exception': Throw an exception.
155     \
156     '406': Turn to -wf--converter-not-found mode.
157     \
158     'ignore': Ignore. Returned value is not defined.
159     @Formatting:
160     __ATTRTEXT:%page__;__ATTRTEXT:%comment__;
161     my $page = $o->{wiki}->name ($p->{page} || $o->{wiki}->{var}->{page});
162     my @page;
163     if (@$page != 1 and $page->[0] eq 'Wiki') {
164     push @page, $page;
165     } else {
166     my $list;
167     try {
168     $list = $o->{wiki}->{db}->get (content_map => $page);
169     } catch SuikaWiki::DB::Util::Error with {
170     my $err = shift;
171     $err->throw if $err->{-type} eq 'ERROR_REPORTED';
172     $list = undef;
173     };
174     push @page, map {$o->{wiki}->name ([0+$_])} grep $_, split /\n/, $list || '';
175     }
176    
177     my %param;
178     if ($p->{Type} or $p->{Name}) {
179     for (qw/Type Name Version IsFragment return_type/) {
180     $param{$_} = $p->{$_};
181     }
182     ## TODO: Type_param
183     } else {
184     %param = (Type => 'text/html', IsFragment => 1);
185     }
186    
187     __ATTRTEXT:%paragraph__;
188     my $para_template = $p->{paragraph} ||
189     $WIKIRESOURCE->get_text
190     (name => 'Paragraph:Read:Paragraph',
191     o => $o, wiki => $o->{wiki});
192     for my $page (@page) {
193     local $o->{para__paragraph} = {
194     number => 0 + $page->[0],
195     page => $page,
196     };
197     try {
198     $f->replace ($para_template, param => $o, -parent => $p->{-parent});
199     } catch Message::Util::Formatter::error with {
200     my $err = shift;
201     SuikaWiki::Plugin->module_package ('Error')
202     ->reporting_formatting_template_error
203     ($err, $err->{option}->{param}->{wiki});
204     throw SuikaWiki::View::Implementation::error -type => 'ERROR_REPORTED';
205     };
206     }
207    
208     FormattingRule:
209     @Category[list]:
210     view
211     view-resource
212     form-input
213     page-link
214     link-to-resource
215     @Name: para--page-name
216     @Description:
217     @@@: WikiName for paragraph
218     @@lang: en
219     @Formatting:
220     $p->{-parent}->append_text ($o->{para__paragraph}->{page}->stringify (wiki => $o->{wiki}));
221    
222     FormattingRule:
223     @Category[list]:
224     view
225     view-resource
226     form-input
227     page-link
228     link-to-resource
229     @Name: para--number
230     @Description:
231     @@@: Sequential number for paragraph
232     @@lang: en
233     @Formatting:
234     $p->{-parent}->append_text ($o->{para__paragraph}->{number} + 0);
235    
236     ViewFragment:
237     @Name: links
238     @Description:
239     @@@: Link to read mode of the WikiPage
240     @@lang:en
241     @Formatting:
242     %link-wiki(mode=>para--read,rel=>view,class=>wiki-cmd,
243     description=>{%res(name=>{Link:View:Description});}p,up-to-date);
244    
245     ViewFragment:
246     @Name: navbar
247     @Description:
248     @@@: Link to read mode of the WikiPage
249     @Order: 0
250     @Formatting:
251     %link-to-wikipage (
252     rel => view,
253     mode => para--read,
254     up-to-date,
255     label => {%link-to-it (
256     class => wiki-cmd,
257     label => {%res(name=>ViewThisPage);}p,
258     description => {%res(name=>ViewThisPageLong);}p,
259     );},
260     );
261    
262     FormattingRule:
263     @Category[list]:
264     view
265     view-resource
266     form-input
267     @Name: para--new-paragraph
268     @Formatting:
269     my $page = $o->{wiki}->name ($p->{page} || $o->{wiki}->{var}->{page});
270     SuikaWiki::Plugin->module_package ('WikiFormCore')
271     ->make_form_in_html
272     ($p->{-parent}, $p->{content} ||
273     $WIKIRESOURCE->get
274     (name => 'Paragraph:NewForm:Content',
275     o => $o, wiki => $o->{wiki}),
276     wiki => $o->{wiki}, o => $o,
277     index => -1,
278     output => {
279     mode => 'para--new',
280     page => $page,
281     });
282    
283     ViewDefinition:
284     @Mode: para--new
285     @Condition:
286     @@output: http-cgi
287     @@http-method[list]:
288     POST
289     @Description:
290     @@@: Create a new paragraph
291     @@lang:en
292     @method:
293     @@@:
294     my $wiki = $self->{view}->{wiki};
295     ## Open Database
296     $wiki->{var}->{db}->{read_only}->{content} = 0;
297     $wiki->{var}->{db}->{read_only}->{content_prop} = 0;
298     $wiki->{var}->{db}->{read_only}->{lastmodified} = 0;
299     $self->{view}->init_db;
300    
301     my $page = $wiki->{var}->{page};
302     my $o = {
303     wiki => $wiki,
304     };
305     $o->{para__paragraph}->{number} = $wiki->{db}->_do (content => '_next_number');
306    
307     $wiki->{db}->set (content => [$o->{para__paragraph}->{number}],
308     => scalar $wiki->{input}->parameter ('para--content'));
309     $wiki->{db}->set (lastmodified => [$o->{para__paragraph}->{number}],
310     => time);
311    
312     my $map = $wiki->{db}->get (content_map => $page);
313     $map .= "\n" . $o->{para__paragraph}->{number};
314     $wiki->{db}->set (content_map => $page => $map);
315     $wiki->{db}->set (lastmodified => $page => time);
316    
317     my $uri = $self->{view}->{wiki}->uri_reference
318     (page => $page, up_to_date => 1);
319    
320     require SuikaWiki::Output::HTTP;
321     my $output = SuikaWiki::Output::HTTP->new (wiki => $self->{view}->{wiki});
322     $output->set_redirect (uri => $uri, status_code => 303,
323     status_phrase => q(Created));
324     ## Should we use 201 Created?
325     $output->output (output => 'http-cgi');
326     @@Name: main
327    
328     Resource:
329     @Paragraph:New:Title:
330     @@@: Add
331     @@lang: en
332     @Paragraph:NewForm:Content:
333     %line (content => {
334     %textarea (
335     id => para--content,
336     label => {%res (name => {Paragraph:NewForm:MainText:Label});}p,
337     size => 20,
338     lines => 10,
339     );
340     }p);
341     %line (content => {
342     %submit (label => {%res (name => {Paragraph:NewForm:Submit:Label});}p);
343     }p);
344     @Paragraph:NewForm:MainText:Label:
345     @@@: Content
346     @@lang: en
347     @Paragraph:NewForm:Submit:Label:
348     @@@: Add
349     @@lang: en
350     @Paragraph:Read:Paragraph:
351     %block (
352     class => para--page,
353     content => {
354     %read (page => {%para--page-name;}p);
355     %block (
356     class => para--footer,
357     content => {
358     %link-to-wikipage (
359     label => {%link-to-it (label => {#%para--number;}p);},
360     page => {%para--number;}p,
361     mode => para--para-read,
362     );
363     @%last-modified (page => {%para--number;}p);
364     }p,
365     );
366     }p,
367     );
368    
369    
370    
371    
372    
373    
374    
375    
376    

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24