Fossil

Check-in [d661c12c]
Login

Check-in [d661c12c]

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

Overview
Comment:Extended style.css to optionally be able to load page-specific CSS if the 'page' URL param is provided and a builtin file named style.{{page}}.css is found. The stylesheet_url TH1 var now adds URL param page=g.zPath if builtin file style.{{g.zPath}}.css is available.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | fileedit-ajaxify
Files: files | file ages | folders
SHA3-256: d661c12cbadef066fcd747c7526cd64d5f27fa340021f3a3fa4d98e0af3970e7
User & Date: stephan 2020-05-17 03:19:55
References
2020-05-17
03:32
Moved fileedit-specific CSS to style.fileedit.css, as enabled by previous commit [d661c12cbade]. ... (check-in: 95f1753f user: stephan tags: fileedit-ajaxify)
Context
2020-05-17
03:32
Moved fileedit-specific CSS to style.fileedit.css, as enabled by previous commit [d661c12cbade]. ... (check-in: 95f1753f user: stephan tags: fileedit-ajaxify)
03:19
Extended style.css to optionally be able to load page-specific CSS if the 'page' URL param is provided and a builtin file named style.{{page}}.css is found. The stylesheet_url TH1 var now adds URL param page=g.zPath if builtin file style.{{g.zPath}}.css is available. ... (check-in: d661c12c user: stephan tags: fileedit-ajaxify)
2020-05-16
17:05
Clear the preview/diff views after a non-dry-run commit. Added toggle to include (or not) manifest in the commit response. Added branch name to finfo objects from the server so that we have the branch names for stashed non-leaf edits. Extended fossil.connectPagePreviewers() to be able to optionally specify methods, instead of element IDs, for the 'from' source and 'to' target, in order to support custom editor/preview widgets. ... (check-in: b5944d4e user: stephan tags: fileedit-ajaxify)
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/style.c.

368
369
370
371
372
373
374

375













376

377

378
379
380
381
382
383
384
385
386
*/
static void url_var(
  const char *zVarPrefix,
  const char *zConfigName,
  const char *zPageName
){
  char *zVarName = mprintf("%s_url", zVarPrefix);

  char *zUrl = mprintf("%R/%s?id=%x", zPageName,













                       skin_id(zConfigName));

  Th_Store(zVarName, zUrl);

  free(zUrl);
  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.
*/
static void image_url_var(const char *zImageName){







>
|
>
>
>
>
>
>
>
>
>
>
>
>
>
|
>

>
|
|







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
*/
static void url_var(
  const char *zVarPrefix,
  const char *zConfigName,
  const char *zPageName
){
  char *zVarName = mprintf("%s_url", zVarPrefix);
  char *zExtra = 0;
  char *zUrl = 0;
  if(0==strcmp("css",zConfigName)){
    /* Account for page-specific CSS, appending a page=NAME url flag
    ** 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);
    if(builtin_file(zBuiltin,0)!=0){
      zExtra = mprintf("&page=%s", g.zPath);
    }
    fossil_free(zBuiltin);
  }
  zUrl = mprintf("%R/%s?id=%x%s", zPageName,
                 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.
*/
static void image_url_var(const char *zImageName){
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070

1071
1072


































1073

1074
1075
1076
1077
1078
1079
1080

/*
** WEBPAGE: style.css
**
** Return the style sheet.
*/
void page_style_css(void){
  Blob css;
  int i;
  int isInit = 0;


  cgi_set_content_type("text/css");


































  blob_init(&css,skin_get("css"),-1);


  /* add special missing definitions */
  for(i=1; cssDefaultList[i].elementClass; i++){
    char *z = blob_str(&css);
    if( !containsSelector(z, cssDefaultList[i].elementClass) ){
      if( !isInit ){
        isInit = 1;







|


>


>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
>







1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132

/*
** WEBPAGE: style.css
**
** Return the style sheet.
*/
void page_style_css(void){
  Blob css = empty_blob;
  int i;
  int isInit = 0;
  const char * zPage = P("page");

  cgi_set_content_type("text/css");
  if(zPage!=0 && zPage[0]!=0
     && strlen(zPage)<30/*marginal safety measure vs malicious input*/){
    /* Check for page-specific CSS. The placement of this CSS is kinda
    ** tricky. It "very probably needs" to come before any
    ** skin-supplied CSS, but if it does then a system-level skin
    ** which does silly things like set *all* textareas to the same
    ** 32px tall (Ardoise) can effectively ruin page-specific
    ** layout. If the page-specific CSS is emitted after the skin,
    ** then the page-specific CSS will potentially override any user
    ** edits made to the skin, leaving the user with no way to
    ** override them except to import a separate CSS file from their
    ** custom skin, after this one. Thus the page CSS needs to come
    ** first, but it also needs "unusually specific"
    ** (i.e. strongly-binding) CSS classes for any style which "needs"
    ** to override the *default* skin CSS, but which is nonetheless
    ** overridable by client-side edits by using CSS selectors of
    ** equal or higher specificity.
    **
    ** The alternative to this approach is that we pack all
    ** page-specific CSS into default_css.txt, which can explode it
    ** tremendously. e.g. /fileedit itself includes 330-ish lines of
    ** CSS.
    */
    int nLen = 0;
    char * zPageCss = mprintf("style.%s.css",zPage);
    const char * zBuiltin = (const char *)builtin_file(zPageCss, &nLen);
    fossil_free(zPageCss);
    if(nLen>0){
      blob_append(&css, zBuiltin, nLen);
    }
  }
  if(blob_size(&css)>0){
    blob_append(&css,skin_get("css"),-1);
  }else{
    blob_init(&css,skin_get("css"),-1);
  }

  /* add special missing definitions */
  for(i=1; cssDefaultList[i].elementClass; i++){
    char *z = blob_str(&css);
    if( !containsSelector(z, cssDefaultList[i].elementClass) ){
      if( !isInit ){
        isInit = 1;