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.
Commit
10dfd9e51bebc8fd1b82bc1803be2d9881c4b333d7c44b18f1347326eba83133
Parent
7db18bfe960901a…
2 files changed
+5
-5
+12
-3
+5
-5
| --- src/skins.c | ||
| +++ src/skins.c | ||
| @@ -134,28 +134,28 @@ | ||
| 134 | 134 | ** |
| 135 | 135 | ** 3) Skin properties from the CONFIG db table |
| 136 | 136 | ** |
| 137 | 137 | ** 4) Default skin. |
| 138 | 138 | ** |
| 139 | -** As a special case, the name "_repo" resets zAltSkinDir and | |
| 139 | +** As a special case, a NULL or empty name resets zAltSkinDir and | |
| 140 | 140 | ** pAltSkin to 0 to indicate that the current config-side skin should |
| 141 | 141 | ** be used (rank 3, above), then returns 0. |
| 142 | 142 | */ |
| 143 | 143 | char *skin_use_alternative(const char *zName, int rank){ |
| 144 | 144 | static int currentRank = 5; |
| 145 | 145 | int i; |
| 146 | 146 | Blob err = BLOB_INITIALIZER; |
| 147 | 147 | if(rank > currentRank) return 0; |
| 148 | - if( 1==rank && strchr(zName, '/')!=0 ){ | |
| 148 | + if( zName && 1==rank && strchr(zName, '/')!=0 ){ | |
| 149 | 149 | zAltSkinDir = fossil_strdup(zName); |
| 150 | 150 | return 0; |
| 151 | 151 | } |
| 152 | - if( sqlite3_strglob("draft[1-9]", zName)==0 ){ | |
| 152 | + if( zName && sqlite3_strglob("draft[1-9]", zName)==0 ){ | |
| 153 | 153 | skin_use_draft(zName[5] - '0'); |
| 154 | 154 | return 0; |
| 155 | 155 | } |
| 156 | - if(zName && 0==strcmp("_repo",zName)){ | |
| 156 | + if(!zName || !*zName){ | |
| 157 | 157 | pAltSkin = 0; |
| 158 | 158 | zAltSkinDir = 0; |
| 159 | 159 | return 0; |
| 160 | 160 | } |
| 161 | 161 | for(i=0; i<count(aBuiltinSkin); i++){ |
| @@ -1207,11 +1207,11 @@ | ||
| 1207 | 1207 | @ <p>The following skins are available for this repository:</p> |
| 1208 | 1208 | @ <ul> |
| 1209 | 1209 | if( pAltSkin==0 && zAltSkinDir==0 && iDraftSkin==0 ){ |
| 1210 | 1210 | @ <li> Standard skin for this repository ← <i>Currently in use</i> |
| 1211 | 1211 | }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> | |
| 1213 | 1213 | } |
| 1214 | 1214 | for(i=0; i<count(aBuiltinSkin); i++){ |
| 1215 | 1215 | if( pAltSkin==&aBuiltinSkin[i] ){ |
| 1216 | 1216 | @ <li> %h(aBuiltinSkin[i].zDesc) ← <i>Currently in use</i> |
| 1217 | 1217 | }else{ |
| 1218 | 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, 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 ← <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) ← <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 ← <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) ← <i>Currently in use</i> |
| 1217 | }else{ |
| 1218 |
+12
-3
| --- src/style.c | ||
| +++ src/style.c | ||
| @@ -378,11 +378,15 @@ | ||
| 378 | 378 | const char *zPageName |
| 379 | 379 | ){ |
| 380 | 380 | char *zVarName = mprintf("%s_url", zVarPrefix); |
| 381 | 381 | char *zUrl = 0; /* stylesheet URL */ |
| 382 | 382 | 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; | |
| 384 | 388 | if(0==strcmp("css",zConfigName)){ |
| 385 | 389 | /* Account for page-specific CSS, appending a /{{g.zPath}} to the |
| 386 | 390 | ** url only if we have a corresponding built-in page-specific CSS |
| 387 | 391 | ** file. Do not append it to all pages because we would |
| 388 | 392 | ** effectively cache-bust all pages which do not have |
| @@ -389,14 +393,19 @@ | ||
| 389 | 393 | ** page-specific CSS. */ |
| 390 | 394 | char * zBuiltin = mprintf("style.%s.css", g.zPath); |
| 391 | 395 | hasBuiltin = builtin_file(zBuiltin,0)!=0; |
| 392 | 396 | fossil_free(zBuiltin); |
| 393 | 397 | } |
| 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, | |
| 395 | 402 | hasBuiltin ? "/" : "", hasBuiltin ? g.zPath : "", |
| 396 | - skin_id(zConfigName)); | |
| 403 | + skin_id(zConfigName), | |
| 404 | + zExtra ? zExtra : ""); | |
| 397 | 405 | Th_Store(zVarName, zUrl); |
| 406 | + fossil_free(zExtra); | |
| 398 | 407 | fossil_free(zUrl); |
| 399 | 408 | fossil_free(zVarName); |
| 400 | 409 | } |
| 401 | 410 | |
| 402 | 411 | /* |
| 403 | 412 |
| --- 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 |