Check-in [677aa71bca]
Not logged in
Overview

SHA1 Hash:677aa71bca93b776afc2f0d9b2e06bb972c1d94d
Date: 2007-10-12 22:56:18
User: drh
Comment:The g.zExtra parameter is now always available as P("name"). This means the /wiki/xyz and /wiki?name=xyz are equivalent URLs.
Timelines: ancestors | descendants | both | trunk
Other Links: files | ZIP archive | manifest

Tags And Properties
Changes
[hide diffs]

Modified src/cgi.c from [3772dc1166] to [fa39badf00].

@@ -306,10 +306,16 @@
   cgi_set_status(302, "Moved Temporarily");
   free(zLocation);
   cgi_reply();
   exit(0);
 }
+void cgi_redirectf(const char *zFormat, ...){
+  va_list ap;
+  va_start(ap, zFormat);
+  cgi_redirect(vmprintf(zFormat, ap));
+  va_end(ap);
+}
 
 /*
 ** Information about all query parameters and cookies are stored
 ** in these variables.
 */
@@ -329,11 +335,11 @@
 ** is its fully decoded value.
 **
 ** zName and zValue are not copied and must not change or be
 ** deallocated after this routine returns.
 */
-static void cgi_set_parameter_nocopy(const char *zName, const char *zValue){
+void cgi_set_parameter_nocopy(const char *zName, const char *zValue){
   if( nAllocQP<=nUsedQP ){
     nAllocQP = nAllocQP*2 + 10;
     aParamQP = realloc( aParamQP, nAllocQP*sizeof(aParamQP[0]) );
     if( aParamQP==0 ) exit(1);
   }

Modified src/info.c from [9f9776b1a2] to [2ca8ead9e1].

@@ -289,22 +289,22 @@
 }
 
 
 /*
 ** WEBPAGE: vinfo
+** URL:  /vinfo?name=RID|UUID
 **
-** Return information about a version.  The version number is contained
-** in g.zExtra.
+** Return information about a version.
 */
 void vinfo_page(void){
   Stmt q;
   int rid;
   int isLeaf;
 
   login_check_credentials();
   if( !g.okHistory ){ login_needed(); return; }
-  rid = name_to_rid(g.zExtra);
+  rid = name_to_rid(PD("name","0"));
   if( rid==0 ){
     style_header("Version Information Error");
     @ No such object: %h(g.argv[2])
     style_footer();
     return;
@@ -364,11 +364,11 @@
     }else if( fid ){
       @ <b>Added:</b>
     }else{
       @ <b>Deleted:</b>
     }
-    @ <a href="%s(g.zBaseURL)/finfo/%T(zName)">%h(zName)</a></li>
+    @ <a href="%s(g.zBaseURL)/finfo?name=%T(zName)">%h(zName)</a></li>
   }
   @ </ul>
   compute_leaves(rid);
   showDescendents(rid, 2, "Descendents");
   showLeaves();
@@ -376,21 +376,21 @@
   style_footer();
 }
 
 /*
 ** WEBPAGE: winfo
+** URL:  /winfo?name=RID
 **
-** Return information about a wiki page.  The version number is contained
-** in g.zExtra.
+** Return information about a wiki page.
 */
 void winfo_page(void){
   Stmt q;
   int rid;
 
   login_check_credentials();
   if( !g.okHistory ){ login_needed(); return; }
-  rid = name_to_rid(g.zExtra);
+  rid = name_to_rid(PD("name","0"));
   if( rid==0 ){
     style_header("Wiki Page Information Error");
     @ No such object: %h(g.argv[2])
     style_footer();
     return;
@@ -421,11 +421,11 @@
     }
     @ <tr><th>Original&nbsp;User:</th><td>%s(db_column_text(&q, 3))</td></tr>
     @ <tr><th>Commands:</th>
     @   <td>
 /*    @     <a href="%s(g.zBaseURL)/wdiff/%d(rid)">diff</a> | */
-    @     <a href="%s(g.zBaseURL)/whistory/%t(zName)">history</a>
+    @     <a href="%s(g.zBaseURL)/whistory?page=%t(zName)">history</a>
     @     | <a href="%s(g.zBaseURL)/fview/%d(rid)">raw-text</a>
     @   </td>
     @ </tr>
     @ </table></p>
   }else{
@@ -436,22 +436,24 @@
   style_footer();
 }
 
 /*
 ** WEBPAGE: finfo
+** URL: /finfo?name=FILENAME
 **
-** Show the complete change history for a single file.  The name
-** of the file is in g.zExtra
+** Show the complete change history for a single file.
 */
 void finfo_page(void){
   Stmt q;
+  const char *zFilename;
   char zPrevDate[20];
   login_check_credentials();
   if( !g.okHistory ){ login_needed(); return; }
   style_header("File History");
 
   zPrevDate[0] = 0;
+  zFilename = PD("name","");
   db_prepare(&q,
     "SELECT a.uuid, substr(b.uuid,1,10), datetime(event.mtime,'localtime'),"
     "       coalesce(event.ecomment, event.comment),"
     "       coalesce(event.euser, event.user),"
     "       mlink.pid, mlink.fid"
@@ -459,13 +461,13 @@
     " WHERE mlink.fnid=(SELECT fnid FROM filename WHERE name=%Q)"
     "   AND a.rid=mlink.mid"
     "   AND b.rid=mlink.fid"
     "   AND event.objid=mlink.mid"
     " ORDER BY event.mtime DESC",
-    g.zExtra
+    zFilename
   );
-  @ <h2>History of %h(g.zExtra)</h2>
+  @ <h2>History of %h(zFilename)</h2>
   @ <table cellspacing=0 border=0 cellpadding=0>
   while( db_step(&q)==SQLITE_ROW ){
     const char *zVers = db_column_text(&q, 0);
     const char *zUuid = db_column_text(&q, 1);
     const char *zDate = db_column_text(&q, 2);
@@ -489,11 +491,13 @@
     @ <td valign="top" align="left">
     hyperlink_to_uuid(zVers);
     @ %h(zCom) (By: %h(zUser))
     @ Id: %s(zUuid)/%d(frid)
     @ <a href="%s(g.zBaseURL)/fview/%d(frid)">[view]</a>
-    @ <a href="%s(g.zBaseURL)/fdiff?v1=%d(fpid)&amp;v2=%d(frid)">[diff]</a>
+    if( fpid ){
+      @ <a href="%s(g.zBaseURL)/fdiff?v1=%d(fpid)&amp;v2=%d(frid)">[diff]</a>
+    }
     @ </td>
   }
   db_finalize(&q);
   @ </table>
   style_footer();
@@ -515,12 +519,13 @@
   blob_reset(&out);
 }
 
 /*
 ** WEBPAGE: vdiff
+** URL: /vdiff?name=RID
 **
-** Show all differences for a particular check-in specified by g.zExtra
+** Show all differences for a particular check-in.
 */
 void vdiff_page(void){
   int rid;
   Stmt q;
   char *zUuid;
@@ -527,11 +532,11 @@
 
   login_check_credentials();
   if( !g.okHistory ){ login_needed(); return; }
   style_header("Version Diff");
 
-  rid = name_to_rid(g.zExtra);
+  rid = name_to_rid(PD("name",""));
   if( rid==0 ){
     cgi_redirect("index");
   }
   db_prepare(&q,
      "SELECT pid, fid, name"
@@ -547,11 +552,11 @@
   @ </h2>
   while( db_step(&q)==SQLITE_ROW ){
     int pid = db_column_int(&q,0);
     int fid = db_column_int(&q,1);
     const char *zName = db_column_text(&q,2);
-    @ <p><a href="%s(g.zBaseURL)/finfo/%T(zName)">%h(zName)</a></p>
+    @ <p><a href="%s(g.zBaseURL)/finfo?name=%T(zName)">%h(zName)</a></p>
     @ <blockquote><pre>
     append_diff(pid, fid);
     @ </pre></blockquote>
   }
   db_finalize(&q);
@@ -596,11 +601,11 @@
     const char *zDate = db_column_text(&q, 1);
     const char *zFuuid = db_column_text(&q, 2);
     const char *zCom = db_column_text(&q, 3);
     const char *zUser = db_column_text(&q, 4);
     const char *zVers = db_column_text(&q, 5);
-    @ File <a href="%s(g.zBaseURL)/finfo/%T(zName)">%h(zName)</a>
+    @ File <a href="%s(g.zBaseURL)/finfo?name=%T(zName)">%h(zName)</a>
     @ uuid %s(zFuuid) part of check-in
     hyperlink_to_uuid(zVers);
     @ %s(zCom) by %s(zUser) on %s(zDate).
     cnt++;
   }
@@ -619,11 +624,12 @@
   while( db_step(&q)==SQLITE_ROW ){
     const char *zPagename = db_column_text(&q, 0);
     const char *zDate = db_column_text(&q, 1);
     const char *zUser = db_column_text(&q, 2);
     const char *zUuid = db_column_text(&q, 3);
-    @ Wiki page [<a href="%s(g.zBaseURL)/wiki/%t(zPagename)">%h(zPagename)</a>]
+    @ Wiki page
+    @ [<a href="%s(g.zBaseURL)/wiki?page=%t(zPagename)">%h(zPagename)</a>]
     @ uuid %s(zUuid) by %h(zUser) on %s(zDate)
     nWiki++;
     cnt++;
   }
   db_finalize(&q);
@@ -692,20 +698,20 @@
 }
 
 /*
 ** WEBPAGE: info
 ** WEBPAGE: fview
-** URL: /fview/UUID
+** URL: /fview?name=UUID
 **
 ** Show the complete content of a file identified by UUID
 ** as preformatted text.
 */
 void fview_page(void){
   int rid;
   Blob content;
 
-  rid = name_to_rid(g.zExtra);
+  rid = name_to_rid(PD("name","0"));
   login_check_credentials();
   if( !g.okHistory ){ login_needed(); return; }
   if( g.zPath[0]=='i' ){
     if( db_exists("SELECT 1 FROM tagxref JOIN tag USING(tagid)"
                   " WHERE rid=%d AND tagname LIKE 'wiki-%%'", rid) ){

Modified src/main.c from [53217aa48d] to [d1ff45663d].

@@ -448,11 +448,11 @@
 }
 
 /*
 ** Preconditions:
 **
-**    * Environment various are set up according to the CGI standard.
+**    * Environment variables are set up according to the CGI standard.
 **    * The respository database has been located and opened.
 **
 ** Process the webpage specified by the PATH_INFO or REQUEST_URI
 ** environment variable.
 */
@@ -494,10 +494,11 @@
   if( g.zExtra ){
     /* CGI parameters get this treatment elsewhere, but places like getfile
     ** will use g.zExtra directly.
     */
     dehttpize(g.zExtra);
+    cgi_set_parameter_nocopy("name", g.zExtra);
   }
 
   /* Prevent robots from indexing this site.
   */
   if( strcmp(g.zPath, "robots.txt")==0 ){

Modified src/style.c from [07fba9de0a] to [43dff7bad0].

@@ -119,11 +119,11 @@
       char *zTail = i<nSubmenu-1 ? " | " : "";
       if( p->zLink==0 ){
         @ <span class="label">%h(p->zLabel)</span>
         @ <span class="tail">%s(zTail)</span>
       }else{
-        @ <a class="label" href="%T(p->zLink)">%h(p->zLabel)</a>
+        @ <a class="label" href="%s(p->zLink)">%h(p->zLabel)</a>
         @ <span class="tail">%s(zTail)</span>
       }
     }
     @ </div>
   }
@@ -239,9 +239,8 @@
 */
 void page_test_env(void){
   style_header("Environment Test");
   @ g.zBaseURL = %h(g.zBaseURL)<br>
   @ g.zTop = %h(g.zTop)<br>
-  @ g.zExtra = %h(g.zExtra)<hr>
   cgi_print_all();
   style_footer();
 }

Modified src/wiki.c from [c34537ff45] to [63e0aa644a].

@@ -79,10 +79,11 @@
 void home_page(void){
   char *zPageName = db_get("project-name",0);
   if( zPageName ){
     login_check_credentials();
     g.zExtra = zPageName;
+    cgi_set_parameter_nocopy("name", g.zExtra);
     g.okRdWiki = 1;
     g.okApndWiki = 0;
     g.okWrWiki = 0;
     g.okHistory = 0;
     wiki_page();
@@ -98,25 +99,24 @@
   style_footer();
 }
 
 /*
 ** WEBPAGE: wiki
-** URL: /wiki/PAGENAME
+** URL: /wiki?name=PAGENAME
 */
 void wiki_page(void){
   char *zTag;
   int rid;
   Blob wiki;
   Manifest m;
-  char *zPageName;
+  const char *zPageName;
   char *zHtmlPageName;
   char *zBody = mprintf("%s","<i>Empty Page</i>");
 
   login_check_credentials();
   if( !g.okRdWiki ){ login_needed(); return; }
-  zPageName = mprintf("%s", g.zExtra);
-  dehttpize(zPageName);
+  zPageName = PD("name","");
   if( check_name(zPageName) ) return;
   zTag = mprintf("wiki-%s", zPageName);
   rid = db_int(0,
     "SELECT rid FROM tagxref"
     " WHERE tagid=(SELECT tagid FROM tag WHERE tagname=%Q)"
@@ -133,19 +133,19 @@
       zBody = m.zWiki;
     }
   }
   if( (rid && g.okWrWiki) || (!rid && g.okNewWiki) ){
     style_submenu_element("Edit", "Edit Wiki Page",
-       mprintf("%s/wikiedit/%s", g.zTop, g.zExtra));
+       mprintf("%s/wikiedit?name=%t", g.zTop, zPageName));
   }
   if( rid && g.okApndWiki ){
     style_submenu_element("Append", "Add A Comment",
-       mprintf("%s/wikiappend/%s", g.zTop, g.zExtra));
+       mprintf("%s/wikiappend?name=%t", g.zTop, zPageName));
   }
   if( g.okHistory ){
     style_submenu_element("History", "History",
-         mprintf("%s/whistory/%s", g.zTop, g.zExtra));
+         mprintf("%s/whistory?name=%t", g.zTop, zPageName));
   }
   zHtmlPageName = mprintf("%h", zPageName);
   style_header(zHtmlPageName);
   blob_init(&wiki, zBody, -1);
   wiki_convert(&wiki, 0);
