Fossil

Check-in [10dfd9e5]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment: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.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 10dfd9e51bebc8fd1b82bc1803be2d9881c4b333d7c44b18f1347326eba83133
User & Date: stephan 2021-03-02 15:33:31
Context
2021-03-02
16:06
Refactor the routines used to generate TH1 variables that hold resource URLs. Functionality should be unchanged. The purpose is to make the code simplier, easier to read, and easier to maintain. ... (check-in: 6acd87f2 user: drh tags: trunk)
15:33
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. ... (check-in: 10dfd9e5 user: stephan tags: trunk)
15:01
When skin=X query parameter is processed, if a param named 'once' is also set then apply the skin change but do not save it to the cookie, as per /chat discussion. The intent is mainly to facilitate the development of docs using both light- and dark-mode skins at the same time, which is somewhat painful when the cookie constantly gets overwritten. ... (check-in: 7db18bfe user: stephan tags: trunk)
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/skins.c.

132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
** skin then that will update the display cookie. If the skin name is
** illegal it is silently ignored.
**
** 3) Skin properties from the CONFIG db table
**
** 4) Default skin.
**
** As a special case, the name "_repo" resets zAltSkinDir and
** pAltSkin to 0 to indicate that the current config-side skin should
** be used (rank 3, above), then returns 0.
*/
char *skin_use_alternative(const char *zName, int rank){
  static int currentRank = 5;
  int i;
  Blob err = BLOB_INITIALIZER;
  if(rank > currentRank) return 0;
  if( 1==rank && strchr(zName, '/')!=0 ){
    zAltSkinDir = fossil_strdup(zName);
    return 0;
  }
  if( sqlite3_strglob("draft[1-9]", zName)==0 ){
    skin_use_draft(zName[5] - '0');
    return 0;
  }
  if(zName && 0==strcmp("_repo",zName)){
    pAltSkin = 0;
    zAltSkinDir = 0;
    return 0;
  }
  for(i=0; i<count(aBuiltinSkin); i++){
    if( fossil_strcmp(aBuiltinSkin[i].zLabel, zName)==0 ){
      pAltSkin = &aBuiltinSkin[i];







|








|



|



|







132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
** skin then that will update the display cookie. If the skin name is
** illegal it is silently ignored.
**
** 3) Skin properties from the CONFIG db table
**
** 4) Default skin.
**
** As a special case, a NULL or empty name resets zAltSkinDir and
** pAltSkin to 0 to indicate that the current config-side skin should
** be used (rank 3, above), then returns 0.
*/
char *skin_use_alternative(const char *zName, int rank){
  static int currentRank = 5;
  int i;
  Blob err = BLOB_INITIALIZER;
  if(rank > currentRank) return 0;
  if( zName && 1==rank && strchr(zName, '/')!=0 ){
    zAltSkinDir = fossil_strdup(zName);
    return 0;
  }
  if( zName && sqlite3_strglob("draft[1-9]", zName)==0 ){
    skin_use_draft(zName[5] - '0');
    return 0;
  }
  if(!zName || !*zName){
    pAltSkin = 0;
    zAltSkinDir = 0;
    return 0;
  }
  for(i=0; i<count(aBuiltinSkin); i++){
    if( fossil_strcmp(aBuiltinSkin[i].zLabel, zName)==0 ){
      pAltSkin = &aBuiltinSkin[i];
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
    @ </p>
  }
  @ <p>The following skins are available for this repository:</p>
  @ <ul>
  if( pAltSkin==0 && zAltSkinDir==0 && iDraftSkin==0 ){
    @ <li> Standard skin for this repository &larr; <i>Currently in use</i>
  }else{
    @ <li> %z(href("%R/skins?skin=_repo"))Standard skin for this repository</a>
  }
  for(i=0; i<count(aBuiltinSkin); i++){
    if( pAltSkin==&aBuiltinSkin[i] ){
      @ <li> %h(aBuiltinSkin[i].zDesc) &larr; <i>Currently in use</i>
    }else{
      char *zUrl = href("%R/skins?skin=%T", aBuiltinSkin[i].zLabel);
      @ <li> %z(zUrl)%h(aBuiltinSkin[i].zDesc)</a>
    }
  }
  @ </ul>
  style_finish_page();
  fossil_free(zBase);
}







|













1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
    @ </p>
  }
  @ <p>The following skins are available for this repository:</p>
  @ <ul>
  if( pAltSkin==0 && zAltSkinDir==0 && iDraftSkin==0 ){
    @ <li> Standard skin for this repository &larr; <i>Currently in use</i>
  }else{
    @ <li> %z(href("%R/skins?skin="))Standard skin for this repository</a>
  }
  for(i=0; i<count(aBuiltinSkin); i++){
    if( pAltSkin==&aBuiltinSkin[i] ){
      @ <li> %h(aBuiltinSkin[i].zDesc) &larr; <i>Currently in use</i>
    }else{
      char *zUrl = href("%R/skins?skin=%T", aBuiltinSkin[i].zLabel);
      @ <li> %z(zUrl)%h(aBuiltinSkin[i].zDesc)</a>
    }
  }
  @ </ul>
  style_finish_page();
  fossil_free(zBase);
}

