Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
| Comment: | Restructured how --mainmenu value is saved. Added support for it to Windows server, but that is untested. |
|---|---|
| Downloads: | Tarball | ZIP archive |
| Timelines: | family | ancestors | descendants | both | mainmenu-override |
| Files: | files | file ages | folders |
| SHA3-256: |
852be6d4200a0c0f2c930f012323b8d7 |
| User & Date: | stephan 2021-02-06 04:40:19.052 |
Context
|
2021-02-06
| ||
| 04:48 | Corrected potential mishandling of memory ownership in the previous commit. ... (check-in: d6e698c265 user: stephan tags: mainmenu-override) | |
| 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) | |
Changes
Changes to src/main.c.
| ︙ | ︙ | |||
208 209 210 211 212 213 214 215 216 217 218 219 220 221 |
int wikiFlags; /* Wiki conversion flags applied to %W */
char isHTTP; /* True if server/CGI modes, else assume CLI. */
char javascriptHyperlink; /* If true, set href= using script, not HTML */
Blob httpHeader; /* Complete text of the HTTP request header */
UrlData url; /* Information about current URL */
const char *zLogin; /* Login name. NULL or "" if not logged in. */
const char *zCkoutAlias; /* doc/ uses this branch as an alias for "ckout" */
const char *zSSLIdentity; /* Value of --ssl-identity option, filename of
** SSL client identity */
#if defined(_WIN32) && USE_SEE
const char *zPidKey; /* Saved value of the --usepidkey option. Only
* applicable when using SEE on Windows. */
#endif
int useLocalauth; /* No login required if from 127.0.0.1 */
| > | 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 |
int wikiFlags; /* Wiki conversion flags applied to %W */
char isHTTP; /* True if server/CGI modes, else assume CLI. */
char javascriptHyperlink; /* If true, set href= using script, not HTML */
Blob httpHeader; /* Complete text of the HTTP request header */
UrlData url; /* Information about current URL */
const char *zLogin; /* Login name. NULL or "" if not logged in. */
const char *zCkoutAlias; /* doc/ uses this branch as an alias for "ckout" */
const char *zMainMenuFile; /* --mainmenu FILE from server/ui/cgi */
const char *zSSLIdentity; /* Value of --ssl-identity option, filename of
** SSL client identity */
#if defined(_WIN32) && USE_SEE
const char *zPidKey; /* Saved value of the --usepidkey option. Only
* applicable when using SEE on Windows. */
#endif
int useLocalauth; /* No login required if from 127.0.0.1 */
|
| ︙ | ︙ | |||
2342 2343 2344 2345 2346 2347 2348 |
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.
*/
| | | | 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 |
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.
*/
g.zMainMenuFile = blob_str(&value);
value = empty_blob/*take over ownership*/;
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.
|
| ︙ | ︙ | |||
2834 2835 2836 2837 2838 2839 2840 | #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 */ | < | 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 */
#if defined(_WIN32)
const char *zStopperFile; /* Name of file used to terminate server */
zStopperFile = find_option("stopper", 0, 1);
#endif
if( g.zErrlog==0 ){
|
| ︙ | ︙ | |||
2883 2884 2885 2886 2887 2888 2889 |
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 |
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);
g.zMainMenuFile = find_option("mainmenu",0,1);
if( g.zMainMenuFile!=0 && file_size(g.zMainMenuFile,ExtFILE)<0 ){
fossil_fatal("Cannot read --mainmenu file %s", g.zMainMenuFile);
}
/* 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;
|
| ︙ | ︙ |
Changes to src/style.c.
| ︙ | ︙ | |||
617 618 619 620 621 622 623 |
/*
** Return the default menu
*/
const char *style_default_mainmenu(void){
return zDfltMainMenu;
}
| < < < < < < < < < < < < < < < < < < < < < | 617 618 619 620 621 622 623 624 625 626 627 628 629 630 |
/*
** 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.
**
|
| ︙ | ︙ | |||
670 671 672 673 674 675 676 677 678 679 680 681 682 683 |
** style_init_th1_vars() because that uses Th_MaybeStore() instead to
** allow webpage implementations to call this before style_header()
** to override that "maybe" default with something better.
*/
void style_set_current_feature(const char* zFeature){
Th_Store("current_feature", zFeature);
}
/*
** Initialize all the default TH1 variables
*/
static void style_init_th1_vars(const char *zTitle){
const char *zNonce = style_nonce();
char *zDfltCsp;
| > > > > > > > > > > > > > > > > > > > > | 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 |
** style_init_th1_vars() because that uses Th_MaybeStore() instead to
** allow webpage implementations to call this before style_header()
** to override that "maybe" default with something better.
*/
void style_set_current_feature(const char* zFeature){
Th_Store("current_feature", zFeature);
}
/*
** Returns the current mainmenu value from either the --mainmenu flag
** (handled by the server/ui/cgi commands), the "mainmenu" config
** setting, or style_default_mainmenu(), in that order, returning the
** first of those which is defined.
*/
const char*style_get_mainmenu(){
static const char *zMenu = 0;
if(!zMenu){
if(g.zMainMenuFile){
Blob b = empty_blob;
blob_read_from_file(&b, g.zMainMenuFile, ExtFILE);
zMenu = blob_str(&b);
}else{
zMenu = db_get("mainmenu", style_default_mainmenu());
}
}
return zMenu;
}
/*
** Initialize all the default TH1 variables
*/
static void style_init_th1_vars(const char *zTitle){
const char *zNonce = style_nonce();
char *zDfltCsp;
|
| ︙ | ︙ | |||
701 702 703 704 705 706 707 |
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);
| | < < | 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 |
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", style_get_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 src/winhttp.c.
| ︙ | ︙ | |||
568 569 570 571 572 573 574 575 576 577 578 579 580 581 |
blob_appendf(&options, " --extroot");
blob_append_escaped_arg(&options, g.zExtRoot);
}
zSkin = skin_in_use();
if( zSkin ){
blob_appendf(&options, " --skin %s", zSkin);
}
#if USE_SEE
zSavedKey = db_get_saved_encryption_key();
savedKeySize = db_get_saved_encryption_key_size();
if( zSavedKey!=0 && savedKeySize>0 ){
blob_appendf(&options, " --usepidkey %lu:%p:%u", GetCurrentProcessId(),
zSavedKey, savedKeySize);
}
| > > > | 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 |
blob_appendf(&options, " --extroot");
blob_append_escaped_arg(&options, g.zExtRoot);
}
zSkin = skin_in_use();
if( zSkin ){
blob_appendf(&options, " --skin %s", zSkin);
}
if( g.zMainMenuFile ){
blob_appendf(&options, " --mainmenu %s", g.zMainMenuFile);
}
#if USE_SEE
zSavedKey = db_get_saved_encryption_key();
savedKeySize = db_get_saved_encryption_key_size();
if( zSavedKey!=0 && savedKeySize>0 ){
blob_appendf(&options, " --usepidkey %lu:%p:%u", GetCurrentProcessId(),
zSavedKey, savedKeySize);
}
|
| ︙ | ︙ |