Fossil SCM
Improvements to the skin file editing.
Commit
2179ffd47a81e8cb17de1fe7487e3c407d0c994c22abd0f93dc9f5e37b6da460
Parent
5840fdd73299f9d…
1 file changed
+16
-7
+16
-7
| --- src/skins.c | ||
| +++ src/skins.c | ||
| @@ -625,10 +625,11 @@ | ||
| 625 | 625 | }; |
| 626 | 626 | const char *zBasis; |
| 627 | 627 | const char *zContent; |
| 628 | 628 | char *zDflt; |
| 629 | 629 | char *zKey; |
| 630 | + char *zTitle; | |
| 630 | 631 | int iSkin; |
| 631 | 632 | int ii; |
| 632 | 633 | int j; |
| 633 | 634 | |
| 634 | 635 | login_check_credentials(); |
| @@ -653,29 +654,30 @@ | ||
| 653 | 654 | |
| 654 | 655 | /* figure out which file is to be edited */ |
| 655 | 656 | ii = atoi(PD("w","0")); |
| 656 | 657 | if( ii<0 || ii>count(aSkinAttr) ) ii = 0; |
| 657 | 658 | zKey = mprintf("draft%d-%s", iSkin, aSkinAttr[ii].zFile); |
| 659 | + zTitle = mprintf("%s for Draft%d", aSkinAttr[ii].zTitle, iSkin); | |
| 658 | 660 | |
| 659 | 661 | zBasis = PD("basis","default"); |
| 660 | 662 | zDflt = mprintf("skins/%s/%s.txt", zBasis, aSkinAttr[ii].zFile); |
| 661 | 663 | db_begin_transaction(); |
| 662 | 664 | if( P("revert")!=0 ){ |
| 663 | 665 | db_multi_exec("DELETE FROM config WHERE name=%Q", aSkinAttr[ii].zFile); |
| 664 | 666 | cgi_replace_parameter(aSkinAttr[ii].zFile, builtin_text(zDflt)); |
| 665 | 667 | } |
| 666 | - style_header("%s", aSkinAttr[ii].zTitle); | |
| 668 | + style_header("%s", zTitle); | |
| 667 | 669 | for(j=0; j<count(aSkinAttr); j++){ |
| 668 | 670 | if( j==ii ) continue; |
| 669 | 671 | style_submenu_element(aSkinAttr[j].zSubmenu, |
| 670 | - "%R/setup_skinedit?w=%d&basis=%h",j,zBasis); | |
| 672 | + "%R/setup_skinedit?w=%d&basis=%h&sk=%d",j,zBasis,iSkin); | |
| 671 | 673 | } |
| 672 | 674 | @ <form action="%s(g.zTop)/setup_skinedit" method="post"><div> |
| 673 | 675 | login_insert_csrf_secret(); |
| 674 | 676 | @ <input type='hidden' name='w' value='%d(ii)'> |
| 675 | 677 | @ <input type='hidden' name='sk' value='%d(iSkin)'> |
| 676 | - @ <h2>Edit %s(aSkinAttr[ii].zTitle):</h2> | |
| 678 | + @ <h2>Edit %s(zTitle):</h2> | |
| 677 | 679 | zContent = textarea_attribute("", 10, 80, zKey, |
| 678 | 680 | aSkinAttr[ii].zFile, builtin_text(zDflt), 0); |
| 679 | 681 | @ <br /> |
| 680 | 682 | @ <input type="submit" name="submit" value="Apply Changes" /> |
| 681 | 683 | @ <hr /> |
| @@ -793,10 +795,11 @@ | ||
| 793 | 795 | int i; /* Loop counter */ |
| 794 | 796 | int iSkin; /* Which draft skin is being edited */ |
| 795 | 797 | int isSetup; /* True for an administrator */ |
| 796 | 798 | int isEditor; /* Others authorized to make edits */ |
| 797 | 799 | char *zAllowedEditors; /* Who may edit the draft skin */ |
| 800 | + char *zBase; /* Base URL for draft under test */ | |
| 798 | 801 | static const char *azTestPages[] = { |
| 799 | 802 | "home", |
| 800 | 803 | "timeline", |
| 801 | 804 | "dir?ci=tip", |
| 802 | 805 | "dir?ci=tip&type=tree", |
| @@ -928,13 +931,13 @@ | ||
| 928 | 931 | @ Contact the administrator of this Fossil repository for help.</p> |
| 929 | 932 | }else{ |
| 930 | 933 | @ <p>Edit the components of the draft%d(iSkin) skin: |
| 931 | 934 | @ <ul> |
| 932 | 935 | @ <li><a href='%R/setup_skinedit?w=0&sk=%d(iSkin)' target='_blank'>CSS</a> |
| 933 | - @ <li><a href='%R/setup_skinedit?w=1&sk=%d(iSkin)' target='_blank'>\ | |
| 936 | + @ <li><a href='%R/setup_skinedit?w=2&sk=%d(iSkin)' target='_blank'>\ | |
| 934 | 937 | @ Header</a> |
| 935 | - @ <li><a href='%R/setup_skinedit?w=2&sk=%d(iSkin)' target='_blank'>\ | |
| 938 | + @ <li><a href='%R/setup_skinedit?w=1&sk=%d(iSkin)' target='_blank'>\ | |
| 936 | 939 | @ Footer</a> |
| 937 | 940 | @ <li><a href='%R/setup_skinedit?w=3&sk=%d(iSkin)' target='_blank'>\ |
| 938 | 941 | @ Details</a> |
| 939 | 942 | @ </ul> |
| 940 | 943 | } |
| @@ -943,14 +946,20 @@ | ||
| 943 | 946 | @ <h1>Step 5: Verify The Draft Skin</h1> |
| 944 | 947 | @ |
| 945 | 948 | @ <p>To test this draft skin, insert text "/draft%d(iSkin)/" just before the |
| 946 | 949 | @ operation name in the URL. Here are a few links to try: |
| 947 | 950 | @ <ul> |
| 951 | + if( iDraftSkin && sqlite3_strglob("*/draft[1-9]", g.zBaseURL)==0 ){ | |
| 952 | + zBase = mprintf("%.*s/draft%d", (int)strlen(g.zBaseURL)-7,g.zBaseURL,iSkin); | |
| 953 | + }else{ | |
| 954 | + zBase = mprintf("%s/draft%d", g.zBaseURL, iSkin); | |
| 955 | + } | |
| 948 | 956 | for(i=0; i<count(azTestPages); i++){ |
| 949 | - @ <li><a href='%s(g.zBaseURL)/draft%d(iSkin)/%s(azTestPages[i])' \ | |
| 950 | - @ target='_blank'>%s(g.zBaseURL)/draft%d(iSkin)/%s(azTestPages[i])</a> | |
| 957 | + @ <li><a href='%s(zBase)/%s(azTestPages[i])' target='_blank'>\ | |
| 958 | + @ %s(zBase)/%s(azTestPages[i])</a> | |
| 951 | 959 | } |
| 960 | + fossil_free(zBase); | |
| 952 | 961 | @ </ul> |
| 953 | 962 | @ |
| 954 | 963 | @ <p>You will probably need to press Reload on your browser before any |
| 955 | 964 | @ CSS changes will take effect.</p> |
| 956 | 965 | @ |
| 957 | 966 |
| --- src/skins.c | |
| +++ src/skins.c | |
| @@ -625,10 +625,11 @@ | |
| 625 | }; |
| 626 | const char *zBasis; |
| 627 | const char *zContent; |
| 628 | char *zDflt; |
| 629 | char *zKey; |
| 630 | int iSkin; |
| 631 | int ii; |
| 632 | int j; |
| 633 | |
| 634 | login_check_credentials(); |
| @@ -653,29 +654,30 @@ | |
| 653 | |
| 654 | /* figure out which file is to be edited */ |
| 655 | ii = atoi(PD("w","0")); |
| 656 | if( ii<0 || ii>count(aSkinAttr) ) ii = 0; |
| 657 | zKey = mprintf("draft%d-%s", iSkin, aSkinAttr[ii].zFile); |
| 658 | |
| 659 | zBasis = PD("basis","default"); |
| 660 | zDflt = mprintf("skins/%s/%s.txt", zBasis, aSkinAttr[ii].zFile); |
| 661 | db_begin_transaction(); |
| 662 | if( P("revert")!=0 ){ |
| 663 | db_multi_exec("DELETE FROM config WHERE name=%Q", aSkinAttr[ii].zFile); |
| 664 | cgi_replace_parameter(aSkinAttr[ii].zFile, builtin_text(zDflt)); |
| 665 | } |
| 666 | style_header("%s", aSkinAttr[ii].zTitle); |
| 667 | for(j=0; j<count(aSkinAttr); j++){ |
| 668 | if( j==ii ) continue; |
| 669 | style_submenu_element(aSkinAttr[j].zSubmenu, |
| 670 | "%R/setup_skinedit?w=%d&basis=%h",j,zBasis); |
| 671 | } |
| 672 | @ <form action="%s(g.zTop)/setup_skinedit" method="post"><div> |
| 673 | login_insert_csrf_secret(); |
| 674 | @ <input type='hidden' name='w' value='%d(ii)'> |
| 675 | @ <input type='hidden' name='sk' value='%d(iSkin)'> |
| 676 | @ <h2>Edit %s(aSkinAttr[ii].zTitle):</h2> |
| 677 | zContent = textarea_attribute("", 10, 80, zKey, |
| 678 | aSkinAttr[ii].zFile, builtin_text(zDflt), 0); |
| 679 | @ <br /> |
| 680 | @ <input type="submit" name="submit" value="Apply Changes" /> |
| 681 | @ <hr /> |
| @@ -793,10 +795,11 @@ | |
| 793 | int i; /* Loop counter */ |
| 794 | int iSkin; /* Which draft skin is being edited */ |
| 795 | int isSetup; /* True for an administrator */ |
| 796 | int isEditor; /* Others authorized to make edits */ |
| 797 | char *zAllowedEditors; /* Who may edit the draft skin */ |
| 798 | static const char *azTestPages[] = { |
| 799 | "home", |
| 800 | "timeline", |
| 801 | "dir?ci=tip", |
| 802 | "dir?ci=tip&type=tree", |
| @@ -928,13 +931,13 @@ | |
| 928 | @ Contact the administrator of this Fossil repository for help.</p> |
| 929 | }else{ |
| 930 | @ <p>Edit the components of the draft%d(iSkin) skin: |
| 931 | @ <ul> |
| 932 | @ <li><a href='%R/setup_skinedit?w=0&sk=%d(iSkin)' target='_blank'>CSS</a> |
| 933 | @ <li><a href='%R/setup_skinedit?w=1&sk=%d(iSkin)' target='_blank'>\ |
| 934 | @ Header</a> |
| 935 | @ <li><a href='%R/setup_skinedit?w=2&sk=%d(iSkin)' target='_blank'>\ |
| 936 | @ Footer</a> |
| 937 | @ <li><a href='%R/setup_skinedit?w=3&sk=%d(iSkin)' target='_blank'>\ |
| 938 | @ Details</a> |
| 939 | @ </ul> |
| 940 | } |
| @@ -943,14 +946,20 @@ | |
| 943 | @ <h1>Step 5: Verify The Draft Skin</h1> |
| 944 | @ |
| 945 | @ <p>To test this draft skin, insert text "/draft%d(iSkin)/" just before the |
| 946 | @ operation name in the URL. Here are a few links to try: |
| 947 | @ <ul> |
| 948 | for(i=0; i<count(azTestPages); i++){ |
| 949 | @ <li><a href='%s(g.zBaseURL)/draft%d(iSkin)/%s(azTestPages[i])' \ |
| 950 | @ target='_blank'>%s(g.zBaseURL)/draft%d(iSkin)/%s(azTestPages[i])</a> |
| 951 | } |
| 952 | @ </ul> |
| 953 | @ |
| 954 | @ <p>You will probably need to press Reload on your browser before any |
| 955 | @ CSS changes will take effect.</p> |
| 956 | @ |
| 957 |
| --- src/skins.c | |
| +++ src/skins.c | |
| @@ -625,10 +625,11 @@ | |
| 625 | }; |
| 626 | const char *zBasis; |
| 627 | const char *zContent; |
| 628 | char *zDflt; |
| 629 | char *zKey; |
| 630 | char *zTitle; |
| 631 | int iSkin; |
| 632 | int ii; |
| 633 | int j; |
| 634 | |
| 635 | login_check_credentials(); |
| @@ -653,29 +654,30 @@ | |
| 654 | |
| 655 | /* figure out which file is to be edited */ |
| 656 | ii = atoi(PD("w","0")); |
| 657 | if( ii<0 || ii>count(aSkinAttr) ) ii = 0; |
| 658 | zKey = mprintf("draft%d-%s", iSkin, aSkinAttr[ii].zFile); |
| 659 | zTitle = mprintf("%s for Draft%d", aSkinAttr[ii].zTitle, iSkin); |
| 660 | |
| 661 | zBasis = PD("basis","default"); |
| 662 | zDflt = mprintf("skins/%s/%s.txt", zBasis, aSkinAttr[ii].zFile); |
| 663 | db_begin_transaction(); |
| 664 | if( P("revert")!=0 ){ |
| 665 | db_multi_exec("DELETE FROM config WHERE name=%Q", aSkinAttr[ii].zFile); |
| 666 | cgi_replace_parameter(aSkinAttr[ii].zFile, builtin_text(zDflt)); |
| 667 | } |
| 668 | style_header("%s", zTitle); |
| 669 | for(j=0; j<count(aSkinAttr); j++){ |
| 670 | if( j==ii ) continue; |
| 671 | style_submenu_element(aSkinAttr[j].zSubmenu, |
| 672 | "%R/setup_skinedit?w=%d&basis=%h&sk=%d",j,zBasis,iSkin); |
| 673 | } |
| 674 | @ <form action="%s(g.zTop)/setup_skinedit" method="post"><div> |
| 675 | login_insert_csrf_secret(); |
| 676 | @ <input type='hidden' name='w' value='%d(ii)'> |
| 677 | @ <input type='hidden' name='sk' value='%d(iSkin)'> |
| 678 | @ <h2>Edit %s(zTitle):</h2> |
| 679 | zContent = textarea_attribute("", 10, 80, zKey, |
| 680 | aSkinAttr[ii].zFile, builtin_text(zDflt), 0); |
| 681 | @ <br /> |
| 682 | @ <input type="submit" name="submit" value="Apply Changes" /> |
| 683 | @ <hr /> |
| @@ -793,10 +795,11 @@ | |
| 795 | int i; /* Loop counter */ |
| 796 | int iSkin; /* Which draft skin is being edited */ |
| 797 | int isSetup; /* True for an administrator */ |
| 798 | int isEditor; /* Others authorized to make edits */ |
| 799 | char *zAllowedEditors; /* Who may edit the draft skin */ |
| 800 | char *zBase; /* Base URL for draft under test */ |
| 801 | static const char *azTestPages[] = { |
| 802 | "home", |
| 803 | "timeline", |
| 804 | "dir?ci=tip", |
| 805 | "dir?ci=tip&type=tree", |
| @@ -928,13 +931,13 @@ | |
| 931 | @ Contact the administrator of this Fossil repository for help.</p> |
| 932 | }else{ |
| 933 | @ <p>Edit the components of the draft%d(iSkin) skin: |
| 934 | @ <ul> |
| 935 | @ <li><a href='%R/setup_skinedit?w=0&sk=%d(iSkin)' target='_blank'>CSS</a> |
| 936 | @ <li><a href='%R/setup_skinedit?w=2&sk=%d(iSkin)' target='_blank'>\ |
| 937 | @ Header</a> |
| 938 | @ <li><a href='%R/setup_skinedit?w=1&sk=%d(iSkin)' target='_blank'>\ |
| 939 | @ Footer</a> |
| 940 | @ <li><a href='%R/setup_skinedit?w=3&sk=%d(iSkin)' target='_blank'>\ |
| 941 | @ Details</a> |
| 942 | @ </ul> |
| 943 | } |
| @@ -943,14 +946,20 @@ | |
| 946 | @ <h1>Step 5: Verify The Draft Skin</h1> |
| 947 | @ |
| 948 | @ <p>To test this draft skin, insert text "/draft%d(iSkin)/" just before the |
| 949 | @ operation name in the URL. Here are a few links to try: |
| 950 | @ <ul> |
| 951 | if( iDraftSkin && sqlite3_strglob("*/draft[1-9]", g.zBaseURL)==0 ){ |
| 952 | zBase = mprintf("%.*s/draft%d", (int)strlen(g.zBaseURL)-7,g.zBaseURL,iSkin); |
| 953 | }else{ |
| 954 | zBase = mprintf("%s/draft%d", g.zBaseURL, iSkin); |
| 955 | } |
| 956 | for(i=0; i<count(azTestPages); i++){ |
| 957 | @ <li><a href='%s(zBase)/%s(azTestPages[i])' target='_blank'>\ |
| 958 | @ %s(zBase)/%s(azTestPages[i])</a> |
| 959 | } |
| 960 | fossil_free(zBase); |
| 961 | @ </ul> |
| 962 | @ |
| 963 | @ <p>You will probably need to press Reload on your browser before any |
| 964 | @ CSS changes will take effect.</p> |
| 965 | @ |
| 966 |