Diff
Not logged in

Differences From:

File src/main.c part of check-in [9f89a8e68e] - Fix the wiki editor so that it can handle wiki page names that include spaces. by drh on 2007-10-10 15:21:53. [view]

To:

File src/main.c part of check-in [50a58adb76] - Many changes and bug fixes in the wiki processing. Moving toward a workable wiki system. The "Home" menu option now takes you to the wiki page whose name is the same as the Project Name. There is a "wcontent" page, but no link to it yet. Many other changes. by drh on 2007-10-10 21:15:17. [view]

@@ -60,8 +60,9 @@
   int fHttpTrace;         /* Trace outbound HTTP requests */
   char *zPath;            /* Name of webpage being served */
   char *zExtra;           /* Extra path information past the webpage name */
   char *zBaseURL;         /* Full text of the URL being served */
+  char *zTop;             /* Parent directory of zPath */
   const char *zContentType;  /* The content type of the input HTTP request */
   int iErrPriority;       /* Priority of current error message */
   char *zErrMsg;          /* Text of an error message */
   Blob cgiIn;             /* Input to an xfer www method */
@@ -99,8 +100,9 @@
   int okRdWiki;           /* j: view wiki via web */
   int okNewWiki;          /* f: create new wiki via web */
   int okApndWiki;         /* m: append to wiki via web */
   int okWrWiki;           /* k: edit wiki via web */
+  int okLockWiki;         /* l: lock and unlock wiki via web */
   int okRdTkt;            /* r: view tickets via web */
   int okNewTkt;           /* n: create new tickets */
   int okApndTkt;          /* c: append to tickets via the web */
   int okWrTkt;            /* w: make changes to tickets via web */
@@ -413,13 +415,13 @@
   putchar('\n');
 }
 
 /*
-** RSS feeds need to reference absolute URLs so we need to calculate
-** the base URL onto which we add components. This is basically
-** cgi_redirect() stripped down and always returning an absolute URL.
+** Set the g.zBaseURL value to the full URL for the toplevel of
+** the fossil tree.  Set g.zHomeURL to g.zBaseURL without the
+** leading "http://" and the host and port.
 */
-static char *get_base_url(void){
+void set_base_url(void){
   int i;
   const char *zHost = PD("HTTP_HOST","");
   const char *zMode = PD("HTTPS","off");
   const char *zCur = PD("REQUEST_URI","/");
@@ -437,11 +439,14 @@
   while( i>0 && zCur[i-1]!='/' ){ i--; }
   while( i>0 && zCur[i-1]=='/' ){ i--; }
 
   if( strcmp(zMode,"on")==0 ){
-    return mprintf("https://%s%.*s", zHost, i, zCur);
-  }
-  return mprintf("http://%s%.*s", zHost, i, zCur);
+    g.zBaseURL = mprintf("https://%s%.*s", zHost, i, zCur);
+    g.zTop = &g.zBaseURL[8+strlen(zHost)+i];
+  }else{
+    g.zBaseURL = mprintf("http://%s%.*s", zHost, i, zCur);
+    g.zTop = &g.zBaseURL[7+strlen(zHost)+i];
+  }
 }
 
 /*
 ** Preconditions:
@@ -485,9 +490,9 @@
     g.zExtra = &zPath[i+1];
   }else{
     g.zExtra = 0;
   }
-  g.zBaseURL = get_base_url();
+  set_base_url();
   if( g.zExtra ){
     /* CGI parameters get this treatment elsewhere, but places like getfile
     ** will use g.zExtra directly.
     */