@@ -154,29 +154,28 @@
   style_footer();
 }
 
 /*
 ** WEBPAGE: wikiedit
-** URL: /wikiedit/PAGENAME
+** URL: /wikiedit?page=PAGENAME
 */
 void wikiedit_page(void){
   char *zTag;
   int rid;
   Blob wiki;
   Manifest m;
-  char *zPageName;
+  const char *zPageName;
   char *zHtmlPageName;
   int n;
   const char *z;
   char *zBody = (char*)P("w");
 
   if( zBody ){
     zBody = mprintf("%s", zBody);
   }
   login_check_credentials();
-  zPageName = mprintf("%s", g.zExtra);
-  dehttpize(zPageName);
+  zPageName = PD("name","");
   if( check_name(zPageName) ) return;
   zTag = mprintf("wiki-%s", zPageName);
   rid = db_int(0,
     "SELECT rid FROM tagxref"
     " WHERE tagid=(SELECT tagid FROM tag WHERE tagname=%Q)"
@@ -224,14 +223,14 @@
     db_multi_exec("INSERT OR IGNORE INTO unsent VALUES(%d)", nrid);
     manifest_crosslink(nrid, &wiki);
     blob_reset(&wiki);
     content_deltify(rid, nrid, 0);
     db_end_transaction(0);
-    cgi_redirect(mprintf("wiki/%s", g.zExtra));
+    cgi_redirectf("wiki?name=%t", zPageName);
   }
   if( P("cancel")!=0 ){
-    cgi_redirect(mprintf("wiki/%s", g.zExtra));
+    cgi_redirectf("wiki?name=%t", zPageName);
     return;
   }
   if( zBody==0 ){
     zBody = mprintf("<i>Empty Page</i>");
   }
@@ -248,11 +247,12 @@
   for(n=2, z=zBody; z[0]; z++){
     if( z[0]=='\n' ) n++;
   }
   if( n<20 ) n = 20;
   if( n>200 ) n = 200;
-  @ <form method="POST" action="%s(g.zBaseURL)/wikiedit/%t(g.zExtra)">
+  @ <form method="POST" action="%s(g.zBaseURL)/wikiedit">
+  @ <input type="hidden" name="name" value="%t(zPageName)">
   @ <textarea name="w" class="wikiedit" cols="80"
   @  rows="%d(n)" wrap="virtual">%h(zBody)</textarea>
   @ <br>
   @ <input type="submit" name="preview" value="Preview Your Changes">
   @ <input type="submit" name="submit" value="Apply These Changes">
@@ -281,22 +281,21 @@
   blob_appendf(p, " added:\n\n%s", zRemark);
 }
 
 /*
 ** WEBPAGE: wikiappend
-** URL: /wikiappend/PAGENAME
+** URL: /wikiappend?name=PAGENAME
 */
 void wikiappend_page(void){
   char *zTag;
   int rid;
-  char *zPageName;
+  const char *zPageName;
   char *zHtmlPageName;
   const char *zUser;
 
   login_check_credentials();
-  zPageName = mprintf("%s", g.zExtra);
-  dehttpize(zPageName);
+  zPageName = PD("name","");
   if( check_name(zPageName) ) return;
   zTag = mprintf("wiki-%s", zPageName);
   rid = db_int(0,
     "SELECT rid FROM tagxref"
     " WHERE tagid=(SELECT tagid FROM tag WHERE tagname=%Q)"
@@ -351,14 +350,14 @@
     db_multi_exec("INSERT OR IGNORE INTO unsent VALUES(%d)", nrid);
     manifest_crosslink(nrid, &wiki);
     blob_reset(&wiki);
     content_deltify(rid, nrid, 0);
     db_end_transaction(0);
-    cgi_redirect(mprintf("wiki/%s", g.zExtra));
+    cgi_redirectf("wiki?name=%t", zPageName);
   }
   if( P("cancel")!=0 ){
-    cgi_redirect(mprintf("wiki/%s", g.zExtra));
+    cgi_redirectf("wiki?name=%t", zPageName);
     return;
   }
   zHtmlPageName = mprintf("Append Comment To: %h", zPageName);
   style_header(zHtmlPageName);
   if( P("preview")!=0 ){
@@ -369,11 +368,12 @@
     wiki_convert(&preview, 0);
     @ <hr>
     blob_reset(&preview);
   }
   zUser = PD("u", g.zLogin);
-  @ <form method="POST" action="%s(g.zBaseURL)/wikiappend/%t(g.zExtra)">
+  @ <form method="POST" action="%s(g.zBaseURL)/wikiappend">
+  @ <input type="hidden" name="name" value="%t(zPageName)">
   @ Your Name:
   @ <input type="text" name="u" size="20" value="%h(zUser)"><br>
   @ Comment to append:<br>
   @ <textarea name="r" class="wikiedit" cols="80"
   @  rows="10" wrap="virtual">%h(PD("r",""))</textarea>
@@ -385,29 +385,31 @@
   style_footer();
 }
 
 /*
 ** WEBPAGE: whistory
+** URL: /whistory?name=PAGENAME
 **
-** Show the complete change history for a single wiki page.  The name
-** of the wiki is in g.zExtra
+** Show the complete change history for a single wiki page.
 */
 void whistory_page(void){
   Stmt q;
   char *zTitle;
   char *zSQL;
+  const char *zPageName;
   login_check_credentials();
   if( !g.okHistory ){ login_needed(); return; }
-  zTitle = mprintf("History Of %h", g.zExtra);
+  zPageName = PD("name","");
+  zTitle = mprintf("History Of %h", zPageName);
   style_header(zTitle);
   free(zTitle);
 
   zSQL = mprintf("%s AND event.objid IN "
                  "  (SELECT rid FROM tagxref WHERE tagid="
                        "(SELECT tagid FROM tag WHERE tagname='wiki-%q'))"
                  "ORDER BY mtime DESC",
-                 timeline_query_for_www(), g.zExtra);
+                 timeline_query_for_www(), zPageName);
   db_prepare(&q, zSQL);
   free(zSQL);
   www_print_timeline(&q, 0, 0, 0, 0);
   db_finalize(&q);
   style_footer();
