Diff
Not logged in

Differences From:

File src/wiki.c part of check-in [dec4685720] - Fix over-quoting of wiki names. Ticket e4a31ae35cd521b by drh on 2009-09-15 00:58:58. [view]

To:

File src/wiki.c part of check-in [aa57354736] - Add a screen to prompt the user for the name of a new wiki page. by drh on 2009-09-15 12:04:31. [view]

@@ -51,8 +51,21 @@
   return 1;
 }
 
 /*
+** Output rules for well-formed wiki pages
+*/
+static void well_formed_wiki_name_rules(void){
+  @ <ul>
+  @ <li> Must not begin or end with a space.
+  @ <li> Must not contain any control characters, including tab or
+  @      newline.
+  @ <li> Must not have two or more spaces in a row internally.
+  @ <li> Must be between 3 and 100 characters in length.
+  @ </ul>
+}
+
+/*
 ** Check a wiki name.  If it is not well-formed, then issue an error
 ** and return true.  If it is well-formed, return false.
 */
 static int check_name(const char *z){
@@ -59,15 +72,9 @@
   if( !wiki_name_is_wellformed(z) ){
     style_header("Wiki Page Name Error");
     @ The wiki name "<b>%h(z)</b>" is not well-formed.  Rules for
     @ wiki page names:
-    @ <ul>
-    @ <li> Must not begin or end with a space.
-    @ <li> Must not contain any control characters, including tab or
-    @      newline.
-    @ <li> Must not have two or more spaces in a row internally.
-    @ <li> Must be between 3 and 100 characters in length.
-    @ </ul>
+    well_formed_wiki_name_rules();
     style_footer();
     return 1;
   }
   return 0;
@@ -140,8 +147,11 @@
     @ <li> <a href="%s(g.zBaseURL)/wiki_rules">Formatting rules</a> for
     @      wiki.</li>
     @ <li> Use the <a href="%s(g.zBaseURL)/wiki?name=Sandbox">Sandbox</a>
     @      to experiment.</li>
+    if( g.okNewWiki ){
+      @ <li>  Create a <a href="%s(g.zBaseURL)/wikinew">new wiki page</a>.</li>
+    }
     @ <li> <a href="%s(g.zBaseURL)/wcontent">List of All Wiki Pages</a>
     @      available on this server.</li>
     @ </ul>
     style_footer();
@@ -322,8 +332,43 @@
   style_footer();
 }
 
 /*
+** WEBPAGE: wikinew
+** URL /wikinew
+**
+** Prompt the user to enter the name of a new wiki page.  Then redirect
+** to the wikiedit screen for that new page.
+*/
+void wikinew_page(void){
+  const char *zName;
+  login_check_credentials();
+  if( !g.okNewWiki ){
+    login_needed();
+    return;
+  }
+  zName = PD("name","");
+  if( zName[0] && wiki_name_is_wellformed(zName) ){
+    cgi_redirectf("wikiedit?name=%T", zName);
+  }
+  style_header("Create A New Wiki Page");
+  @ <p>Rules for wiki page names:
+  well_formed_wiki_name_rules();
+  @ </p>
+  @ <form method="POST" action="%s(g.zBaseURL)/wikinew">
+  @ <p>Name of new wiki page:
+  @ <input type="text" width="35" name="name" value="%h(zName)">
+  @ <input type="submit" value="Create">
+  @ </p></form>
+  if( zName[0] ){
+    @ <p><b><font color="red">
+    @ "%h(zName)" is not a valid wiki page name!</font></b></p>
+  }
+  style_footer();
+}
+
+
+/*
 ** Append the wiki text for an remark to the end of the given BLOB.
 */
 static void appendRemark(Blob *p){
   char *zDate;
@@ -430,9 +475,9 @@
   if( P("cancel")!=0 ){
     cgi_redirectf("wiki?name=%T", zPageName);
     return;
   }
-  zHtmlPageName = mprintf("Append Comment To: %h", zPageName);
+  zHtmlPageName = mprintf("Append Comment To: %s", zPageName);
   style_header(zHtmlPageName);
   if( P("preview")!=0 ){
     Blob preview;
     blob_zero(&preview);
@@ -468,9 +513,9 @@
 ** Function called to output extra text at the end of each line in
 ** a wiki history listing.
 */
 static void wiki_history_extra(int rid){
-  @ <a href="%s(g.zTop)/wdiff?name=%h(zWikiPageName)&a=%d(rid)">[diff]</a>
+  @ <a href="%s(g.zTop)/wdiff?name=%t(zWikiPageName)&a=%d(rid)">[diff]</a>
 }
 
 /*
 ** WEBPAGE: whistory