Fossil SCM

Add a screen to prompt the user for the name of a new wiki page.

drh 2009-09-15 12:04 trunk
Commit aa573547364950615afd709d834882c5ee558adc
1 file changed +54 -9
+54 -9
--- src/wiki.c
+++ src/wiki.c
@@ -48,10 +48,23 @@
4848
}
4949
if( z[i-1]==' ' ) return 0;
5050
if( i<3 || i>100 ) return 0;
5151
return 1;
5252
}
53
+
54
+/*
55
+** Output rules for well-formed wiki pages
56
+*/
57
+static void well_formed_wiki_name_rules(void){
58
+ @ <ul>
59
+ @ <li> Must not begin or end with a space.
60
+ @ <li> Must not contain any control characters, including tab or
61
+ @ newline.
62
+ @ <li> Must not have two or more spaces in a row internally.
63
+ @ <li> Must be between 3 and 100 characters in length.
64
+ @ </ul>
65
+}
5366
5467
/*
5568
** Check a wiki name. If it is not well-formed, then issue an error
5669
** and return true. If it is well-formed, return false.
5770
*/
@@ -58,17 +71,11 @@
5871
static int check_name(const char *z){
5972
if( !wiki_name_is_wellformed(z) ){
6073
style_header("Wiki Page Name Error");
6174
@ The wiki name "<b>%h(z)</b>" is not well-formed. Rules for
6275
@ wiki page names:
63
- @ <ul>
64
- @ <li> Must not begin or end with a space.
65
- @ <li> Must not contain any control characters, including tab or
66
- @ newline.
67
- @ <li> Must not have two or more spaces in a row internally.
68
- @ <li> Must be between 3 and 100 characters in length.
69
- @ </ul>
76
+ well_formed_wiki_name_rules();
7077
style_footer();
7178
return 1;
7279
}
7380
return 0;
7481
}
@@ -139,10 +146,13 @@
139146
@ pages. </li>
140147
@ <li> <a href="%s(g.zBaseURL)/wiki_rules">Formatting rules</a> for
141148
@ wiki.</li>
142149
@ <li> Use the <a href="%s(g.zBaseURL)/wiki?name=Sandbox">Sandbox</a>
143150
@ to experiment.</li>
151
+ if( g.okNewWiki ){
152
+ @ <li> Create a <a href="%s(g.zBaseURL)/wikinew">new wiki page</a>.</li>
153
+ }
144154
@ <li> <a href="%s(g.zBaseURL)/wcontent">List of All Wiki Pages</a>
145155
@ available on this server.</li>
146156
@ </ul>
147157
style_footer();
148158
return;
@@ -319,10 +329,45 @@
319329
if( !isSandbox ){
320330
manifest_clear(&m);
321331
}
322332
style_footer();
323333
}
334
+
335
+/*
336
+** WEBPAGE: wikinew
337
+** URL /wikinew
338
+**
339
+** Prompt the user to enter the name of a new wiki page. Then redirect
340
+** to the wikiedit screen for that new page.
341
+*/
342
+void wikinew_page(void){
343
+ const char *zName;
344
+ login_check_credentials();
345
+ if( !g.okNewWiki ){
346
+ login_needed();
347
+ return;
348
+ }
349
+ zName = PD("name","");
350
+ if( zName[0] && wiki_name_is_wellformed(zName) ){
351
+ cgi_redirectf("wikiedit?name=%T", zName);
352
+ }
353
+ style_header("Create A New Wiki Page");
354
+ @ <p>Rules for wiki page names:
355
+ well_formed_wiki_name_rules();
356
+ @ </p>
357
+ @ <form method="POST" action="%s(g.zBaseURL)/wikinew">
358
+ @ <p>Name of new wiki page:
359
+ @ <input type="text" width="35" name="name" value="%h(zName)">
360
+ @ <input type="submit" value="Create">
361
+ @ </p></form>
362
+ if( zName[0] ){
363
+ @ <p><b><font color="red">
364
+ @ "%h(zName)" is not a valid wiki page name!</font></b></p>
365
+ }
366
+ style_footer();
367
+}
368
+
324369
325370
/*
326371
** Append the wiki text for an remark to the end of the given BLOB.
327372
*/
328373
static void appendRemark(Blob *p){
@@ -429,11 +474,11 @@
429474
}
430475
if( P("cancel")!=0 ){
431476
cgi_redirectf("wiki?name=%T", zPageName);
432477
return;
433478
}
434
- zHtmlPageName = mprintf("Append Comment To: %h", zPageName);
479
+ zHtmlPageName = mprintf("Append Comment To: %s", zPageName);
435480
style_header(zHtmlPageName);
436481
if( P("preview")!=0 ){
437482
Blob preview;
438483
blob_zero(&preview);
439484
appendRemark(&preview);
@@ -467,11 +512,11 @@
467512
/*
468513
** Function called to output extra text at the end of each line in
469514
** a wiki history listing.
470515
*/
471516
static void wiki_history_extra(int rid){
472
- @ <a href="%s(g.zTop)/wdiff?name=%h(zWikiPageName)&a=%d(rid)">[diff]</a>
517
+ @ <a href="%s(g.zTop)/wdiff?name=%t(zWikiPageName)&a=%d(rid)">[diff]</a>
473518
}
474519
475520
/*
476521
** WEBPAGE: whistory
477522
** URL: /whistory?name=PAGENAME
478523
--- src/wiki.c
+++ src/wiki.c
@@ -48,10 +48,23 @@
48 }
49 if( z[i-1]==' ' ) return 0;
50 if( i<3 || i>100 ) return 0;
51 return 1;
52 }
 
 
 
 
 
 
 
 
 
 
 
 
 
53
54 /*
55 ** Check a wiki name. If it is not well-formed, then issue an error
56 ** and return true. If it is well-formed, return false.
57 */
@@ -58,17 +71,11 @@
58 static int check_name(const char *z){
59 if( !wiki_name_is_wellformed(z) ){
60 style_header("Wiki Page Name Error");
61 @ The wiki name "<b>%h(z)</b>" is not well-formed. Rules for
62 @ wiki page names:
63 @ <ul>
64 @ <li> Must not begin or end with a space.
65 @ <li> Must not contain any control characters, including tab or
66 @ newline.
67 @ <li> Must not have two or more spaces in a row internally.
68 @ <li> Must be between 3 and 100 characters in length.
69 @ </ul>
70 style_footer();
71 return 1;
72 }
73 return 0;
74 }
@@ -139,10 +146,13 @@
139 @ pages. </li>
140 @ <li> <a href="%s(g.zBaseURL)/wiki_rules">Formatting rules</a> for
141 @ wiki.</li>
142 @ <li> Use the <a href="%s(g.zBaseURL)/wiki?name=Sandbox">Sandbox</a>
143 @ to experiment.</li>
 
 
 
144 @ <li> <a href="%s(g.zBaseURL)/wcontent">List of All Wiki Pages</a>
145 @ available on this server.</li>
146 @ </ul>
147 style_footer();
148 return;
@@ -319,10 +329,45 @@
319 if( !isSandbox ){
320 manifest_clear(&m);
321 }
322 style_footer();
323 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
324
325 /*
326 ** Append the wiki text for an remark to the end of the given BLOB.
327 */
328 static void appendRemark(Blob *p){
@@ -429,11 +474,11 @@
429 }
430 if( P("cancel")!=0 ){
431 cgi_redirectf("wiki?name=%T", zPageName);
432 return;
433 }
434 zHtmlPageName = mprintf("Append Comment To: %h", zPageName);
435 style_header(zHtmlPageName);
436 if( P("preview")!=0 ){
437 Blob preview;
438 blob_zero(&preview);
439 appendRemark(&preview);
@@ -467,11 +512,11 @@
467 /*
468 ** Function called to output extra text at the end of each line in
469 ** a wiki history listing.
470 */
471 static void wiki_history_extra(int rid){
472 @ <a href="%s(g.zTop)/wdiff?name=%h(zWikiPageName)&a=%d(rid)">[diff]</a>
473 }
474
475 /*
476 ** WEBPAGE: whistory
477 ** URL: /whistory?name=PAGENAME
478
--- src/wiki.c
+++ src/wiki.c
@@ -48,10 +48,23 @@
48 }
49 if( z[i-1]==' ' ) return 0;
50 if( i<3 || i>100 ) return 0;
51 return 1;
52 }
53
54 /*
55 ** Output rules for well-formed wiki pages
56 */
57 static void well_formed_wiki_name_rules(void){
58 @ <ul>
59 @ <li> Must not begin or end with a space.
60 @ <li> Must not contain any control characters, including tab or
61 @ newline.
62 @ <li> Must not have two or more spaces in a row internally.
63 @ <li> Must be between 3 and 100 characters in length.
64 @ </ul>
65 }
66
67 /*
68 ** Check a wiki name. If it is not well-formed, then issue an error
69 ** and return true. If it is well-formed, return false.
70 */
@@ -58,17 +71,11 @@
71 static int check_name(const char *z){
72 if( !wiki_name_is_wellformed(z) ){
73 style_header("Wiki Page Name Error");
74 @ The wiki name "<b>%h(z)</b>" is not well-formed. Rules for
75 @ wiki page names:
76 well_formed_wiki_name_rules();
 
 
 
 
 
 
77 style_footer();
78 return 1;
79 }
80 return 0;
81 }
@@ -139,10 +146,13 @@
146 @ pages. </li>
147 @ <li> <a href="%s(g.zBaseURL)/wiki_rules">Formatting rules</a> for
148 @ wiki.</li>
149 @ <li> Use the <a href="%s(g.zBaseURL)/wiki?name=Sandbox">Sandbox</a>
150 @ to experiment.</li>
151 if( g.okNewWiki ){
152 @ <li> Create a <a href="%s(g.zBaseURL)/wikinew">new wiki page</a>.</li>
153 }
154 @ <li> <a href="%s(g.zBaseURL)/wcontent">List of All Wiki Pages</a>
155 @ available on this server.</li>
156 @ </ul>
157 style_footer();
158 return;
@@ -319,10 +329,45 @@
329 if( !isSandbox ){
330 manifest_clear(&m);
331 }
332 style_footer();
333 }
334
335 /*
336 ** WEBPAGE: wikinew
337 ** URL /wikinew
338 **
339 ** Prompt the user to enter the name of a new wiki page. Then redirect
340 ** to the wikiedit screen for that new page.
341 */
342 void wikinew_page(void){
343 const char *zName;
344 login_check_credentials();
345 if( !g.okNewWiki ){
346 login_needed();
347 return;
348 }
349 zName = PD("name","");
350 if( zName[0] && wiki_name_is_wellformed(zName) ){
351 cgi_redirectf("wikiedit?name=%T", zName);
352 }
353 style_header("Create A New Wiki Page");
354 @ <p>Rules for wiki page names:
355 well_formed_wiki_name_rules();
356 @ </p>
357 @ <form method="POST" action="%s(g.zBaseURL)/wikinew">
358 @ <p>Name of new wiki page:
359 @ <input type="text" width="35" name="name" value="%h(zName)">
360 @ <input type="submit" value="Create">
361 @ </p></form>
362 if( zName[0] ){
363 @ <p><b><font color="red">
364 @ "%h(zName)" is not a valid wiki page name!</font></b></p>
365 }
366 style_footer();
367 }
368
369
370 /*
371 ** Append the wiki text for an remark to the end of the given BLOB.
372 */
373 static void appendRemark(Blob *p){
@@ -429,11 +474,11 @@
474 }
475 if( P("cancel")!=0 ){
476 cgi_redirectf("wiki?name=%T", zPageName);
477 return;
478 }
479 zHtmlPageName = mprintf("Append Comment To: %s", zPageName);
480 style_header(zHtmlPageName);
481 if( P("preview")!=0 ){
482 Blob preview;
483 blob_zero(&preview);
484 appendRemark(&preview);
@@ -467,11 +512,11 @@
512 /*
513 ** Function called to output extra text at the end of each line in
514 ** a wiki history listing.
515 */
516 static void wiki_history_extra(int rid){
517 @ <a href="%s(g.zTop)/wdiff?name=%t(zWikiPageName)&a=%d(rid)">[diff]</a>
518 }
519
520 /*
521 ** WEBPAGE: whistory
522 ** URL: /whistory?name=PAGENAME
523

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button