Fossil SCM

Add the --mainmenu option to the various web interface commands, to override the main menu for testing purposes.

drh 2021-02-06 13:17 trunk merge
Commit 73ca280af9ec54ffd4f01b57de786bc9f8e0971e44e2b5f27c0c6cbc8ac86813
+27 -1
--- src/main.c
+++ src/main.c
@@ -210,10 +210,11 @@
210210
char javascriptHyperlink; /* If true, set href= using script, not HTML */
211211
Blob httpHeader; /* Complete text of the HTTP request header */
212212
UrlData url; /* Information about current URL */
213213
const char *zLogin; /* Login name. NULL or "" if not logged in. */
214214
const char *zCkoutAlias; /* doc/ uses this branch as an alias for "ckout" */
215
+ const char *zMainMenuFile; /* --mainmenu FILE from server/ui/cgi */
215216
const char *zSSLIdentity; /* Value of --ssl-identity option, filename of
216217
** SSL client identity */
217218
#if defined(_WIN32) && USE_SEE
218219
const char *zPidKey; /* Saved value of the --usepidkey option. Only
219220
* applicable when using SEE on Windows. */
@@ -2143,10 +2144,13 @@
21432144
** an unconditional redirect to URL is taken.
21442145
**
21452146
** jsmode: VALUE Specifies the delivery mode for JavaScript
21462147
** files. See the help text for the --jsmode
21472148
** flag of the http command.
2149
+**
2150
+** mainmenu: FILE Override the mainmenu config setting with the
2151
+** contents of the given file.
21482152
**
21492153
** Most CGI files contain only a "repository:" line. It is uncommon to
21502154
** use any other option.
21512155
**
21522156
** See also: [[http]], [[server]], [[winsrv]]
@@ -2333,10 +2337,21 @@
23332337
** requirements of any given page.
23342338
*/
23352339
builtin_set_js_delivery_mode(blob_str(&value),0);
23362340
blob_reset(&value);
23372341
continue;
2342
+ }
2343
+ if( blob_eq(&key, "mainmenu:") && blob_token(&line, &value) ){
2344
+ /* mainmenu: FILENAME
2345
+ **
2346
+ ** Use the contents of FILENAME as the value of the site's
2347
+ ** "mainmenu" setting, overriding the contents (for this
2348
+ ** request) of the db-side setting or the hard-coded default.
2349
+ */
2350
+ g.zMainMenuFile = mprintf("%s", blob_str(&value));
2351
+ blob_reset(&value);
2352
+ continue;
23382353
}
23392354
if( blob_eq(&key, "cgi-debug:") && blob_token(&line, &value) ){
23402355
/* cgi-debug: FILENAME
23412356
**
23422357
** Causes output from cgi_debug() and CGIDEBUG(()) calls to go
@@ -2544,10 +2559,12 @@
25442559
** --out FILE write results to FILE instead of to standard output
25452560
** --repolist If REPOSITORY is directory, URL "/" lists all repos
25462561
** --scgi Interpret input as SCGI rather than HTTP
25472562
** --skin LABEL Use override skin LABEL
25482563
** --th-trace trace TH1 execution (for debugging purposes)
2564
+** --mainmenu FILE Override the mainmenu config setting with the contents
2565
+** of the given file.
25492566
** --usepidkey Use saved encryption key from parent process. This is
25502567
** only necessary when using SEE on Windows.
25512568
**
25522569
** See also: [[cgi]], [[server]], [[winsrv]]
25532570
*/
@@ -2611,10 +2628,14 @@
26112628
zIpAddr = fossil_getenv("REMOTE_HOST"); /* From stunnel */
26122629
cgi_replace_parameter("HTTPS","on");
26132630
}
26142631
zHost = find_option("host", 0, 1);
26152632
if( zHost ) cgi_replace_parameter("HTTP_HOST",zHost);
2633
+ g.zMainMenuFile = find_option("mainmenu",0,1);
2634
+ if( g.zMainMenuFile!=0 && file_size(g.zMainMenuFile,ExtFILE)<0 ){
2635
+ fossil_fatal("Cannot read --mainmenu file %s", g.zMainMenuFile);
2636
+ }
26162637
26172638
/* We should be done with options.. */
26182639
verify_all_options();
26192640
26202641
if( g.argc!=2 && g.argc!=3 ) usage("?REPOSITORY?");
@@ -2797,10 +2818,12 @@
27972818
** -P|--port TCPPORT listen to request on port TCPPORT
27982819
** --th-trace trace TH1 execution (for debugging purposes)
27992820
** --repolist If REPOSITORY is dir, URL "/" lists repos.
28002821
** --scgi Accept SCGI rather than HTTP
28012822
** --skin LABEL Use override skin LABEL
2823
+** --mainmenu FILE Override the mainmenu config setting with the contents
2824
+** of the given file.
28022825
** --usepidkey Use saved encryption key from parent process. This is
28032826
** only necessary when using SEE on Windows.
28042827
**
28052828
** See also: [[cgi]], [[http]], [[winsrv]]
28062829
*/
@@ -2868,11 +2891,14 @@
28682891
}
28692892
if( find_option("localhost", 0, 0)!=0 ){
28702893
flags |= HTTP_SERVER_LOCALHOST;
28712894
}
28722895
g.zCkoutAlias = find_option("ckout-alias",0,1);
2873
-
2896
+ g.zMainMenuFile = find_option("mainmenu",0,1);
2897
+ if( g.zMainMenuFile!=0 && file_size(g.zMainMenuFile,ExtFILE)<0 ){
2898
+ fossil_fatal("Cannot read --mainmenu file %s", g.zMainMenuFile);
2899
+ }
28742900
/* We should be done with options.. */
28752901
verify_all_options();
28762902
28772903
if( g.argc!=2 && g.argc!=3 ) usage("?REPOSITORY?");
28782904
if( isUiCmd ){
28792905
--- src/main.c
+++ src/main.c
@@ -210,10 +210,11 @@
210 char javascriptHyperlink; /* If true, set href= using script, not HTML */
211 Blob httpHeader; /* Complete text of the HTTP request header */
212 UrlData url; /* Information about current URL */
213 const char *zLogin; /* Login name. NULL or "" if not logged in. */
214 const char *zCkoutAlias; /* doc/ uses this branch as an alias for "ckout" */
 
215 const char *zSSLIdentity; /* Value of --ssl-identity option, filename of
216 ** SSL client identity */
217 #if defined(_WIN32) && USE_SEE
218 const char *zPidKey; /* Saved value of the --usepidkey option. Only
219 * applicable when using SEE on Windows. */
@@ -2143,10 +2144,13 @@
2143 ** an unconditional redirect to URL is taken.
2144 **
2145 ** jsmode: VALUE Specifies the delivery mode for JavaScript
2146 ** files. See the help text for the --jsmode
2147 ** flag of the http command.
 
 
 
2148 **
2149 ** Most CGI files contain only a "repository:" line. It is uncommon to
2150 ** use any other option.
2151 **
2152 ** See also: [[http]], [[server]], [[winsrv]]
@@ -2333,10 +2337,21 @@
2333 ** requirements of any given page.
2334 */
2335 builtin_set_js_delivery_mode(blob_str(&value),0);
2336 blob_reset(&value);
2337 continue;
 
 
 
 
 
 
 
 
 
 
 
2338 }
2339 if( blob_eq(&key, "cgi-debug:") && blob_token(&line, &value) ){
2340 /* cgi-debug: FILENAME
2341 **
2342 ** Causes output from cgi_debug() and CGIDEBUG(()) calls to go
@@ -2544,10 +2559,12 @@
2544 ** --out FILE write results to FILE instead of to standard output
2545 ** --repolist If REPOSITORY is directory, URL "/" lists all repos
2546 ** --scgi Interpret input as SCGI rather than HTTP
2547 ** --skin LABEL Use override skin LABEL
2548 ** --th-trace trace TH1 execution (for debugging purposes)
 
 
2549 ** --usepidkey Use saved encryption key from parent process. This is
2550 ** only necessary when using SEE on Windows.
2551 **
2552 ** See also: [[cgi]], [[server]], [[winsrv]]
2553 */
@@ -2611,10 +2628,14 @@
2611 zIpAddr = fossil_getenv("REMOTE_HOST"); /* From stunnel */
2612 cgi_replace_parameter("HTTPS","on");
2613 }
2614 zHost = find_option("host", 0, 1);
2615 if( zHost ) cgi_replace_parameter("HTTP_HOST",zHost);
 
 
 
 
2616
2617 /* We should be done with options.. */
2618 verify_all_options();
2619
2620 if( g.argc!=2 && g.argc!=3 ) usage("?REPOSITORY?");
@@ -2797,10 +2818,12 @@
2797 ** -P|--port TCPPORT listen to request on port TCPPORT
2798 ** --th-trace trace TH1 execution (for debugging purposes)
2799 ** --repolist If REPOSITORY is dir, URL "/" lists repos.
2800 ** --scgi Accept SCGI rather than HTTP
2801 ** --skin LABEL Use override skin LABEL
 
 
2802 ** --usepidkey Use saved encryption key from parent process. This is
2803 ** only necessary when using SEE on Windows.
2804 **
2805 ** See also: [[cgi]], [[http]], [[winsrv]]
2806 */
@@ -2868,11 +2891,14 @@
2868 }
2869 if( find_option("localhost", 0, 0)!=0 ){
2870 flags |= HTTP_SERVER_LOCALHOST;
2871 }
2872 g.zCkoutAlias = find_option("ckout-alias",0,1);
2873
 
 
 
