Fossil SCM
Add the --mainmenu option to the various web interface commands, to override the main menu for testing purposes.
Commit
73ca280af9ec54ffd4f01b57de786bc9f8e0971e44e2b5f27c0c6cbc8ac86813
Parent
3c8831ec47cef55…
5 files changed
+27
-1
+27
-1
+21
-1
+4
+11
+27
-1
| --- src/main.c | ||
| +++ src/main.c | ||
| @@ -210,10 +210,11 @@ | ||
| 210 | 210 | char javascriptHyperlink; /* If true, set href= using script, not HTML */ |
| 211 | 211 | Blob httpHeader; /* Complete text of the HTTP request header */ |
| 212 | 212 | UrlData url; /* Information about current URL */ |
| 213 | 213 | const char *zLogin; /* Login name. NULL or "" if not logged in. */ |
| 214 | 214 | const char *zCkoutAlias; /* doc/ uses this branch as an alias for "ckout" */ |
| 215 | + const char *zMainMenuFile; /* --mainmenu FILE from server/ui/cgi */ | |
| 215 | 216 | const char *zSSLIdentity; /* Value of --ssl-identity option, filename of |
| 216 | 217 | ** SSL client identity */ |
| 217 | 218 | #if defined(_WIN32) && USE_SEE |
| 218 | 219 | const char *zPidKey; /* Saved value of the --usepidkey option. Only |
| 219 | 220 | * applicable when using SEE on Windows. */ |
| @@ -2143,10 +2144,13 @@ | ||
| 2143 | 2144 | ** an unconditional redirect to URL is taken. |
| 2144 | 2145 | ** |
| 2145 | 2146 | ** jsmode: VALUE Specifies the delivery mode for JavaScript |
| 2146 | 2147 | ** files. See the help text for the --jsmode |
| 2147 | 2148 | ** flag of the http command. |
| 2149 | +** | |
| 2150 | +** mainmenu: FILE Override the mainmenu config setting with the | |
| 2151 | +** contents of the given file. | |
| 2148 | 2152 | ** |
| 2149 | 2153 | ** Most CGI files contain only a "repository:" line. It is uncommon to |
| 2150 | 2154 | ** use any other option. |
| 2151 | 2155 | ** |
| 2152 | 2156 | ** See also: [[http]], [[server]], [[winsrv]] |
| @@ -2333,10 +2337,21 @@ | ||
| 2333 | 2337 | ** requirements of any given page. |
| 2334 | 2338 | */ |
| 2335 | 2339 | builtin_set_js_delivery_mode(blob_str(&value),0); |
| 2336 | 2340 | blob_reset(&value); |
| 2337 | 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; | |
| 2338 | 2353 | } |
| 2339 | 2354 | if( blob_eq(&key, "cgi-debug:") && blob_token(&line, &value) ){ |
| 2340 | 2355 | /* cgi-debug: FILENAME |
| 2341 | 2356 | ** |
| 2342 | 2357 | ** Causes output from cgi_debug() and CGIDEBUG(()) calls to go |
| @@ -2544,10 +2559,12 @@ | ||
| 2544 | 2559 | ** --out FILE write results to FILE instead of to standard output |
| 2545 | 2560 | ** --repolist If REPOSITORY is directory, URL "/" lists all repos |
| 2546 | 2561 | ** --scgi Interpret input as SCGI rather than HTTP |
| 2547 | 2562 | ** --skin LABEL Use override skin LABEL |
| 2548 | 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. | |
| 2549 | 2566 | ** --usepidkey Use saved encryption key from parent process. This is |
| 2550 | 2567 | ** only necessary when using SEE on Windows. |
| 2551 | 2568 | ** |
| 2552 | 2569 | ** See also: [[cgi]], [[server]], [[winsrv]] |
| 2553 | 2570 | */ |
| @@ -2611,10 +2628,14 @@ | ||
| 2611 | 2628 | zIpAddr = fossil_getenv("REMOTE_HOST"); /* From stunnel */ |
| 2612 | 2629 | cgi_replace_parameter("HTTPS","on"); |
| 2613 | 2630 | } |
| 2614 | 2631 | zHost = find_option("host", 0, 1); |
| 2615 | 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 | + } | |
| 2616 | 2637 | |
| 2617 | 2638 | /* We should be done with options.. */ |
| 2618 | 2639 | verify_all_options(); |
| 2619 | 2640 | |
| 2620 | 2641 | if( g.argc!=2 && g.argc!=3 ) usage("?REPOSITORY?"); |
| @@ -2797,10 +2818,12 @@ | ||
| 2797 | 2818 | ** -P|--port TCPPORT listen to request on port TCPPORT |
| 2798 | 2819 | ** --th-trace trace TH1 execution (for debugging purposes) |
| 2799 | 2820 | ** --repolist If REPOSITORY is dir, URL "/" lists repos. |
| 2800 | 2821 | ** --scgi Accept SCGI rather than HTTP |
| 2801 | 2822 | ** --skin LABEL Use override skin LABEL |
| 2823 | +** --mainmenu FILE Override the mainmenu config setting with the contents | |
| 2824 | +** of the given file. | |
| 2802 | 2825 | ** --usepidkey Use saved encryption key from parent process. This is |
| 2803 | 2826 | ** only necessary when using SEE on Windows. |
| 2804 | 2827 | ** |
| 2805 | 2828 | ** See also: [[cgi]], [[http]], [[winsrv]] |
| 2806 | 2829 | */ |
| @@ -2868,11 +2891,14 @@ | ||
| 2868 | 2891 | } |
| 2869 | 2892 | if( find_option("localhost", 0, 0)!=0 ){ |
| 2870 | 2893 | flags |= HTTP_SERVER_LOCALHOST; |
| 2871 | 2894 | } |
| 2872 | 2895 | 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 | + } | |
| 2874 | 2900 | /* We should be done with options.. */ |
| 2875 | 2901 | verify_all_options(); |
| 2876 | 2902 | |
| 2877 | 2903 | if( g.argc!=2 && g.argc!=3 ) usage("?REPOSITORY?"); |
| 2878 | 2904 | if( isUiCmd ){ |
| 2879 | 2905 |
| --- 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 @@ | ||
| 210 | 210 | char javascriptHyperlink; /* If true, set href= using script, not HTML */ |
| 211 | 211 | Blob httpHeader; /* Complete text of the HTTP request header */ |
| 212 | 212 | UrlData url; /* Information about current URL */ |
| 213 | 213 | const char *zLogin; /* Login name. NULL or "" if not logged in. */ |
| 214 | 214 | const char *zCkoutAlias; /* doc/ uses this branch as an alias for "ckout" */ |
| 215 | + const char *zMainMenuFile; /* --mainmenu FILE from server/ui/cgi */ | |
| 215 | 216 | const char *zSSLIdentity; /* Value of --ssl-identity option, filename of |
| 216 | 217 | ** SSL client identity */ |
| 217 | 218 | #if defined(_WIN32) && USE_SEE |
| 218 | 219 | const char *zPidKey; /* Saved value of the --usepidkey option. Only |
| 219 | 220 | * applicable when using SEE on Windows. */ |
| @@ -2143,10 +2144,13 @@ | ||
| 2143 | 2144 | ** an unconditional redirect to URL is taken. |
| 2144 | 2145 | ** |
| 2145 | 2146 | ** jsmode: VALUE Specifies the delivery mode for JavaScript |
| 2146 | 2147 | ** files. See the help text for the --jsmode |
| 2147 | 2148 | ** flag of the http command. |
| 2149 | +** | |
| 2150 | +** mainmenu: FILE Override the mainmenu config setting with the | |
| 2151 | +** contents of the given file. | |
| 2148 | 2152 | ** |
| 2149 | 2153 | ** Most CGI files contain only a "repository:" line. It is uncommon to |
| 2150 | 2154 | ** use any other option. |
| 2151 | 2155 | ** |
| 2152 | 2156 | ** See also: [[http]], [[server]], [[winsrv]] |
| @@ -2333,10 +2337,21 @@ | ||
| 2333 | 2337 | ** requirements of any given page. |
| 2334 | 2338 | */ |
| 2335 | 2339 | builtin_set_js_delivery_mode(blob_str(&value),0); |
| 2336 | 2340 | blob_reset(&value); |
| 2337 | 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; | |
| 2338 | 2353 | } |
| 2339 | 2354 | if( blob_eq(&key, "cgi-debug:") && blob_token(&line, &value) ){ |
| 2340 | 2355 | /* cgi-debug: FILENAME |
| 2341 | 2356 | ** |
| 2342 | 2357 | ** Causes output from cgi_debug() and CGIDEBUG(()) calls to go |
| @@ -2544,10 +2559,12 @@ | ||
| 2544 | 2559 | ** --out FILE write results to FILE instead of to standard output |
| 2545 | 2560 | ** --repolist If REPOSITORY is directory, URL "/" lists all repos |
| 2546 | 2561 | ** --scgi Interpret input as SCGI rather than HTTP |
| 2547 | 2562 | ** --skin LABEL Use override skin LABEL |
| 2548 | 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. | |
| 2549 | 2566 | ** --usepidkey Use saved encryption key from parent process. This is |
| 2550 | 2567 | ** only necessary when using SEE on Windows. |
| 2551 | 2568 | ** |
| 2552 | 2569 | ** See also: [[cgi]], [[server]], [[winsrv]] |
| 2553 | 2570 | */ |
| @@ -2611,10 +2628,14 @@ | ||
| 2611 | 2628 | zIpAddr = fossil_getenv("REMOTE_HOST"); /* From stunnel */ |
| 2612 | 2629 | cgi_replace_parameter("HTTPS","on"); |
| 2613 | 2630 | } |
| 2614 | 2631 | zHost = find_option("host", 0, 1); |
| 2615 | 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 | + } | |
| 2616 | 2637 | |
| 2617 | 2638 | /* We should be done with options.. */ |
| 2618 | 2639 | verify_all_options(); |
| 2619 | 2640 | |
| 2620 | 2641 | if( g.argc!=2 && g.argc!=3 ) usage("?REPOSITORY?"); |
| @@ -2797,10 +2818,12 @@ | ||
| 2797 | 2818 | ** -P|--port TCPPORT listen to request on port TCPPORT |
| 2798 | 2819 | ** --th-trace trace TH1 execution (for debugging purposes) |
| 2799 | 2820 | ** --repolist If REPOSITORY is dir, URL "/" lists repos. |
| 2800 | 2821 | ** --scgi Accept SCGI rather than HTTP |
| 2801 | 2822 | ** --skin LABEL Use override skin LABEL |
| 2823 | +** --mainmenu FILE Override the mainmenu config setting with the contents | |
| 2824 | +** of the given file. | |
| 2802 | 2825 | ** --usepidkey Use saved encryption key from parent process. This is |
| 2803 | 2826 | ** only necessary when using SEE on Windows. |
| 2804 | 2827 | ** |
| 2805 | 2828 | ** See also: [[cgi]], [[http]], [[winsrv]] |
| 2806 | 2829 | */ |
| @@ -2868,11 +2891,14 @@ | ||
| 2868 | 2891 | } |
| 2869 | 2892 | if( find_option("localhost", 0, 0)!=0 ){ |
| 2870 | 2893 | flags |= HTTP_SERVER_LOCALHOST; |
| 2871 | 2894 | } |
| 2872 | 2895 | 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 | + } | |
| 2874 | 2900 | /* We should be done with options.. */ |
| 2875 | 2901 | verify_all_options(); |
| 2876 | 2902 | |
| 2877 | 2903 | if( g.argc!=2 && g.argc!=3 ) usage("?REPOSITORY?"); |
| 2878 | 2904 | if( isUiCmd ){ |
| 2879 | 2905 |
| --- 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 @@ | ||
| 651 | 651 | ** to override that "maybe" default with something better. |
| 652 | 652 | */ |
| 653 | 653 | void style_set_current_feature(const char* zFeature){ |
| 654 | 654 | Th_Store("current_feature", zFeature); |
| 655 | 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 | +} | |
| 656 | 676 | |
| 657 | 677 | /* |
| 658 | 678 | ** Initialize all the default TH1 variables |
| 659 | 679 | */ |
| 660 | 680 | static void style_init_th1_vars(const char *zTitle){ |
| @@ -682,11 +702,11 @@ | ||
| 682 | 702 | Th_Store("csrf_token", g.zCsrfToken); |
| 683 | 703 | Th_Store("release_version", RELEASE_VERSION); |
| 684 | 704 | Th_Store("manifest_version", MANIFEST_VERSION); |
| 685 | 705 | Th_Store("manifest_date", MANIFEST_DATE); |
| 686 | 706 | Th_Store("compiler_name", COMPILER_NAME); |
| 687 | - Th_Store("mainmenu", db_get("mainmenu", style_default_mainmenu())); | |
| 707 | + Th_Store("mainmenu", style_get_mainmenu()); | |
| 688 | 708 | url_var("stylesheet", "css", "style.css"); |
| 689 | 709 | image_url_var("logo"); |
| 690 | 710 | image_url_var("background"); |
| 691 | 711 | if( !login_is_nobody() ){ |
| 692 | 712 | Th_Store("login", g.zLogin); |
| 693 | 713 |
| --- 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 |
+4
| --- src/winhttp.c | ||
| +++ src/winhttp.c | ||
| @@ -570,10 +570,14 @@ | ||
| 570 | 570 | } |
| 571 | 571 | zSkin = skin_in_use(); |
| 572 | 572 | if( zSkin ){ |
| 573 | 573 | blob_appendf(&options, " --skin %s", zSkin); |
| 574 | 574 | } |
| 575 | + if( g.zMainMenuFile ){ | |
| 576 | + blob_appendf(&options, " --mainmenu "); | |
| 577 | + blob_append_escaped_arg(&options, g.zMainMenuFile); | |
| 578 | + } | |
| 575 | 579 | #if USE_SEE |
| 576 | 580 | zSavedKey = db_get_saved_encryption_key(); |
| 577 | 581 | savedKeySize = db_get_saved_encryption_key_size(); |
| 578 | 582 | if( zSavedKey!=0 && savedKeySize>0 ){ |
| 579 | 583 | blob_appendf(&options, " --usepidkey %lu:%p:%u", GetCurrentProcessId(), |
| 580 | 584 |
| --- 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 @@ | ||
| 135 | 135 | This parameter can be repeated as many times as necessary. |
| 136 | 136 | |
| 137 | 137 | <h2 id="HOME">HOME: <i>PATH</i></h2> |
| 138 | 138 | |
| 139 | 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 | + | |
| 140 | 151 | |
| 141 | 152 | <h2 id="cgi-debug">cgi-debug: <i>FILE</i></h2> |
| 142 | 153 | |
| 143 | 154 | Cause CGI-related debugging information to be appended in <i>FILE</i>. Use |
| 144 | 155 | this to help debug CGI problems. |
| 145 | 156 |
| --- 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 |