Fossil

Check-in [b828d8fd59]
Login

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

Overview
Comment:Show the custom skin as an option on the /skins page, if it exists.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: b828d8fd59a18b923087ca180de269b25407a4621d684efe3af18a74fa029a00
User & Date: drh 2024-02-23 23:29:54.225
Context
2024-02-23
23:31
Remove a debugging printf() accidently left in the previous check-in. Also remove an unused variable. check-in: 00dad9a2f2 user: drh tags: trunk
23:29
Show the custom skin as an option on the /skins page, if it exists. check-in: b828d8fd59 user: drh tags: trunk
22:35
Improvements to the "/skins" page to work better with the new default-skin setting. check-in: 99575d4cbc user: drh tags: trunk
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/skins.c.
193
194
195
196
197
198
199






200
201
202
203
204
205
206
    iSkinSource = iSource;
    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];
      iSkinSource = iSource;
      return 0;
    }







>
>
>
>
>
>







193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
    iSkinSource = iSource;
    return 0;
  }
  if(!zName || !*zName){
    pAltSkin = 0;
    zAltSkinDir = 0;
    return 0;
  }
  if( fossil_strcmp(zName, "custom")==0 ){
    pAltSkin = 0;
    zAltSkinDir = 0;
    iSkinSource = iSource;
    return 0;
  }
  for(i=0; i<count(aBuiltinSkin); i++){
    if( fossil_strcmp(aBuiltinSkin[i].zLabel, zName)==0 ){
      pAltSkin = &aBuiltinSkin[i];
      iSkinSource = iSource;
      return 0;
    }
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
    fossil_free(z);
  }else{
    zOut = db_get(zWhat, 0);
    if( zOut==0 ){
      z = mprintf("skins/default/%s.txt", zWhat);
      zOut = builtin_text(z);
      fossil_free(z);
    }else{
      iSkinSource = SKIN_FROM_CUSTOM;
    }
  }
  return zOut;
}

/*







|







287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
    fossil_free(z);
  }else{
    zOut = db_get(zWhat, 0);
    if( zOut==0 ){
      z = mprintf("skins/default/%s.txt", zWhat);
      zOut = builtin_text(z);
      fossil_free(z);
    }else if( iSkinSource==SKIN_FROM_DEFAULT ){
      iSkinSource = SKIN_FROM_CUSTOM;
    }
  }
  return zOut;
}

/*
1344
1345
1346
1347
1348
1349
1350

1351
1352
1353
1354
1355
1356
1357
** Show a list of all of the built-in skins, plus the responsitory skin,
** and provide the user with an opportunity to change to any of them.
*/
void skins_page(void){
  int i;
  char *zBase = fossil_strdup(g.zTop);
  size_t nBase = strlen(zBase);

  login_check_credentials();
  if( iDraftSkin && sqlite3_strglob("*/draft?", zBase)==0 ){
    nBase -= 7;
    zBase[nBase] = 0;
  }else if( pAltSkin ){
    char *zPattern = mprintf("*/skn_%s", pAltSkin->zLabel);
    if( sqlite3_strglob(zPattern, zBase)==0 ){







>







1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
** Show a list of all of the built-in skins, plus the responsitory skin,
** and provide the user with an opportunity to change to any of them.
*/
void skins_page(void){
  int i;
  char *zBase = fossil_strdup(g.zTop);
  size_t nBase = strlen(zBase);
  const char *z;
  login_check_credentials();
  if( iDraftSkin && sqlite3_strglob("*/draft?", zBase)==0 ){
    nBase -= 7;
    zBase[nBase] = 0;
  }else if( pAltSkin ){
    char *zPattern = mprintf("*/skn_%s", pAltSkin->zLabel);
    if( sqlite3_strglob(zPattern, zBase)==0 ){
1374
1375
1376
1377
1378
1379
1380








1381
1382
1383
1384
1385
1386
1387
    @ "%z(href("%R/fdscookie"))fossil_display_settings</a>" cookie
    @ but will not be used so long as the site has a
    @ higher-priority skin in place.
    @ </p>
  }
  @ <p>The following skins are available for this repository:</p>
  @ <ul>








  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>
    }







>
>
>
>
>
>
>
>







1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
    @ "%z(href("%R/fdscookie"))fossil_display_settings</a>" cookie
    @ but will not be used so long as the site has a
    @ higher-priority skin in place.
    @ </p>
  }
  @ <p>The following skins are available for this repository:</p>
  @ <ul>
  if( skin_exists_custom() ){
    if( pAltSkin==0 && zAltSkinDir==0 && iDraftSkin==0 ){
      @ <li> Custom skin for this repository &larr; <i>Currently in use</i>
    }else{
      @ <li> %z(href("%R/skins?skin=custom"))\
      @ Custom 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>
    }
1407
1408
1409
1410
1411
1412
1413

1414
1415
1416
1417
1418
1419
1420
         @ "%z(href("%R/fdscookie"))fossil_display_settings</a>" cookie.
         break;
      case SKIN_FROM_SETTING:
         @ the "default-skin" setting on the repository.
         break;
    }
  }

  if( iSkinSource==SKIN_FROM_COOKIE || iSkinSource==SKIN_FROM_QPARAM ){
    @ <ul>
    @ <li> %z(href("%R/skins?skin="))<i>Let Fossil choose \
    @ which skin to use</i></a>
    @ </ul>
  }
  style_finish_page();







>







1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
         @ "%z(href("%R/fdscookie"))fossil_display_settings</a>" cookie.
         break;
      case SKIN_FROM_SETTING:
         @ the "default-skin" setting on the repository.
         break;
    }
  }
fprintf(stderr, "iSkinSource = %d\n", iSkinSource);
  if( iSkinSource==SKIN_FROM_COOKIE || iSkinSource==SKIN_FROM_QPARAM ){
    @ <ul>
    @ <li> %z(href("%R/skins?skin="))<i>Let Fossil choose \
    @ which skin to use</i></a>
    @ </ul>
  }
  style_finish_page();