2874 /* We should be done with options.. */
2875 verify_all_options();
2876
2877 if( g.argc!=2 && g.argc!=3 ) usage("?REPOSITORY?");
2878 if( isUiCmd ){
2879
--- src/main.c
+++ src/main.c
@@ -210,10 +210,11 @@
210 char javascriptHyperlink; /* If true, set href= using script, not HTML */
211 Blob httpHeader; /* Complete text of the HTTP request header */
212 UrlData url; /* Information about current URL */
213 const char *zLogin; /* Login name. NULL or "" if not logged in. */
214 const char *zCkoutAlias; /* doc/ uses this branch as an alias for "ckout" */
215 const char *zMainMenuFile; /* --mainmenu FILE from server/ui/cgi */
216 const char *zSSLIdentity; /* Value of --ssl-identity option, filename of
217 ** SSL client identity */
218 #if defined(_WIN32) && USE_SEE
219 const char *zPidKey; /* Saved value of the --usepidkey option. Only
220 * applicable when using SEE on Windows. */
@@ -2143,10 +2144,13 @@
2144 ** an unconditional redirect to URL is taken.
2145 **
2146 ** jsmode: VALUE Specifies the delivery mode for JavaScript
2147 ** files. See the help text for the --jsmode
2148 ** flag of the http command.
2149 **
2150 ** mainmenu: FILE Override the mainmenu config setting with the
2151 ** contents of the given file.
2152 **
2153 ** Most CGI files contain only a "repository:" line. It is uncommon to
2154 ** use any other option.
2155 **
2156 ** See also: [[http]], [[server]], [[winsrv]]
@@ -2333,10 +2337,21 @@
2337 ** requirements of any given page.
2338 */
2339 builtin_set_js_delivery_mode(blob_str(&value),0);
2340 blob_reset(&value);
2341 continue;
2342 }
2343 if( blob_eq(&key, "mainmenu:") && blob_token(&line, &value) ){
2344 /* mainmenu: FILENAME
2345 **
2346 ** Use the contents of FILENAME as the value of the site's
2347 ** "mainmenu" setting, overriding the contents (for this
2348 ** request) of the db-side setting or the hard-coded default.
2349 */
2350 g.zMainMenuFile = mprintf("%s", blob_str(&value));
2351 blob_reset(&value);
2352 continue;
2353 }
2354 if( blob_eq(&key, "cgi-debug:") && blob_token(&line, &value) ){
2355 /* cgi-debug: FILENAME
2356 **
2357 ** Causes output from cgi_debug() and CGIDEBUG(()) calls to go
@@ -2544,10 +2559,12 @@
2559 ** --out FILE write results to FILE instead of to standard output
2560 ** --repolist If REPOSITORY is directory, URL "/" lists all repos
2561 ** --scgi Interpret input as SCGI rather than HTTP
2562 ** --skin LABEL Use override skin LABEL
2563 ** --th-trace trace TH1 execution (for debugging purposes)
2564 ** --mainmenu FILE Override the mainmenu config setting with the contents
2565 ** of the given file.
2566 ** --usepidkey Use saved encryption key from parent process. This is
2567 ** only necessary when using SEE on Windows.
2568 **
2569 ** See also: [[cgi]], [[server]], [[winsrv]]
2570 */
@@ -2611,10 +2628,14 @@
2628 zIpAddr = fossil_getenv("REMOTE_HOST"); /* From stunnel */
2629 cgi_replace_parameter("HTTPS","on");
2630 }
2631 zHost = find_option("host", 0, 1);
2632 if( zHost ) cgi_replace_parameter("HTTP_HOST",zHost);
2633 g.zMainMenuFile = find_option("mainmenu",0,1);
2634 if( g.zMainMenuFile!=0 && file_size(g.zMainMenuFile,ExtFILE)<0 ){
2635 fossil_fatal("Cannot read --mainmenu file %s", g.zMainMenuFile);
2636 }
2637
2638 /* We should be done with options.. */
2639 verify_all_options();
2640
2641 if( g.argc!=2 && g.argc!=3 ) usage("?REPOSITORY?");
@@ -2797,10 +2818,12 @@
2818 ** -P|--port TCPPORT listen to request on port TCPPORT
2819 ** --th-trace trace TH1 execution (for debugging purposes)
2820 ** --repolist If REPOSITORY is dir, URL "/" lists repos.
2821 ** --scgi Accept SCGI rather than HTTP
2822 ** --skin LABEL Use override skin LABEL
2823 ** --mainmenu FILE Override the mainmenu config setting with the contents
2824 ** of the given file.
2825 ** --usepidkey Use saved encryption key from parent process. This is
2826 ** only necessary when using SEE on Windows.
2827 **
2828 ** See also: [[cgi]], [[http]], [[winsrv]]
2829 */
@@ -2868,11 +2891,14 @@
2891 }
2892 if( find_option("localhost", 0, 0)!=0 ){
2893 flags |= HTTP_SERVER_LOCALHOST;
2894 }
2895 g.zCkoutAlias = find_option("ckout-alias",0,1);
2896 g.zMainMenuFile = find_option("mainmenu",0,1);
2897 if( g.zMainMenuFile!=0 && file_size(g.zMainMenuFile,ExtFILE)<0 ){
2898 fossil_fatal("Cannot read --mainmenu file %s", g.zMainMenuFile);
2899 }
2900 /* We should be done with options.. */
2901 verify_all_options();
2902
2903 if( g.argc!=2 && g.argc!=3 ) usage("?REPOSITORY?");
2904 if( isUiCmd ){
2905
+27 -1
--- src/main.c
+++ src/main.c
@@ -210,10 +210,11 @@
210210
char javascriptHyperlink; /* If true, set href= using script, not HTML */
211211
Blob httpHeader; /* Complete text of the HTTP request header */
212212
UrlData url; /* Information about current URL */
213213
const char *zLogin; /* Login name. NULL or "" if not logged in. */
214214
const char *zCkoutAlias; /* doc/ uses this branch as an alias for "ckout" */
215
+ const char *zMainMenuFile; /* --mainmenu FILE from server/ui/cgi */
215216
const char *zSSLIdentity; /* Value of --ssl-identity option, filename of
216217
** SSL client identity */
217218
#if defined(_WIN32) && USE_SEE
218219
const char *zPidKey; /* Saved value of the --usepidkey option. Only
219220
* applicable when using SEE on Windows. */
@@ -2143,10 +2144,13 @@
21432144
** an unconditional redirect to URL is taken.
21442145
**
21452146
** jsmode: VALUE Specifies the delivery mode for JavaScript
21462147
** files. See the help text for the --jsmode
21472148
** flag of the http command.
2149
+**
2150
+** mainmenu: FILE Override the mainmenu config setting with the
2151
+** contents of the given file.
21482152
**
21492153
** Most CGI files contain only a "repository:" line. It is uncommon to
21502154
** use any other option.
21512155
**
21522156
** See also: [[http]], [[server]], [[winsrv]]
@@ -2333,10 +2337,21 @@
23332337
** requirements of any given page.
23342338
*/
23352339
builtin_set_js_delivery_mode(blob_str(&value),0);
23362340
blob_reset(&value);
23372341
continue;
2342
+ }
2343
+ if( blob_eq(&key, "mainmenu:") && blob_token(&line, &value) ){
2344
+ /* mainmenu: FILENAME
2345
+ **
2346
+ ** Use the contents of FILENAME as the value of the site's
2347
+ ** "mainmenu" setting, overriding the contents (for this
2348
+ ** request) of the db-side setting or the hard-coded default.
2349
+ */
2350
+ g.zMainMenuFile = mprintf("%s", blob_str(&value));
2351
+ blob_reset(&value);
2352
+ continue;
23382353
}
23392354
if( blob_eq(&key, "cgi-debug:") && blob_token(&line, &value) ){
23402355
/* cgi-debug: FILENAME
23412356
**
23422357
** Causes output from cgi_debug() and CGIDEBUG(()) calls to go
@@ -2544,10 +2559,12 @@
25442559
** --out FILE write results to FILE instead of to standard output
25452560
** --repolist If REPOSITORY is directory, URL "/" lists all repos
25462561
** --scgi Interpret input as SCGI rather than HTTP
25472562
** --skin LABEL Use override skin LABEL
25482563
** --th-trace trace TH1 execution (for debugging purposes)
2564
+** --mainmenu FILE Override the mainmenu config setting with the contents
2565
+** of the given file.
25492566
** --usepidkey Use saved encryption key from parent process. This is
25502567
** only necessary when using SEE on Windows.
25512568
**
25522569
** See also: [[cgi]], [[server]], [[winsrv]]
25532570
*/
@@ -2611,10 +2628,14 @@
26112628
zIpAddr = fossil_getenv("REMOTE_HOST"); /* From stunnel */
26122629
cgi_replace_parameter("HTTPS","on");
26132630
}
26142631
zHost = find_option("host", 0, 1);
26152632
if( zHost ) cgi_replace_parameter("HTTP_HOST",zHost);
2633
+ g.zMainMenuFile = find_option("mainmenu",0,1);
2634
+ if( g.zMainMenuFile!=0 && file_size(g.zMainMenuFile,ExtFILE)<0 ){
2635
+ fossil_fatal("Cannot read --mainmenu file %s", g.zMainMenuFile);
2636
+ }
26162637
26172638
/* We should be done with options.. */
26182639
verify_all_options();
26192640
26202641
if( g.argc!=2 && g.argc!=3 ) usage("?REPOSITORY?");
@@ -2797,10 +2818,12 @@
27972818
** -P|--port TCPPORT listen to request on port TCPPORT
27982819
** --th-trace trace TH1 execution (for debugging purposes)
27992820
** --repolist If REPOSITORY is dir, URL "/" lists repos.
28002821
** --scgi Accept SCGI rather than HTTP
28012822
** --skin LABEL Use override skin LABEL
2823
+** --mainmenu FILE Override the mainmenu config setting with the contents
2824
+** of the given file.
28022825
** --usepidkey Use saved encryption key from parent process. This is
28032826
** only necessary when using SEE on Windows.
28042827
**
28052828
** See also: [[cgi]], [[http]], [[winsrv]]
28062829
*/
@@ -2868,11 +2891,14 @@
28682891
}
28692892
if( find_option("localhost", 0, 0)!=0 ){
28702893
flags |= HTTP_SERVER_LOCALHOST;
28712894
}
28722895
g.zCkoutAlias = find_option("ckout-alias",0,1);
2873
-
2896
+ g.zMainMenuFile = find_option("mainmenu",0,1);
2897
+ if( g.zMainMenuFile!=0 && file_size(g.zMainMenuFile,ExtFILE)<0 ){
2898
+ fossil_fatal("Cannot read --mainmenu file %s", g.zMainMenuFile);
2899
+ }
28742900
/* We should be done with options.. */
28752901
verify_all_options();
28762902
28772903
if( g.argc!=2 && g.argc!=3 ) usage("?REPOSITORY?");
28782904
if( isUiCmd ){
28792905
--- src/main.c
+++ src/main.c
@@ -210,10 +210,11 @@
210 char javascriptHyperlink; /* If true, set href= using script, not HTML */
211 Blob httpHeader; /* Complete text of the HTTP request header */
212 UrlData url; /* Information about current URL */
213 const char *zLogin; /* Login name. NULL or "" if not logged in. */
214 const char *zCkoutAlias; /* doc/ uses this branch as an alias for "ckout" */
 
215 const char *zSSLIdentity; /* Value of --ssl-identity option, filename of
216 ** SSL client identity */
217 #if defined(_WIN32) && USE_SEE
218 const char *zPidKey; /* Saved value of the --usepidkey option. Only
219 * applicable when using SEE on Windows. */
@@ -2143,10 +2144,13 @@
2143 ** an unconditional redirect to URL is taken.
2144 **
2145 ** jsmode: VALUE Specifies the delivery mode for JavaScript
2146 ** files. See the help text for the --jsmode
2147 ** flag of the http command.
 
 
 
2148 **
2149 ** Most CGI files contain only a "repository:" line. It is uncommon to
2150 ** use any other option.
2151 **
2152 ** See also: [[http]], [[server]], [[winsrv]]
@@ -2333,10 +2337,21 @@
2333 ** requirements of any given page.
2334 */
2335 builtin_set_js_delivery_mode(blob_str(&value),0);
2336 blob_reset(&value);
2337 continue;
 
 
 
 
 
 
 
 
 
 
 
2338 }
2339 if( blob_eq(&key, "cgi-debug:") && blob_token(&line, &value) ){
2340 /* cgi-debug: FILENAME
2341 **
2342 ** Causes output from cgi_debug() and CGIDEBUG(()) calls to go
@@ -2544,10 +2559,12 @@
2544 ** --out FILE write results to FILE instead of to standard output
2545 ** --repolist If REPOSITORY is directory, URL "/" lists all repos
2546 ** --scgi Interpret input as SCGI rather than HTTP
2547 ** --skin LABEL Use override skin LABEL
2548 ** --th-trace trace TH1 execution (for debugging purposes)
 
 
2549 ** --usepidkey Use saved encryption key from parent process. This is
2550 ** only necessary when using SEE on Windows.
2551 **
2552 ** See also: [[cgi]], [[server]], [[winsrv]]
2553 */
@@ -2611,10 +2628,14 @@
2611 zIpAddr = fossil_getenv("REMOTE_HOST"); /* From stunnel */
2612 cgi_replace_parameter("HTTPS","on");
2613 }
2614 zHost = find_option("host", 0, 1);
2615 if( zHost ) cgi_replace_parameter("HTTP_HOST",zHost);
 
 
 
 
2616
2617 /* We should be done with options.. */
2618 verify_all_options();
2619
2620 if( g.argc!=2 && g.argc!=3 ) usage("?REPOSITORY?");
@@ -2797,10 +2818,12 @@
2797 ** -P|--port TCPPORT listen to request on port TCPPORT
2798 ** --th-trace trace TH1 execution (for debugging purposes)
2799 ** --repolist If REPOSITORY is dir, URL "/" lists repos.
2800 ** --scgi Accept SCGI rather than HTTP
2801 ** --skin LABEL Use override skin LABEL
 
 
2802 ** --usepidkey Use saved encryption key from parent process. This is
2803 ** only necessary when using SEE on Windows.
2804 **
2805 ** See also: [[cgi]], [[http]], [[winsrv]]
2806 */
@@ -2868,11 +2891,14 @@
2868 }
2869 if( find_option("localhost", 0, 0)!=0 ){
2870 flags |= HTTP_SERVER_LOCALHOST;
2871 }
2872 g.zCkoutAlias = find_option("ckout-alias",0,1);
2873
 
 
 
