-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathusemodpatches.html
863 lines (835 loc) · 33.6 KB
/
usemodpatches.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>4.7. UseModWiki 补丁</title>
<link rel="stylesheet" href="/stylesheets/master.css" type="text/css">
<link rel="stylesheet" href="/stylesheets/syntax.css" type="text/css">
<link rel="stylesheet" href="/docbook/includes/css/docbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.72.0">
<link rel="start" href="index.html" title="知识管理">
<link rel="up" href="usemod.html" title="4. UseModWiki">
<link rel="prev" href="usemodadmin.html" title="4.6. UseModWiki 的管理">
<link rel="next" href="wikiclone.html" title="5. Another Wiki Clone?">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<script language="javascript" type="text/javascript" src="/docbook/includes/js/header.js"></script><script language="javascript"> write_header("/docbook"); </script><div class="navheader">
<table width="100%" summary="Navigation header">
<tr><th colspan="3" align="center">4.7. UseModWiki 补丁</th></tr>
<tr>
<td width="20%" align="left">
<a accesskey="p" href="usemodadmin.html"><img src="/docbook/includes/images/docbook/prev.png" alt="上一页"></a> </td>
<th width="60%" align="center">4. UseModWiki</th>
<td width="20%" align="right"> <a accesskey="n" href="wikiclone.html"><img src="/docbook/includes/images/docbook/next.png" alt="下一页"></a>
</td>
</tr>
</table>
<hr>
</div>
<div class="sect2" lang="zh-cn">
<div class="titlepage"><div><div><h3 class="title">
<a name="usemodpatches"></a>4.7. UseModWiki 补丁</h3></div></div></div>
<div class="toc"><dl>
<dt><span class="sect3"><a href="usemodpatches.html#idp4700304">4.7.1. UseModWiki Bug 修正</a></span></dt>
<dt><span class="sect3"><a href="usemodpatches.html#idp4735520">4.7.2. UseModWiki 功能扩展</a></span></dt>
</dl></div>
<p>
在开始撰写本文档时,UseModWiki 的发布版本是 0.92 版,下面的内容有些是针对 0.92 版的,1.0 版本已经修正,因此请对号入座。
</p>
<div class="sect3" lang="zh-cn">
<div class="titlepage"><div><div><h4 class="title">
<a name="idp4700304"></a>4.7.1. UseModWiki Bug 修正</h4></div></div></div>
<p>
BUG 修正:
</p>
<div class="itemizedlist"><ul type="disc">
<li>
<p><a name="AnchorsInFreeLinkBugFix"></a>
修正在 FreeLinks 中使用内部链接的显示错误
</p>
<p>
适用于 1.0 版本。参见:<a href="http://www.usemod.com/cgi-bin/wiki.pl?WikiPatches/AnchorsInFreeLinkBugFix" target="_top">http://www.usemod.com/cgi-bin/wiki.pl?WikiPatches/AnchorsInFreeLinkBugFix</a>。
</p>
<p>
如果在 FreeLinks 中使用了 Anchor,即页面内部链接,显示不正常。例如:如下代码
</p>
<pre class="screen">
* [[WikiPatches/AnchorsInFreeLinkBugFix#bottom|Goto bottom]]
* [[WikiPatches/AnchorsInFreeLinkBugFix#bottom]]
</pre>
<p>
在 1.0 版本的Wiki中显示为
</p>
<pre class="screen">
* [[<a href="http://www.usemod.com/cgi-bin/wiki.pl?WikiPatches/AnchorsInFreeLinkBugFix#bottom" target="_top">WikiPatches/AnchorsInFreeLinkBugFix#bottom</a>|Goto bottom]]
* [[<a href="http://www.usemod.com/cgi-bin/wiki.pl?WikiPatches/AnchorsInFreeLinkBugFix#bottom" target="_top">WikiPatches/AnchorsInFreeLinkBugFix#bottom</a>]]
</pre>
<p>
如果应用了如下修正,则能正常显示:
</p>
<pre class="screen">
<a href="http://www.usemod.com/cgi-bin/wiki.pl?WikiPatches/AnchorsInFreeLinkBugFix#bottom" target="_top">Goto bottom</a>
<a href="http://www.usemod.com/cgi-bin/wiki.pl?WikiPatches/AnchorsInFreeLinkBugFix#bottom" target="_top">WikiPatches/AnchorsInFreeLinkBugFix#bottom</a>
</pre>
<p>
修正如下:
</p>
<pre class="screen">
--- wiki.pl 2003-09-11 20:21:02.000000000 +0800
+++ wiki.pl.freelink 2003-11-16 22:36:36.468750000 +0800
@@ -301,9 +301,17 @@
$AnyLetter = "[-,.()' _0-9A-Za-z]";
}
}
- $FreeLinkPattern = "($AnyLetter+)";
+ $FreeLinkPattern = "($AnyLetter+";
if ($UseSubpage) {
- $FreeLinkPattern = "((?:(?:$AnyLetter+)?\\/)?$AnyLetter+)";
+ $FreeLinkPattern = "((?:(?:$AnyLetter+)?\\/)?$AnyLetter+";
+ }
+ if ($NamedAnchors)
+ {
+ $FreeLinkPattern .= "(?:#(?:\\w+))?)";
+ }
+ else
+ {
+ $FreeLinkPattern .= ")";
}
$FreeLinkPattern .= $QDelim;
# Url-style links are delimited by one of:
@@ -1157,6 +1165,7 @@
sub GetPageOrEditAnchoredLink {
my ($id, $anchor, $name) = @_;
my (@temp, $exists);
+ my $NamedFreeLink = 0;
if ($name eq "") {
$name = $id;
@@ -1164,6 +1173,10 @@
$name =~ s/_/ /g;
}
}
+ else
+ {
+ $NamedFreeLink = 1;
+ }
$id =~ s|^/|$MainPage/|;
if ($FreeLinks) {
$id = &FreeToNormal($id);
@@ -1179,7 +1192,7 @@
}
if ($exists) {
$id = "$id#$anchor" if $anchor;
- $name = "$name#$anchor" if $anchor && $NamedAnchors != 2;
+ $name = "$name#$anchor" if $anchor && $NamedAnchors != 2 && !$NamedFreeLink;
return &GetPageLinkText($id, $name);
}
if ($FreeLinks && !$EditNameLink) {
@@ -1196,7 +1209,8 @@
sub GetPageOrEditLink {
my ($id, $name) = @_;
- return &GetPageOrEditAnchoredLink($id, "", $name);
+ my ($link, $anchor) = split( /#/, $id, 2);
+ return &GetPageOrEditAnchoredLink($link, $anchor, $name);
}
sub GetBackLinksSearchLink {
</pre>
</li>
<li>
<p><a name="UseNamedAnchorInTOC"></a>
使用编号作为目录索引的链接名称
</p>
<p>
适用于 1.0 版本。参见:<a href="http://www.usemod.com/cgi-bin/wiki.pl?WikiPatches/UseNamedAnchorInTOC" target="_top">http://www.usemod.com/cgi-bin/wiki.pl?WikiPatches/UseNamedAnchorInTOC</a>。
</p>
<p>
上面介绍过,可以使用如下方式为文章建立索引和带编号的标题。
</p>
<pre class="screen">
<toc>
== # heading1 ==
...
=== # heading2 ===
...
==== # heading3 ====
...
</pre>
<p>
建立好的目录索引可以跳转到相应的文内链接。建立文内链接的方法是提取相应标题中英文字母进行组合。这就产生了一个问题,如果是相同内容的标题,则会造成重复的文内链接,对于中英文混合的标题,这个内容更加严重。通过应用下面的这个补丁,强制使用数字编号作为目录索引指向的文内链接的名称。
</p>
<pre class="screen">
--- wiki.pl 2003-09-11 20:21:02.000000000 +0800
+++ wiki.pl.numanchor 2003-11-16 22:37:38.515625000 +0800
@@ -53,7 +53,7 @@
@IsbnNames @IsbnPre @IsbnPost $EmailFile $FavIcon $RssDays $UserHeader
$UserBody $StartUID $ParseParas $AuthorFooter $UseUpload $AllUpload
$UploadDir $UploadUrl $LimitFileUrl $MaintTrimRc $SearchButton
- $EditNameLink $UseMetaWiki @ImageSites $BracketImg );
+ $EditNameLink $UseMetaWiki @ImageSites $UseNumberedAnchor);
# Note: $NotifyDefault is kept because it was a config variable in 0.90
# Other global variables:
use vars qw(%Page %Section %Text %InterSite %SaveUrl %SaveNumUrl
@@ -175,6 +175,8 @@
$EditNameLink = 0; # 1 = edit links use name (CSS), 0 = '?' links
$UseMetaWiki = 0; # 1 = add MetaWiki search links, 0 = no MW links
$BracketImg = 1; # 1 = [url url.gif] becomes image link, 0 = no img
+$UseNumberedAnchor = 1; # 1 = use numbered anchor in NumberedHeadings,
+ # 0 = cook anchor by canonicalizing text
# Names of sites. (The first entry is used for the number link.)
@IsbnNames = ('bn.com', 'amazon.com', 'search');
@@ -2116,12 +2118,15 @@
$text =~ s/\<a\s[^\>]*?\>\?\<\/a\>//si; # No such page syntax
$text =~ s/\<a\s[^\>]*?\>(.*?)\<\/a\>/$1/si;
# Cook anchor by canonicalizing $text.
- $anchor = $text;
- $anchor =~ s/\<.*?\>//g;
- $anchor =~ s/\W/_/g;
- $anchor =~ s/__+/_/g;
- $anchor =~ s/^_//;
- $anchor =~ s/_$//;
+ if (!$UseNumberedAnchor)
+ {
+ $anchor = $text;
+ $anchor =~ s/\<.*?\>//g;
+ $anchor =~ s/\W/_/g;
+ $anchor =~ s/__+/_/g;
+ $anchor =~ s/^_//;
+ $anchor =~ s/_$//;
+ }
# Last ditch effort
$anchor = '_' . (join '_', @HeadingNumbers) unless $anchor;
$TableOfContents .= $number . &ScriptLink("$OpenPageName#$anchor",$text)
</pre>
</li>
<li>
<p>
禁止页面缓存
</p>
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note">
<tr>
<td rowspan="2" align="center" valign="top" width="25"><img alt="[注意]" src="/docbook/includes/images/docbook/note.png"></td>
<th align="left"></th>
</tr>
<tr><td align="left" valign="top"><p>
适用于 0.92 版,1.0 可以参照进行类似修改。
</p></td></tr>
</table></div>
<p>
页面缓存会引起网页浏览者不能及时看到更新的网页。在 <a href="http://www.usemod.com/cgi-bin/wiki.pl?WikiPatches/PageCacheBugFix" target="_top">http://www.usemod.com/cgi-bin/wiki.pl?WikiPatches/PageCacheBugFix</a> 上面有一个补丁。
</p>
<pre class="screen">
--- usemod092/wiki.pl Sun Apr 22 00:44:10 2001
+++ wiki.cgi Sun Apr 29 00:01:57 2001
@@ -973,6 +973,8 @@
sub GetHttpHeader {
my $cookie;
+ my $now;
+ $now = gmtime;
if (defined($SetCookie{'id'})) {
$cookie = "$CookieName="
. "rev&" . $SetCookie{'rev'}
@@ -981,12 +983,20 @@
$cookie .= ";expires=Fri, 08-Sep-2010 19:48:23 GMT";
if ($HttpCharset ne '') {
return $q->header(-cookie=>$cookie,
+ -pragma=>"no-cache",
+ -cache_control=>"no-cache",
+ -last_modified=>"$now",
+ -expires=>"+10s",
-type=>"text/html; charset=$HttpCharset");
}
return $q->header(-cookie=>$cookie);
}
if ($HttpCharset ne '') {
- return $q->header(-type=>"text/html; charset=$HttpCharset");
+ return $q->header(-type=>"text/html; charset=$HttpCharset",
+ -pragma=>"no-cache",
+ -cache_control=>"no-cache",
+ -last_modified=>"$now",
+ -expires=>"+10s");
}
return $q->header();
}
</pre>
</li>
<li>
<p>
解决 $ThinLine 和 $UseHeadings 引起的冲突
</p>
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note">
<tr>
<td rowspan="2" align="center" valign="top" width="25"><img alt="[注意]" src="/docbook/includes/images/docbook/note.png"></td>
<th align="left"></th>
</tr>
<tr><td align="left" valign="top"><p>
适用于 0.92 版,1.0 可以参照进行类似修改。
</p></td></tr>
</table></div>
<p>
如下的解决方案来自:<a href="http://www.usemod.com/cgi-bin/wiki.pl?WikiPatches/ThinLineHeadingsConflict" target="_top">http://www.usemod.com/cgi-bin/wiki.pl?WikiPatches/ThinLineHeadingsConflict</a>。更严格的匹配 ==== ,避免了误将第四级的标题处理成为两条水平线。
</p>
<pre class="screen">
--- usemod092/wiki.pl
+++ wiki.cgi
@@ -1223,7 +1233,7 @@
s/$ISBNPattern/&StoreISBN($1)/geo;
if ($ThinLine) {
s/----+/<hr noshade size=1>/g;
- s/====+/<hr noshade size=2>/g;
+ s/^\s*====+\s*$/<hr noshade size=2>/gmx;
} else {
s/----+/<hr>/g;
}
</pre>
<p>
有另外一种解决方案,即用减号"-"的多少来决定分隔线的粗细,而不是用易于混淆的等号。
</p>
<pre class="screen">
--- usemod092/wiki.pl
+++ wiki.cgi
@@ -1222,8 +1222,11 @@
s/$RFCPattern/&StoreRFC($1)/geo;
s/$ISBNPattern/&StoreISBN($1)/geo;
if ($ThinLine) {
- s/----+/<hr noshade size=1>/g;
- s/====+/<hr noshade size=2>/g;
+ s/--------+/<hr noshade style="height:5px">/g;
+ s/-------+/<hr noshade style="height:4px">/g;
+ s/------+/<hr noshade style="height:3px">/g;
+ s/-----+/<hr noshade style="height:2px">/g;
+ s/----+/<hr noshade style="height:1px">/g;
} else {
s/----+/<hr>/g;
}
</pre>
</li>
<li>
<p>
引用相对 URL 的补丁
</p>
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note">
<tr>
<td rowspan="2" align="center" valign="top" width="25"><img alt="[注意]" src="/docbook/includes/images/docbook/note.png"></td>
<th align="left"></th>
</tr>
<tr><td align="left" valign="top"><p>
适用于 0.92 版,1.0 已支持。
</p></td></tr>
</table></div>
<p>
UseModWiki 0.92 版本处理文本中的 URL 有一个缺陷。即没法使用相对或者决定路径来引用本网站的内容,如果需要引用本网站的内容,也必须把 URL 写成如:http://foobar.worldhello.net/images/usemod.gif。这是多么的不方便,而且如果网站名称修改,那么文中的链接就都出错了。UseMod 网站上有一个补丁可以解决这个问题,即允许通过写 URL片断(非正规URL格式)达到引用本网站链接的目的:<a href="http://www.usemod.com/cgi-bin/wiki.pl?WikiPatches/PartialUrlFix" target="_top">http://www.usemod.com/cgi-bin/wiki.pl?WikiPatches/PartialUrlFix</a>。
</p>
<p>
修改如下:
</p>
<pre class="screen">
*** usemod092/wiki.pl Sat Apr 21 17:44:10 2001
--- wiki.pl Fri Jan 18 11:36:25 2002
***************
*** 1417,1422 ****
--- 1417,1423 ----
}
# Restricted image URLs so that mailto:[email protected] is not an image
if ($useImage && ($name =~ /^(http:|https:|ftp:).+\.$ImageExtensions$/)) {
+ $name = $1 if ($name =~ /^https?:(.*)/ && $1 !~ /^\/\//); <a name="co.usemod.patch.parturl1"></a><img src="/docbook/includes/images/callouts/1.png" alt="1" border="0">
return ("<img src=\"$name\">", $punct);
}
return ("<a href=\"$name\">$name</a>", $punct);
***************
*** 1425,1430 ****
--- 1426,1432 ----
sub StoreBracketUrl {
my ($url, $text) = @_;
+ $url = $1 if ($url =~ /^https?:(.*)/ && $1 !~ /^\/\//); <a name="co.usemod.patch.parturl2"></a><img src="/docbook/includes/images/callouts/2.png" alt="2" border="0">
if ($text eq "") {
$text = &GetBracketUrlIndex($url);
}
</pre>
<div class="calloutlist"><table border="0" summary="Callout list">
<tr>
<td width="5%" valign="top" align="left">
<a href="#co.usemod.patch.parturl1"><img src="/docbook/includes/images/callouts/1.png" alt="1" border="0"></a> </td>
<td valign="top" align="left"><p>
对于形如 http:/images/usemod.gif 的非正规 URL,如果不加修正,返回 <img src="http:/images/usemod.gif">,这是不正确的。对于此情况,将 $name 修改为: "/images/usemod.gif",返回的链接为 <img src="/images/usemod.gif"> 是正确的。
</p></td>
</tr>
<tr>
<td width="5%" valign="top" align="left">
<a href="#co.usemod.patch.parturl2"><img src="/docbook/includes/images/callouts/2.png" alt="2" border="0"></a> </td>
<td valign="top" align="left"><p>
同上
</p></td>
</tr>
</table></div>
</li>
</ul></div>
</div>
<div class="sect3" lang="zh-cn">
<div class="titlepage"><div><div><h4 class="title">
<a name="idp4735520"></a>4.7.2. UseModWiki 功能扩展</h4></div></div></div>
<p>
功能扩展
</p>
<div class="itemizedlist"><ul type="disc">
<li>
<p><a name="usemod-table"></a>
添加支持表格语法的功能
</p>
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note">
<tr>
<td rowspan="2" align="center" valign="top" width="25"><img alt="[注意]" src="/docbook/includes/images/docbook/note.png"></td>
<th align="left"></th>
</tr>
<tr><td align="left" valign="top"><p>
适用于 0.92 版,1.0 已支持。
</p></td></tr>
</table></div>
<p>
当一行以双竖线"||"开始,表示开始绘制表格的语法,例如:
</p>
<pre class="screen">
||align=center border=1 width=50%
||居左 || 居中 || 居右||
|| 测试 || 测试||测试 ||
|||| 跨越多栏 || 测试||
</pre>
<p>
将显示如下:
</p>
<div class="mediaobject">
<img src="images/wiki-9-usemod-table.gif" alt="Wiki 绘制表格"><div class="caption"><p>
Wiki 绘制表格
</p></div>
</div>
<p>
其补丁可以在 <a href="http://www.usemod.com/cgi-bin/wiki.pl?WikiPatches/TableSyntax" target="_top">http://www.usemod.com/cgi-bin/wiki.pl?WikiPatches/TableSyntax</a> 上找到。这个页面上可以看到许多开发者对这个功能的补充,充分展示了 Wiki 的协作精神。
</p>
<pre class="screen">
--- wiki_92.pl
+++ wiki.pl
@@ -45,7 +45,7 @@
$UrlProtocols $UrlPattern $ImageExtensions $RFCPattern $ISBNPattern
$FS $FS1 $FS2 $FS3 $CookieName $SiteBase $StyleSheet $NotFoundPg
$FooterNote $EditNote $MaxPost $NewText $NotifyDefault $HttpCharset
- $UserGotoBar);
+ $UserGotoBar $TableMode $TableSyntax); <a name="co.usemod.patch.tab.var"></a><img src="/docbook/includes/images/callouts/1.png" alt="1" border="0">
# Note: $NotifyDefault is kept because it was a config variable in 0.90
# Other global variables:
use vars qw(%Page %Section %Text %InterSite %SaveUrl %SaveNumUrl
@@ -98,6 +98,7 @@
$RunCGI = 1; # 1 = Run script as CGI, 0 = Load but do not run
$EmailNotify = 0; # 1 = use email notices, 0 = no email on changes
$EmbedWiki = 0; # 1 = no headers/footers, 0 = normal wiki pages
+$TableSyntax = 1; # 1 = wiki syntax tables, 0 = no magic table syntax <a name="co.usemod.patch.tab.init"></a><img src="/docbook/includes/images/callouts/2.png" alt="2" border="0">
# Minor options:
$LogoLeft = 0; # 1 = logo on left, 0 = logo on right
@@ -1152,6 +1153,7 @@
# ==== Common wiki markup ====
sub WikiToHTML {
my ($pageText) = @_;
+ $TableMode = 0; #PATCH
%SaveUrl = ();
%SaveNumUrl = ();
@@ -1236,18 +1238,29 @@
if ($UseHeadings) {
s/(^|\n)\s*(\=+)\s+([^\n]+)\s+\=+/&WikiHeading($1, $2, $3)/geo;
}
+ if ($TableMode) {
+ while (/(\|\|)+([^\|<]+)/) {
+ my $align = $2;
+ $align = $align =~/^ / ? ($align =~/ $/ ? 'CENTER' : 'RIGHT') : ($align =~/ $/ ? 'LEFT' : 'CENTER'); <a name="co.usemod.patch.tab.align"></a><img src="/docbook/includes/images/callouts/3.png" alt="3" border="0">
+ s/((\|\|)+)/"<\/TD><TD ALIGN='$align' COLSPAN=\"" . (length($1)\/2) . "\">"/e;
+ }
+ }
}
return $_;
}
sub WikiLinesToHtml {
my ($pageText) = @_;
- my ($pageHtml, @htmlStack, $code, $depth, $oldCode);
+ my ($pageHtml, @htmlStack, $code, $codeAttributes, $depth, $oldCode); #PATCH
+
@htmlStack = ();
$depth = 0;
$pageHtml = "";
- foreach (split(/\n/, $pageText)) { # Process lines one-at-a-time
+ $codeAttributes = ''; <a name="co.usemod.patch.tab.codeattr"></a><img src="/docbook/includes/images/callouts/4.png" alt="4" border="0">
+ foreach (split(/\r?\n/, $pageText)) { # Process lines one-at-a-time
+ $code = ''; #PATCH
+ $TableMode = 0;
$_ .= "\n";
if (s/^(\;+)([^:]+\:?)\:/<dt>$2<dd>/) {
$code = "DL";
@@ -1261,12 +1274,25 @@
} elsif (s/^(\#+)/<li>/) {
$code = "OL";
$depth = length $1;
+ } elsif ($TableSyntax && s/^\|\|\s*(.*[^\|])\n\z//) { <a name="co.usemod.patch.tab.matchtblattr"></a><img src="/docbook/includes/images/callouts/5.png" alt="5" border="0">
+ $TableMode = 1;
+ $codeAttributes = $1;
+ } elsif ($TableSyntax && /^(\|\|)+.*\|\|\s*$/) { <a name="co.usemod.patch.tab.matchrow"></a><img src="/docbook/includes/images/callouts/6.png" alt="6" border="0">
+ /^(\|\|)+([^\|]+)/;
+ my $align = $2;
+ $align = $align =~/^ / ? ($align =~/ $/ ? 'CENTER' : 'RIGHT') : ($align =~/ $/ ? 'LEFT' : 'CENTER');
+ s/^((\|\|)+)(.*)\|\|\s*$/"<TR VALIGN='CENTER'><TD ALIGN='$align' COLSPAN='" . (length($1)\/2) . "'>$3<\/TD><\/TR>\n"/e;
+ $code = "TABLE";
+ $codeAttributes ||= "BORDER=\"1\"";
+ $TableMode = 1;
+ $depth = 1;
} elsif (/^[ \t].*\S/) {
$code = "PRE";
$depth = 1;
} else {
$depth = 0;
}
+ $codeAttributes = '' unless $TableMode;
while (@htmlStack > $depth) { # Close tags as needed
$pageHtml .= "</" . pop(@htmlStack) . ">\n";
}
@@ -1281,7 +1307,7 @@
}
while (@htmlStack < $depth) {
push(@htmlStack, $code);
- $pageHtml .= "<$code>\n";
+ $pageHtml .= "<$code $codeAttributes>\n"; #PATCH
}
}
s/^\s*$/<p>\n/; # Blank lines become <p> tags
</pre>
<div class="calloutlist"><table border="0" summary="Callout list">
<tr>
<td width="5%" valign="top" align="left">
<a href="#co.usemod.patch.tab.var"><img src="/docbook/includes/images/callouts/1.png" alt="1" border="0"></a> </td>
<td valign="top" align="left"><p>
添加全局变量:$TableMode, $TableSyntax
</p></td>
</tr>
<tr>
<td width="5%" valign="top" align="left">
<a href="#co.usemod.patch.tab.init"><img src="/docbook/includes/images/callouts/2.png" alt="2" border="0"></a> </td>
<td valign="top" align="left"><p>
打开表格语法功能的开关
</p></td>
</tr>
<tr>
<td width="5%" valign="top" align="left">
<a href="#co.usemod.patch.tab.align"><img src="/docbook/includes/images/callouts/3.png" alt="3" border="0"></a> </td>
<td valign="top" align="left"><p>
根据包含在两个双竖线"||"中文字的左右是否包含空格,确定一个表格单元格中文字的对齐方式。对于 "||居左 ||" 设置为居左,"|| 居中 ||" 设置为居中,"|| 居右||" 设置为居右。
</p></td>
</tr>
<tr>
<td width="5%" valign="top" align="left">
<a href="#co.usemod.patch.tab.codeattr"><img src="/docbook/includes/images/callouts/4.png" alt="4" border="0"></a> </td>
<td valign="top" align="left"><p>
$codeAttributes 将保存整个表格的格式信息
</p></td>
</tr>
<tr>
<td width="5%" valign="top" align="left">
<a href="#co.usemod.patch.tab.matchtblattr"><img src="/docbook/includes/images/callouts/5.png" alt="5" border="0"></a> </td>
<td valign="top" align="left"><p>
匹配表格属性行,设置表格格式信息 $codeAttributes。例如匹配:“||align=center border=1 width=50%”。
</p></td>
</tr>
<tr>
<td width="5%" valign="top" align="left">
<a href="#co.usemod.patch.tab.matchrow"><img src="/docbook/includes/images/callouts/6.png" alt="6" border="0"></a> </td>
<td valign="top" align="left"><p>
匹配表格内容描述行,将内容转换为对应的 HTML 表格。例如匹配:“||居左 || 居中 || 居右||”。
</p></td>
</tr>
</table></div>
</li>
<li>
<p>
TaviStyleHistory
</p>
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note">
<tr>
<td rowspan="2" align="center" valign="top" width="25"><img alt="[注意]" src="/docbook/includes/images/docbook/note.png"></td>
<th align="left"></th>
</tr>
<tr><td align="left" valign="top"><p>
适用于 0.92 版,1.0 已支持。
</p></td></tr>
</table></div>
<p>
Taiv 是以 PHP 实现的另一种著名的 WikiClone,其版本比较的界面功能比较强,可以选择某两个版本进行比较,它的功能已经被移植到 UseModWiki。参见:
</p>
<p>
<a href="http://www.usemod.com/cgi-bin/wiki.pl?WikiPatches/TaviStyleHistory" target="_top">http://www.usemod.com/cgi-bin/wiki.pl?WikiPatches/TaviStyleHistory</a>
</p>
</li>
<li>
<p>
为管理员添加工具箱
</p>
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note">
<tr>
<td rowspan="2" align="center" valign="top" width="25"><img alt="[注意]" src="/docbook/includes/images/docbook/note.png"></td>
<th align="left"></th>
</tr>
<tr><td align="left" valign="top"><p>
适用于 0.92 版,1.0 已支持。
</p></td></tr>
</table></div>
<p>
当用户以管理员身份登录后,在页面的最低端,显示出管理功能的链接。代码参见:<a href="http://www.usemod.com/cgi-bin/wiki.pl?WikiPatches/GetAdminBar" target="_top">http://www.usemod.com/cgi-bin/wiki.pl?WikiPatches/GetAdminBar</a>。
</p>
</li>
<li>
<p>
删除页面功能
</p>
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note">
<tr>
<td rowspan="2" align="center" valign="top" width="25"><img alt="[注意]" src="/docbook/includes/images/docbook/note.png"></td>
<th align="left"></th>
</tr>
<tr><td align="left" valign="top"><p>
适用于 0.92 版,1.0 已支持。
</p></td></tr>
</table></div>
<p>
UseModWiki 的管理员可以通过 action=editlinks 删除页面,而普通用户则不能。下面的这个功能扩展,允许用户将页面的第一行插入 "DeletedPage",将页面标记为待删除,在下次系统维护时,将标记为删除且过期的页面删除。参见: <a href="http://www.usemod.com/cgi-bin/wiki.pl?WikiPatches/PageDeletion" target="_top">http://www.usemod.com/cgi-bin/wiki.pl?WikiPatches/PageDeletion</a>
</p>
<pre class="screen">
*** usemod092/wiki.pl Sat Apr 21 17:44:10 2001
--- wiki.pl
@@ -45,7 +45,7 @@
$UrlProtocols $UrlPattern $ImageExtensions $RFCPattern $ISBNPattern
$FS $FS1 $FS2 $FS3 $CookieName $SiteBase $StyleSheet $NotFoundPg
$FooterNote $EditNote $MaxPost $NewText $NotifyDefault $HttpCharset
- $UserGotoBar);
+ $UserGotoBar $DeletedPage);
# Note: $NotifyDefault is kept because it was a config variable in 0.90
# Other global variables:
use vars qw(%Page %Section %Text %InterSite %SaveUrl %SaveNumUrl
@@ -98,6 +98,7 @@
$RunCGI = 1; # 1 = Run script as CGI, 0 = Load but do not run
$EmailNotify = 0; # 1 = use email notices, 0 = no email on changes
$EmbedWiki = 0; # 1 = no headers/footers, 0 = normal wiki pages
+$DeletedPage = "DeletedPage"; # 0 = disable page deletion; "string" for page deletion marker text
# Minor options:
$LogoLeft = 0; # 1 = logo on left, 0 = logo on right
@@ -3497,6 +3558,28 @@
close(OUT);
}
+# Actions are vetoable if someone edits the page before
+# the keep expiry time. For example, page deletion. If
+# no one edits the page by the time the keep expiry time
+# elapses, then no one has vetoed the last action, and the
+# action is accepted.
+# See http://www.usemod.com/cgi-bin/mb.pl?PageDeletion
+#
+# returns ' (deleted)' if the page has been deleted, 0 otherwise.
+sub ProcessVetos {
+ my ($expirets);
+ $expirets = $Now - ($KeepDays * 24 * 60 * 60);
+ return 0 unless $Page{'ts'} < $expirets; <a name="co.usemod.patch.delpage.expir"></a><img src="/docbook/includes/images/callouts/1.png" alt="1" border="0">
+
+ if( $DeletedPage && $Text{'text'} =~ /^\s*$DeletedPage\W*?(\n|$)/o ) <a name="co.usemod.patch.delpage.match"></a><img src="/docbook/includes/images/callouts/2.png" alt="2" border="0">
+ {
+ &DeletePage($OpenPageName, 1, 1);
+ return ' (deleted)'; <a name="co.usemod.patch.delpage.returntxt"></a><img src="/docbook/includes/images/callouts/3.png" alt="3" border="0">
+ }
+
+ return 0;
+}
+
sub DoMaintain {
my ($name, $fname, $data);
print &GetHeader('', T('Maintenance on all pages'), '');
@@ -3515,9 +3598,11 @@
foreach $name (&AllPagesList()) {
&OpenPage($name);
&OpenDefaultText();
- &ExpireKeepFile();
+ my $message = &ProcessVetos();
+ &ExpireKeepFile() unless $message eq ' (deleted)';
print ".... " if ($name =~ m|/|);
- print &GetPageLink($name), "<br>\n";
+ print &GetPageLink($name);
+ print "$message<br>\n";
}
&WriteStringToFile($fname, "Maintenance done at " . &TimeToText($Now));
&ReleaseLock();
]]>
</pre>
<div class="calloutlist"><table border="0" summary="Callout list">
<tr>
<td width="5%" valign="top" align="left">
<a href="#co.usemod.patch.delpage.expir"><img src="/docbook/includes/images/callouts/1.png" alt="1" border="0"></a> </td>
<td valign="top" align="left"><p>
如果文件没有过期,不进行下面的判断。
</p></td>
</tr>
<tr>
<td width="5%" valign="top" align="left">
<a href="#co.usemod.patch.delpage.match"><img src="/docbook/includes/images/callouts/2.png" alt="2" border="0"></a> </td>
<td valign="top" align="left"><p>
仅在文件的第一行进行匹配,$DeletedPage 前面可以有空格,后面可以有任意非单词字符([^_0-9a-zA-Z]),符合这样的规则的文件标记为删除。
</p></td>
</tr>
<tr>
<td width="5%" valign="top" align="left">
<a href="#co.usemod.patch.delpage.returntxt"><img src="/docbook/includes/images/callouts/3.png" alt="3" border="0"></a> </td>
<td valign="top" align="left"><p>
返回的文字,将显示在维护页面上。
</p></td>
</tr>
</table></div>
</li>
<li>
<p>
BetterEditPage
</p>
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note">
<tr>
<td rowspan="2" align="center" valign="top" width="25"><img alt="[注意]" src="/docbook/includes/images/docbook/note.png"></td>
<th align="left"></th>
</tr>
<tr><td align="left" valign="top"><p>
适用于 0.92 版,1.0 可以参照进行类似修改。
</p></td></tr>
</table></div>
<p>
在编辑页面加入语法提示,对 Wiki 新手非常有帮助。参见:
</p>
<p>
<a href="http://www.usemod.com/cgi-bin/wiki.pl?WikiPatches/BetterEditPage" target="_top">http://www.usemod.com/cgi-bin/wiki.pl?WikiPatches/BetterEditPage</a>
</p>
</li>
<li>
<p>
定制导航条
</p>
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note">
<tr>
<td rowspan="2" align="center" valign="top" width="25"><img alt="[注意]" src="/docbook/includes/images/docbook/note.png"></td>
<th align="left"></th>
</tr>
<tr><td align="left" valign="top"><p>
适用于 0.92 版,1.0 可以参照进行类似修改。
</p></td></tr>
</table></div>
<p>
在导航条添加新的选项,如 Login(登录), Index(页面索引),亦即调用 "action=login" 和 "action=index"。参见:
</p>
<p>
<a href="http://www.usemod.com/cgi-bin/wiki.pl?WikiPatches/Login" target="_top">http://www.usemod.com/cgi-bin/wiki.pl?WikiPatches/Login</a>
</p>
<p>
<a href="http://www.usemod.com/cgi-bin/wiki.pl?WikiPatches/Index" target="_top">http://www.usemod.com/cgi-bin/wiki.pl?WikiPatches/Index</a>
</p>
</li>
<li>
<p>
SaveButtonAtBottomOfPreview
</p>
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note">
<tr>
<td rowspan="2" align="center" valign="top" width="25"><img alt="[注意]" src="/docbook/includes/images/docbook/note.png"></td>
<th align="left"></th>
</tr>
<tr><td align="left" valign="top"><p>
适用于 0.92 版,1.0 可以参照进行类似修改。
</p></td></tr>
</table></div>
<p>
在预览之后加上保存的按钮,不用再将窗口滚动到上面来保存内容。参见:
</p>
<p>
<a href="http://www.usemod.com/cgi-bin/wiki.pl?WikiPatches/SaveButtonAtBottomOfPreview" target="_top">http://www.usemod.com/cgi-bin/wiki.pl?WikiPatches/SaveButtonAtBottomOfPreview</a>
</p>
</li>
<li>
<p>
添加样式表支持
</p>
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note">
<tr>
<td rowspan="2" align="center" valign="top" width="25"><img alt="[注意]" src="/docbook/includes/images/docbook/note.png"></td>
<th align="left"></th>
</tr>
<tr><td align="left" valign="top"><p>
适用于 0.92 版,1.0 已支持。
</p></td></tr>
</table></div>
<p>
参照如下网址,修改 wiki.pl,使生成的页面支持样式表。
</p>
<p>
<a href="http://www.usemod.com/cgi-bin/wiki.pl?WikiWithCascadingStyleSheet/CSSClasses" target="_top">http://www.usemod.com/cgi-bin/wiki.pl?WikiWithCascadingStyleSheet/CSSClasses</a>
</p>
<p>
写一个相应的样式表。UseModWiki 网站上有示例:<a href="http://www.usemod.com/cgi-bin/wiki.pl?WikiWithCascadingStyleSheet/WikiStyleSheet" target="_top">http://www.usemod.com/cgi-bin/wiki.pl?WikiWithCascadingStyleSheet/WikiStyleSheet</a>。
</p>
<p>
设置 config 配置文件中的 $StyleSheet,使之指向我们定制好的样式表文件,示例如下:
</p>
<pre class="screen">
$StyleSheet = "/inc/css/usemodwiki.css";
</pre>
</li>
<li>
<p>
设置网页编辑确省发送邮件
</p>
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note">
<tr>
<td rowspan="2" align="center" valign="top" width="25"><img alt="[注意]" src="/docbook/includes/images/docbook/note.png"></td>
<th align="left"></th>
</tr>
<tr><td align="left" valign="top"><p>
适用于 1.0 版本。
</p></td></tr>
</table></div>
<p>
网页编译中的发送邮件选项确省关闭,如果想要修改该确省值,参照如下方式修改:
</p>
<pre class="screen">
if ($EmailNotify) {
print "&nbsp;&nbsp;&nbsp;" .
- $q->checkbox(-name=> 'do_email_notify',
+ $q->checkbox(-name=> 'do_email_notify', -checked=>1,
-label=>Ts('Send email notification that %s has been changed.', $id));
}
</pre>
</li>
</ul></div>
<p>
更多的 UseModWiki 功能扩充参见:<a href="http://www.usemod.com/cgi-bin/wiki.pl?WikiSuggestions" target="_top">http://www.usemod.com/cgi-bin/wiki.pl?WikiSuggestions</a>。
</p>
</div>
</div>
<table class="copyright" border="0" cellpadding="0" cellspacing="0" width="100%">
<col width="33%">
<col width="33%">
<col width="33%">
<tr>
<td></td>
<td align="center" valign="center"></td>
<td align="right" valign="center"><p class="copyright">
Copyright © 2006 <a href="http://www.worldhello.net/doc/"><b>WorldHello 开放文档之源</b> 计划</a></p></td>
</tr>
</table>
<div class="navfooter">
<hr>
<table width="100%" summary="Navigation footer">
<tr>
<td width="40%" align="left">
<a accesskey="p" href="usemodadmin.html"><img src="/docbook/includes/images/docbook/prev.png" alt="上一页"></a> </td>
<td width="20%" align="center"><a accesskey="u" href="usemod.html"><img src="/docbook/includes/images/docbook/up.png" alt="上一级"></a></td>
<td width="40%" align="right"> <a accesskey="n" href="wikiclone.html"><img src="/docbook/includes/images/docbook/next.png" alt="下一页"></a>
</td>
</tr>
<tr>
<td width="40%" align="left" valign="top">4.6. UseModWiki 的管理 </td>
<td width="20%" align="center"><a accesskey="h" href="index.html"><img src="/docbook/includes/images/docbook/home.png" alt="首页"></a></td>
<td width="40%" align="right" valign="top"> 5. Another Wiki Clone?</td>
</tr>
</table>
</div>
<script language="javascript" type="text/javascript" src="/docbook/includes/js/footer.js"></script><script language="javascript"> write_footer("/docbook"); </script>
</body>
</html>