| | @@ -619,31 +619,10 @@ |
| 619 | 619 | */ |
| 620 | 620 | const char *style_default_mainmenu(void){ |
| 621 | 621 | return zDfltMainMenu; |
| 622 | 622 | } |
| 623 | 623 | |
| 624 | | -/* |
| 625 | | -** Main menu setting value overridden by the server/ui/cgi --mainmenu |
| 626 | | -** CLI flag or the "mainmenu:" CGI wrapper script config option. |
| 627 | | -*/ |
| 628 | | -static const char * zOverrideMainMenu = 0; |
| 629 | | -/* |
| 630 | | -** Sets the contents of the given filename (of type ExtFILE) to |
| 631 | | -** override the "mainmenu" site config setting. Returns 0 on success, |
| 632 | | -** non-0 if the file cannot be stat'd. |
| 633 | | -*/ |
| 634 | | -int style_default_mainmenu_override(const char *zFilename){ |
| 635 | | - if(file_size(zFilename, ExtFILE)<0){ |
| 636 | | - return 1; |
| 637 | | - }else{ |
| 638 | | - Blob content = empty_blob; |
| 639 | | - blob_read_from_file(&content, zFilename, ExtFILE); |
| 640 | | - zOverrideMainMenu = blob_str(&content); |
| 641 | | - return 0; |
| 642 | | - } |
| 643 | | -} |
| 644 | | - |
| 645 | 624 | /* |
| 646 | 625 | ** Given a URL path, extract the first element as a "feature" name, |
| 647 | 626 | ** used as the <body class="FEATURE"> value by default, though |
| 648 | 627 | ** later-running code may override this, typically to group multiple |
| 649 | 628 | ** Fossil UI URLs into a single "feature" so you can have per-feature |
| | @@ -672,10 +651,30 @@ |
| 672 | 651 | ** to override that "maybe" default with something better. |
| 673 | 652 | */ |
| 674 | 653 | void style_set_current_feature(const char* zFeature){ |
| 675 | 654 | Th_Store("current_feature", zFeature); |
| 676 | 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 | +} |
| 677 | 676 | |
| 678 | 677 | /* |
| 679 | 678 | ** Initialize all the default TH1 variables |
| 680 | 679 | */ |
| 681 | 680 | static void style_init_th1_vars(const char *zTitle){ |
| | @@ -703,13 +702,11 @@ |
| 703 | 702 | Th_Store("csrf_token", g.zCsrfToken); |
| 704 | 703 | Th_Store("release_version", RELEASE_VERSION); |
| 705 | 704 | Th_Store("manifest_version", MANIFEST_VERSION); |
| 706 | 705 | Th_Store("manifest_date", MANIFEST_DATE); |
| 707 | 706 | Th_Store("compiler_name", COMPILER_NAME); |
| 708 | | - Th_Store("mainmenu", zOverrideMainMenu |
| 709 | | - ? zOverrideMainMenu |
| 710 | | - : db_get("mainmenu", style_default_mainmenu())); |
| 707 | + Th_Store("mainmenu", style_get_mainmenu()); |
| 711 | 708 | url_var("stylesheet", "css", "style.css"); |
| 712 | 709 | image_url_var("logo"); |
| 713 | 710 | image_url_var("background"); |
| 714 | 711 | if( !login_is_nobody() ){ |
| 715 | 712 | Th_Store("login", g.zLogin); |
| 716 | 713 | |