Fossil SCM
Style improvements and code consolidation.
Commit
67a2bfb0dc85711aff3a31118faec363a8bd4bd55ed58cfb7a145e554629647d
Parent
65b6c01afdaf28f…
2 files changed
+32
-10
+133
-58
+32
-10
| --- src/default_css.txt | ||
| +++ src/default_css.txt | ||
| @@ -861,26 +861,35 @@ | ||
| 861 | 861 | // #setup_skinedit_css_defaults > tbody > tr > td:nth-of-type(2) > div { |
| 862 | 862 | // max-width: 30em; |
| 863 | 863 | // overflow: auto; |
| 864 | 864 | // } |
| 865 | 865 | // .fileedit-XXX => /fileedit page |
| 866 | -.fileedit-form textarea { | |
| 866 | +form.fileedit textarea { | |
| 867 | 867 | font-family: monospace; |
| 868 | 868 | width: 100%; |
| 869 | 869 | } |
| 870 | -.fileedit-form fieldset { | |
| 870 | +form.fileedit fieldset { | |
| 871 | + margin: 0.5em 0 0 0; | |
| 871 | 872 | border-radius: 0.5em; |
| 873 | + border-color: inherit; | |
| 874 | + border-width: 1px; | |
| 875 | +} | |
| 876 | +form.fileedit fieldset > legend { | |
| 877 | + margin-left: 1em; | |
| 878 | +} | |
| 879 | +form.fileedit fieldset > div { | |
| 880 | + margin: 0 0.25em; | |
| 872 | 881 | } |
| 873 | -.fileedit-form .fileedit-options { | |
| 882 | +form.fileedit fieldset > div > .input-with-label { | |
| 874 | 883 | padding: 0.5em; |
| 875 | - margin: 1em 0 0 0; | |
| 884 | + margin: 0.25em 0.5em; | |
| 876 | 885 | } |
| 877 | -.fileedit-form .fileedit-buttons > div > * { | |
| 878 | - margin: 0 0.25em 0.25em 0.25em; | |
| 886 | +form.fileedit fieldset > div > button { | |
| 887 | + margin: 0.25em 0.5em; | |
| 879 | 888 | } |
| 880 | -.fileedit-form .fileedit-options > div > * { | |
| 881 | - margin: 0 0.25em 0.25em 0.25em; | |
| 889 | +form.fileedit input:invalid { | |
| 890 | + border-left: 0.2em dashed red; | |
| 882 | 891 | } |
| 883 | 892 | .fileedit-hint { |
| 884 | 893 | font-size: 80%; |
| 885 | 894 | opacity: 0.75; |
| 886 | 895 | } |
| @@ -901,26 +910,39 @@ | ||
| 901 | 910 | padding: 0; |
| 902 | 911 | } |
| 903 | 912 | .fileedit-preview > div:first-child { |
| 904 | 913 | border-bottom: 1px dashed; |
| 905 | 914 | } |
| 915 | + | |
| 906 | 916 | .input-with-label { |
| 907 | 917 | border: 1px inset #808080; |
| 908 | 918 | border-radius: 0.5em; |
| 909 | 919 | padding: 0.25em 0.4em; |
| 910 | 920 | margin: 0 0.5em; |
| 911 | 921 | display: inline-block; |
| 912 | 922 | cursor: pointer; |
| 913 | 923 | } |
| 924 | +.input-with-label > * { | |
| 925 | + vertical-align: middle; | |
| 926 | +} | |
| 914 | 927 | .input-with-label > input { |
| 915 | 928 | margin: 0; |
| 929 | +} | |
| 930 | +.input-with-label > select { | |
| 931 | + margin: 0; | |
| 932 | +} | |
| 933 | +.input-with-label > input[type=text] { | |
| 934 | + margin: 0; | |
| 935 | +} | |
| 936 | +.input-with-label > textarea { | |
| 937 | + margin: 0; | |
| 916 | 938 | } |
| 917 | 939 | .input-with-label > input[type=checkbox] { |
| 918 | 940 | vertical-align: sub; |
| 919 | 941 | } |
| 920 | 942 | .input-with-label > input[type=radio] { |
| 921 | 943 | vertical-align: sub; |
| 922 | 944 | } |
| 923 | 945 | .input-with-label > span { |
| 924 | - margin: 0 0 0 0.4em; | |
| 925 | - vertical-align: text-bottom; | |
| 946 | + margin: 0 0.25em 0 0.25em; | |
| 947 | + vertical-align: middle; | |
| 926 | 948 | } |
| 927 | 949 |
| --- src/default_css.txt | |
| +++ src/default_css.txt | |
| @@ -861,26 +861,35 @@ | |
| 861 | // #setup_skinedit_css_defaults > tbody > tr > td:nth-of-type(2) > div { |
| 862 | // max-width: 30em; |
| 863 | // overflow: auto; |
| 864 | // } |
| 865 | // .fileedit-XXX => /fileedit page |
| 866 | .fileedit-form textarea { |
| 867 | font-family: monospace; |
| 868 | width: 100%; |
| 869 | } |
| 870 | .fileedit-form fieldset { |
| 871 | border-radius: 0.5em; |
| 872 | } |
| 873 | .fileedit-form .fileedit-options { |
| 874 | padding: 0.5em; |
| 875 | margin: 1em 0 0 0; |
| 876 | } |
| 877 | .fileedit-form .fileedit-buttons > div > * { |
| 878 | margin: 0 0.25em 0.25em 0.25em; |
| 879 | } |
| 880 | .fileedit-form .fileedit-options > div > * { |
| 881 | margin: 0 0.25em 0.25em 0.25em; |
| 882 | } |
| 883 | .fileedit-hint { |
| 884 | font-size: 80%; |
| 885 | opacity: 0.75; |
| 886 | } |
| @@ -901,26 +910,39 @@ | |
| 901 | padding: 0; |
| 902 | } |
| 903 | .fileedit-preview > div:first-child { |
| 904 | border-bottom: 1px dashed; |
| 905 | } |
| 906 | .input-with-label { |
| 907 | border: 1px inset #808080; |
| 908 | border-radius: 0.5em; |
| 909 | padding: 0.25em 0.4em; |
| 910 | margin: 0 0.5em; |
| 911 | display: inline-block; |
| 912 | cursor: pointer; |
| 913 | } |
| 914 | .input-with-label > input { |
| 915 | margin: 0; |
| 916 | } |
| 917 | .input-with-label > input[type=checkbox] { |
| 918 | vertical-align: sub; |
| 919 | } |
| 920 | .input-with-label > input[type=radio] { |
| 921 | vertical-align: sub; |
| 922 | } |
| 923 | .input-with-label > span { |
| 924 | margin: 0 0 0 0.4em; |
| 925 | vertical-align: text-bottom; |
| 926 | } |
| 927 |
| --- src/default_css.txt | |
| +++ src/default_css.txt | |
| @@ -861,26 +861,35 @@ | |
| 861 | // #setup_skinedit_css_defaults > tbody > tr > td:nth-of-type(2) > div { |
| 862 | // max-width: 30em; |
| 863 | // overflow: auto; |
| 864 | // } |
| 865 | // .fileedit-XXX => /fileedit page |
| 866 | form.fileedit textarea { |
| 867 | font-family: monospace; |
| 868 | width: 100%; |
| 869 | } |
| 870 | form.fileedit fieldset { |
| 871 | margin: 0.5em 0 0 0; |
| 872 | border-radius: 0.5em; |
| 873 | border-color: inherit; |
| 874 | border-width: 1px; |
| 875 | } |
| 876 | form.fileedit fieldset > legend { |
| 877 | margin-left: 1em; |
| 878 | } |
| 879 | form.fileedit fieldset > div { |
| 880 | margin: 0 0.25em; |
| 881 | } |
| 882 | form.fileedit fieldset > div > .input-with-label { |
| 883 | padding: 0.5em; |
| 884 | margin: 0.25em 0.5em; |
| 885 | } |
| 886 | form.fileedit fieldset > div > button { |
| 887 | margin: 0.25em 0.5em; |
| 888 | } |
| 889 | form.fileedit input:invalid { |
| 890 | border-left: 0.2em dashed red; |
| 891 | } |
| 892 | .fileedit-hint { |
| 893 | font-size: 80%; |
| 894 | opacity: 0.75; |
| 895 | } |
| @@ -901,26 +910,39 @@ | |
| 910 | padding: 0; |
| 911 | } |
| 912 | .fileedit-preview > div:first-child { |
| 913 | border-bottom: 1px dashed; |
| 914 | } |
| 915 | |
| 916 | .input-with-label { |
| 917 | border: 1px inset #808080; |
| 918 | border-radius: 0.5em; |
| 919 | padding: 0.25em 0.4em; |
| 920 | margin: 0 0.5em; |
| 921 | display: inline-block; |
| 922 | cursor: pointer; |
| 923 | } |
| 924 | .input-with-label > * { |
| 925 | vertical-align: middle; |
| 926 | } |
| 927 | .input-with-label > input { |
| 928 | margin: 0; |
| 929 | } |
| 930 | .input-with-label > select { |
| 931 | margin: 0; |
| 932 | } |
| 933 | .input-with-label > input[type=text] { |
| 934 | margin: 0; |
| 935 | } |
| 936 | .input-with-label > textarea { |
| 937 | margin: 0; |
| 938 | } |
| 939 | .input-with-label > input[type=checkbox] { |
| 940 | vertical-align: sub; |
| 941 | } |
| 942 | .input-with-label > input[type=radio] { |
| 943 | vertical-align: sub; |
| 944 | } |
| 945 | .input-with-label > span { |
| 946 | margin: 0 0.25em 0 0.25em; |
| 947 | vertical-align: middle; |
| 948 | } |
| 949 |
+133
-58
| --- src/fileedit.c | ||
| +++ src/fileedit.c | ||
| @@ -18,10 +18,11 @@ | ||
| 18 | 18 | ** This file contains code for the /fileedit page and related code. |
| 19 | 19 | */ |
| 20 | 20 | #include "config.h" |
| 21 | 21 | #include "fileedit.h" |
| 22 | 22 | #include <assert.h> |
| 23 | +#include <stdarg.h> | |
| 23 | 24 | |
| 24 | 25 | /* |
| 25 | 26 | ** State for the "mini-checkin" infrastructure, which enables the |
| 26 | 27 | ** ability to commit changes to a single file without a checkout |
| 27 | 28 | ** db, e.g. for use via an HTTP request. |
| @@ -40,11 +41,11 @@ | ||
| 40 | 41 | relative to the top of the repo. */ |
| 41 | 42 | Blob fileContent; /* Content of file referred to by zFilename. */ |
| 42 | 43 | Blob fileHash; /* Hash of this->fileContent, using the repo's |
| 43 | 44 | preferred hash method. */ |
| 44 | 45 | Blob comment; /* Check-in comment text */ |
| 45 | - char *zMimetype; /* Mimetype of comment. May be NULL */ | |
| 46 | + char *zCommentMimetype; /* Mimetype of comment. May be NULL */ | |
| 46 | 47 | char *zUser; /* User name */ |
| 47 | 48 | char *zDate; /* Optionally force this date string (anything |
| 48 | 49 | supported by date_in_standard_format()). |
| 49 | 50 | Maybe be NULL. */ |
| 50 | 51 | Blob *pMfOut; /* If not NULL, checkin_mini() will write a |
| @@ -160,11 +161,11 @@ | ||
| 160 | 161 | manifest_destroy(p->pParent); |
| 161 | 162 | } |
| 162 | 163 | fossil_free(p->zFilename); |
| 163 | 164 | fossil_free(p->zDate); |
| 164 | 165 | fossil_free(p->zParentUuid); |
| 165 | - fossil_free(p->zMimetype); | |
| 166 | + fossil_free(p->zCommentMimetype); | |
| 166 | 167 | fossil_free(p->zUser); |
| 167 | 168 | CheckinMiniInfo_init(p); |
| 168 | 169 | } |
| 169 | 170 | |
| 170 | 171 | /* |
| @@ -370,12 +371,12 @@ | ||
| 370 | 371 | } |
| 371 | 372 | blob_appendf(pOut, "D %s\n", pCI->zDate); |
| 372 | 373 | if(create_manifest_mini_fcards(pOut,pCI,asDelta,pErr)==0){ |
| 373 | 374 | return 0; |
| 374 | 375 | } |
| 375 | - if(pCI->zMimetype!=0 && pCI->zMimetype[0]!=0){ | |
| 376 | - blob_appendf(pOut, "N %F\n", pCI->zMimetype); | |
| 376 | + if(pCI->zCommentMimetype!=0 && pCI->zCommentMimetype[0]!=0){ | |
| 377 | + blob_appendf(pOut, "N %F\n", pCI->zCommentMimetype); | |
| 377 | 378 | } |
| 378 | 379 | blob_appendf(pOut, "P %s\n", pCI->zParentUuid); |
| 379 | 380 | blob_appendf(pOut, "U %F\n", pCI->zUser); |
| 380 | 381 | md5sum_blob(pOut, &zCard); |
| 381 | 382 | blob_appendf(pOut, "Z %b\n", &zCard); |
| @@ -979,18 +980,18 @@ | ||
| 979 | 980 | static void style_labeled_checkbox(const char *zFieldName, |
| 980 | 981 | const char * zLabel, |
| 981 | 982 | const char * zValue, |
| 982 | 983 | const char * zTip, |
| 983 | 984 | int isChecked){ |
| 984 | - CX("<span class='input-with-label'"); | |
| 985 | + CX("<div class='input-with-label'"); | |
| 985 | 986 | if(zTip && *zTip){ |
| 986 | 987 | CX(" title='%h'", zTip); |
| 987 | 988 | } |
| 988 | 989 | CX("><input type='checkbox' name='%s' value='%T'%s/>", |
| 989 | 990 | zFieldName, |
| 990 | 991 | zValue ? zValue : "", isChecked ? " checked" : ""); |
| 991 | - CX("<span>%h</span></span>", zLabel); | |
| 992 | + CX("<span>%h</span></div>", zLabel); | |
| 992 | 993 | } |
| 993 | 994 | |
| 994 | 995 | enum fileedit_render_preview_flags { |
| 995 | 996 | FE_PREVIEW_LINE_NUMBERS = 1 |
| 996 | 997 | }; |
| @@ -1056,10 +1057,90 @@ | ||
| 1056 | 1057 | break; |
| 1057 | 1058 | } |
| 1058 | 1059 | } |
| 1059 | 1060 | CX("</div><!--.fileedit-preview-->\n"); |
| 1060 | 1061 | } |
| 1062 | + | |
| 1063 | +/* | |
| 1064 | +** Outputs a SELECT list from a compile-time list of integers. | |
| 1065 | +** The vargs must be a list of (const char *, int) pairs, terminated | |
| 1066 | +** with a single NULL. Each pair is interpreted as... | |
| 1067 | +** | |
| 1068 | +** If the (const char *) is NULL, it is the end of the list, else | |
| 1069 | +** a new OPTION entry is created. If the string is empty, the | |
| 1070 | +** label and value of the OPTION is the integer part of the pair. | |
| 1071 | +** If the string is not empty, it becomes the label and the integer | |
| 1072 | +** the value. If that value == selectedValue then that OPTION | |
| 1073 | +** element gets the 'selected' attribute. | |
| 1074 | +** | |
| 1075 | +** Note that the pairs are not in (int, const char *) order because | |
| 1076 | +** there is no well-known integer value which we can definitively use | |
| 1077 | +** as a list terminator. | |
| 1078 | +** | |
| 1079 | +** zFieldName is the value of the form element's name attribute. | |
| 1080 | +** | |
| 1081 | +** zLabel is an optional string to use as a "label" for the element | |
| 1082 | +** (see below). | |
| 1083 | +** | |
| 1084 | +** zTooltip is an optional value for the SELECT's title attribute. | |
| 1085 | +** | |
| 1086 | +** The structure of the emited HTML is: | |
| 1087 | +** | |
| 1088 | +** <div class='input-with-label'> | |
| 1089 | +** <span>{{zLabel}}</span> | |
| 1090 | +** <select>...</select> | |
| 1091 | +** </div> | |
| 1092 | +** | |
| 1093 | +*/ | |
| 1094 | +static void style_select_list_int_v(const char *zFieldName, | |
| 1095 | + const char * zLabel, | |
| 1096 | + const char * zToolTip, | |
| 1097 | + int selectedVal, va_list vargs){ | |
| 1098 | + CX("<div class='input-with-label'"); | |
| 1099 | + if(zToolTip && *zToolTip){ | |
| 1100 | + CX(" title='%h'",zToolTip); | |
| 1101 | + } | |
| 1102 | + CX(">"); | |
| 1103 | + if(zLabel && *zLabel){ | |
| 1104 | + CX("<span>%h</span>", zLabel); | |
| 1105 | + } | |
| 1106 | + CX("<select name='%s'>",zFieldName); | |
| 1107 | + while(1){ | |
| 1108 | + const char * zOption = va_arg(vargs,char *); | |
| 1109 | + int v; | |
| 1110 | + if(NULL==zOption){ | |
| 1111 | + break; | |
| 1112 | + } | |
| 1113 | + v = va_arg(vargs,int); | |
| 1114 | + CX("<option value='%d'%s>", | |
| 1115 | + v, v==selectedVal ? " selected" : ""); | |
| 1116 | + if(*zOption){ | |
| 1117 | + CX("%s", zOption); | |
| 1118 | + }else{ | |
| 1119 | + CX("%d",v); | |
| 1120 | + } | |
| 1121 | + CX("</option>\n"); | |
| 1122 | + } | |
| 1123 | + CX("</select>\n"); | |
| 1124 | + if(zLabel && *zLabel){ | |
| 1125 | + CX("</div>\n"); | |
| 1126 | + } | |
| 1127 | +} | |
| 1128 | + | |
| 1129 | +/* | |
| 1130 | +** The ellipsis-args counterpart of style_select_list_int_v(). | |
| 1131 | +*/ | |
| 1132 | +void style_select_list_int(const char *zFieldName, | |
| 1133 | + const char * zLabel, | |
| 1134 | + const char * zToolTip, | |
| 1135 | + int selectedVal, ... ){ | |
| 1136 | + va_list vargs; | |
| 1137 | + va_start(vargs,selectedVal); | |
| 1138 | + style_select_list_int_v(zFieldName, zLabel, zToolTip, | |
| 1139 | + selectedVal, vargs); | |
| 1140 | + va_end(vargs); | |
| 1141 | +} | |
| 1061 | 1142 | |
| 1062 | 1143 | /* |
| 1063 | 1144 | ** WEBPAGE: fileedit |
| 1064 | 1145 | ** |
| 1065 | 1146 | ** EXPERIMENTAL and subject to change and removal at any time. The goal |
| @@ -1139,11 +1220,11 @@ | ||
| 1139 | 1220 | if(submitMode < SUBMIT_NONE || submitMode > SUBMIT_DIFF){ |
| 1140 | 1221 | submitMode = 0; |
| 1141 | 1222 | } |
| 1142 | 1223 | zFlagCheck = P("comment_mimetype"); |
| 1143 | 1224 | if(zFlagCheck){ |
| 1144 | - cimi.zMimetype = mprintf("%s",zFlagCheck); | |
| 1225 | + cimi.zCommentMimetype = mprintf("%s",zFlagCheck); | |
| 1145 | 1226 | zFlagCheck = 0; |
| 1146 | 1227 | } |
| 1147 | 1228 | cimi.zUser = mprintf("%s",g.zLogin); |
| 1148 | 1229 | |
| 1149 | 1230 | style_header("File Editor"); |
| @@ -1226,28 +1307,18 @@ | ||
| 1226 | 1307 | CX("<p>This page is <em>far from complete</em> and may still have " |
| 1227 | 1308 | "significant bugs. USE AT YOUR OWN RISK, preferably on a test " |
| 1228 | 1309 | "repo.</p>\n"); |
| 1229 | 1310 | |
| 1230 | 1311 | CX("<form action='%R/fileedit#options' method='POST' " |
| 1231 | - "class='fileedit-form'>\n"); | |
| 1312 | + "class='fileedit'>\n"); | |
| 1232 | 1313 | |
| 1233 | 1314 | /******* Hidden fields *******/ |
| 1234 | 1315 | CX("<input type='hidden' name='r' value='%s'>", |
| 1235 | 1316 | cimi.zParentUuid); |
| 1236 | 1317 | CX("<input type='hidden' name='file' value='%T'>", |
| 1237 | 1318 | zFilename); |
| 1238 | 1319 | |
| 1239 | - /******* Comment *******/ | |
| 1240 | - CX("<h3>Checkin Comment</h3>\n"); | |
| 1241 | - CX("<textarea name='comment' rows='3' cols='80'>"); | |
| 1242 | - if(zComment && *zComment){ | |
| 1243 | - CX("%h"/*%h? %s?*/, zComment); | |
| 1244 | - } | |
| 1245 | - CX("</textarea>\n"); | |
| 1246 | - CX("<div class='fileedit-hint'>Comments use the Fossil wiki markup " | |
| 1247 | - "syntax.</div>"/*TODO: radiobuttons for fossil/me/plain text*/); | |
| 1248 | - | |
| 1249 | 1320 | /******* Content *******/ |
| 1250 | 1321 | CX("<h3>File Content</h3>\n"); |
| 1251 | 1322 | CX("<textarea name='content' id='fileedit-content' " |
| 1252 | 1323 | "rows='20' cols='80'>"); |
| 1253 | 1324 | if(0==loadMode){ |
| @@ -1319,76 +1390,78 @@ | ||
| 1319 | 1390 | switch(eolMode){ |
| 1320 | 1391 | case 1: cimi.flags |= CIMINI_CONVERT_EOL_UNIX; break; |
| 1321 | 1392 | case 2: cimi.flags |= CIMINI_CONVERT_EOL_WINDOWS; break; |
| 1322 | 1393 | default: cimi.flags |= CIMINI_CONVERT_EOL_INHERIT; break; |
| 1323 | 1394 | } |
| 1324 | - CX("<select name='eol' " | |
| 1325 | - "title='EOL conversion policy, noting that form-processing " | |
| 1326 | - "may implicitly change the line endings of the input.'>"); | |
| 1327 | - CX("<option value='0'%s>Inherit EOLs</option>", | |
| 1328 | - (eolMode!=1 && eolMode!=2) ? " selected" : ""); | |
| 1329 | - CX("<option value='1'%s/>Unix EOLs</option>", | |
| 1330 | - eolMode==1 ? " selected" : ""); | |
| 1331 | - CX("<option value='2'%s>Windows EOLs</option>", | |
| 1332 | - eolMode==2 ? " selected" : ""); | |
| 1333 | - CX("</select>"); | |
| 1395 | + style_select_list_int("eol", "EOL Style", | |
| 1396 | + "EOL conversion policy, noting that " | |
| 1397 | + "form-processing may implicitly change the " | |
| 1398 | + "line endings of the input.", | |
| 1399 | + eolMode==1||eolMode==2 ? eolMode : 0, | |
| 1400 | + "Inherit", 0, | |
| 1401 | + "Unix", 1, | |
| 1402 | + "Windows", 2, | |
| 1403 | + NULL); | |
| 1334 | 1404 | } |
| 1335 | 1405 | |
| 1336 | 1406 | CX("</div></fieldset>") /* end of checkboxes */; |
| 1337 | 1407 | |
| 1408 | + /******* Comment *******/ | |
| 1409 | + CX("<a id='comment'></a>"); | |
| 1410 | + CX("<fieldset><legend>Commit message</legend><div>"); | |
| 1411 | + CX("<textarea name='comment' rows='3' cols='80'>"); | |
| 1412 | + /* ^^^ adding the 'required' attribute means we cannot even submit | |
| 1413 | + ** for PREVIEW mode if it's empty :/. */ | |
| 1414 | + if(zComment && *zComment){ | |
| 1415 | + CX("%h"/*%h? %s?*/, zComment); | |
| 1416 | + } | |
| 1417 | + CX("</textarea>\n"); | |
| 1418 | + CX("<div class='fileedit-hint'>Comments use the Fossil wiki markup " | |
| 1419 | + "syntax.</div>\n"/*TODO: select for fossil/md/plain text*/); | |
| 1420 | + CX("</div></fieldset>\n"); | |
| 1421 | + | |
| 1422 | + | |
| 1423 | + | |
| 1338 | 1424 | /******* Buttons *******/ |
| 1339 | 1425 | CX("<a id='buttons'></a>"); |
| 1340 | 1426 | CX("<fieldset class='fileedit-options'>" |
| 1341 | 1427 | "<legend>Tell the server to...</legend><div>"); |
| 1342 | 1428 | CX("<button type='submit' name='submit' value='1'>" |
| 1343 | 1429 | "Save</button>"); |
| 1344 | 1430 | CX("<button type='submit' name='submit' value='2'>" |
| 1345 | 1431 | "Preview</button>"); |
| 1346 | - CX("<button type='submit' name='submit' value='3'>" | |
| 1347 | - "Diff (TODO)</button>"); | |
| 1348 | 1432 | { |
| 1349 | 1433 | /* Preview rendering mode selection... */ |
| 1350 | 1434 | previewRenderMode = atoi(PD("preview_render_mode","0")); |
| 1351 | 1435 | if(0==previewRenderMode){ |
| 1352 | 1436 | previewRenderMode = fileedit_render_mode_for_mimetype(zFileMime); |
| 1353 | 1437 | } |
| 1354 | - CX("<br>"); | |
| 1355 | - CX("<select name='preview_render_mode'>\n"); | |
| 1356 | - CX("<option value='%d' disabled>Preview Mode</option>", | |
| 1357 | - FE_RENDER_GUESS); | |
| 1358 | - CX("<option value='%d'%s>Guess</option>", | |
| 1359 | - FE_RENDER_GUESS, | |
| 1360 | - FE_RENDER_GUESS==previewRenderMode ? " selected" : ""); | |
| 1361 | - CX("<option value='%d'%s>Wiki/Markdown</option>", | |
| 1362 | - FE_RENDER_WIKI, | |
| 1363 | - FE_RENDER_WIKI==previewRenderMode ? " selected" : ""); | |
| 1364 | - CX("<option value='%d'%s>HTML (iframe)</option>", | |
| 1365 | - FE_RENDER_HTML, | |
| 1366 | - FE_RENDER_HTML==previewRenderMode ? " selected" : ""); | |
| 1367 | - CX("<option value='%d'%s>Plain Text</option>", | |
| 1368 | - FE_RENDER_PLAIN_TEXT, | |
| 1369 | - FE_RENDER_PLAIN_TEXT==previewRenderMode ? " selected" : ""); | |
| 1370 | - CX("</select>\n"); | |
| 1438 | + style_select_list_int("preview_render_mode", | |
| 1439 | + "Preview Mode", | |
| 1440 | + "Preview mode format.", | |
| 1441 | + previewRenderMode, | |
| 1442 | + "Guess", FE_RENDER_GUESS, | |
| 1443 | + "Wiki/Markdown", FE_RENDER_WIKI, | |
| 1444 | + "HTML (iframe)", FE_RENDER_HTML, | |
| 1445 | + "Plain Text", FE_RENDER_PLAIN_TEXT, | |
| 1446 | + NULL); | |
| 1371 | 1447 | if(FE_RENDER_HTML==previewRenderMode){ |
| 1372 | 1448 | /* HTML preview mode iframe height... */ |
| 1373 | - int i; | |
| 1374 | 1449 | if(submitMode==SUBMIT_PREVIEW){ |
| 1375 | 1450 | previewHtmlHeight = atoi(PD("preview_html_ems","0")); |
| 1376 | 1451 | }else{ |
| 1377 | 1452 | previewHtmlHeight = 40; |
| 1378 | 1453 | } |
| 1379 | 1454 | /* Allow selection of HTML preview iframe height */ |
| 1380 | - CX("<select name='preview_html_ems' " | |
| 1381 | - "title='Height (in EMs) of the iframe used for HTML " | |
| 1382 | - "preview.'>\n"); | |
| 1383 | - CX("<option disabled value='40'>HTML Preview Height (EMs)" | |
| 1384 | - "</option>\n"); | |
| 1385 | - for( i = 20; i <= 100; i+=20 ){ | |
| 1386 | - CX("<option value='%d'%s>%d</option>\n", | |
| 1387 | - i, (previewHtmlHeight==i) ? " selected" : "", i); | |
| 1388 | - } | |
| 1389 | - CX("</select>\n"); | |
| 1455 | + style_select_list_int("preview_html_ems", | |
| 1456 | + "Preview IFrame Height (EMs)", | |
| 1457 | + "Height (in EMs) of the iframe used for " | |
| 1458 | + "HTML preview", | |
| 1459 | + previewHtmlHeight, | |
| 1460 | + "", 20, "", 40, | |
| 1461 | + "", 60, "", 80, | |
| 1462 | + "", 100, NULL); | |
| 1390 | 1463 | } |
| 1391 | 1464 | else if(FE_RENDER_PLAIN_TEXT==previewRenderMode){ |
| 1392 | 1465 | style_labeled_checkbox("preview_ln", |
| 1393 | 1466 | "Add line numbers to plain-text previews?", |
| 1394 | 1467 | "1", |
| @@ -1395,10 +1468,12 @@ | ||
| 1395 | 1468 | "If on, plain-text files (only) will get " |
| 1396 | 1469 | "line numbers added to the preview.", |
| 1397 | 1470 | previewLn); |
| 1398 | 1471 | } |
| 1399 | 1472 | } |
| 1473 | + CX("<button type='submit' name='submit' value='3'>" | |
| 1474 | + "Diff (TODO)</button>"); | |
| 1400 | 1475 | CX("</div></fieldset>"); |
| 1401 | 1476 | |
| 1402 | 1477 | /******* End of form *******/ |
| 1403 | 1478 | CX("</form>\n"); |
| 1404 | 1479 | |
| 1405 | 1480 |
| --- src/fileedit.c | |
| +++ src/fileedit.c | |
| @@ -18,10 +18,11 @@ | |
| 18 | ** This file contains code for the /fileedit page and related code. |
| 19 | */ |
| 20 | #include "config.h" |
| 21 | #include "fileedit.h" |
| 22 | #include <assert.h> |
| 23 | |
| 24 | /* |
| 25 | ** State for the "mini-checkin" infrastructure, which enables the |
| 26 | ** ability to commit changes to a single file without a checkout |
| 27 | ** db, e.g. for use via an HTTP request. |
| @@ -40,11 +41,11 @@ | |
| 40 | relative to the top of the repo. */ |
| 41 | Blob fileContent; /* Content of file referred to by zFilename. */ |
| 42 | Blob fileHash; /* Hash of this->fileContent, using the repo's |
| 43 | preferred hash method. */ |
| 44 | Blob comment; /* Check-in comment text */ |
| 45 | char *zMimetype; /* Mimetype of comment. May be NULL */ |
| 46 | char *zUser; /* User name */ |
| 47 | char *zDate; /* Optionally force this date string (anything |
| 48 | supported by date_in_standard_format()). |
| 49 | Maybe be NULL. */ |
| 50 | Blob *pMfOut; /* If not NULL, checkin_mini() will write a |
| @@ -160,11 +161,11 @@ | |
| 160 | manifest_destroy(p->pParent); |
| 161 | } |
| 162 | fossil_free(p->zFilename); |
| 163 | fossil_free(p->zDate); |
| 164 | fossil_free(p->zParentUuid); |
| 165 | fossil_free(p->zMimetype); |
| 166 | fossil_free(p->zUser); |
| 167 | CheckinMiniInfo_init(p); |
| 168 | } |
| 169 | |
| 170 | /* |
| @@ -370,12 +371,12 @@ | |
| 370 | } |
| 371 | blob_appendf(pOut, "D %s\n", pCI->zDate); |
| 372 | if(create_manifest_mini_fcards(pOut,pCI,asDelta,pErr)==0){ |
| 373 | return 0; |
| 374 | } |
| 375 | if(pCI->zMimetype!=0 && pCI->zMimetype[0]!=0){ |
| 376 | blob_appendf(pOut, "N %F\n", pCI->zMimetype); |
| 377 | } |
| 378 | blob_appendf(pOut, "P %s\n", pCI->zParentUuid); |
| 379 | blob_appendf(pOut, "U %F\n", pCI->zUser); |
| 380 | md5sum_blob(pOut, &zCard); |
| 381 | blob_appendf(pOut, "Z %b\n", &zCard); |
| @@ -979,18 +980,18 @@ | |
| 979 | static void style_labeled_checkbox(const char *zFieldName, |
| 980 | const char * zLabel, |
| 981 | const char * zValue, |
| 982 | const char * zTip, |
| 983 | int isChecked){ |
| 984 | CX("<span class='input-with-label'"); |
| 985 | if(zTip && *zTip){ |
| 986 | CX(" title='%h'", zTip); |
| 987 | } |
| 988 | CX("><input type='checkbox' name='%s' value='%T'%s/>", |
| 989 | zFieldName, |
| 990 | zValue ? zValue : "", isChecked ? " checked" : ""); |
| 991 | CX("<span>%h</span></span>", zLabel); |
| 992 | } |
| 993 | |
| 994 | enum fileedit_render_preview_flags { |
| 995 | FE_PREVIEW_LINE_NUMBERS = 1 |
| 996 | }; |
| @@ -1056,10 +1057,90 @@ | |
| 1056 | break; |
| 1057 | } |
| 1058 | } |
| 1059 | CX("</div><!--.fileedit-preview-->\n"); |
| 1060 | } |
| 1061 | |
| 1062 | /* |
| 1063 | ** WEBPAGE: fileedit |
| 1064 | ** |
| 1065 | ** EXPERIMENTAL and subject to change and removal at any time. The goal |
| @@ -1139,11 +1220,11 @@ | |
| 1139 | if(submitMode < SUBMIT_NONE || submitMode > SUBMIT_DIFF){ |
| 1140 | submitMode = 0; |
| 1141 | } |
| 1142 | zFlagCheck = P("comment_mimetype"); |
| 1143 | if(zFlagCheck){ |
| 1144 | cimi.zMimetype = mprintf("%s",zFlagCheck); |
| 1145 | zFlagCheck = 0; |
| 1146 | } |
| 1147 | cimi.zUser = mprintf("%s",g.zLogin); |
| 1148 | |
| 1149 | style_header("File Editor"); |
| @@ -1226,28 +1307,18 @@ | |
| 1226 | CX("<p>This page is <em>far from complete</em> and may still have " |
| 1227 | "significant bugs. USE AT YOUR OWN RISK, preferably on a test " |
| 1228 | "repo.</p>\n"); |
| 1229 | |
| 1230 | CX("<form action='%R/fileedit#options' method='POST' " |
| 1231 | "class='fileedit-form'>\n"); |
| 1232 | |
| 1233 | /******* Hidden fields *******/ |
| 1234 | CX("<input type='hidden' name='r' value='%s'>", |
| 1235 | cimi.zParentUuid); |
| 1236 | CX("<input type='hidden' name='file' value='%T'>", |
| 1237 | zFilename); |
| 1238 | |
| 1239 | /******* Comment *******/ |
| 1240 | CX("<h3>Checkin Comment</h3>\n"); |
| 1241 | CX("<textarea name='comment' rows='3' cols='80'>"); |
| 1242 | if(zComment && *zComment){ |
| 1243 | CX("%h"/*%h? %s?*/, zComment); |
| 1244 | } |
| 1245 | CX("</textarea>\n"); |
| 1246 | CX("<div class='fileedit-hint'>Comments use the Fossil wiki markup " |
| 1247 | "syntax.</div>"/*TODO: radiobuttons for fossil/me/plain text*/); |
| 1248 | |
| 1249 | /******* Content *******/ |
| 1250 | CX("<h3>File Content</h3>\n"); |
| 1251 | CX("<textarea name='content' id='fileedit-content' " |
| 1252 | "rows='20' cols='80'>"); |
| 1253 | if(0==loadMode){ |
| @@ -1319,76 +1390,78 @@ | |
| 1319 | switch(eolMode){ |
| 1320 | case 1: cimi.flags |= CIMINI_CONVERT_EOL_UNIX; break; |
| 1321 | case 2: cimi.flags |= CIMINI_CONVERT_EOL_WINDOWS; break; |
| 1322 | default: cimi.flags |= CIMINI_CONVERT_EOL_INHERIT; break; |
| 1323 | } |
| 1324 | CX("<select name='eol' " |
| 1325 | "title='EOL conversion policy, noting that form-processing " |
| 1326 | "may implicitly change the line endings of the input.'>"); |
| 1327 | CX("<option value='0'%s>Inherit EOLs</option>", |
| 1328 | (eolMode!=1 && eolMode!=2) ? " selected" : ""); |
| 1329 | CX("<option value='1'%s/>Unix EOLs</option>", |
| 1330 | eolMode==1 ? " selected" : ""); |
| 1331 | CX("<option value='2'%s>Windows EOLs</option>", |
| 1332 | eolMode==2 ? " selected" : ""); |
| 1333 | CX("</select>"); |
| 1334 | } |
| 1335 | |
| 1336 | CX("</div></fieldset>") /* end of checkboxes */; |
| 1337 | |
| 1338 | /******* Buttons *******/ |
| 1339 | CX("<a id='buttons'></a>"); |
| 1340 | CX("<fieldset class='fileedit-options'>" |
| 1341 | "<legend>Tell the server to...</legend><div>"); |
| 1342 | CX("<button type='submit' name='submit' value='1'>" |
| 1343 | "Save</button>"); |
| 1344 | CX("<button type='submit' name='submit' value='2'>" |
| 1345 | "Preview</button>"); |
| 1346 | CX("<button type='submit' name='submit' value='3'>" |
| 1347 | "Diff (TODO)</button>"); |
| 1348 | { |
| 1349 | /* Preview rendering mode selection... */ |
| 1350 | previewRenderMode = atoi(PD("preview_render_mode","0")); |
| 1351 | if(0==previewRenderMode){ |
| 1352 | previewRenderMode = fileedit_render_mode_for_mimetype(zFileMime); |
| 1353 | } |
| 1354 | CX("<br>"); |
| 1355 | CX("<select name='preview_render_mode'>\n"); |
| 1356 | CX("<option value='%d' disabled>Preview Mode</option>", |
| 1357 | FE_RENDER_GUESS); |
| 1358 | CX("<option value='%d'%s>Guess</option>", |
| 1359 | FE_RENDER_GUESS, |
| 1360 | FE_RENDER_GUESS==previewRenderMode ? " selected" : ""); |
| 1361 | CX("<option value='%d'%s>Wiki/Markdown</option>", |
| 1362 | FE_RENDER_WIKI, |
| 1363 | FE_RENDER_WIKI==previewRenderMode ? " selected" : ""); |
| 1364 | CX("<option value='%d'%s>HTML (iframe)</option>", |
| 1365 | FE_RENDER_HTML, |
| 1366 | FE_RENDER_HTML==previewRenderMode ? " selected" : ""); |
| 1367 | CX("<option value='%d'%s>Plain Text</option>", |
| 1368 | FE_RENDER_PLAIN_TEXT, |
| 1369 | FE_RENDER_PLAIN_TEXT==previewRenderMode ? " selected" : ""); |
| 1370 | CX("</select>\n"); |
| 1371 | if(FE_RENDER_HTML==previewRenderMode){ |
| 1372 | /* HTML preview mode iframe height... */ |
| 1373 | int i; |
| 1374 | if(submitMode==SUBMIT_PREVIEW){ |
| 1375 | previewHtmlHeight = atoi(PD("preview_html_ems","0")); |
| 1376 | }else{ |
| 1377 | previewHtmlHeight = 40; |
| 1378 | } |
| 1379 | /* Allow selection of HTML preview iframe height */ |
| 1380 | CX("<select name='preview_html_ems' " |
| 1381 | "title='Height (in EMs) of the iframe used for HTML " |
| 1382 | "preview.'>\n"); |
| 1383 | CX("<option disabled value='40'>HTML Preview Height (EMs)" |
| 1384 | "</option>\n"); |
| 1385 | for( i = 20; i <= 100; i+=20 ){ |
| 1386 | CX("<option value='%d'%s>%d</option>\n", |
| 1387 | i, (previewHtmlHeight==i) ? " selected" : "", i); |
| 1388 | } |
| 1389 | CX("</select>\n"); |
| 1390 | } |
| 1391 | else if(FE_RENDER_PLAIN_TEXT==previewRenderMode){ |
| 1392 | style_labeled_checkbox("preview_ln", |
| 1393 | "Add line numbers to plain-text previews?", |
| 1394 | "1", |
| @@ -1395,10 +1468,12 @@ | |
| 1395 | "If on, plain-text files (only) will get " |
| 1396 | "line numbers added to the preview.", |
| 1397 | previewLn); |
| 1398 | } |
| 1399 | } |
| 1400 | CX("</div></fieldset>"); |
| 1401 | |
| 1402 | /******* End of form *******/ |
| 1403 | CX("</form>\n"); |
| 1404 | |
| 1405 |
| --- src/fileedit.c | |
| +++ src/fileedit.c | |
| @@ -18,10 +18,11 @@ | |
| 18 | ** This file contains code for the /fileedit page and related code. |
| 19 | */ |
| 20 | #include "config.h" |
| 21 | #include "fileedit.h" |
| 22 | #include <assert.h> |
| 23 | #include <stdarg.h> |
| 24 | |
| 25 | /* |
| 26 | ** State for the "mini-checkin" infrastructure, which enables the |
| 27 | ** ability to commit changes to a single file without a checkout |
| 28 | ** db, e.g. for use via an HTTP request. |
| @@ -40,11 +41,11 @@ | |
| 41 | relative to the top of the repo. */ |
| 42 | Blob fileContent; /* Content of file referred to by zFilename. */ |
| 43 | Blob fileHash; /* Hash of this->fileContent, using the repo's |
| 44 | preferred hash method. */ |
| 45 | Blob comment; /* Check-in comment text */ |
| 46 | char *zCommentMimetype; /* Mimetype of comment. May be NULL */ |
| 47 | char *zUser; /* User name */ |
| 48 | char *zDate; /* Optionally force this date string (anything |
| 49 | supported by date_in_standard_format()). |
| 50 | Maybe be NULL. */ |
| 51 | Blob *pMfOut; /* If not NULL, checkin_mini() will write a |
| @@ -160,11 +161,11 @@ | |
| 161 | manifest_destroy(p->pParent); |
| 162 | } |
| 163 | fossil_free(p->zFilename); |
| 164 | fossil_free(p->zDate); |
| 165 | fossil_free(p->zParentUuid); |
| 166 | fossil_free(p->zCommentMimetype); |
| 167 | fossil_free(p->zUser); |
| 168 | CheckinMiniInfo_init(p); |
| 169 | } |
| 170 | |
| 171 | /* |
| @@ -370,12 +371,12 @@ | |
| 371 | } |
| 372 | blob_appendf(pOut, "D %s\n", pCI->zDate); |
| 373 | if(create_manifest_mini_fcards(pOut,pCI,asDelta,pErr)==0){ |
| 374 | return 0; |
| 375 | } |
| 376 | if(pCI->zCommentMimetype!=0 && pCI->zCommentMimetype[0]!=0){ |
| 377 | blob_appendf(pOut, "N %F\n", pCI->zCommentMimetype); |
| 378 | } |
| 379 | blob_appendf(pOut, "P %s\n", pCI->zParentUuid); |
| 380 | blob_appendf(pOut, "U %F\n", pCI->zUser); |
| 381 | md5sum_blob(pOut, &zCard); |
| 382 | blob_appendf(pOut, "Z %b\n", &zCard); |
| @@ -979,18 +980,18 @@ | |
| 980 | static void style_labeled_checkbox(const char *zFieldName, |
| 981 | const char * zLabel, |
| 982 | const char * zValue, |
| 983 | const char * zTip, |
| 984 | int isChecked){ |
| 985 | CX("<div class='input-with-label'"); |
| 986 | if(zTip && *zTip){ |
| 987 | CX(" title='%h'", zTip); |
| 988 | } |
| 989 | CX("><input type='checkbox' name='%s' value='%T'%s/>", |
| 990 | zFieldName, |
| 991 | zValue ? zValue : "", isChecked ? " checked" : ""); |
| 992 | CX("<span>%h</span></div>", zLabel); |
| 993 | } |
| 994 | |
| 995 | enum fileedit_render_preview_flags { |
| 996 | FE_PREVIEW_LINE_NUMBERS = 1 |
| 997 | }; |
| @@ -1056,10 +1057,90 @@ | |
| 1057 | break; |
| 1058 | } |
| 1059 | } |
| 1060 | CX("</div><!--.fileedit-preview-->\n"); |
| 1061 | } |
| 1062 | |
| 1063 | /* |
| 1064 | ** Outputs a SELECT list from a compile-time list of integers. |
| 1065 | ** The vargs must be a list of (const char *, int) pairs, terminated |
| 1066 | ** with a single NULL. Each pair is interpreted as... |
| 1067 | ** |
| 1068 | ** If the (const char *) is NULL, it is the end of the list, else |
| 1069 | ** a new OPTION entry is created. If the string is empty, the |
| 1070 | ** label and value of the OPTION is the integer part of the pair. |
| 1071 | ** If the string is not empty, it becomes the label and the integer |
| 1072 | ** the value. If that value == selectedValue then that OPTION |
| 1073 | ** element gets the 'selected' attribute. |
| 1074 | ** |
| 1075 | ** Note that the pairs are not in (int, const char *) order because |
| 1076 | ** there is no well-known integer value which we can definitively use |
| 1077 | ** as a list terminator. |
| 1078 | ** |
| 1079 | ** zFieldName is the value of the form element's name attribute. |
| 1080 | ** |
| 1081 | ** zLabel is an optional string to use as a "label" for the element |
| 1082 | ** (see below). |
| 1083 | ** |
| 1084 | ** zTooltip is an optional value for the SELECT's title attribute. |
| 1085 | ** |
| 1086 | ** The structure of the emited HTML is: |
| 1087 | ** |
| 1088 | ** <div class='input-with-label'> |
| 1089 | ** <span>{{zLabel}}</span> |
| 1090 | ** <select>...</select> |
| 1091 | ** </div> |
| 1092 | ** |
| 1093 | */ |
| 1094 | static void style_select_list_int_v(const char *zFieldName, |
| 1095 | const char * zLabel, |
| 1096 | const char * zToolTip, |
| 1097 | int selectedVal, va_list vargs){ |
| 1098 | CX("<div class='input-with-label'"); |
| 1099 | if(zToolTip && *zToolTip){ |
| 1100 | CX(" title='%h'",zToolTip); |
| 1101 | } |
| 1102 | CX(">"); |
| 1103 | if(zLabel && *zLabel){ |
| 1104 | CX("<span>%h</span>", zLabel); |
| 1105 | } |
| 1106 | CX("<select name='%s'>",zFieldName); |
| 1107 | while(1){ |
| 1108 | const char * zOption = va_arg(vargs,char *); |
| 1109 | int v; |
| 1110 | if(NULL==zOption){ |
| 1111 | break; |
| 1112 | } |
| 1113 | v = va_arg(vargs,int); |
| 1114 | CX("<option value='%d'%s>", |
| 1115 | v, v==selectedVal ? " selected" : ""); |
| 1116 | if(*zOption){ |
| 1117 | CX("%s", zOption); |
| 1118 | }else{ |
| 1119 | CX("%d",v); |
| 1120 | } |
| 1121 | CX("</option>\n"); |
| 1122 | } |
| 1123 | CX("</select>\n"); |
| 1124 | if(zLabel && *zLabel){ |
| 1125 | CX("</div>\n"); |
| 1126 | } |
| 1127 | } |
| 1128 | |
| 1129 | /* |
| 1130 | ** The ellipsis-args counterpart of style_select_list_int_v(). |
| 1131 | */ |
| 1132 | void style_select_list_int(const char *zFieldName, |
| 1133 | const char * zLabel, |
| 1134 | const char * zToolTip, |
| 1135 | int selectedVal, ... ){ |
| 1136 | va_list vargs; |
| 1137 | va_start(vargs,selectedVal); |
| 1138 | style_select_list_int_v(zFieldName, zLabel, zToolTip, |
| 1139 | selectedVal, vargs); |
| 1140 | va_end(vargs); |
| 1141 | } |
| 1142 | |
| 1143 | /* |
| 1144 | ** WEBPAGE: fileedit |
| 1145 | ** |
| 1146 | ** EXPERIMENTAL and subject to change and removal at any time. The goal |
| @@ -1139,11 +1220,11 @@ | |
| 1220 | if(submitMode < SUBMIT_NONE || submitMode > SUBMIT_DIFF){ |
| 1221 | submitMode = 0; |
| 1222 | } |
| 1223 | zFlagCheck = P("comment_mimetype"); |
| 1224 | if(zFlagCheck){ |
| 1225 | cimi.zCommentMimetype = mprintf("%s",zFlagCheck); |
| 1226 | zFlagCheck = 0; |
| 1227 | } |
| 1228 | cimi.zUser = mprintf("%s",g.zLogin); |
| 1229 | |
| 1230 | style_header("File Editor"); |
| @@ -1226,28 +1307,18 @@ | |
| 1307 | CX("<p>This page is <em>far from complete</em> and may still have " |
| 1308 | "significant bugs. USE AT YOUR OWN RISK, preferably on a test " |
| 1309 | "repo.</p>\n"); |
| 1310 | |
| 1311 | CX("<form action='%R/fileedit#options' method='POST' " |
| 1312 | "class='fileedit'>\n"); |
| 1313 | |
| 1314 | /******* Hidden fields *******/ |
| 1315 | CX("<input type='hidden' name='r' value='%s'>", |
| 1316 | cimi.zParentUuid); |
| 1317 | CX("<input type='hidden' name='file' value='%T'>", |
| 1318 | zFilename); |
| 1319 | |
| 1320 | /******* Content *******/ |
| 1321 | CX("<h3>File Content</h3>\n"); |
| 1322 | CX("<textarea name='content' id='fileedit-content' " |
| 1323 | "rows='20' cols='80'>"); |
| 1324 | if(0==loadMode){ |
| @@ -1319,76 +1390,78 @@ | |
| 1390 | switch(eolMode){ |
| 1391 | case 1: cimi.flags |= CIMINI_CONVERT_EOL_UNIX; break; |
| 1392 | case 2: cimi.flags |= CIMINI_CONVERT_EOL_WINDOWS; break; |
| 1393 | default: cimi.flags |= CIMINI_CONVERT_EOL_INHERIT; break; |
| 1394 | } |
| 1395 | style_select_list_int("eol", "EOL Style", |
| 1396 | "EOL conversion policy, noting that " |
| 1397 | "form-processing may implicitly change the " |
| 1398 | "line endings of the input.", |
| 1399 | eolMode==1||eolMode==2 ? eolMode : 0, |
| 1400 | "Inherit", 0, |
| 1401 | "Unix", 1, |
| 1402 | "Windows", 2, |
| 1403 | NULL); |
| 1404 | } |
| 1405 | |
| 1406 | CX("</div></fieldset>") /* end of checkboxes */; |
| 1407 | |
| 1408 | /******* Comment *******/ |
| 1409 | CX("<a id='comment'></a>"); |
| 1410 | CX("<fieldset><legend>Commit message</legend><div>"); |
| 1411 | CX("<textarea name='comment' rows='3' cols='80'>"); |
| 1412 | /* ^^^ adding the 'required' attribute means we cannot even submit |
| 1413 | ** for PREVIEW mode if it's empty :/. */ |
| 1414 | if(zComment && *zComment){ |
| 1415 | CX("%h"/*%h? %s?*/, zComment); |
| 1416 | } |
| 1417 | CX("</textarea>\n"); |
| 1418 | CX("<div class='fileedit-hint'>Comments use the Fossil wiki markup " |
| 1419 | "syntax.</div>\n"/*TODO: select for fossil/md/plain text*/); |
| 1420 | CX("</div></fieldset>\n"); |
| 1421 | |
| 1422 | |
| 1423 | |
| 1424 | /******* Buttons *******/ |
| 1425 | CX("<a id='buttons'></a>"); |
| 1426 | CX("<fieldset class='fileedit-options'>" |
| 1427 | "<legend>Tell the server to...</legend><div>"); |
| 1428 | CX("<button type='submit' name='submit' value='1'>" |
| 1429 | "Save</button>"); |
| 1430 | CX("<button type='submit' name='submit' value='2'>" |
| 1431 | "Preview</button>"); |
| 1432 | { |
| 1433 | /* Preview rendering mode selection... */ |
| 1434 | previewRenderMode = atoi(PD("preview_render_mode","0")); |
| 1435 | if(0==previewRenderMode){ |
| 1436 | previewRenderMode = fileedit_render_mode_for_mimetype(zFileMime); |
| 1437 | } |
| 1438 | style_select_list_int("preview_render_mode", |
| 1439 | "Preview Mode", |
| 1440 | "Preview mode format.", |
| 1441 | previewRenderMode, |
| 1442 | "Guess", FE_RENDER_GUESS, |
| 1443 | "Wiki/Markdown", FE_RENDER_WIKI, |
| 1444 | "HTML (iframe)", FE_RENDER_HTML, |
| 1445 | "Plain Text", FE_RENDER_PLAIN_TEXT, |
| 1446 | NULL); |
| 1447 | if(FE_RENDER_HTML==previewRenderMode){ |
| 1448 | /* HTML preview mode iframe height... */ |
| 1449 | if(submitMode==SUBMIT_PREVIEW){ |
| 1450 | previewHtmlHeight = atoi(PD("preview_html_ems","0")); |
| 1451 | }else{ |
| 1452 | previewHtmlHeight = 40; |
| 1453 | } |
| 1454 | /* Allow selection of HTML preview iframe height */ |
| 1455 | style_select_list_int("preview_html_ems", |
| 1456 | "Preview IFrame Height (EMs)", |
| 1457 | "Height (in EMs) of the iframe used for " |
| 1458 | "HTML preview", |
| 1459 | previewHtmlHeight, |
| 1460 | "", 20, "", 40, |
| 1461 | "", 60, "", 80, |
| 1462 | "", 100, NULL); |
| 1463 | } |
| 1464 | else if(FE_RENDER_PLAIN_TEXT==previewRenderMode){ |
| 1465 | style_labeled_checkbox("preview_ln", |
| 1466 | "Add line numbers to plain-text previews?", |
| 1467 | "1", |
| @@ -1395,10 +1468,12 @@ | |
| 1468 | "If on, plain-text files (only) will get " |
| 1469 | "line numbers added to the preview.", |
| 1470 | previewLn); |
| 1471 | } |
| 1472 | } |
| 1473 | CX("<button type='submit' name='submit' value='3'>" |
| 1474 | "Diff (TODO)</button>"); |
| 1475 | CX("</div></fieldset>"); |
| 1476 | |
| 1477 | /******* End of form *******/ |
| 1478 | CX("</form>\n"); |
| 1479 | |
| 1480 |