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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.2 - (show annotations) (download)
Fri Jan 16 07:48:39 2004 UTC (22 years, 5 months ago) by wakaba
Branch: MAIN
Changes since 1.1: +25 -3 lines
(wpp--next-anchor-index): New rule

1 #?SuikaWikiConfig/2.0
2
3 Plugin:
4 @Name: WikiPageProp
5 @Description:
6 @@@: WikiPage property
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 @Date.RCS: $Date: 2003/11/25 12:39:40 $
16 @RequiredModule[list]:
17 WikiFormat
18
19 PluginConst:
20 @NS_XHTML1:
21 http://www.w3.org/1999/xhtml
22
23 FormattingRule:
24 @Category[list]:
25 view
26 view-resource
27 form-input
28 @Name: last-modified
29 @Description:
30 @@@:
31 Last-modified date-time of the WikiPage.
32 \
33 Note: Date-time value returned by this rule might not be
34 the "real" last-modified date-time, in case last-modified
35 value is not updated when content is modified (so called
36 "sage" feature).
37 @@lang: en
38 @Parameter:
39 @@Name: page
40 @@Type: WikiName
41 @@Default: (current)
42 @@Description:
43 @@@@: Target WikiPage
44 @@@lang:en
45 @Formatting:
46 __ATTRTEXT:%page__;
47 my $page = length $p->{page} ?
48 [split $o->{wiki}->{config}->{name}->{space}->{separator_regex},
49 $p->{page}]:
50 $o->{wiki}->{var}->{page};
51 $p->{-parent}->append_text
52 ( __FUNCPACK__::unixtime_to_string
53 ($o->{wiki}->{db}->get (lastmodified => $page)));
54 ## TODO: format string
55
56 FormattingRule:
57 @Category[list]: page-link
58 @Name: last-modified
59 @Description:
60 @@@:
61 Last-modified date-time of the WikiPage.
62 \
63 Note: Date-time value returned by this rule might not be
64 the "real" last-modified date-time, in case last-modified
65 value is not updated when content is modified (so called
66 "sage" feature).
67 @@lang: en
68 @Formatting:
69 my $date;
70 if (defined $o->{link}->{dest}->{page_lastmodified}) {
71 $date = $o->{link}->{dest}->{page_lastmodified};
72 } else {
73 ## TODO:
74 my $page = [$o->{link}->{dest}->{page_name}];
75 $date = $o->{wiki}->{db}->get (lastmodified => $page);
76 }
77 $p->{-parent}->append_text (__FUNCPACK__::unixtime_to_string ($date));
78 ## TODO: Update to new interface
79
80 FormattingRule:
81 @Category[list]:
82 view
83 view-resource
84 form-input
85 @Name: page-name
86 @Description:
87 @@@:
88 WikiName in string repersentation
89 @@lang: en
90 @Parameter:
91 @@Name:separator
92 @@Type:string
93 @@Default:(config)
94 @@Description:
95 @@@@:Separator used to delimit namespace components (ie. path delimiter)
96 @@@lang:en
97 @Formatting:
98 __ATTRTEXT:%page__;
99 ## TODO:
100 my $page = length $p->{page} ?
101 [split $o->{wiki}->{config}->{name}->{space}->{separator_regex},
102 $p->{page}]:
103 $o->{wiki}->{var}->{page};
104 $p->{-parent}->append_text (join
105 (($p->{separator} || $o->{wiki}->{config}->{name}->{space}->{separator}),
106 @{$page}));
107
108 FormattingRule:
109 @Category[list]:page-link
110 @Name: page-name
111 @Description:
112 @@@:WikiName in string representation
113 @@lang:en
114 @Parameter:
115 @@Name:relative
116 @@Type:boolean
117 @@Default:"0"
118 @@Description:
119 @@@@:Whether relative to "this" page
120 @@@lang:en
121 @Formatting:
122 __ATTRTEXT:%relative__;
123 if ($p->{relative}) {
124 $p->{-parent}->append_text (join '//', @{$o->{link}->{dest}->{page_name_relative}});
125 } else {
126 $p->{-parent}->append_text (join '//', @{$o->{link}->{dest}->{page_name}});
127 }
128
129 FormattingRule:
130 @Category[list]:page-link
131 @Name: page-title
132 @Description:
133 @@@:Title of the WikiPage
134 @@lang:en
135 @Parameter:
136 @@Name:relative
137 @@Type:boolean
138 @@Default:"0"
139 @@Description:
140 @@@@:Whether relative to "this" page
141 @@@lang:en
142 @Formatting:
143 __ATTRTEXT:%relative__;
144 if (defined $o->{link}->{dest}->{page_title}) {
145 $p->{-parent}->append_text ($o->{link}->{dest}->{page_title});
146 } elsif ($p->{relative}) {
147 $p->{-parent}->append_text ($o->{link}->{dest}->{page_name_relative});
148 } else {
149 $p->{-parent}->append_text ($o->{link}->{dest}->{page_name});
150 }
151
152 FormattingRule:
153 @Category[list]:page-link
154 @Name:page-headline
155 @Description:
156 @@@:Headline summary of the WikiPage
157 @@lang:en
158 @Formatting:
159 $p->{-parent}->append_text
160 (__FUNCPACK__::_temp_get_headline
161 ([split $o->{wiki}->{config}->{name}->{space}->{separator_reg},
162 $o->{link}->{dest}->{page_name}]));
163
164 FormattingRule:
165 @Category[list]: form-input
166 @Name: wpp--next-anchor-index
167 @Description:
168 @@@: Next "anchor index" number
169 @@lang: en
170 @Formatting:
171 my $page = $o->{wiki}->{var}->{page};
172 my $content = $o->{wiki}->{db}->get (content => $page);
173
174 ## Get Format Handler
175 my $format = SuikaWiki::Plugin->module_package ('WikiFormat')
176 ->handler (\$content,
177 wiki => $o->{wiki});
178
179 $p->{-parent}->append_text ($format->next_index_for_anchor
180 (\$content, wiki => $o->{wiki},
181 page => $page));
182
183 Function:
184 @Name: unixtime_to_string
185 @Description
186 @@@:
187 Convert internal date-time format to other (possibly human readable)
188 format.
189 \
190 Note: Currently, only one fixed format is supported, whilst
191 future version is expected to support highly customizable
192 formatting supported by Message::Field::Date.
193 @@lang:en
194 @Main:
195 my @date = gmtime shift;
196 sprintf '%04d-%02d-%02d %02d:%02d:%02d +00:00',
197 $date[5] + 1900,
198 $date[4] + 1,
199 @date[3,2,1,0];
200
201 Function:
202 @Name: _temp_get_headline
203 @Description:
204 @@@: Returns headline summary of SuikaWiki/0.9 document
205 @@lang:en
206 @Main:
207 my ($page, %option) = @_;
208 return undef;
209 my $SubjectLine = SuikaWiki::Plugin->cache ('headline');
210 unless (defined $SubjectLine->{$page}) {
211 $SubjectLine->{$page} = do {
212 my $s=SuikaWiki::Plugin->get_data (content => $page);
213 $s =~ tr/\x0D//d;
214 $s =~ s!^\#\?[^\x0A\x0D]+[\x0A\x0D]*!!s;
215 $s =~ s/\x0A\x0A.*//s;
216 if (length ($s) > 500) {
217 $s = substr ($s, 0, 500);
218 $s =~ s/[^\x09\x0A\x20-\x7E]+$//s;
219 $s .= '...';
220 }
221 #if ($s =~ /^([^\x0A]*(?:\x0A+[^\x0A]+){0,9})/s) {
222 # $s = $1;
223 #}
224 $s =~ s/[\x09\x0A\x20]+/\x20/gs;
225 $s =~ s/^[-=*>,:]+//;
226 $s =~ s/'''?//g;
227 $s =~ s/\[\[([^]]+)\]\]/$1/g;
228 $s =~ s/__&&([^&]+)&&__/$1/g;
229 $s =~ s/\[[A-Z]+(?:\([^)]+\))?\[([^]]+)\](?:\s\[([^]]+)\])?\]/$1$2/g;
230 $s =~ s/\([^\(\)]+\)//g;
231 $s =~ s/\[[^\[\]]+\]//g;
232 $s =~ s/>>[0-9]+//g;
233 $s =~ s/<[^<>]+>//g;
234 $s =~ s/20[0-9][0-9]-[01][0-9]-[0-3][0-9]\x20*[0-2][0-9]:[0-5][0-9]//g;
235 $s =~ s/ [Aa]n? / /g;
236 $s =~ s/ [Aa]t / @ /g;
237 $s =~ s/ [Tt]he / /g;
238 $s =~ s/,? and / & /g;
239 $s =~ s!,? or ! / !g;
240 $s =~ s! not !n't !g;
241 $s =~ s! (?:i|ha)s !'s !g;
242 $s =~ s! are !'re !g;
243 $s =~ s! [Ww]ith(in|out)? !' w/'.substr ($1,0,1).' '!ge;
244 $s =~ s![.,]\x20?$!!g;
245 $s =~ s/\x20+/\x20/g;
246 if (length ($s) > 400) {
247 $s = substr ($s, 0, 400);
248 $s =~ s/[^\x20-\x7E]+$//s;
249 $s .= '...';
250 }
251 $s};
252 }
253 $SubjectLine->{$page};
254
255 ViewFragment:
256 @Name: ws--post-content
257 @Description:
258 @@@: After content body -- last modified date and time of the WikiPage
259 @@lang:en
260 @Order: 800
261 @Formatting:
262 %block (
263 id => last-modified,
264 content => {%res(name=>{LastModified=});%last-modified;}p,
265 );
266
267 Resource:
268 @LastModified=:
269 @@@:
270 Last modified:
271 @@lang: en

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24