Fossil

Check-in [38762b9f]
Login

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

Overview
Comment:Improvements and fixes to the new skin editing.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | skin-setup-refactor
Files: files | file ages | folders
SHA3-256: 38762b9f6c56ad3f39ebc405abb1e739ff0cbe391f47c5a13afa7044e2219cf4
User & Date: drh 2017-12-03 01:29:19.560
Context
2017-12-03
01:57
On the Skins admin page, add Step 8 which gives administrators a link to the legacy Skin control page, with updates to deal with drafts. ... (check-in: 49d923bd user: drh tags: skin-setup-refactor)
01:29
Improvements and fixes to the new skin editing. ... (check-in: 38762b9f user: drh tags: skin-setup-refactor)
2017-12-02
21:48
Improvements to the skin file editing. ... (check-in: 2179ffd4 user: drh tags: skin-setup-refactor)
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/skins.c.
438
439
440
441
442
443
444

445
446
447
448
449
450
451
452
453
    "INSERT OR IGNORE INTO config(name, value, mtime)"
    "VALUES('skin:%q',%Q,now())",
    zNewName, zCurrent
  );
  return 0;
}


/*
** WEBPAGE: setup_skin_old
**
** Show a list of available skins with buttons for selecting which
** skin to use.  Requires Setup privilege.
*/
void setup_skin_old(void){
  const char *z;
  char *zName;







>

|







438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
    "INSERT OR IGNORE INTO config(name, value, mtime)"
    "VALUES('skin:%q',%Q,now())",
    zNewName, zCurrent
  );
  return 0;
}

#if 0
/*
** WEB**PAGE: setup_skin_old
**
** Show a list of available skins with buttons for selecting which
** skin to use.  Requires Setup privilege.
*/
void setup_skin_old(void){
  const char *z;
  char *zName;
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
    @ <input type="submit" name="save" value="Save">
    @ </form>
  }
  @ </table>
  style_footer();
  db_end_transaction(0);
}


/*
** WEBPAGE: setup_skinedit
**
** Edit aspects of a skin determined by the w= query parameter.
** Requires Setup privileges.
**







|







598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
    @ <input type="submit" name="save" value="Save">
    @ </form>
  }
  @ </table>
  style_footer();
  db_end_transaction(0);
}
#endif

/*
** WEBPAGE: setup_skinedit
**
** Edit aspects of a skin determined by the w= query parameter.
** Requires Setup privileges.
**
723
724
725
726
727
728
729

730
731
732

733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
** skin named by zTemplate.
*/
static void skin_initialize_draft(int iSkin, const char *zTemplate){
  int i;
  if( zTemplate==0 ) return;
  if( strcmp(zTemplate, "current")==0 ){
    for(i=0; i<count(azSkinFile); i++){

      db_unset_mprintf("draft%d-%s", 0, iSkin, azSkinFile[i]);
    }
  }else{

    for(i=0; i<count(aBuiltinSkin); i++){
      if( strcmp(zTemplate, aBuiltinSkin[i].zLabel)==0 ){
        for(i=0; i<count(azSkinFile); i++){
          char *zKey = mprintf("skins/%s/%s.txt", zTemplate, azSkinFile[i]);
          db_set_mprintf("draft%d-%s", builtin_text(zKey), 0,
                         iSkin, azSkinFile[i]);
        }
        break;
      }
    }
  }
}

/*
** Publish the draft skin iSkin as the new default.
*/







>
|

|
>
|
|
|
|
|
|
|
|
<







724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743

744
745
746
747
748
749
750
** skin named by zTemplate.
*/
static void skin_initialize_draft(int iSkin, const char *zTemplate){
  int i;
  if( zTemplate==0 ) return;
  if( strcmp(zTemplate, "current")==0 ){
    for(i=0; i<count(azSkinFile); i++){
      db_set_mprintf("draft%d-%s", db_get(azSkinFile[i],""), 0,
                     iSkin, azSkinFile[i]);
    }
    return;
  }
  for(i=0; i<count(aBuiltinSkin); i++){
    if( strcmp(zTemplate, aBuiltinSkin[i].zLabel)==0 ){
      for(i=0; i<count(azSkinFile); i++){
        char *zKey = mprintf("skins/%s/%s.txt", zTemplate, azSkinFile[i]);
        db_set_mprintf("draft%d-%s", builtin_text(zKey), 0,
                       iSkin, azSkinFile[i]);
      }
      return;

    }
  }
}

/*
** Publish the draft skin iSkin as the new default.
*/
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
      "  strftime('skin:Backup On %%Y-%%m-%%d %%H:%%M:%%S'),"
      "  %Q,now())", zCurrent
    );
  }

  /* Publish draft iSkin */
  for(i=0; i<count(azSkinFile); i++){
    db_multi_exec(
      "UPDATE config"
      " SET value=(SELECT value FROM config AS x"
                  " WHERE x.name = printf('draft%d-%%s',config.name)),"
      "     mtime=now()"
      " WHERE name IN ('css','header','footer','details')", iSkin
    );
  }
}

/*
** WEBPAGE: setup_skin
**
** Generate a page showing the steps needed to customize a skin.







<
<
<
|
<
<
|







774
775
776
777
778
779
780



781


782
783
784
785
786
787
788
789
      "  strftime('skin:Backup On %%Y-%%m-%%d %%H:%%M:%%S'),"
      "  %Q,now())", zCurrent
    );
  }

  /* Publish draft iSkin */
  for(i=0; i<count(azSkinFile); i++){



    char *zNew = db_get_mprintf("draft%d-%s", "", iSkin, azSkinFile[i]);


    db_set(azSkinFile[i], zNew, 0);
  }
}

/*
** WEBPAGE: setup_skin
**
** Generate a page showing the steps needed to customize a skin.