Fossil SCM

Rework the Setup/Skin page so that all edits are done on a draft, then tested, then the draft is published to become the default skin. This specific check-in is just the beginning. Must code needs to be added. This is just an incremental check-in.

drh 2017-12-02 14:39 UTC trunk
Commit 9bafe6cb601b35962d7b0c51c7761a5c813e9547aab93b5438220b7dbaf4314f
1 file changed +100 -10
+100 -10
--- src/skins.c
+++ src/skins.c
@@ -2,11 +2,11 @@
22
** Copyright (c) 2009 D. Richard Hipp
33
**
44
** This program is free software; you can redistribute it and/or
55
** modify it under the terms of the Simplified BSD License (also
66
** known as the "2-Clause License" or "FreeBSD License".)
7
-
7
+**
88
** This program is distributed in the hope that it will be useful,
99
** but without any warranty; without even the implied warranty of
1010
** merchantability or fitness for a particular purpose.
1111
**
1212
** Author contact information:
@@ -355,11 +355,11 @@
355355
style_header("Rename A Skin");
356356
if( ex ){
357357
@ <p><span class="generalError">There is already another skin
358358
@ named "%h(zNewName)". Choose a different name.</span></p>
359359
}
360
- @ <form action="%s(g.zTop)/setup_skin" method="post"><div>
360
+ @ <form action="%s(g.zTop)/setup_skin_old" method="post"><div>
361361
@ <table border="0"><tr>
362362
@ <tr><td align="right">Current name:<td align="left"><b>%h(zOldName)</b>
363363
@ <tr><td align="right">New name:<td align="left">
364364
@ <input type="text" size="35" name="newname" value="%h(zNewName)">
365365
@ <tr><td><td>
@@ -395,11 +395,11 @@
395395
style_header("Save Current Skin");
396396
if( ex ){
397397
@ <p><span class="generalError">There is already another skin
398398
@ named "%h(zNewName)". Choose a different name.</span></p>
399399
}
400
- @ <form action="%s(g.zTop)/setup_skin" method="post"><div>
400
+ @ <form action="%s(g.zTop)/setup_skin_old" method="post"><div>
401401
@ <table border="0"><tr>
402402
@ <tr><td align="right">Name for this skin:<td align="left">
403403
@ <input type="text" size="35" name="svname" value="%h(zNewName)">
404404
@ <tr><td><td>
405405
@ <input type="submit" name="save" value="Save">
@@ -417,16 +417,16 @@
417417
);
418418
return 0;
419419
}
420420
421421
/*
422
-** WEBPAGE: setup_skin
422
+** WEBPAGE: setup_skin_old
423423
**
424424
** Show a list of available skins with buttons for selecting which
425425
** skin to use. Requires Admin privilege.
426426
*/
427
-void setup_skin(void){
427
+void setup_skin_old(void){
428428
const char *z;
429429
char *zName;
430430
char *zErr = 0;
431431
const char *zCurrent = 0; /* Current skin */
432432
int i; /* Loop counter */
@@ -445,11 +445,11 @@
445445
}
446446
447447
/* Process requests to delete a user-defined skin */
448448
if( P("del1") && (zName = skinVarName(P("sn"), 1))!=0 ){
449449
style_header("Confirm Custom Skin Delete");
450
- @ <form action="%s(g.zTop)/setup_skin" method="post"><div>
450
+ @ <form action="%s(g.zTop)/setup_skin_old" method="post"><div>
451451
@ <p>Deletion of a custom skin is a permanent action that cannot
452452
@ be undone. Please confirm that this is what you want to do:</p>
453453
@ <input type="hidden" name="sn" value="%h(P("sn"))" />
454454
@ <input type="submit" name="del2" value="Confirm - Delete The Skin" />
455455
@ <input type="submit" name="cancel" value="Cancel - Do Not Delete" />
@@ -531,11 +531,11 @@
531531
@ <tr><td>%d(i+1).<td>%h(z)<td>&nbsp;&nbsp;<td>
532532
if( fossil_strcmp(aBuiltinSkin[i].zSQL, zCurrent)==0 ){
533533
@ (Currently In Use)
534534
seenCurrent = 1;
535535
}else{
536
- @ <form action="%s(g.zTop)/setup_skin" method="post">
536
+ @ <form action="%s(g.zTop)/setup_skin_old" method="post">
537537
@ <input type="hidden" name="sn" value="%h(z)" />
538538
@ <input type="submit" name="load" value="Install" />
539539
if( pAltSkin==&aBuiltinSkin[i] ){
540540
@ (Current override)
541541
}
@@ -551,11 +551,11 @@
551551
while( db_step(&q)==SQLITE_ROW ){
552552
const char *zN = db_column_text(&q, 0);
553553
const char *zV = db_column_text(&q, 1);
554554
i++;
555555
@ <tr><td>%d(i).<td>%h(zN)<td>&nbsp;&nbsp;<td>
556
- @ <form action="%s(g.zTop)/setup_skin" method="post">
556
+ @ <form action="%s(g.zTop)/setup_skin_old" method="post">
557557
if( fossil_strcmp(zV, zCurrent)==0 ){
558558
@ (Currently In Use)
559559
seenCurrent = 1;
560560
}else{
561561
@ <input type="submit" name="load" value="Install">
@@ -567,11 +567,11 @@
567567
}
568568
db_finalize(&q);
569569
if( !seenCurrent ){
570570
i++;
571571
@ <tr><td>%d(i).<td><i>Current Configuration</i><td>&nbsp;&nbsp;<td>
572
- @ <form action="%s(g.zTop)/setup_skin" method="post">
572
+ @ <form action="%s(g.zTop)/setup_skin_old" method="post">
573573
@ <input type="submit" name="save" value="Save">
574574
@ </form>
575575
}
576576
@ </table>
577577
style_footer();
@@ -622,11 +622,11 @@
622622
for(j=0; j<count(aSkinAttr); j++){
623623
if( j==ii ) continue;
624624
style_submenu_element(aSkinAttr[j].zSubmenu,
625625
"%R/setup_skinedit?w=%d&basis=%h",j,zBasis);
626626
}
627
- style_submenu_element("Skins", "%R/setup_skin");
627
+ style_submenu_element("Skins", "%R/setup_skin_old");
628628
@ <form action="%s(g.zTop)/setup_skinedit" method="post"><div>
629629
login_insert_csrf_secret();
630630
@ <input type='hidden' name='w' value='%d(ii)'>
631631
@ <h2>Edit %s(aSkinAttr[ii].zTitle):</h2>
632632
zContent = textarea_attribute("", 10, 80, aSkinAttr[ii].zFile,
@@ -668,5 +668,95 @@
668668
}
669669
@ </div></form>
670670
style_footer();
671671
db_end_transaction(0);
672672
}
673
+
674
+/*
675
+** WEBPAGE: setup_skin
676
+**
677
+** Generate a page showing the steps needed to customize a skin.
678
+*/
679
+void setup_skin(void){
680
+ int i; /* Loop counter */
681
+ int iSkin; /* Which draft skin is being edited */
682
+ static const char *azTestPages[] = {
683
+ "home",
684
+ "timeline",
685
+ "dir?ci=tip",
686
+ "dir?ci=tip&type=tree",
687
+ "brlist",
688
+ "info/trunk",
689
+ };
690
+
691
+
692
+ iSkin = atoi(PD("sk","1"));
693
+ if( iSkin<1 || iSkin>9 ) iSkin = 1;
694
+ login_check_credentials();
695
+ style_header("Customize Skin");
696
+
697
+#if 0
698
+ @ <p>
699
+ cgi_print_all(0);
700
+ @ </p>
701
+#endif
702
+
703
+ @ <p>Customize the look of this Fossil repository by making changes
704
+ @ to the CSS, Header, Footer, and Detail Settings in one of nine "draft"
705
+ @ configurations. Then, after verifying that all is working correctly,
706
+ @ publish the draft to become the new main Skin.<p>
707
+ @
708
+ @ <a name='step1'></a>
709
+ @ <h1>Step 1: Identify Which Draft To Use</h1>
710
+ @
711
+ @ <p>The main skin of Fossil cannot be edited directly. Instead,
712
+ @ edits are made to one of nine draft skins. A draft skin can then
713
+ @ be published to become the default skin.
714
+ @ Nine separate drafts are available to facilitate A/B testing.</p>
715
+ @
716
+ @ <form method='POST' action='%R/setup_skin#step2' id='f01'>
717
+ @ <p>Skin to edit:
718
+ @ <select size='1' name='sk' onchange='gebi("f01").submit()'>
719
+ for(i=1; i<=9; i++){
720
+ if( i==iSkin ){
721
+ @ <option value='%d(i)' selected>draft%d(i)</option>
722
+ }else{
723
+ @ <option value='%d(i)'>draft%d(i)</option>
724
+ }
725
+ }
726
+ @ </select>
727
+ @ </p>
728
+ @
729
+ @ <a name='step2'></a>
730
+ @ <h1>Step 2: Authenticate
731
+ @
732
+ @ <a name='step3'></a>
733
+ @ <h1>Step 3: Initialize The Draft</h1>
734
+ @
735
+ @ <a name='step4'></a>
736
+ @ <h1>Step 4: Make Edits</h1>
737
+ @
738
+ @ <a name='step5'></a>
739
+ @ <h1>Step 5: Verify The Draft Skin</h1>
740
+ @
741
+ @ <p>To test this draft skin, insert text "/draft%d(iSkin)/" just before the
742
+ @ operation name in the URL. Here are a few links to try:
743
+ @ <ul>
744
+ for(i=0; i<sizeof(azTestPages)/sizeof(azTestPages[0]); i++){
745
+ @ <li><a href='%s(g.zBaseURL)/draft%d(iSkin)/%s(azTestPages[i])'>\
746
+ @ %s(g.zBaseURL)/draft%d(iSkin)/%s(azTestPages[i])</a>
747
+ }
748
+ @ </ul>
749
+ @
750
+ @ <a name='step6'></a>
751
+ @ <h1>Step 6: Publish The Draft</h1>
752
+ if( !g.perm.Setup ){
753
+ @ <p>Only administrators are allowed to publish draft skins. Contact
754
+ @ an administrator to get this "draft%d(iSkin)" skin published.</p>
755
+ }else{
756
+
757
+ }
758
+ @
759
+ @ <a name='step7'></a>
760
+ @ <h1>Step 7: Cleanup</h1>
761
+ style_footer();
762
+}
673763
--- src/skins.c
+++ src/skins.c
@@ -2,11 +2,11 @@
2 ** Copyright (c) 2009 D. Richard Hipp
3 **
4 ** This program is free software; you can redistribute it and/or
5 ** modify it under the terms of the Simplified BSD License (also
6 ** known as the "2-Clause License" or "FreeBSD License".)
7
8 ** This program is distributed in the hope that it will be useful,
9 ** but without any warranty; without even the implied warranty of
10 ** merchantability or fitness for a particular purpose.
11 **
12 ** Author contact information:
@@ -355,11 +355,11 @@
355 style_header("Rename A Skin");
356 if( ex ){
357 @ <p><span class="generalError">There is already another skin
358 @ named "%h(zNewName)". Choose a different name.</span></p>
359 }
360 @ <form action="%s(g.zTop)/setup_skin" method="post"><div>
361 @ <table border="0"><tr>
362 @ <tr><td align="right">Current name:<td align="left"><b>%h(zOldName)</b>
363 @ <tr><td align="right">New name:<td align="left">
364 @ <input type="text" size="35" name="newname" value="%h(zNewName)">
365 @ <tr><td><td>
@@ -395,11 +395,11 @@
395 style_header("Save Current Skin");
396 if( ex ){
397 @ <p><span class="generalError">There is already another skin
398 @ named "%h(zNewName)". Choose a different name.</span></p>
399 }
400 @ <form action="%s(g.zTop)/setup_skin" method="post"><div>
401 @ <table border="0"><tr>
402 @ <tr><td align="right">Name for this skin:<td align="left">
403 @ <input type="text" size="35" name="svname" value="%h(zNewName)">
404 @ <tr><td><td>
405 @ <input type="submit" name="save" value="Save">
@@ -417,16 +417,16 @@
417 );
418 return 0;
419 }
420
421 /*
422 ** WEBPAGE: setup_skin
423 **
424 ** Show a list of available skins with buttons for selecting which
425 ** skin to use. Requires Admin privilege.
426 */
427 void setup_skin(void){
428 const char *z;
429 char *zName;
430 char *zErr = 0;
431 const char *zCurrent = 0; /* Current skin */
432 int i; /* Loop counter */
@@ -445,11 +445,11 @@
445 }
446
447 /* Process requests to delete a user-defined skin */
448 if( P("del1") && (zName = skinVarName(P("sn"), 1))!=0 ){
449 style_header("Confirm Custom Skin Delete");
450 @ <form action="%s(g.zTop)/setup_skin" method="post"><div>
451 @ <p>Deletion of a custom skin is a permanent action that cannot
452 @ be undone. Please confirm that this is what you want to do:</p>
453 @ <input type="hidden" name="sn" value="%h(P("sn"))" />
454 @ <input type="submit" name="del2" value="Confirm - Delete The Skin" />
455 @ <input type="submit" name="cancel" value="Cancel - Do Not Delete" />
@@ -531,11 +531,11 @@
531 @ <tr><td>%d(i+1).<td>%h(z)<td>&nbsp;&nbsp;<td>
532 if( fossil_strcmp(aBuiltinSkin[i].zSQL, zCurrent)==0 ){
533 @ (Currently In Use)
534 seenCurrent = 1;
535 }else{
536 @ <form action="%s(g.zTop)/setup_skin" method="post">
537 @ <input type="hidden" name="sn" value="%h(z)" />
538 @ <input type="submit" name="load" value="Install" />
539 if( pAltSkin==&aBuiltinSkin[i] ){
540 @ (Current override)
541 }
@@ -551,11 +551,11 @@
551 while( db_step(&q)==SQLITE_ROW ){
552 const char *zN = db_column_text(&q, 0);
553 const char *zV = db_column_text(&q, 1);
554 i++;
555 @ <tr><td>%d(i).<td>%h(zN)<td>&nbsp;&nbsp;<td>
556 @ <form action="%s(g.zTop)/setup_skin" method="post">
557 if( fossil_strcmp(zV, zCurrent)==0 ){
558 @ (Currently In Use)
559 seenCurrent = 1;
560 }else{
561 @ <input type="submit" name="load" value="Install">
@@ -567,11 +567,11 @@
567 }
568 db_finalize(&q);
569 if( !seenCurrent ){
570 i++;
571 @ <tr><td>%d(i).<td><i>Current Configuration</i><td>&nbsp;&nbsp;<td>
572 @ <form action="%s(g.zTop)/setup_skin" method="post">
573 @ <input type="submit" name="save" value="Save">
574 @ </form>
575 }
576 @ </table>
577 style_footer();
@@ -622,11 +622,11 @@
622 for(j=0; j<count(aSkinAttr); j++){
623 if( j==ii ) continue;
624 style_submenu_element(aSkinAttr[j].zSubmenu,
625 "%R/setup_skinedit?w=%d&basis=%h",j,zBasis);
626 }
627 style_submenu_element("Skins", "%R/setup_skin");
628 @ <form action="%s(g.zTop)/setup_skinedit" method="post"><div>
629 login_insert_csrf_secret();
630 @ <input type='hidden' name='w' value='%d(ii)'>
631 @ <h2>Edit %s(aSkinAttr[ii].zTitle):</h2>
632 zContent = textarea_attribute("", 10, 80, aSkinAttr[ii].zFile,
@@ -668,5 +668,95 @@
668 }
669 @ </div></form>
670 style_footer();
671 db_end_transaction(0);
672 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
673
--- src/skins.c
+++ src/skins.c
@@ -2,11 +2,11 @@
2 ** Copyright (c) 2009 D. Richard Hipp
3 **
4 ** This program is free software; you can redistribute it and/or
5 ** modify it under the terms of the Simplified BSD License (also
6 ** known as the "2-Clause License" or "FreeBSD License".)
7 **
8 ** This program is distributed in the hope that it will be useful,
9 ** but without any warranty; without even the implied warranty of
10 ** merchantability or fitness for a particular purpose.
11 **
12 ** Author contact information:
@@ -355,11 +355,11 @@
355 style_header("Rename A Skin");
356 if( ex ){
357 @ <p><span class="generalError">There is already another skin
358 @ named "%h(zNewName)". Choose a different name.</span></p>
359 }
360 @ <form action="%s(g.zTop)/setup_skin_old" method="post"><div>
361 @ <table border="0"><tr>
362 @ <tr><td align="right">Current name:<td align="left"><b>%h(zOldName)</b>
363 @ <tr><td align="right">New name:<td align="left">
364 @ <input type="text" size="35" name="newname" value="%h(zNewName)">
365 @ <tr><td><td>
@@ -395,11 +395,11 @@
395 style_header("Save Current Skin");
396 if( ex ){
397 @ <p><span class="generalError">There is already another skin
398 @ named "%h(zNewName)". Choose a different name.</span></p>
399 }
400 @ <form action="%s(g.zTop)/setup_skin_old" method="post"><div>
401 @ <table border="0"><tr>
402 @ <tr><td align="right">Name for this skin:<td align="left">
403 @ <input type="text" size="35" name="svname" value="%h(zNewName)">
404 @ <tr><td><td>
405 @ <input type="submit" name="save" value="Save">
@@ -417,16 +417,16 @@
417 );
418 return 0;
419 }
420
421 /*
422 ** WEBPAGE: setup_skin_old
423 **
424 ** Show a list of available skins with buttons for selecting which
425 ** skin to use. Requires Admin privilege.
426 */
427 void setup_skin_old(void){
428 const char *z;
429 char *zName;
430 char *zErr = 0;
431 const char *zCurrent = 0; /* Current skin */
432 int i; /* Loop counter */
@@ -445,11 +445,11 @@
445 }
446
447 /* Process requests to delete a user-defined skin */
448 if( P("del1") && (zName = skinVarName(P("sn"), 1))!=0 ){
449 style_header("Confirm Custom Skin Delete");
450 @ <form action="%s(g.zTop)/setup_skin_old" method="post"><div>
451 @ <p>Deletion of a custom skin is a permanent action that cannot
452 @ be undone. Please confirm that this is what you want to do:</p>
453 @ <input type="hidden" name="sn" value="%h(P("sn"))" />
454 @ <input type="submit" name="del2" value="Confirm - Delete The Skin" />
455 @ <input type="submit" name="cancel" value="Cancel - Do Not Delete" />
@@ -531,11 +531,11 @@
531 @ <tr><td>%d(i+1).<td>%h(z)<td>&nbsp;&nbsp;<td>
532 if( fossil_strcmp(aBuiltinSkin[i].zSQL, zCurrent)==0 ){
533 @ (Currently In Use)
534 seenCurrent = 1;
535 }else{
536 @ <form action="%s(g.zTop)/setup_skin_old" method="post">
537 @ <input type="hidden" name="sn" value="%h(z)" />
538 @ <input type="submit" name="load" value="Install" />
539 if( pAltSkin==&aBuiltinSkin[i] ){
540 @ (Current override)
541 }
@@ -551,11 +551,11 @@
551 while( db_step(&q)==SQLITE_ROW ){
552 const char *zN = db_column_text(&q, 0);
553 const char *zV = db_column_text(&q, 1);
554 i++;
555 @ <tr><td>%d(i).<td>%h(zN)<td>&nbsp;&nbsp;<td>
556 @ <form action="%s(g.zTop)/setup_skin_old" method="post">
557 if( fossil_strcmp(zV, zCurrent)==0 ){
558 @ (Currently In Use)
559 seenCurrent = 1;
560 }else{
561 @ <input type="submit" name="load" value="Install">
@@ -567,11 +567,11 @@
567 }
568 db_finalize(&q);
569 if( !seenCurrent ){
570 i++;
571 @ <tr><td>%d(i).<td><i>Current Configuration</i><td>&nbsp;&nbsp;<td>
572 @ <form action="%s(g.zTop)/setup_skin_old" method="post">
573 @ <input type="submit" name="save" value="Save">
574 @ </form>
575 }
576 @ </table>
577 style_footer();
@@ -622,11 +622,11 @@
622 for(j=0; j<count(aSkinAttr); j++){
623 if( j==ii ) continue;
624 style_submenu_element(aSkinAttr[j].zSubmenu,
625 "%R/setup_skinedit?w=%d&basis=%h",j,zBasis);
626 }
627 style_submenu_element("Skins", "%R/setup_skin_old");
628 @ <form action="%s(g.zTop)/setup_skinedit" method="post"><div>
629 login_insert_csrf_secret();
630 @ <input type='hidden' name='w' value='%d(ii)'>
631 @ <h2>Edit %s(aSkinAttr[ii].zTitle):</h2>
632 zContent = textarea_attribute("", 10, 80, aSkinAttr[ii].zFile,
@@ -668,5 +668,95 @@
668 }
669 @ </div></form>
670 style_footer();
671 db_end_transaction(0);
672 }
673
674 /*
675 ** WEBPAGE: setup_skin
676 **
677 ** Generate a page showing the steps needed to customize a skin.
678 */
679 void setup_skin(void){
680 int i; /* Loop counter */
681 int iSkin; /* Which draft skin is being edited */
682 static const char *azTestPages[] = {
683 "home",
684 "timeline",
685 "dir?ci=tip",
686 "dir?ci=tip&type=tree",
687 "brlist",
688 "info/trunk",
689 };
690
691
692 iSkin = atoi(PD("sk","1"));
693 if( iSkin<1 || iSkin>9 ) iSkin = 1;
694 login_check_credentials();
695 style_header("Customize Skin");
696
697 #if 0
698 @ <p>
699 cgi_print_all(0);
700 @ </p>
701 #endif
702
703 @ <p>Customize the look of this Fossil repository by making changes
704 @ to the CSS, Header, Footer, and Detail Settings in one of nine "draft"
705 @ configurations. Then, after verifying that all is working correctly,
706 @ publish the draft to become the new main Skin.<p>
707 @
708 @ <a name='step1'></a>
709 @ <h1>Step 1: Identify Which Draft To Use</h1>
710 @
711 @ <p>The main skin of Fossil cannot be edited directly. Instead,
712 @ edits are made to one of nine draft skins. A draft skin can then
713 @ be published to become the default skin.
714 @ Nine separate drafts are available to facilitate A/B testing.</p>
715 @
716 @ <form method='POST' action='%R/setup_skin#step2' id='f01'>
717 @ <p>Skin to edit:
718 @ <select size='1' name='sk' onchange='gebi("f01").submit()'>
719 for(i=1; i<=9; i++){
720 if( i==iSkin ){
721 @ <option value='%d(i)' selected>draft%d(i)</option>
722 }else{
723 @ <option value='%d(i)'>draft%d(i)</option>
724 }
725 }
726 @ </select>
727 @ </p>
728 @
729 @ <a name='step2'></a>
730 @ <h1>Step 2: Authenticate
731 @
732 @ <a name='step3'></a>
733 @ <h1>Step 3: Initialize The Draft</h1>
734 @
735 @ <a name='step4'></a>
736 @ <h1>Step 4: Make Edits</h1>
737 @
738 @ <a name='step5'></a>
739 @ <h1>Step 5: Verify The Draft Skin</h1>
740 @
741 @ <p>To test this draft skin, insert text "/draft%d(iSkin)/" just before the
742 @ operation name in the URL. Here are a few links to try:
743 @ <ul>
744 for(i=0; i<sizeof(azTestPages)/sizeof(azTestPages[0]); i++){
745 @ <li><a href='%s(g.zBaseURL)/draft%d(iSkin)/%s(azTestPages[i])'>\
746 @ %s(g.zBaseURL)/draft%d(iSkin)/%s(azTestPages[i])</a>
747 }
748 @ </ul>
749 @
750 @ <a name='step6'></a>
751 @ <h1>Step 6: Publish The Draft</h1>
752 if( !g.perm.Setup ){
753 @ <p>Only administrators are allowed to publish draft skins. Contact
754 @ an administrator to get this "draft%d(iSkin)" skin published.</p>
755 }else{
756
757 }
758 @
759 @ <a name='step7'></a>
760 @ <h1>Step 7: Cleanup</h1>
761 style_footer();
762 }
763

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button