@@ -428,36 +430,10 @@
     "SELECT substr(tagname, 6, 1000) FROM tag WHERE tagname GLOB 'wiki-*'"
     " ORDER BY lower(tagname)"
   );
   while( db_step(&q)==SQLITE_ROW ){
     const char *zName = db_column_text(&q, 0);
-    @ <li><a href="%s(g.zBaseURL)/wiki/%t(zName)">%h(zName)</a></li>
+    @ <li><a href="%s(g.zBaseURL)/wiki?page=%t(zName)">%h(zName)</a></li>
   }
   db_finalize(&q);
-  style_footer();
-}
-
-/*
-** WEBPAGE: ambiguous
-**
-** This is the destination for UUID hyperlinks that are ambiguous.
-** Show all possible choices for the destination with links to each.
-**
-** The ambiguous UUID prefix is in g.zExtra
-*/
-void ambiguous_page(void){
-  Stmt q;
-  style_header("Ambiguous UUID");
-  @ <p>The link <a href="%s(g.zBaseURL)/ambiguous/%T(g.zExtra)">
-  @ [%h(g.zExtra)]</a> is ambiguous.  It might mean any of the following:</p>
-  @ <ul>
-  db_prepare(&q, "SELECT uuid, rid FROM blob WHERE uuid>=%Q AND uuid<'%qz'"
-                 " ORDER BY uuid", g.zExtra, g.zExtra);
-  while( db_step(&q)==SQLITE_ROW ){
-    const char *zUuid = db_column_text(&q, 0);
-    int rid = db_column_int(&q, 1);
-    @ <li> %s(zUuid) - %d(rid)
-  }
-  db_finalize(&q);
-  @ </ul>
   style_footer();
 }

Modified src/zip.c from [a6ead783d2] to [359cf5b931].

@@ -322,23 +322,24 @@
   blob_write_to_file(&zip, g.argv[3]);
 }
 
 /*
 ** WEBPAGE: zip
+** URL: /zip/RID.zip
 **
-** Generate a ZIP archive for the baseline specified by g.zExtra
-** and return that ZIP archive as the HTTP reply content.
+** Generate a ZIP archive for the baseline.
+** Return that ZIP archive as the HTTP reply content.
 */
 void baseline_zip_page(void){
   int rid;
   char *zName;
   int i;
   Blob zip;
 
   login_check_credentials();
   if( !g.okRead || !g.okHistory ){ login_needed(); return; }
-  zName = mprintf("%s", g.zExtra);
+  zName = mprintf("%s", PD("name",""));
   i = strlen(zName);
   for(i=strlen(zName)-1; i>5; i--){
     if( zName[i]=='.' ){
       zName[i] = 0;
       break;