Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
| Comment: | Added ui/server/cgi --mainmenu FILE option, and CGI wrapper script mainmenu: option, to override the mainmenu setting, similar to how --skin/skin: overrides the skin. |
|---|---|
| Downloads: | Tarball | ZIP archive |
| Timelines: | family | ancestors | descendants | both | mainmenu-override |
| Files: | files | file ages | folders |
| SHA3-256: |
bcca09106b2aa813fca1aa4691d6e06e |
| User & Date: | stephan 2021-02-05 10:36:05.551 |
Context
|
2021-02-06
| ||
| 04:40 | Restructured how --mainmenu value is saved. Added support for it to Windows server, but that is untested. ... (check-in: 852be6d420 user: stephan tags: mainmenu-override) | |
|
2021-02-05
| ||
| 10:36 | Added ui/server/cgi --mainmenu FILE option, and CGI wrapper script mainmenu: option, to override the mainmenu setting, similar to how --skin/skin: overrides the skin. ... (check-in: bcca09106b user: stephan tags: mainmenu-override) | |
| 03:51 | Minor reordering of diff command help, per forum suggestion. ... (check-in: dd13191359 user: stephan tags: trunk) | |
Changes
Changes to src/main.c.
| ︙ | ︙ | |||
2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 |
** can be multiple "redirect:" lines that are
** processed in order. If the REPO is "*", then
** an unconditional redirect to URL is taken.
**
** jsmode: VALUE Specifies the delivery mode for JavaScript
** files. See the help text for the --jsmode
** flag of the http command.
**
** Most CGI files contain only a "repository:" line. It is uncommon to
** use any other option.
**
** See also: [[http]], [[server]], [[winsrv]]
*/
void cmd_cgi(void){
| > > > | 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 |
** can be multiple "redirect:" lines that are
** processed in order. If the REPO is "*", then
** an unconditional redirect to URL is taken.
**
** jsmode: VALUE Specifies the delivery mode for JavaScript
** files. See the help text for the --jsmode
** flag of the http command.
**
** mainmenu: FILE Override the mainmenu config setting with the
** contents of the given file.
**
** Most CGI files contain only a "repository:" line. It is uncommon to
** use any other option.
**
** See also: [[http]], [[server]], [[winsrv]]
*/
void cmd_cgi(void){
|
| ︙ | ︙ | |||
2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 |
** auxiliary HTTP request. Noting, however, that "single" might
** actually mean more than one, depending on the script-timing
** requirements of any given page.
*/
builtin_set_js_delivery_mode(blob_str(&value),0);
blob_reset(&value);
continue;
}
if( blob_eq(&key, "cgi-debug:") && blob_token(&line, &value) ){
/* cgi-debug: FILENAME
**
** Causes output from cgi_debug() and CGIDEBUG(()) calls to go
** into FILENAME. Useful for debugging CGI configuration problems.
*/
| > > > > > > > > > > > | 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 |
** auxiliary HTTP request. Noting, however, that "single" might
** actually mean more than one, depending on the script-timing
** requirements of any given page.
*/
builtin_set_js_delivery_mode(blob_str(&value),0);
blob_reset(&value);
continue;
}
if( blob_eq(&key, "mainmenu:") && blob_token(&line, &value) ){
/* mainmenu: FILENAME
**
** Use the contents of FILENAME as the value of the site's
** "mainmenu" setting, overriding the contents (for this
** request) of the db-side setting or the hard-coded default.
*/
style_default_mainmenu_override(blob_str(&value));
blob_reset(&value);
continue;
}
if( blob_eq(&key, "cgi-debug:") && blob_token(&line, &value) ){
/* cgi-debug: FILENAME
**
** Causes output from cgi_debug() and CGIDEBUG(()) calls to go
** into FILENAME. Useful for debugging CGI configuration problems.
*/
|
| ︙ | ︙ | |||
2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808 |
** --notfound URL Redirect
** --page PAGE Start "ui" on PAGE. ex: --page "timeline?y=ci"
** -P|--port TCPPORT listen to request on port TCPPORT
** --th-trace trace TH1 execution (for debugging purposes)
** --repolist If REPOSITORY is dir, URL "/" lists repos.
** --scgi Accept SCGI rather than HTTP
** --skin LABEL Use override skin LABEL
** --usepidkey Use saved encryption key from parent process. This is
** only necessary when using SEE on Windows.
**
** See also: [[cgi]], [[http]], [[winsrv]]
*/
void cmd_webserver(void){
int iPort, mxPort; /* Range of TCP ports allowed */
| > > | 2809 2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 2821 2822 2823 2824 |
** --notfound URL Redirect
** --page PAGE Start "ui" on PAGE. ex: --page "timeline?y=ci"
** -P|--port TCPPORT listen to request on port TCPPORT
** --th-trace trace TH1 execution (for debugging purposes)
** --repolist If REPOSITORY is dir, URL "/" lists repos.
** --scgi Accept SCGI rather than HTTP
** --skin LABEL Use override skin LABEL
** --mainmenu FILE Override the mainmenu config setting with the contents
** of the given file.
** --usepidkey Use saved encryption key from parent process. This is
** only necessary when using SEE on Windows.
**
** See also: [[cgi]], [[http]], [[winsrv]]
*/
void cmd_webserver(void){
int iPort, mxPort; /* Range of TCP ports allowed */
|
| ︙ | ︙ | |||
2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 |
#endif
int allowRepoList; /* List repositories on URL "/" */
const char *zAltBase; /* Argument to the --baseurl option */
const char *zFileGlob; /* Static content must match this */
char *zIpAddr = 0; /* Bind to this IP address */
int fCreate = 0; /* The --create flag */
const char *zInitPage = 0; /* Start on this page. --page option */
#if defined(_WIN32)
const char *zStopperFile; /* Name of file used to terminate server */
zStopperFile = find_option("stopper", 0, 1);
#endif
if( g.zErrlog==0 ){
| > | 2834 2835 2836 2837 2838 2839 2840 2841 2842 2843 2844 2845 2846 2847 2848 |
#endif
int allowRepoList; /* List repositories on URL "/" */
const char *zAltBase; /* Argument to the --baseurl option */
const char *zFileGlob; /* Static content must match this */
char *zIpAddr = 0; /* Bind to this IP address */
int fCreate = 0; /* The --create flag */
const char *zInitPage = 0; /* Start on this page. --page option */
const char *zMainMenu = 0; /* --mainmenu option */
#if defined(_WIN32)
const char *zStopperFile; /* Name of file used to terminate server */
zStopperFile = find_option("stopper", 0, 1);
#endif
if( g.zErrlog==0 ){
|
| ︙ | ︙ | |||
2866 2867 2868 2869 2870 2871 2872 |
if( find_option("https",0,0)!=0 ){
cgi_replace_parameter("HTTPS","on");
}
if( find_option("localhost", 0, 0)!=0 ){
flags |= HTTP_SERVER_LOCALHOST;
}
g.zCkoutAlias = find_option("ckout-alias",0,1);
| > > > > | > | 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 |
if( find_option("https",0,0)!=0 ){
cgi_replace_parameter("HTTPS","on");
}
if( find_option("localhost", 0, 0)!=0 ){
flags |= HTTP_SERVER_LOCALHOST;
}
g.zCkoutAlias = find_option("ckout-alias",0,1);
zMainMenu = find_option("mainmenu",0,1);
if( zMainMenu!=0 ){
if(0!=style_default_mainmenu_override(zMainMenu)){
fossil_fatal("Cannot read --mainmenu file %s", zMainMenu);
}
}
/* We should be done with options.. */
verify_all_options();
if( g.argc!=2 && g.argc!=3 ) usage("?REPOSITORY?");
if( isUiCmd ){
flags |= HTTP_SERVER_LOCALHOST|HTTP_SERVER_REPOLIST;
g.useLocalauth = 1;
|
| ︙ | ︙ |
Changes to src/style.c.
| ︙ | ︙ | |||
616 617 618 619 620 621 622 623 624 625 626 627 628 629 |
/*
** Return the default menu
*/
const char *style_default_mainmenu(void){
return zDfltMainMenu;
}
/*
** Given a URL path, extract the first element as a "feature" name,
** used as the <body class="FEATURE"> value by default, though
** later-running code may override this, typically to group multiple
** Fossil UI URLs into a single "feature" so you can have per-feature
** CSS rules.
| > > > > > > > > > > > > > > > > > > > > > | 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 |
/*
** Return the default menu
*/
const char *style_default_mainmenu(void){
return zDfltMainMenu;
}
/*
** Main menu setting value overridden by the server/ui/cgi --mainmenu
** CLI flag or the "mainmenu:" CGI wrapper script config option.
*/
static const char * zOverrideMainMenu = 0;
/*
** Sets the contents of the given filename (of type ExtFILE) to
** override the "mainmenu" site config setting. Returns 0 on success,
** non-0 if the file cannot be stat'd.
*/
int style_default_mainmenu_override(const char *zFilename){
if(file_size(zFilename, ExtFILE)<0){
return 1;
}else{
Blob content = empty_blob;
blob_read_from_file(&content, zFilename, ExtFILE);
zOverrideMainMenu = blob_str(&content);
return 0;
}
}
/*
** Given a URL path, extract the first element as a "feature" name,
** used as the <body class="FEATURE"> value by default, though
** later-running code may override this, typically to group multiple
** Fossil UI URLs into a single "feature" so you can have per-feature
** CSS rules.
|
| ︙ | ︙ | |||
680 681 682 683 684 685 686 |
if( local_zCurrentPage==0 ) style_set_current_page("%T", g.zPath);
Th_Store("current_page", local_zCurrentPage);
Th_Store("csrf_token", g.zCsrfToken);
Th_Store("release_version", RELEASE_VERSION);
Th_Store("manifest_version", MANIFEST_VERSION);
Th_Store("manifest_date", MANIFEST_DATE);
Th_Store("compiler_name", COMPILER_NAME);
| > > | | 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 |
if( local_zCurrentPage==0 ) style_set_current_page("%T", g.zPath);
Th_Store("current_page", local_zCurrentPage);
Th_Store("csrf_token", g.zCsrfToken);
Th_Store("release_version", RELEASE_VERSION);
Th_Store("manifest_version", MANIFEST_VERSION);
Th_Store("manifest_date", MANIFEST_DATE);
Th_Store("compiler_name", COMPILER_NAME);
Th_Store("mainmenu", zOverrideMainMenu
? zOverrideMainMenu
: db_get("mainmenu", style_default_mainmenu()));
url_var("stylesheet", "css", "style.css");
image_url_var("logo");
image_url_var("background");
if( !login_is_nobody() ){
Th_Store("login", g.zLogin);
}
Th_MaybeStore("current_feature", feature_from_page_path(local_zCurrentPage) );
|
| ︙ | ︙ |
Changes to www/cgi.wiki.
| ︙ | ︙ | |||
133 134 135 136 137 138 139 140 141 142 143 144 | This parameter causes additional environment variable NAME to have VALUE. This parameter can be repeated as many times as necessary. <h2 id="HOME">HOME: <i>PATH</i></h2> This parameter is a short-hand for "<b>setenv HOME <i>PATH</i></b>". <h2 id="cgi-debug">cgi-debug: <i>FILE</i></h2> Cause CGI-related debugging information to be appended in <i>FILE</i>. Use this to help debug CGI problems. | > > > > > > > > > > > | 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 | This parameter causes additional environment variable NAME to have VALUE. This parameter can be repeated as many times as necessary. <h2 id="HOME">HOME: <i>PATH</i></h2> This parameter is a short-hand for "<b>setenv HOME <i>PATH</i></b>". <h2 id="mainmenu">mainmenu: <i>FILE</i></h2> This parameter causes the contents of the given file to override the site's <tt>mainmenu</tt> configuration setting, much in the same way that the <tt>skin</tt> setting overrides the skin. This can be used to apply a common main menu to a number of sites, and centrally maintain it, without having to copy its contents into each site. Note, however, that the contents of this setting are not stored in the repository and will not be cloned along with the repository. <h2 id="cgi-debug">cgi-debug: <i>FILE</i></h2> Cause CGI-related debugging information to be appended in <i>FILE</i>. Use this to help debug CGI problems. |