Check-in [29374daa0d]
Not logged in
Overview

SHA1 Hash:29374daa0de3b02373a715ea197a95d6732772a4
Date: 2008-05-15 22:05:52
User: stephan
Comment:/home link content can now be pulled from a Wiki entry or an arbitrary link relative to the fossil root url. See the WWW Configuration dialog for details.
Timelines: ancestors | descendants | both | trunk
Other Links: files | ZIP archive | manifest

Tags And Properties
Changes
[hide diffs]

Modified src/setup.c from [ccb6e89143] to [ba00230314].

@@ -600,10 +600,22 @@
   @ <hr />
   textarea_attribute("Project Description", 5, 60,
                      "project-description", "pd", "");
   @ <p>Describe your project. This will be used in page headers for search
   @ engines as well as a short RSS description.</p>
+  @ <hr />
+  entry_attribute("Home page", 60, "project-home", "phome", "");
+  @ <p>This sets the content source for the Home page ([/home]).
+  @ Enter a wiki page name (as wiki/PageName) or another URL relative to
+  @ this server's root (%s(g.zBaseURL)/).
+  @ The default is to use wiki/ProjectName. Make sure to use a valid name,
+  @ or your /home link will likely crash! (If that happens, simply come back
+  @ to this page and set it to a good (or empty) value.)
+  @ To use .wiki or .html files in your source tree as content, use a URL
+  @ in the form <tt>doc/VERSION/path/to/doc.wiki</tt>, where VERSION is either
+  @ the UUID of a version of that page or the word 'tip' to get the most recent
+  @ version.</p>
   @ <hr />
   @ <p><input type="submit"  name="submit" value="Apply Changes"></p>
   @ </form>
   db_end_transaction(0);
   style_footer();

Modified src/wiki.c from [02c5204f87] to [efba03523b].

@@ -77,22 +77,42 @@
 ** WEBPAGE: home
 ** WEBPAGE: index
 ** WEBPAGE: not_found
 */
 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();
+  char *zHomePage;        /* name of home page */
+  char *zProjName;        /* name of project */
+  zProjName = db_get("project-name",0);
+  zHomePage = db_get("project-home", zProjName );
+  if( zProjName && zHomePage[0] ){
+    /* beware: this code causes cyclic redirects on a 404 because
+       not_found is directed here.
+     */
+    int lenP;             /* strncmp() bounder */
+    int lenH;             /* length of zProjName */
+    if(  zHomePage && ! zHomePage[0] ){
+        zHomePage = zProjName;
+    }
+    lenP = strlen(zProjName);
+    lenH = strlen(zHomePage);
+    if( lenP < lenH ) lenP = lenH;
+    if( (zProjName == zHomePage) || (0==strncmp(zProjName,zHomePage,lenP)) ||
+      (0==strncmp(zHomePage,"home",lenP)/*avoid endless loop*/) ){
+        login_check_credentials();
+        g.zExtra = zHomePage;
+        cgi_set_parameter_nocopy("name", g.zExtra);
+        g.okRdWiki = 1;
+        g.okApndWiki = 0;
+        g.okWrWiki = 0;
+        g.okHistory = 0;
+        wiki_page();
+    }else{
+        cgi_redirect( zHomePage );
+    }
     return;
   }
+
   style_header("Home");
   @ <p>This is a stub home-page for the project.
   @ To fill in this page, first go to
   @ <a href="%s(g.zBaseURL)/setup_config">setup/config</a>
   @ and establish a "Project Name".  Then create a
@@ -630,14 +650,14 @@
   int nrid;               /* not really sure */
   char * zDate;           /* timestamp */
   char * zUuid;           /* uuid for rid */
 
   rid = db_int(0, "SELECT x.rid FROM tag t, tagxref x"
-	       " WHERE x.tagid=t.tagid AND t.tagname='wiki-%q'"
+               " WHERE x.tagid=t.tagid AND t.tagname='wiki-%q'"
 	       " ORDER BY x.mtime DESC LIMIT 1",
-	       zPageName
-	       );
+               zPageName
+               );
   if( ! rid ){
     fossil_fatal("wiki commit NewEntry not yet implemented.");
   }