Fossil SCM
Improvements to the skin editor.
Commit
bd2bf81c352f67940f1cfbb8556ff94c65858680a61f9393fbd5536a5f262338
Parent
d6cd1477d453c89…
1 file changed
+20
-9
+20
-9
| --- src/skins.c | ||
| +++ src/skins.c | ||
| @@ -703,18 +703,21 @@ | ||
| 703 | 703 | /* 1 */ { "footer", "Page Footer", "Footer", }, |
| 704 | 704 | /* 2 */ { "header", "Page Header", "Header", }, |
| 705 | 705 | /* 3 */ { "details", "Display Details", "Details", }, |
| 706 | 706 | }; |
| 707 | 707 | const char *zBasis; /* The baseline file */ |
| 708 | + const char *zOrig; /* Original content prior to editing */ | |
| 708 | 709 | const char *zContent; /* Content after editing */ |
| 710 | + const char *zDflt; /* Default content */ | |
| 709 | 711 | char *zDraft; /* Which draft: "draft%d" */ |
| 710 | 712 | char *zKey; /* CONFIG table key name: "draft%d-%s" */ |
| 711 | 713 | char *zTitle; /* Title of this page */ |
| 712 | 714 | const char *zFile; /* One of "css", "footer", "header", "details" */ |
| 713 | 715 | int iSkin; /* draft number. 1..9 */ |
| 714 | 716 | int ii; /* Index in aSkinAttr[] of this file */ |
| 715 | 717 | int j; /* Loop counter */ |
| 718 | + int isRevert = 0; /* True if Revert-to-Baseline was pressed */ | |
| 716 | 719 | |
| 717 | 720 | login_check_credentials(); |
| 718 | 721 | |
| 719 | 722 | /* Figure out which skin we are editing */ |
| 720 | 723 | iSkin = atoi(PD("sk","1")); |
| @@ -745,33 +748,41 @@ | ||
| 745 | 748 | zFile = aSkinAttr[ii].zFile; |
| 746 | 749 | zDraft = mprintf("draft%d", iSkin); |
| 747 | 750 | zKey = mprintf("draft%d-%s", iSkin, zFile); |
| 748 | 751 | zTitle = mprintf("%s for Draft%d", aSkinAttr[ii].zTitle, iSkin); |
| 749 | 752 | zBasis = PD("basis","current"); |
| 753 | + zDflt = skin_file_content(zBasis, zFile); | |
| 754 | + zOrig = db_get(zKey, zDflt); | |
| 755 | + zContent = PD(zFile,zOrig); | |
| 756 | + if( P("revert")!=0 && cgi_csrf_safe(0) ){ | |
| 757 | + zContent = zDflt; | |
| 758 | + isRevert = 1; | |
| 759 | + } | |
| 750 | 760 | |
| 751 | 761 | db_begin_transaction(); |
| 752 | 762 | style_header("%s", zTitle); |
| 753 | 763 | for(j=0; j<count(aSkinAttr); j++){ |
| 754 | - if( j==ii ) continue; | |
| 755 | 764 | style_submenu_element(aSkinAttr[j].zSubmenu, |
| 756 | 765 | "%R/setup_skinedit?w=%d&basis=%h&sk=%d",j,zBasis,iSkin); |
| 757 | 766 | } |
| 758 | 767 | @ <form action="%s(g.zTop)/setup_skinedit" method="post"><div> |
| 759 | 768 | login_insert_csrf_secret(); |
| 760 | 769 | @ <input type='hidden' name='w' value='%d(ii)'> |
| 761 | 770 | @ <input type='hidden' name='sk' value='%d(iSkin)'> |
| 762 | 771 | @ <h2>Edit %s(zTitle):</h2> |
| 763 | - zContent = textarea_attribute( | |
| 764 | - "", /* Text label */ | |
| 765 | - 10, 80, /* Height and width of the edit area */ | |
| 766 | - zKey, /* Name of CONFIG table entry */ | |
| 767 | - zFile, /* CGI query parameter name */ | |
| 768 | - skin_file_content(zBasis, zFile), /* Default value of the text */ | |
| 769 | - 0 /* Disabled flag */ | |
| 770 | - ); | |
| 772 | + if( P("submit") && cgi_csrf_safe(0) && strcmp(zOrig,zContent)!=0 ){ | |
| 773 | + db_set(zKey, zContent, 0); | |
| 774 | + } | |
| 775 | + @ <textarea name="%s(zFile)" rows="10" cols="80">\ | |
| 776 | + @ %h(zContent)</textarea> | |
| 771 | 777 | @ <br /> |
| 772 | 778 | @ <input type="submit" name="submit" value="Apply Changes" /> |
| 779 | + if( isRevert ){ | |
| 780 | + @ ← Press to complete reversion to "%s(zBasis)" | |
| 781 | + }else if( fossil_strcmp(zContent,zDflt)!=0 ){ | |
| 782 | + @ <input type="submit" name="revert" value='Revert To "%s(zBasis)"' /> | |
| 783 | + } | |
| 773 | 784 | @ <hr /> |
| 774 | 785 | @ Baseline: \ |
| 775 | 786 | skin_emit_skin_selector("basis", zBasis, zDraft); |
| 776 | 787 | @ <input type="submit" name="diff" value="Unified Diff" /> |
| 777 | 788 | @ <input type="submit" name="sbsdiff" value="Side-by-Side Diff" /> |
| 778 | 789 |
| --- src/skins.c | |
| +++ src/skins.c | |
| @@ -703,18 +703,21 @@ | |
| 703 | /* 1 */ { "footer", "Page Footer", "Footer", }, |
| 704 | /* 2 */ { "header", "Page Header", "Header", }, |
| 705 | /* 3 */ { "details", "Display Details", "Details", }, |
| 706 | }; |
| 707 | const char *zBasis; /* The baseline file */ |
| 708 | const char *zContent; /* Content after editing */ |
| 709 | char *zDraft; /* Which draft: "draft%d" */ |
| 710 | char *zKey; /* CONFIG table key name: "draft%d-%s" */ |
| 711 | char *zTitle; /* Title of this page */ |
| 712 | const char *zFile; /* One of "css", "footer", "header", "details" */ |
| 713 | int iSkin; /* draft number. 1..9 */ |
| 714 | int ii; /* Index in aSkinAttr[] of this file */ |
| 715 | int j; /* Loop counter */ |
| 716 | |
| 717 | login_check_credentials(); |
| 718 | |
| 719 | /* Figure out which skin we are editing */ |
| 720 | iSkin = atoi(PD("sk","1")); |
| @@ -745,33 +748,41 @@ | |
| 745 | zFile = aSkinAttr[ii].zFile; |
| 746 | zDraft = mprintf("draft%d", iSkin); |
| 747 | zKey = mprintf("draft%d-%s", iSkin, zFile); |
| 748 | zTitle = mprintf("%s for Draft%d", aSkinAttr[ii].zTitle, iSkin); |
| 749 | zBasis = PD("basis","current"); |
| 750 | |
| 751 | db_begin_transaction(); |
| 752 | style_header("%s", zTitle); |
| 753 | for(j=0; j<count(aSkinAttr); j++){ |
| 754 | if( j==ii ) continue; |
| 755 | style_submenu_element(aSkinAttr[j].zSubmenu, |
| 756 | "%R/setup_skinedit?w=%d&basis=%h&sk=%d",j,zBasis,iSkin); |
| 757 | } |
| 758 | @ <form action="%s(g.zTop)/setup_skinedit" method="post"><div> |
| 759 | login_insert_csrf_secret(); |
| 760 | @ <input type='hidden' name='w' value='%d(ii)'> |
| 761 | @ <input type='hidden' name='sk' value='%d(iSkin)'> |
| 762 | @ <h2>Edit %s(zTitle):</h2> |
| 763 | zContent = textarea_attribute( |
| 764 | "", /* Text label */ |
| 765 | 10, 80, /* Height and width of the edit area */ |
| 766 | zKey, /* Name of CONFIG table entry */ |
| 767 | zFile, /* CGI query parameter name */ |
| 768 | skin_file_content(zBasis, zFile), /* Default value of the text */ |
| 769 | 0 /* Disabled flag */ |
| 770 | ); |
| 771 | @ <br /> |
| 772 | @ <input type="submit" name="submit" value="Apply Changes" /> |
| 773 | @ <hr /> |
| 774 | @ Baseline: \ |
| 775 | skin_emit_skin_selector("basis", zBasis, zDraft); |
| 776 | @ <input type="submit" name="diff" value="Unified Diff" /> |
| 777 | @ <input type="submit" name="sbsdiff" value="Side-by-Side Diff" /> |
| 778 |
| --- src/skins.c | |
| +++ src/skins.c | |
| @@ -703,18 +703,21 @@ | |
| 703 | /* 1 */ { "footer", "Page Footer", "Footer", }, |
| 704 | /* 2 */ { "header", "Page Header", "Header", }, |
| 705 | /* 3 */ { "details", "Display Details", "Details", }, |
| 706 | }; |
| 707 | const char *zBasis; /* The baseline file */ |
| 708 | const char *zOrig; /* Original content prior to editing */ |
| 709 | const char *zContent; /* Content after editing */ |
| 710 | const char *zDflt; /* Default content */ |
| 711 | char *zDraft; /* Which draft: "draft%d" */ |
| 712 | char *zKey; /* CONFIG table key name: "draft%d-%s" */ |
| 713 | char *zTitle; /* Title of this page */ |
| 714 | const char *zFile; /* One of "css", "footer", "header", "details" */ |
| 715 | int iSkin; /* draft number. 1..9 */ |
| 716 | int ii; /* Index in aSkinAttr[] of this file */ |
| 717 | int j; /* Loop counter */ |
| 718 | int isRevert = 0; /* True if Revert-to-Baseline was pressed */ |
| 719 | |
| 720 | login_check_credentials(); |
| 721 | |
| 722 | /* Figure out which skin we are editing */ |
| 723 | iSkin = atoi(PD("sk","1")); |
| @@ -745,33 +748,41 @@ | |
| 748 | zFile = aSkinAttr[ii].zFile; |
| 749 | zDraft = mprintf("draft%d", iSkin); |
| 750 | zKey = mprintf("draft%d-%s", iSkin, zFile); |
| 751 | zTitle = mprintf("%s for Draft%d", aSkinAttr[ii].zTitle, iSkin); |
| 752 | zBasis = PD("basis","current"); |
| 753 | zDflt = skin_file_content(zBasis, zFile); |
| 754 | zOrig = db_get(zKey, zDflt); |
| 755 | zContent = PD(zFile,zOrig); |
| 756 | if( P("revert")!=0 && cgi_csrf_safe(0) ){ |
| 757 | zContent = zDflt; |
| 758 | isRevert = 1; |
| 759 | } |
| 760 | |
| 761 | db_begin_transaction(); |
| 762 | style_header("%s", zTitle); |
| 763 | for(j=0; j<count(aSkinAttr); j++){ |
| 764 | style_submenu_element(aSkinAttr[j].zSubmenu, |
| 765 | "%R/setup_skinedit?w=%d&basis=%h&sk=%d",j,zBasis,iSkin); |
| 766 | } |
| 767 | @ <form action="%s(g.zTop)/setup_skinedit" method="post"><div> |
| 768 | login_insert_csrf_secret(); |
| 769 | @ <input type='hidden' name='w' value='%d(ii)'> |
| 770 | @ <input type='hidden' name='sk' value='%d(iSkin)'> |
| 771 | @ <h2>Edit %s(zTitle):</h2> |
| 772 | if( P("submit") && cgi_csrf_safe(0) && strcmp(zOrig,zContent)!=0 ){ |
| 773 | db_set(zKey, zContent, 0); |
| 774 | } |
| 775 | @ <textarea name="%s(zFile)" rows="10" cols="80">\ |
| 776 | @ %h(zContent)</textarea> |
| 777 | @ <br /> |
| 778 | @ <input type="submit" name="submit" value="Apply Changes" /> |
| 779 | if( isRevert ){ |
| 780 | @ ← Press to complete reversion to "%s(zBasis)" |
| 781 | }else if( fossil_strcmp(zContent,zDflt)!=0 ){ |
| 782 | @ <input type="submit" name="revert" value='Revert To "%s(zBasis)"' /> |
| 783 | } |
| 784 | @ <hr /> |
| 785 | @ Baseline: \ |
| 786 | skin_emit_skin_selector("basis", zBasis, zDraft); |
| 787 | @ <input type="submit" name="diff" value="Unified Diff" /> |
| 788 | @ <input type="submit" name="sbsdiff" value="Side-by-Side Diff" /> |
| 789 |