Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
| Comment: | 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. |
|---|---|
| Downloads: | Tarball | ZIP archive |
| Timelines: | family | ancestors | descendants | both | trunk |
| Files: | files | file ages | folders |
| SHA3-256: |
6acd87f2c16724f9fcbea6541d53f3b9 |
| User & Date: | drh 2021-03-02 16:06:40.017 |
Context
|
2021-03-02
| ||
| 16:44 | Update to the change log. ... (check-in: c0c1235998 user: drh tags: trunk) | |
| 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: 6acd87f2c1 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: 10dfd9e51b user: stephan tags: trunk) | |
Changes
Changes to src/style.c.
| ︙ | ︙ | |||
364 365 366 367 368 369 370 |
va_start(ap, zFormat);
local_zCurrentPage = vmprintf(zFormat, ap);
va_end(ap);
}
}
/*
| | > | | > > > > | < < < < < | | | | < < | > | | | > > > > | > > | > | > > | | > > | | > > > > | | | < < < > | < | < | > > > > > > | | > > | > | | | 364 365 366 367 368 369 370 371 372 373 374 375 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 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 |
va_start(ap, zFormat);
local_zCurrentPage = vmprintf(zFormat, ap);
va_end(ap);
}
}
/*
** Create a TH1 variable containing the URL for the stylesheet.
**
** The name of the new variable will be "stylesheet_url".
**
** The value will be a URL for accessing the appropriate stylesheet.
** This URL will include query parameters such as "id=" and "once&skin="
** to cause the correct stylesheet to be loaded after a skin change
** or after a change to the stylesheet.
*/
static void stylesheet_url_var(void){
char *zBuiltin; /* Auxiliary page-specific CSS page */
Blob url; /* The URL */
/* Initialize the URL to its baseline */
url = empty_blob;
blob_appendf(&url, "%R/style.css");
/* If page-specific CSS exists for the current page, then append
** the pathname for the page-specific CSS. The default CSS is
**
** /style.css
**
** But for the "/wikiedit" page (to name but one example), we
** append a path as follows:
**
** /style.css/wikiedit
**
** The /style.css page (implemented below) will detect this extra "wikiedit"
** path information and include the page-specific CSS along with the
** default CSS when it delivers the page.
*/
zBuiltin = mprintf("style.%s.css", g.zPath);
if( builtin_file(zBuiltin,0)!=0 ){
blob_appendf(&url, "/%s", g.zPath);
}
fossil_free(zBuiltin);
/* Add query parameters that will change whenever the skin changes
** or after any updates to the CSS files
*/
blob_appendf(&url, "?id=%x", skin_id("css"));
if( P("once")!=0 && P("skin")!=0 ){
blob_appendf(&url, "&skin=%s&once", skin_in_use());
}
/* Generate the CSS URL variable */
Th_Store("stylesheet_url", blob_str(&url));
blob_reset(&url);
}
/*
** Create a TH1 variable containing the URL for the specified image.
** The resulting variable name will be of the form $[zImageName]_image_url.
** The value will be a URL that includes an id= query parameter that
** changes if the underlying resource changes or if a different skin
** is selected.
*/
static void image_url_var(const char *zImageName){
char *zVarName; /* Name of the new TH1 variable */
char *zResource; /* Name of CONFIG entry holding content */
char *zUrl; /* The URL */
zResource = mprintf("%s-image", zImageName);
zUrl = mprintf("%R/%s?id=%x", zImageName, skin_id(zResource));
free(zResource);
zVarName = mprintf("%s_image_url", zImageName);
Th_Store(zVarName, zUrl);
free(zVarName);
free(zUrl);
}
/*
** Output TEXT with a click-to-copy button next to it. Loads the copybtn.js
** Javascript module, and generates HTML elements with the following IDs:
**
** TARGETID: The <span> wrapper around TEXT.
|
| ︙ | ︙ | |||
712 713 714 715 716 717 718 |
Th_Store("current_page", local_zCurrentPage);
Th_Store("csrf_token", g.zCsrfToken);
Th_Store("release_version", RELEASE_VERSION);
Th_Store("manifest_version", MANIFEST_VERSION);
Th_Store("manifest_date", MANIFEST_DATE);
Th_Store("compiler_name", COMPILER_NAME);
Th_Store("mainmenu", style_get_mainmenu());
| | | 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 |
Th_Store("current_page", local_zCurrentPage);
Th_Store("csrf_token", g.zCsrfToken);
Th_Store("release_version", RELEASE_VERSION);
Th_Store("manifest_version", MANIFEST_VERSION);
Th_Store("manifest_date", MANIFEST_DATE);
Th_Store("compiler_name", COMPILER_NAME);
Th_Store("mainmenu", style_get_mainmenu());
stylesheet_url_var();
image_url_var("logo");
image_url_var("background");
if( !login_is_nobody() ){
Th_Store("login", g.zLogin);
}
Th_MaybeStore("current_feature", feature_from_page_path(local_zCurrentPage) );
}
|
| ︙ | ︙ |