Fossil SCM
During fossil's JS bootstrapping, ensure that the BODY element's CSS classes are set to those which the skin system would output. This resolves [forum:31cc00b361496cb8:forum post 31cc00b361496cb8], in which a custom skin which emits its own BODY element is missing the cpage-X and rpage-X CSS classes, which an increasing number of JS and CSS bits use for limiting their blast radius to a specific page.
Commit
c9525608f061213780a8267c5c053636bf86732530306bf36caf7cc57454cfe3
Parent
901894f520a066a…
2 files changed
+14
+8
+14
| --- src/builtin.c | ||
| +++ src/builtin.c | ||
| @@ -698,10 +698,24 @@ | ||
| 698 | 698 | CX("isAdmin: %s,", JBOOL(g.perm.Admin || g.perm.Setup)); |
| 699 | 699 | CX("mayAttachForum: %s,", JBOOL(g.perm.AttachForum)); |
| 700 | 700 | CX("enableDebug: %s,", JBOOL(g.perm.Debug || g.perm.Admin)); |
| 701 | 701 | CX("isIndividual: %s", JBOOL(login_is_individual())); |
| 702 | 702 | CX("};\n"/*fossil.user*/); |
| 703 | + { /* Workaround for cases like: | |
| 704 | + ** https://fossil-scm.org/forum/forumpost/31cc00b361496cb8 | |
| 705 | + ** Summary: custom skins which emit their own BODY need to have | |
| 706 | + ** the BODY element's CSS classes set so that various CSS selectors | |
| 707 | + ** and JS-side filters will work. */ | |
| 708 | + char *pSlash = strchr(g.zPath,'/')/*hack taken from style.c*/; | |
| 709 | + if( pSlash ) *pSlash = 0; | |
| 710 | + Th_Store("requested_page", escape_quotes(g.zPath)); | |
| 711 | + CX("window.fossil.pageClasses = [%!j, \"rpage-%j\"," | |
| 712 | + "\"cpage-%j\"];\n", | |
| 713 | + style_get_current_feature(), g.zPath, g.zPhase+1); | |
| 714 | + if( pSlash ) *pSlash = '/'; | |
| 715 | + CX("document.body.classList.add(...window.fossil.pageClasses);\n"); | |
| 716 | + } | |
| 703 | 717 | CX("if(fossil.config.skin.isDark) " |
| 704 | 718 | "document.body.classList.add('fossil-dark-style');\n"); |
| 705 | 719 | /* |
| 706 | 720 | ** fossil.page holds info about the current page. This is also |
| 707 | 721 | ** where the current page "should" store any of its own |
| 708 | 722 |
| --- src/builtin.c | |
| +++ src/builtin.c | |
| @@ -698,10 +698,24 @@ | |
| 698 | CX("isAdmin: %s,", JBOOL(g.perm.Admin || g.perm.Setup)); |
| 699 | CX("mayAttachForum: %s,", JBOOL(g.perm.AttachForum)); |
| 700 | CX("enableDebug: %s,", JBOOL(g.perm.Debug || g.perm.Admin)); |
| 701 | CX("isIndividual: %s", JBOOL(login_is_individual())); |
| 702 | CX("};\n"/*fossil.user*/); |
| 703 | CX("if(fossil.config.skin.isDark) " |
| 704 | "document.body.classList.add('fossil-dark-style');\n"); |
| 705 | /* |
| 706 | ** fossil.page holds info about the current page. This is also |
| 707 | ** where the current page "should" store any of its own |
| 708 |
| --- src/builtin.c | |
| +++ src/builtin.c | |
| @@ -698,10 +698,24 @@ | |
| 698 | CX("isAdmin: %s,", JBOOL(g.perm.Admin || g.perm.Setup)); |
| 699 | CX("mayAttachForum: %s,", JBOOL(g.perm.AttachForum)); |
| 700 | CX("enableDebug: %s,", JBOOL(g.perm.Debug || g.perm.Admin)); |
| 701 | CX("isIndividual: %s", JBOOL(login_is_individual())); |
| 702 | CX("};\n"/*fossil.user*/); |
| 703 | { /* Workaround for cases like: |
| 704 | ** https://fossil-scm.org/forum/forumpost/31cc00b361496cb8 |
| 705 | ** Summary: custom skins which emit their own BODY need to have |
| 706 | ** the BODY element's CSS classes set so that various CSS selectors |
| 707 | ** and JS-side filters will work. */ |
| 708 | char *pSlash = strchr(g.zPath,'/')/*hack taken from style.c*/; |
| 709 | if( pSlash ) *pSlash = 0; |
| 710 | Th_Store("requested_page", escape_quotes(g.zPath)); |
| 711 | CX("window.fossil.pageClasses = [%!j, \"rpage-%j\"," |
| 712 | "\"cpage-%j\"];\n", |
| 713 | style_get_current_feature(), g.zPath, g.zPhase+1); |
| 714 | if( pSlash ) *pSlash = '/'; |
| 715 | CX("document.body.classList.add(...window.fossil.pageClasses);\n"); |
| 716 | } |
| 717 | CX("if(fossil.config.skin.isDark) " |
| 718 | "document.body.classList.add('fossil-dark-style');\n"); |
| 719 | /* |
| 720 | ** fossil.page holds info about the current page. This is also |
| 721 | ** where the current page "should" store any of its own |
| 722 |
+8
| --- src/style.c | ||
| +++ src/style.c | ||
| @@ -744,10 +744,18 @@ | ||
| 744 | 744 | void style_set_current_feature(const char* zFeature){ |
| 745 | 745 | fossil_free( local_zCurrentFeature ); |
| 746 | 746 | local_zCurrentFeature = fossil_strdup(zFeature); |
| 747 | 747 | Th_Store("current_feature", zFeature); |
| 748 | 748 | } |
| 749 | + | |
| 750 | +/* | |
| 751 | +** Returns the local feature string, owned by this file and | |
| 752 | +** invalidated by style_set_current_feature(). | |
| 753 | +*/ | |
| 754 | +const char * style_get_current_feature(void){ | |
| 755 | + return local_zCurrentFeature; | |
| 756 | +} | |
| 749 | 757 | |
| 750 | 758 | /* |
| 751 | 759 | ** Returns the current mainmenu value from either the --mainmenu flag |
| 752 | 760 | ** (handled by the server/ui/cgi commands), the "mainmenu" config |
| 753 | 761 | ** setting, or style_default_mainmenu(), in that order, returning the |
| 754 | 762 |
| --- src/style.c | |
| +++ src/style.c | |
| @@ -744,10 +744,18 @@ | |
| 744 | void style_set_current_feature(const char* zFeature){ |
| 745 | fossil_free( local_zCurrentFeature ); |
| 746 | local_zCurrentFeature = fossil_strdup(zFeature); |
| 747 | Th_Store("current_feature", zFeature); |
| 748 | } |
| 749 | |
| 750 | /* |
| 751 | ** Returns the current mainmenu value from either the --mainmenu flag |
| 752 | ** (handled by the server/ui/cgi commands), the "mainmenu" config |
| 753 | ** setting, or style_default_mainmenu(), in that order, returning the |
| 754 |
| --- src/style.c | |
| +++ src/style.c | |
| @@ -744,10 +744,18 @@ | |
| 744 | void style_set_current_feature(const char* zFeature){ |
| 745 | fossil_free( local_zCurrentFeature ); |
| 746 | local_zCurrentFeature = fossil_strdup(zFeature); |
| 747 | Th_Store("current_feature", zFeature); |
| 748 | } |
| 749 | |
| 750 | /* |
| 751 | ** Returns the local feature string, owned by this file and |
| 752 | ** invalidated by style_set_current_feature(). |
| 753 | */ |
| 754 | const char * style_get_current_feature(void){ |
| 755 | return local_zCurrentFeature; |
| 756 | } |
| 757 | |
| 758 | /* |
| 759 | ** Returns the current mainmenu value from either the --mainmenu flag |
| 760 | ** (handled by the server/ui/cgi commands), the "mainmenu" config |
| 761 | ** setting, or style_default_mainmenu(), in that order, returning the |
| 762 |