Changes to src/style.c.

376
377
378
379
380
381
382
383




384
385
386
387
388
389
390
391
392
393



394
395
396

397

398
399
400
401
402
403
404
  const char *zVarPrefix,
  const char *zConfigName,
  const char *zPageName
){
  char *zVarName = mprintf("%s_url", zVarPrefix);
  char *zUrl = 0;              /* stylesheet URL */
  int hasBuiltin = 0;          /* true for built-in page-specific CSS */





  if(0==strcmp("css",zConfigName)){
    /* Account for page-specific CSS, appending a /{{g.zPath}} to the
    ** url only if we have a corresponding built-in page-specific CSS
    ** file. Do not append it to all pages because we would
    ** effectively cache-bust all pages which do not have
    ** page-specific CSS. */
    char * zBuiltin = mprintf("style.%s.css", g.zPath);
    hasBuiltin = builtin_file(zBuiltin,0)!=0;
    fossil_free(zBuiltin);
  }



  zUrl = mprintf("%R/%s%s%s?id=%x", zPageName,
                 hasBuiltin ? "/" : "", hasBuiltin ? g.zPath : "",
                 skin_id(zConfigName));

  Th_Store(zVarName, zUrl);

  fossil_free(zUrl);
  fossil_free(zVarName);
}

/*
** Create a TH1 variable containing the URL for the specified config image.
** The resulting variable name will be of the form $[zImageName]_image_url.







|
>
>
>
>










>
>
>
|

|
>

>







376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
  const char *zVarPrefix,
  const char *zConfigName,
  const char *zPageName
){
  char *zVarName = mprintf("%s_url", zVarPrefix);
  char *zUrl = 0;              /* stylesheet URL */
  int hasBuiltin = 0;          /* true for built-in page-specific CSS */
  char const * zSkinName = P("once") ? skin_in_use() : 0
    /* In order to avoid a delayed-load issue which results in the
       page and CSS having different skin definitions, we need to
       pass the skin name along to the CSS-load URL. */;
  char * zExtra = 0;
  if(0==strcmp("css",zConfigName)){
    /* Account for page-specific CSS, appending a /{{g.zPath}} to the
    ** url only if we have a corresponding built-in page-specific CSS
    ** file. Do not append it to all pages because we would
    ** effectively cache-bust all pages which do not have
    ** page-specific CSS. */
    char * zBuiltin = mprintf("style.%s.css", g.zPath);
    hasBuiltin = builtin_file(zBuiltin,0)!=0;
    fossil_free(zBuiltin);
  }
  if(zSkinName && *zSkinName){
    zExtra = mprintf("&skin=%T&once", zSkinName);
  }
  zUrl = mprintf("%R/%s%s%s?id=%x%s", zPageName,
                 hasBuiltin ? "/" : "", hasBuiltin ? g.zPath : "",
                 skin_id(zConfigName),
                 zExtra ? zExtra : "");
  Th_Store(zVarName, zUrl);
  fossil_free(zExtra);
  fossil_free(zUrl);
  fossil_free(zVarName);
}

/*
** Create a TH1 variable containing the URL for the specified config image.
** The resulting variable name will be of the form $[zImageName]_image_url.