Fossil SCM

When a page with skin=X&once generates its style.css link, append skin=X&once to that lnik so that it gets the proper skin when style.css is loaded (asynchronously). Renamed the skin=_repo (reset to site-specific skin) to skin= (blank name), per /chat discussion.

stephan 2021-03-02 15:33 trunk
Commit 10dfd9e51bebc8fd1b82bc1803be2d9881c4b333d7c44b18f1347326eba83133
2 files changed +5 -5 +12 -3
+5 -5
--- src/skins.c
+++ src/skins.c
@@ -134,28 +134,28 @@
134134
**
135135
** 3) Skin properties from the CONFIG db table
136136
**
137137
** 4) Default skin.
138138
**
139
-** As a special case, the name "_repo" resets zAltSkinDir and
139
+** As a special case, a NULL or empty name resets zAltSkinDir and
140140
** pAltSkin to 0 to indicate that the current config-side skin should
141141
** be used (rank 3, above), then returns 0.
142142
*/
143143
char *skin_use_alternative(const char *zName, int rank){
144144
static int currentRank = 5;
145145
int i;
146146
Blob err = BLOB_INITIALIZER;
147147
if(rank > currentRank) return 0;
148
- if( 1==rank && strchr(zName, '/')!=0 ){
148
+ if( zName && 1==rank && strchr(zName, '/')!=0 ){
149149
zAltSkinDir = fossil_strdup(zName);
150150
return 0;
151151
}
152
- if( sqlite3_strglob("draft[1-9]", zName)==0 ){
152
+ if( zName && sqlite3_strglob("draft[1-9]", zName)==0 ){
153153
skin_use_draft(zName[5] - '0');
154154
return 0;
155155
}
156
- if(zName && 0==strcmp("_repo",zName)){
156
+ if(!zName || !*zName){
157157
pAltSkin = 0;
158158
zAltSkinDir = 0;
159159
return 0;
160160
}
161161
for(i=0; i<count(aBuiltinSkin); i++){
@@ -1207,11 +1207,11 @@
12071207
@ <p>The following skins are available for this repository:</p>
12081208
@ <ul>
12091209
if( pAltSkin==0 && zAltSkinDir==0 && iDraftSkin==0 ){
12101210
@ <li> Standard skin for this repository &larr; <i>Currently in use</i>
12111211
}else{
1212
- @ <li> %z(href("%R/skins?skin=_repo"))Standard skin for this repository</a>
1212
+ @ <li> %z(href("%R/skins?skin="))Standard skin for this repository</a>
12131213
}
12141214
for(i=0; i<count(aBuiltinSkin); i++){
12151215
if( pAltSkin==&aBuiltinSkin[i] ){
12161216
@ <li> %h(aBuiltinSkin[i].zDesc) &larr; <i>Currently in use</i>
12171217
}else{
12181218
--- src/skins.c
+++ src/skins.c
@@ -134,28 +134,28 @@
134 **
135 ** 3) Skin properties from the CONFIG db table
136 **
137 ** 4) Default skin.
138 **
139 ** As a special case, the name "_repo" resets zAltSkinDir and
140 ** pAltSkin to 0 to indicate that the current config-side skin should
141 ** be used (rank 3, above), then returns 0.
142 */
143 char *skin_use_alternative(const char *zName, int rank){
144 static int currentRank = 5;
145 int i;
146 Blob err = BLOB_INITIALIZER;
147 if(rank > currentRank) return 0;
148 if( 1==rank && strchr(zName, '/')!=0 ){
149 zAltSkinDir = fossil_strdup(zName);
150 return 0;
151 }
152 if( sqlite3_strglob("draft[1-9]", zName)==0 ){
153 skin_use_draft(zName[5] - '0');
154 return 0;
155 }
156 if(zName && 0==strcmp("_repo",zName)){
157 pAltSkin = 0;
158 zAltSkinDir = 0;
159 return 0;
160 }
161 for(i=0; i<count(aBuiltinSkin); i++){
@@ -1207,11 +1207,11 @@
1207 @ <p>The following skins are available for this repository:</p>
1208 @ <ul>
1209 if( pAltSkin==0 && zAltSkinDir==0 && iDraftSkin==0 ){
1210 @ <li> Standard skin for this repository &larr; <i>Currently in use</i>
1211 }else{
1212 @ <li> %z(href("%R/skins?skin=_repo"))Standard skin for this repository</a>
1213 }
1214 for(i=0; i<count(aBuiltinSkin); i++){
1215 if( pAltSkin==&aBuiltinSkin[i] ){
1216 @ <li> %h(aBuiltinSkin[i].zDesc) &larr; <i>Currently in use</i>
1217 }else{
1218
--- src/skins.c
+++ src/skins.c
@@ -134,28 +134,28 @@
134 **
135 ** 3) Skin properties from the CONFIG db table
136 **
137 ** 4) Default skin.
138 **
139 ** As a special case, a NULL or empty name resets zAltSkinDir and
140 ** pAltSkin to 0 to indicate that the current config-side skin should
141 ** be used (rank 3, above), then returns 0.
142 */
143 char *skin_use_alternative(const char *zName, int rank){
144 static int currentRank = 5;
145 int i;
146 Blob err = BLOB_INITIALIZER;
147 if(rank > currentRank) return 0;
148 if( zName && 1==rank && strchr(zName, '/')!=0 ){
149 zAltSkinDir = fossil_strdup(zName);
150 return 0;
151 }
152 if( zName && sqlite3_strglob("draft[1-9]", zName)==0 ){
153 skin_use_draft(zName[5] - '0');
154 return 0;
155 }
156 if(!zName || !*zName){
157 pAltSkin = 0;
158 zAltSkinDir = 0;
159 return 0;
160 }
161 for(i=0; i<count(aBuiltinSkin); i++){
@@ -1207,11 +1207,11 @@
1207 @ <p>The following skins are available for this repository:</p>
1208 @ <ul>
1209 if( pAltSkin==0 && zAltSkinDir==0 && iDraftSkin==0 ){
1210 @ <li> Standard skin for this repository &larr; <i>Currently in use</i>
1211 }else{
1212 @ <li> %z(href("%R/skins?skin="))Standard skin for this repository</a>
1213 }
1214 for(i=0; i<count(aBuiltinSkin); i++){
1215 if( pAltSkin==&aBuiltinSkin[i] ){
1216 @ <li> %h(aBuiltinSkin[i].zDesc) &larr; <i>Currently in use</i>
1217 }else{
1218
+12 -3
--- src/style.c
+++ src/style.c
@@ -378,11 +378,15 @@
378378
const char *zPageName
379379
){
380380
char *zVarName = mprintf("%s_url", zVarPrefix);
381381
char *zUrl = 0; /* stylesheet URL */
382382
int hasBuiltin = 0; /* true for built-in page-specific CSS */
383
-
383
+ char const * zSkinName = P("once") ? skin_in_use() : 0
384
+ /* In order to avoid a delayed-load issue which results in the
385
+ page and CSS having different skin definitions, we need to
386
+ pass the skin name along to the CSS-load URL. */;
387
+ char * zExtra = 0;
384388
if(0==strcmp("css",zConfigName)){
385389
/* Account for page-specific CSS, appending a /{{g.zPath}} to the
386390
** url only if we have a corresponding built-in page-specific CSS
387391
** file. Do not append it to all pages because we would
388392
** effectively cache-bust all pages which do not have
@@ -389,14 +393,19 @@
389393
** page-specific CSS. */
390394
char * zBuiltin = mprintf("style.%s.css", g.zPath);
391395
hasBuiltin = builtin_file(zBuiltin,0)!=0;
392396
fossil_free(zBuiltin);
393397
}
394
- zUrl = mprintf("%R/%s%s%s?id=%x", zPageName,
398
+ if(zSkinName && *zSkinName){
399
+ zExtra = mprintf("&skin=%T&once", zSkinName);
400
+ }
401
+ zUrl = mprintf("%R/%s%s%s?id=%x%s", zPageName,
395402
hasBuiltin ? "/" : "", hasBuiltin ? g.zPath : "",
396
- skin_id(zConfigName));
403
+ skin_id(zConfigName),
404
+ zExtra ? zExtra : "");
397405
Th_Store(zVarName, zUrl);
406
+ fossil_free(zExtra);
398407
fossil_free(zUrl);
399408
fossil_free(zVarName);
400409
}
401410
402411
/*
403412
--- src/style.c
+++ src/style.c
@@ -378,11 +378,15 @@
378 const char *zPageName
379 ){
380 char *zVarName = mprintf("%s_url", zVarPrefix);
381 char *zUrl = 0; /* stylesheet URL */
382 int hasBuiltin = 0; /* true for built-in page-specific CSS */
383
 
 
 
 
384 if(0==strcmp("css",zConfigName)){
385 /* Account for page-specific CSS, appending a /{{g.zPath}} to the
386 ** url only if we have a corresponding built-in page-specific CSS
387 ** file. Do not append it to all pages because we would
388 ** effectively cache-bust all pages which do not have
@@ -389,14 +393,19 @@
389 ** page-specific CSS. */
390 char * zBuiltin = mprintf("style.%s.css", g.zPath);
391 hasBuiltin = builtin_file(zBuiltin,0)!=0;
392 fossil_free(zBuiltin);
393 }
394 zUrl = mprintf("%R/%s%s%s?id=%x", zPageName,
 
 
 
395 hasBuiltin ? "/" : "", hasBuiltin ? g.zPath : "",
396 skin_id(zConfigName));
 
397 Th_Store(zVarName, zUrl);
 
398 fossil_free(zUrl);
399 fossil_free(zVarName);
400 }
401
402 /*
403
--- src/style.c
+++ src/style.c
@@ -378,11 +378,15 @@
378 const char *zPageName
379 ){
380 char *zVarName = mprintf("%s_url", zVarPrefix);
381 char *zUrl = 0; /* stylesheet URL */
382 int hasBuiltin = 0; /* true for built-in page-specific CSS */
383 char const * zSkinName = P("once") ? skin_in_use() : 0
384 /* In order to avoid a delayed-load issue which results in the
385 page and CSS having different skin definitions, we need to
386 pass the skin name along to the CSS-load URL. */;
387 char * zExtra = 0;
388 if(0==strcmp("css",zConfigName)){
389 /* Account for page-specific CSS, appending a /{{g.zPath}} to the
390 ** url only if we have a corresponding built-in page-specific CSS
391 ** file. Do not append it to all pages because we would
392 ** effectively cache-bust all pages which do not have
@@ -389,14 +393,19 @@
393 ** page-specific CSS. */
394 char * zBuiltin = mprintf("style.%s.css", g.zPath);
395 hasBuiltin = builtin_file(zBuiltin,0)!=0;
396 fossil_free(zBuiltin);
397 }
398 if(zSkinName && *zSkinName){
399 zExtra = mprintf("&skin=%T&once", zSkinName);
400 }
401 zUrl = mprintf("%R/%s%s%s?id=%x%s", zPageName,
402 hasBuiltin ? "/" : "", hasBuiltin ? g.zPath : "",
403 skin_id(zConfigName),
404 zExtra ? zExtra : "");
405 Th_Store(zVarName, zUrl);
406 fossil_free(zExtra);
407 fossil_free(zUrl);
408 fossil_free(zVarName);
409 }
410
411 /*
412

Keyboard Shortcuts

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