2874 /* We should be done with options.. */
2875 verify_all_options();
2876
2877 if( g.argc!=2 && g.argc!=3 ) usage("?REPOSITORY?");
2878 if( isUiCmd ){
2879
--- src/main.c
+++ src/main.c
@@ -210,10 +210,11 @@
210 char javascriptHyperlink; /* If true, set href= using script, not HTML */
211 Blob httpHeader; /* Complete text of the HTTP request header */
212 UrlData url; /* Information about current URL */
213 const char *zLogin; /* Login name. NULL or "" if not logged in. */
214 const char *zCkoutAlias; /* doc/ uses this branch as an alias for "ckout" */
215 const char *zMainMenuFile; /* --mainmenu FILE from server/ui/cgi */
216 const char *zSSLIdentity; /* Value of --ssl-identity option, filename of
217 ** SSL client identity */
218 #if defined(_WIN32) && USE_SEE
219 const char *zPidKey; /* Saved value of the --usepidkey option. Only
220 * applicable when using SEE on Windows. */
@@ -2143,10 +2144,13 @@
2144 ** an unconditional redirect to URL is taken.
2145 **
2146 ** jsmode: VALUE Specifies the delivery mode for JavaScript
2147 ** files. See the help text for the --jsmode
2148 ** flag of the http command.
2149 **
2150 ** mainmenu: FILE Override the mainmenu config setting with the
2151 ** contents of the given file.
2152 **
2153 ** Most CGI files contain only a "repository:" line. It is uncommon to
2154 ** use any other option.
2155 **
2156 ** See also: [[http]], [[server]], [[winsrv]]
@@ -2333,10 +2337,21 @@
2337 ** requirements of any given page.
2338 */
2339 builtin_set_js_delivery_mode(blob_str(&value),0);
2340 blob_reset(&value);
2341 continue;
2342 }
2343 if( blob_eq(&key, "mainmenu:") && blob_token(&line, &value) ){
2344 /* mainmenu: FILENAME
2345 **
2346 ** Use the contents of FILENAME as the value of the site's
2347 ** "mainmenu" setting, overriding the contents (for this
2348 ** request) of the db-side setting or the hard-coded default.
2349 */
2350 g.zMainMenuFile = mprintf("%s", blob_str(&value));
2351 blob_reset(&value);
2352 continue;
2353 }
2354 if( blob_eq(&key, "cgi-debug:") && blob_token(&line, &value) ){
2355 /* cgi-debug: FILENAME
2356 **
2357 ** Causes output from cgi_debug() and CGIDEBUG(()) calls to go
@@ -2544,10 +2559,12 @@
2559 ** --out FILE write results to FILE instead of to standard output
2560 ** --repolist If REPOSITORY is directory, URL "/" lists all repos
2561 ** --scgi Interpret input as SCGI rather than HTTP
2562 ** --skin LABEL Use override skin LABEL
2563 ** --th-trace trace TH1 execution (for debugging purposes)
2564 ** --mainmenu FILE Override the mainmenu config setting with the contents
2565 ** of the given file.
2566 ** --usepidkey Use saved encryption key from parent process. This is
2567 ** only necessary when using SEE on Windows.
2568 **
2569 ** See also: [[cgi]], [[server]], [[winsrv]]
2570 */
@@ -2611,10 +2628,14 @@
2628 zIpAddr = fossil_getenv("REMOTE_HOST"); /* From stunnel */
2629 cgi_replace_parameter("HTTPS","on");
2630 }
2631 zHost = find_option("host", 0, 1);
2632 if( zHost ) cgi_replace_parameter("HTTP_HOST",zHost);
2633 g.zMainMenuFile = find_option("mainmenu",0,1);
2634 if( g.zMainMenuFile!=0 && file_size(g.zMainMenuFile,ExtFILE)<0 ){
2635 fossil_fatal("Cannot read --mainmenu file %s", g.zMainMenuFile);
2636 }
2637
2638 /* We should be done with options.. */
2639 verify_all_options();
2640
2641 if( g.argc!=2 && g.argc!=3 ) usage("?REPOSITORY?");
@@ -2797,10 +2818,12 @@
2818 ** -P|--port TCPPORT listen to request on port TCPPORT
2819 ** --th-trace trace TH1 execution (for debugging purposes)
2820 ** --repolist If REPOSITORY is dir, URL "/" lists repos.
2821 ** --scgi Accept SCGI rather than HTTP
2822 ** --skin LABEL Use override skin LABEL
2823 ** --mainmenu FILE Override the mainmenu config setting with the contents
2824 ** of the given file.
2825 ** --usepidkey Use saved encryption key from parent process. This is
2826 ** only necessary when using SEE on Windows.
2827 **
2828 ** See also: [[cgi]], [[http]], [[winsrv]]
2829 */
@@ -2868,11 +2891,14 @@
2891 }
2892 if( find_option("localhost", 0, 0)!=0 ){
2893 flags |= HTTP_SERVER_LOCALHOST;
2894 }
2895 g.zCkoutAlias = find_option("ckout-alias",0,1);
2896 g.zMainMenuFile = find_option("mainmenu",0,1);
2897 if( g.zMainMenuFile!=0 && file_size(g.zMainMenuFile,ExtFILE)<0 ){
2898 fossil_fatal("Cannot read --mainmenu file %s", g.zMainMenuFile);
2899 }
2900 /* We should be done with options.. */
2901 verify_all_options();
2902
2903 if( g.argc!=2 && g.argc!=3 ) usage("?REPOSITORY?");
2904 if( isUiCmd ){
2905
+21 -1
--- src/style.c
+++ src/style.c
@@ -651,10 +651,30 @@
651651
** to override that "maybe" default with something better.
652652
*/
653653
void style_set_current_feature(const char* zFeature){
654654
Th_Store("current_feature", zFeature);
655655
}
656
+
657
+/*
658
+** Returns the current mainmenu value from either the --mainmenu flag
659
+** (handled by the server/ui/cgi commands), the "mainmenu" config
660
+** setting, or style_default_mainmenu(), in that order, returning the
661
+** first of those which is defined.
662
+*/
663
+const char*style_get_mainmenu(){
664
+ static const char *zMenu = 0;
665
+ if(!zMenu){
666
+ if(g.zMainMenuFile){
667
+ Blob b = empty_blob;
668
+ blob_read_from_file(&b, g.zMainMenuFile, ExtFILE);
669
+ zMenu = blob_str(&b);
670
+ }else{
671
+ zMenu = db_get("mainmenu", style_default_mainmenu());
672
+ }
673
+ }
674
+ return zMenu;
675
+}
656676
657677
/*
658678
** Initialize all the default TH1 variables
659679
*/
660680
static void style_init_th1_vars(const char *zTitle){
@@ -682,11 +702,11 @@
682702
Th_Store("csrf_token", g.zCsrfToken);
683703
Th_Store("release_version", RELEASE_VERSION);
684704
Th_Store("manifest_version", MANIFEST_VERSION);
685705
Th_Store("manifest_date", MANIFEST_DATE);
686706
Th_Store("compiler_name", COMPILER_NAME);
687
- Th_Store("mainmenu", db_get("mainmenu", style_default_mainmenu()));
707
+ Th_Store("mainmenu", style_get_mainmenu());
688708
url_var("stylesheet", "css", "style.css");
689709
image_url_var("logo");
690710
image_url_var("background");
691711
if( !login_is_nobody() ){
692712
Th_Store("login", g.zLogin);
693713
--- src/style.c
+++ src/style.c
@@ -651,10 +651,30 @@
651 ** to override that "maybe" default with something better.
652 */
653 void style_set_current_feature(const char* zFeature){
654 Th_Store("current_feature", zFeature);
655 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
656
657 /*
658 ** Initialize all the default TH1 variables
659 */
660 static void style_init_th1_vars(const char *zTitle){
@@ -682,11 +702,11 @@
682 Th_Store("csrf_token", g.zCsrfToken);
683 Th_Store("release_version", RELEASE_VERSION);
684 Th_Store("manifest_version", MANIFEST_VERSION);
685 Th_Store("manifest_date", MANIFEST_DATE);
686 Th_Store("compiler_name", COMPILER_NAME);
687 Th_Store("mainmenu", db_get("mainmenu", style_default_mainmenu()));
688 url_var("stylesheet", "css", "style.css");
689 image_url_var("logo");
690 image_url_var("background");
691 if( !login_is_nobody() ){
692 Th_Store("login", g.zLogin);
693
--- src/style.c
+++ src/style.c
@@ -651,10 +651,30 @@
651 ** to override that "maybe" default with something better.
652 */
653 void style_set_current_feature(const char* zFeature){
654 Th_Store("current_feature", zFeature);
655 }
656
657 /*
658 ** Returns the current mainmenu value from either the --mainmenu flag
659 ** (handled by the server/ui/cgi commands), the "mainmenu" config
660 ** setting, or style_default_mainmenu(), in that order, returning the
661 ** first of those which is defined.
662 */
663 const char*style_get_mainmenu(){
664 static const char *zMenu = 0;
665 if(!zMenu){
666 if(g.zMainMenuFile){
667 Blob b = empty_blob;
668 blob_read_from_file(&b, g.zMainMenuFile, ExtFILE);
669 zMenu = blob_str(&b);
670 }else{
671 zMenu = db_get("mainmenu", style_default_mainmenu());
672 }
673 }
674 return zMenu;
675 }
676
677 /*
678 ** Initialize all the default TH1 variables
679 */
680 static void style_init_th1_vars(const char *zTitle){
@@ -682,11 +702,11 @@
702 Th_Store("csrf_token", g.zCsrfToken);
703 Th_Store("release_version", RELEASE_VERSION);
704 Th_Store("manifest_version", MANIFEST_VERSION);
705 Th_Store("manifest_date", MANIFEST_DATE);
706 Th_Store("compiler_name", COMPILER_NAME);
707 Th_Store("mainmenu", style_get_mainmenu());
708 url_var("stylesheet", "css", "style.css");
709 image_url_var("logo");
710 image_url_var("background");
711 if( !login_is_nobody() ){
712 Th_Store("login", g.zLogin);
713
--- src/winhttp.c
+++ src/winhttp.c
@@ -570,10 +570,14 @@
570570
}
571571
zSkin = skin_in_use();
572572
if( zSkin ){
573573
blob_appendf(&options, " --skin %s", zSkin);
574574
}
575
+ if( g.zMainMenuFile ){
576
+ blob_appendf(&options, " --mainmenu ");
577
+ blob_append_escaped_arg(&options, g.zMainMenuFile);
578
+ }
575579
#if USE_SEE
576580
zSavedKey = db_get_saved_encryption_key();
577581
savedKeySize = db_get_saved_encryption_key_size();
578582
if( zSavedKey!=0 && savedKeySize>0 ){
579583
blob_appendf(&options, " --usepidkey %lu:%p:%u", GetCurrentProcessId(),
580584
--- src/winhttp.c
+++ src/winhttp.c
@@ -570,10 +570,14 @@
570 }
571 zSkin = skin_in_use();
572 if( zSkin ){
573 blob_appendf(&options, " --skin %s", zSkin);
574 }
 
 
 
 
575 #if USE_SEE
576 zSavedKey = db_get_saved_encryption_key();
577 savedKeySize = db_get_saved_encryption_key_size();
578 if( zSavedKey!=0 && savedKeySize>0 ){
579 blob_appendf(&options, " --usepidkey %lu:%p:%u", GetCurrentProcessId(),
580
--- src/winhttp.c
+++ src/winhttp.c
@@ -570,10 +570,14 @@
570 }
571 zSkin = skin_in_use();
572 if( zSkin ){
573 blob_appendf(&options, " --skin %s", zSkin);
574 }
575 if( g.zMainMenuFile ){
576 blob_appendf(&options, " --mainmenu ");
577 blob_append_escaped_arg(&options, g.zMainMenuFile);
578 }
579 #if USE_SEE
580 zSavedKey = db_get_saved_encryption_key();
581 savedKeySize = db_get_saved_encryption_key_size();
582 if( zSavedKey!=0 && savedKeySize>0 ){
583 blob_appendf(&options, " --usepidkey %lu:%p:%u", GetCurrentProcessId(),
584
+11
--- www/cgi.wiki
+++ www/cgi.wiki
@@ -135,10 +135,21 @@
135135
This parameter can be repeated as many times as necessary.
136136
137137
<h2 id="HOME">HOME: <i>PATH</i></h2>
138138
139139
This parameter is a short-hand for "<b>setenv HOME <i>PATH</i></b>".
140
+
141
+<h2 id="mainmenu">mainmenu: <i>FILE</i></h2>
142
+
143
+This parameter causes the contents of the given file to override the
144
+site's <tt>mainmenu</tt> configuration setting, much in the same way
145
+that the <tt>skin</tt> setting overrides the skin. This can be used to
146
+apply a common main menu to a number of sites, and centrally maintain
147
+it, without having to copy its contents into each site. Note, however,
148
+that the contents of this setting are not stored in the repository and
149
+will not be cloned along with the repository.
150
+
140151
141152
<h2 id="cgi-debug">cgi-debug: <i>FILE</i></h2>
142153
143154
Cause CGI-related debugging information to be appended in <i>FILE</i>. Use
144155
this to help debug CGI problems.
145156
--- www/cgi.wiki
+++ www/cgi.wiki
@@ -135,10 +135,21 @@
135 This parameter can be repeated as many times as necessary.
136
137 <h2 id="HOME">HOME: <i>PATH</i></h2>
138
139 This parameter is a short-hand for "<b>setenv HOME <i>PATH</i></b>".
 
 
 
 
 
 
 
 
 
 
 
140
141 <h2 id="cgi-debug">cgi-debug: <i>FILE</i></h2>
142
143 Cause CGI-related debugging information to be appended in <i>FILE</i>. Use
144 this to help debug CGI problems.
145
--- www/cgi.wiki
+++ www/cgi.wiki
@@ -135,10 +135,21 @@
135 This parameter can be repeated as many times as necessary.
136
137 <h2 id="HOME">HOME: <i>PATH</i></h2>
138
139 This parameter is a short-hand for "<b>setenv HOME <i>PATH</i></b>".
140
141 <h2 id="mainmenu">mainmenu: <i>FILE</i></h2>
142
143 This parameter causes the contents of the given file to override the
144 site's <tt>mainmenu</tt> configuration setting, much in the same way
145 that the <tt>skin</tt> setting overrides the skin. This can be used to
146 apply a common main menu to a number of sites, and centrally maintain
147 it, without having to copy its contents into each site. Note, however,
148 that the contents of this setting are not stored in the repository and
149 will not be cloned along with the repository.
150
151
152 <h2 id="cgi-debug">cgi-debug: <i>FILE</i></h2>
153
154 Cause CGI-related debugging information to be appended in <i>FILE</i>. Use
155 this to help debug CGI problems.
156

Keyboard Shortcuts

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