Fossil SCM

Add the "Index Page" setup option to allow each site to configure a page to appear when no URL is specified or when the "Home" menu option is selected.

drh 2008-05-16 13:31 trunk
Commit c7c81df13855c9fa22ad9a9bc96d46d981961f61
3 files changed +5 -8 +25 -8 +2 -1
+5 -8
--- src/main.c
+++ src/main.c
@@ -465,22 +465,20 @@
465465
*/
466466
static void process_one_web_page(void){
467467
const char *zPathInfo;
468468
char *zPath = NULL;
469469
int idx;
470
- int i, j;
470
+ int i;
471471
472472
/* Find the page that the user has requested, construct and deliver that
473473
** page.
474474
*/
475
+ set_base_url();
475476
zPathInfo = P("PATH_INFO");
476
- if( zPathInfo==0 || zPathInfo[0]==0 ){
477
- const char *zUri;
478
- zUri = PD("REQUEST_URI","/");
479
- for(i=0; zUri[i] && zUri[i]!='?' && zUri[i]!='#'; i++){}
480
- for(j=i; j>0 && zUri[j-1]!='/'; j--){}
481
- cgi_redirectf("%.*s/index", i, zUri);
477
+ if( zPathInfo==0 || zPathInfo[0]==0
478
+ || (zPathInfo[0]=='/' && zPathInfo[1]==0) ){
479
+ cgi_redirectf("%s%s", g.zBaseURL, db_get("index-page", "/index"));
482480
}else{
483481
zPath = mprintf("%s", zPathInfo);
484482
}
485483
486484
/* Remove the leading "/" at the beginning of the path.
@@ -491,11 +489,10 @@
491489
zPath[i] = 0;
492490
g.zExtra = &zPath[i+1];
493491
}else{
494492
g.zExtra = 0;
495493
}
496
- set_base_url();
497494
if( g.zExtra ){
498495
/* CGI parameters get this treatment elsewhere, but places like getfile
499496
** will use g.zExtra directly.
500497
*/
501498
dehttpize(g.zExtra);
502499
--- src/main.c
+++ src/main.c
@@ -465,22 +465,20 @@
465 */
466 static void process_one_web_page(void){
467 const char *zPathInfo;
468 char *zPath = NULL;
469 int idx;
470 int i, j;
471
472 /* Find the page that the user has requested, construct and deliver that
473 ** page.
474 */
 
475 zPathInfo = P("PATH_INFO");
476 if( zPathInfo==0 || zPathInfo[0]==0 ){
477 const char *zUri;
478 zUri = PD("REQUEST_URI","/");
479 for(i=0; zUri[i] && zUri[i]!='?' && zUri[i]!='#'; i++){}
480 for(j=i; j>0 && zUri[j-1]!='/'; j--){}
481 cgi_redirectf("%.*s/index", i, zUri);
482 }else{
483 zPath = mprintf("%s", zPathInfo);
484 }
485
486 /* Remove the leading "/" at the beginning of the path.
@@ -491,11 +489,10 @@
491 zPath[i] = 0;
492 g.zExtra = &zPath[i+1];
493 }else{
494 g.zExtra = 0;
495 }
496 set_base_url();
497 if( g.zExtra ){
498 /* CGI parameters get this treatment elsewhere, but places like getfile
499 ** will use g.zExtra directly.
500 */
501 dehttpize(g.zExtra);
502
--- src/main.c
+++ src/main.c
@@ -465,22 +465,20 @@
465 */
466 static void process_one_web_page(void){
467 const char *zPathInfo;
468 char *zPath = NULL;
469 int idx;
470 int i;
471
472 /* Find the page that the user has requested, construct and deliver that
473 ** page.
474 */
475 set_base_url();
476 zPathInfo = P("PATH_INFO");
477 if( zPathInfo==0 || zPathInfo[0]==0
478 || (zPathInfo[0]=='/' && zPathInfo[1]==0) ){
479 cgi_redirectf("%s%s", g.zBaseURL, db_get("index-page", "/index"));
 
 
 
480 }else{
481 zPath = mprintf("%s", zPathInfo);
482 }
483
484 /* Remove the leading "/" at the beginning of the path.
@@ -491,11 +489,10 @@
489 zPath[i] = 0;
490 g.zExtra = &zPath[i+1];
491 }else{
492 g.zExtra = 0;
493 }
 
494 if( g.zExtra ){
495 /* CGI parameters get this treatment elsewhere, but places like getfile
496 ** will use g.zExtra directly.
497 */
498 dehttpize(g.zExtra);
499
+25 -8
--- src/setup.c
+++ src/setup.c
@@ -104,12 +104,12 @@
104104
@ <tr><td valign="top">
105105
@ <b>Users:</b>
106106
@ <table border="1" cellpadding="10"><tr><td>
107107
@ <table cellspacing=0 cellpadding=0 border=0>
108108
@ <tr>
109
- @ <th align="right">User&nbsp;ID</th><th width="15"></td>
110
- @ <th>Capabilities</th><th width="15"></td>
109
+ @ <th align="right">User&nbsp;ID</th><td width="20">&nbsp;</td>
110
+ @ <th>Capabilities</th><td width="15">&nbsp;</td>
111111
@ <th>Contact&nbsp;Info</th>
112112
@ </tr>
113113
db_prepare(&s, "SELECT uid, login, cap, info FROM user ORDER BY login");
114114
while( db_step(&s)==SQLITE_ROW ){
115115
@ <tr>
@@ -119,12 +119,13 @@
119119
}
120120
@ <nobr>%h(db_column_text(&s,1))</nobr>
121121
if( g.okAdmin ){
122122
@ </a>
123123
}
124
- @ </td><td></td>
125
- @ <td align="center">%s(db_column_text(&s,2))</td><td></td>
124
+ @ </td><td>&nbsp;&nbsp;&nbsp;</td>
125
+ @ <td align="center">%s(db_column_text(&s,2))</td>
126
+ @ <td>&nbsp;&nbsp;&nbsp;</td>
126127
@ <td align="left">%s(db_column_text(&s,3))</td>
127128
@ </tr>
128129
}
129130
@ </table></td></tr></table>
130131
@ <td valign="top">
@@ -452,13 +453,13 @@
452453
db_set(zVar, iQ ? "1" : "0", 0);
453454
iVal = iQ;
454455
}
455456
}
456457
if( iVal ){
457
- @ <input type="checkbox" name="%s(zQParm)" checked>%s(zLabel)</input>
458
+ @ <input type="checkbox" name="%s(zQParm)" checked><b>%s(zLabel)</b></input>
458459
}else{
459
- @ <input type="checkbox" name="%s(zQParm)">%s(zLabel)</input>
460
+ @ <input type="checkbox" name="%s(zQParm)"><b>%s(zLabel)</b></input>
460461
}
461462
}
462463
463464
/*
464465
** Generate an entry box for an attribute.
@@ -475,11 +476,11 @@
475476
if( zQ && strcmp(zQ,zVal)!=0 ){
476477
db_set(zVar, zQ, 0);
477478
zVal = zQ;
478479
}
479480
@ <input type="text" name="%s(zQParm)" value="%h(zVal)" size="%d(width)">
480
- @ %s(zLabel)
481
+ @ <b>%s(zLabel)</b>
481482
}
482483
483484
/*
484485
** Generate a text box for an attribute.
485486
*/
@@ -497,11 +498,11 @@
497498
db_set(zVar, zQ, 0);
498499
z = zQ;
499500
}
500501
if( rows>0 && cols>0 ){
501502
@ <textarea name="%s(zQP)" rows="%d(rows)" cols="%d(cols)">%h(z)</textarea>
502
- @ %s(zLabel)
503
+ @ <b>%s(zLabel)</b>
503504
}
504505
}
505506
506507
507508
/*
@@ -601,10 +602,26 @@
601602
textarea_attribute("Project Description", 5, 60,
602603
"project-description", "pd", "");
603604
@ <p>Describe your project. This will be used in page headers for search
604605
@ engines as well as a short RSS description.</p>
605606
@ <hr />
607
+ entry_attribute("Index Page", 60, "index-page", "idxpg", "/home");
608
+ @ <p>Enter the pathname of the page to display when the "Home" menu
609
+ @ option is selected and when no pathname is
610
+ @ specified in the URL. For example, if you visit the url:</p>
611
+ @
612
+ @ <blockquote>%h(g.zBaseURL)</blockquote>
613
+ @
614
+ @ <p>And you have specified an index page of "/home" the above will
615
+ @ automatically redirect to:</p>
616
+ @
617
+ @ <blockquote>%h(g.zBaseURL)/home</blockquote>
618
+ @
619
+ @ <p>The default "/home" page displays a Wiki page with the same name
620
+ @ as the Project Name specified above. Some sites prefer to redirect
621
+ @ to a documentation page (ex: "/doc/tip/index.wiki") or to "/timeline".</p>
622
+ @ <hr />
606623
@ <p><input type="submit" name="submit" value="Apply Changes"></p>
607624
@ </form>
608625
db_end_transaction(0);
609626
style_footer();
610627
}
611628
--- src/setup.c
+++ src/setup.c
@@ -104,12 +104,12 @@
104 @ <tr><td valign="top">
105 @ <b>Users:</b>
106 @ <table border="1" cellpadding="10"><tr><td>
107 @ <table cellspacing=0 cellpadding=0 border=0>
108 @ <tr>
109 @ <th align="right">User&nbsp;ID</th><th width="15"></td>
110 @ <th>Capabilities</th><th width="15"></td>
111 @ <th>Contact&nbsp;Info</th>
112 @ </tr>
113 db_prepare(&s, "SELECT uid, login, cap, info FROM user ORDER BY login");
114 while( db_step(&s)==SQLITE_ROW ){
115 @ <tr>
@@ -119,12 +119,13 @@
119 }
120 @ <nobr>%h(db_column_text(&s,1))</nobr>
121 if( g.okAdmin ){
122 @ </a>
123 }
124 @ </td><td></td>
125 @ <td align="center">%s(db_column_text(&s,2))</td><td></td>
 
126 @ <td align="left">%s(db_column_text(&s,3))</td>
127 @ </tr>
128 }
129 @ </table></td></tr></table>
130 @ <td valign="top">
@@ -452,13 +453,13 @@
452 db_set(zVar, iQ ? "1" : "0", 0);
453 iVal = iQ;
454 }
455 }
456 if( iVal ){
457 @ <input type="checkbox" name="%s(zQParm)" checked>%s(zLabel)</input>
458 }else{
459 @ <input type="checkbox" name="%s(zQParm)">%s(zLabel)</input>
460 }
461 }
462
463 /*
464 ** Generate an entry box for an attribute.
@@ -475,11 +476,11 @@
475 if( zQ && strcmp(zQ,zVal)!=0 ){
476 db_set(zVar, zQ, 0);
477 zVal = zQ;
478 }
479 @ <input type="text" name="%s(zQParm)" value="%h(zVal)" size="%d(width)">
480 @ %s(zLabel)
481 }
482
483 /*
484 ** Generate a text box for an attribute.
485 */
@@ -497,11 +498,11 @@
497 db_set(zVar, zQ, 0);
498 z = zQ;
499 }
500 if( rows>0 && cols>0 ){
501 @ <textarea name="%s(zQP)" rows="%d(rows)" cols="%d(cols)">%h(z)</textarea>
502 @ %s(zLabel)
503 }
504 }
505
506
507 /*
@@ -601,10 +602,26 @@
601 textarea_attribute("Project Description", 5, 60,
602 "project-description", "pd", "");
603 @ <p>Describe your project. This will be used in page headers for search
604 @ engines as well as a short RSS description.</p>
605 @ <hr />
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
606 @ <p><input type="submit" name="submit" value="Apply Changes"></p>
607 @ </form>
608 db_end_transaction(0);
609 style_footer();
610 }
611
--- src/setup.c
+++ src/setup.c
@@ -104,12 +104,12 @@
104 @ <tr><td valign="top">
105 @ <b>Users:</b>
106 @ <table border="1" cellpadding="10"><tr><td>
107 @ <table cellspacing=0 cellpadding=0 border=0>
108 @ <tr>
109 @ <th align="right">User&nbsp;ID</th><td width="20">&nbsp;</td>
110 @ <th>Capabilities</th><td width="15">&nbsp;</td>
111 @ <th>Contact&nbsp;Info</th>
112 @ </tr>
113 db_prepare(&s, "SELECT uid, login, cap, info FROM user ORDER BY login");
114 while( db_step(&s)==SQLITE_ROW ){
115 @ <tr>
@@ -119,12 +119,13 @@
119 }
120 @ <nobr>%h(db_column_text(&s,1))</nobr>
121 if( g.okAdmin ){
122 @ </a>
123 }
124 @ </td><td>&nbsp;&nbsp;&nbsp;</td>
125 @ <td align="center">%s(db_column_text(&s,2))</td>
126 @ <td>&nbsp;&nbsp;&nbsp;</td>
127 @ <td align="left">%s(db_column_text(&s,3))</td>
128 @ </tr>
129 }
130 @ </table></td></tr></table>
131 @ <td valign="top">
@@ -452,13 +453,13 @@
453 db_set(zVar, iQ ? "1" : "0", 0);
454 iVal = iQ;
455 }
456 }
457 if( iVal ){
458 @ <input type="checkbox" name="%s(zQParm)" checked><b>%s(zLabel)</b></input>
459 }else{
460 @ <input type="checkbox" name="%s(zQParm)"><b>%s(zLabel)</b></input>
461 }
462 }
463
464 /*
465 ** Generate an entry box for an attribute.
@@ -475,11 +476,11 @@
476 if( zQ && strcmp(zQ,zVal)!=0 ){
477 db_set(zVar, zQ, 0);
478 zVal = zQ;
479 }
480 @ <input type="text" name="%s(zQParm)" value="%h(zVal)" size="%d(width)">
481 @ <b>%s(zLabel)</b>
482 }
483
484 /*
485 ** Generate a text box for an attribute.
486 */
@@ -497,11 +498,11 @@
498 db_set(zVar, zQ, 0);
499 z = zQ;
500 }
501 if( rows>0 && cols>0 ){
502 @ <textarea name="%s(zQP)" rows="%d(rows)" cols="%d(cols)">%h(z)</textarea>
503 @ <b>%s(zLabel)</b>
504 }
505 }
506
507
508 /*
@@ -601,10 +602,26 @@
602 textarea_attribute("Project Description", 5, 60,
603 "project-description", "pd", "");
604 @ <p>Describe your project. This will be used in page headers for search
605 @ engines as well as a short RSS description.</p>
606 @ <hr />
607 entry_attribute("Index Page", 60, "index-page", "idxpg", "/home");
608 @ <p>Enter the pathname of the page to display when the "Home" menu
609 @ option is selected and when no pathname is
610 @ specified in the URL. For example, if you visit the url:</p>
611 @
612 @ <blockquote>%h(g.zBaseURL)</blockquote>
613 @
614 @ <p>And you have specified an index page of "/home" the above will
615 @ automatically redirect to:</p>
616 @
617 @ <blockquote>%h(g.zBaseURL)/home</blockquote>
618 @
619 @ <p>The default "/home" page displays a Wiki page with the same name
620 @ as the Project Name specified above. Some sites prefer to redirect
621 @ to a documentation page (ex: "/doc/tip/index.wiki") or to "/timeline".</p>
622 @ <hr />
623 @ <p><input type="submit" name="submit" value="Apply Changes"></p>
624 @ </form>
625 db_end_transaction(0);
626 style_footer();
627 }
628
+2 -1
--- src/style.c
+++ src/style.c
@@ -81,10 +81,11 @@
8181
8282
/* Generate the header up through the main menu */
8383
Th_Store("project_name", db_get("project-name","Unnamed Fossil Project"));
8484
Th_Store("title", zTitle);
8585
Th_Store("baseurl", g.zBaseURL);
86
+ Th_Store("index_page", db_get("index-page","/home"));
8687
Th_Store("manifest_version", MANIFEST_VERSION);
8788
Th_Store("manifest_date", MANIFEST_DATE);
8889
if( g.zLogin ){
8990
Th_Store("login", g.zLogin);
9091
}
@@ -155,11 +156,11 @@
155156
@ puts "Not logged in"
156157
@ }
157158
@ </th1></nobr></div>
158159
@ </div>
159160
@ <div class="mainmenu"><th1>
160
-@ html "<a href='$baseurl/home'>Home</a>"
161
+@ html "<a href='$baseurl$index_page'>Home</a>"
161162
@ if {[hascap h]} {
162163
@ html "<a href='$baseurl/dir'>Files</a>"
163164
@ }
164165
@ if {[hascap o]} {
165166
@ html "<a href='$baseurl/leaves'>Leaves</a>"
166167
--- src/style.c
+++ src/style.c
@@ -81,10 +81,11 @@
81
82 /* Generate the header up through the main menu */
83 Th_Store("project_name", db_get("project-name","Unnamed Fossil Project"));
84 Th_Store("title", zTitle);
85 Th_Store("baseurl", g.zBaseURL);
 
86 Th_Store("manifest_version", MANIFEST_VERSION);
87 Th_Store("manifest_date", MANIFEST_DATE);
88 if( g.zLogin ){
89 Th_Store("login", g.zLogin);
90 }
@@ -155,11 +156,11 @@
155 @ puts "Not logged in"
156 @ }
157 @ </th1></nobr></div>
158 @ </div>
159 @ <div class="mainmenu"><th1>
160 @ html "<a href='$baseurl/home'>Home</a>"
161 @ if {[hascap h]} {
162 @ html "<a href='$baseurl/dir'>Files</a>"
163 @ }
164 @ if {[hascap o]} {
165 @ html "<a href='$baseurl/leaves'>Leaves</a>"
166
--- src/style.c
+++ src/style.c
@@ -81,10 +81,11 @@
81
82 /* Generate the header up through the main menu */
83 Th_Store("project_name", db_get("project-name","Unnamed Fossil Project"));
84 Th_Store("title", zTitle);
85 Th_Store("baseurl", g.zBaseURL);
86 Th_Store("index_page", db_get("index-page","/home"));
87 Th_Store("manifest_version", MANIFEST_VERSION);
88 Th_Store("manifest_date", MANIFEST_DATE);
89 if( g.zLogin ){
90 Th_Store("login", g.zLogin);
91 }
@@ -155,11 +156,11 @@
156 @ puts "Not logged in"
157 @ }
158 @ </th1></nobr></div>
159 @ </div>
160 @ <div class="mainmenu"><th1>
161 @ html "<a href='$baseurl$index_page'>Home</a>"
162 @ if {[hascap h]} {
163 @ html "<a href='$baseurl/dir'>Files</a>"
164 @ }
165 @ if {[hascap o]} {
166 @ html "<a href='$baseurl/leaves'>Leaves</a>"
167

Keyboard Shortcuts

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