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.

stephan 2026-07-07 08:11 UTC trunk
Commit c9525608f061213780a8267c5c053636bf86732530306bf36caf7cc57454cfe3
2 files changed +14 +8
--- src/builtin.c
+++ src/builtin.c
@@ -698,10 +698,24 @@
698698
CX("isAdmin: %s,", JBOOL(g.perm.Admin || g.perm.Setup));
699699
CX("mayAttachForum: %s,", JBOOL(g.perm.AttachForum));
700700
CX("enableDebug: %s,", JBOOL(g.perm.Debug || g.perm.Admin));
701701
CX("isIndividual: %s", JBOOL(login_is_individual()));
702702
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
+ }
703717
CX("if(fossil.config.skin.isDark) "
704718
"document.body.classList.add('fossil-dark-style');\n");
705719
/*
706720
** fossil.page holds info about the current page. This is also
707721
** where the current page "should" store any of its own
708722
--- 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
--- src/style.c
+++ src/style.c
@@ -744,10 +744,18 @@
744744
void style_set_current_feature(const char* zFeature){
745745
fossil_free( local_zCurrentFeature );
746746
local_zCurrentFeature = fossil_strdup(zFeature);
747747
Th_Store("current_feature", zFeature);
748748
}
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
+}
749757
750758
/*
751759
** Returns the current mainmenu value from either the --mainmenu flag
752760
** (handled by the server/ui/cgi commands), the "mainmenu" config
753761
** setting, or style_default_mainmenu(), in that order, returning the
754762
--- 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

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button