Fossil SCM
Replaced the /fileedit_AJAX_ROUTE calls with /fileedit?ajax=ROUTE_NAME to eliminate the dispatch-time and help-system bloat.
Commit
9f26fd1eeeddac74ff782d3eb03234c64046513580c888240daaee9c95da1245
Parent
50a6a75ba1e9b97…
2 files changed
+28
-12
+16
-9
+28
-12
| --- src/fileedit.c | ||
| +++ src/fileedit.c | ||
| @@ -1162,11 +1162,11 @@ | ||
| 1162 | 1162 | } |
| 1163 | 1163 | return 1; |
| 1164 | 1164 | } |
| 1165 | 1165 | |
| 1166 | 1166 | /* |
| 1167 | -** WEBPAGE: fileedit_content | |
| 1167 | +** AJAX route /fileedit?ajax=content | |
| 1168 | 1168 | ** |
| 1169 | 1169 | ** Query parameters: |
| 1170 | 1170 | ** |
| 1171 | 1171 | ** filename=FILENAME |
| 1172 | 1172 | ** checkin=CHECKIN_NAME |
| @@ -1174,11 +1174,11 @@ | ||
| 1174 | 1174 | ** User must have Write access to use this page. |
| 1175 | 1175 | ** |
| 1176 | 1176 | ** Responds with the raw content of the given page. On error it |
| 1177 | 1177 | ** produces a JSON response as documented for fileedit_ajax_error(). |
| 1178 | 1178 | */ |
| 1179 | -void fileedit_ajax_content(void){ | |
| 1179 | +static void fileedit_ajax_content(void){ | |
| 1180 | 1180 | const char * zFilename = 0; |
| 1181 | 1181 | const char * zRev = 0; |
| 1182 | 1182 | int vid, frid; |
| 1183 | 1183 | Blob content = empty_blob; |
| 1184 | 1184 | const char * zMime; |
| @@ -1201,11 +1201,11 @@ | ||
| 1201 | 1201 | cgi_set_content_type(zMime); |
| 1202 | 1202 | cgi_set_content(&content); |
| 1203 | 1203 | } |
| 1204 | 1204 | |
| 1205 | 1205 | /* |
| 1206 | -** WEBPAGE: fileedit_preview | |
| 1206 | +** AJAX route /fileedit?ajax=preview | |
| 1207 | 1207 | ** |
| 1208 | 1208 | ** Required query parameters: |
| 1209 | 1209 | ** |
| 1210 | 1210 | ** filename=FILENAME |
| 1211 | 1211 | ** content=text |
| @@ -1223,11 +1223,11 @@ | ||
| 1223 | 1223 | ** User must have Write access to use this page. |
| 1224 | 1224 | ** |
| 1225 | 1225 | ** Responds with the HTML content of the preview. On error it produces |
| 1226 | 1226 | ** a JSON response as documented for fileedit_ajax_error(). |
| 1227 | 1227 | */ |
| 1228 | -void fileedit_ajax_preview(void){ | |
| 1228 | +static void fileedit_ajax_preview(void){ | |
| 1229 | 1229 | const char * zFilename = 0; |
| 1230 | 1230 | const char * zContent = P("content"); |
| 1231 | 1231 | int renderMode = atoi(PD("render_mode","0")); |
| 1232 | 1232 | int ln = atoi(PD("ln","0")); |
| 1233 | 1233 | int iframeHeight = atoi(PD("iframe_height","40")); |
| @@ -1244,11 +1244,11 @@ | ||
| 1244 | 1244 | ln ? FE_PREVIEW_LINE_NUMBERS : 0, |
| 1245 | 1245 | renderMode, iframeHeight); |
| 1246 | 1246 | } |
| 1247 | 1247 | |
| 1248 | 1248 | /* |
| 1249 | -** WEBPAGE: fileedit_diff | |
| 1249 | +** AJAX route /fileedit?ajax=diff | |
| 1250 | 1250 | ** |
| 1251 | 1251 | ** Required query parameters: |
| 1252 | 1252 | ** |
| 1253 | 1253 | ** filename=FILENAME |
| 1254 | 1254 | ** content=text |
| @@ -1261,11 +1261,11 @@ | ||
| 1261 | 1261 | ** User must have Write access to use this page. |
| 1262 | 1262 | ** |
| 1263 | 1263 | ** Responds with the HTML content of the diff. On error it produces a |
| 1264 | 1264 | ** JSON response as documented for fileedit_ajax_error(). |
| 1265 | 1265 | */ |
| 1266 | -void fileedit_ajax_diff(void){ | |
| 1266 | +static void fileedit_ajax_diff(void){ | |
| 1267 | 1267 | /* |
| 1268 | 1268 | ** Reminder: we only need the filename to perform valdiation |
| 1269 | 1269 | ** against fileedit_is_editable(), else this route could be |
| 1270 | 1270 | ** abused to get diffs against content disallowed by the |
| 1271 | 1271 | ** whitelist. |
| @@ -1418,11 +1418,11 @@ | ||
| 1418 | 1418 | fossil_free(zFileUuid); |
| 1419 | 1419 | return rc ? rc : 500; |
| 1420 | 1420 | } |
| 1421 | 1421 | |
| 1422 | 1422 | /* |
| 1423 | -** WEBPAGE: fileedit_filelist | |
| 1423 | +** AJAX route /fileedit?ajax=filelist | |
| 1424 | 1424 | ** |
| 1425 | 1425 | ** Fetches a JSON-format list of leaves and/or filenames for use in |
| 1426 | 1426 | ** creating a file selection list in /fileedit. It has different modes |
| 1427 | 1427 | ** of operation depending on its arguments: |
| 1428 | 1428 | ** |
| @@ -1444,11 +1444,11 @@ | ||
| 1444 | 1444 | ** } |
| 1445 | 1445 | ** |
| 1446 | 1446 | ** On error it produces a JSON response as documented for |
| 1447 | 1447 | ** fileedit_ajax_error(). |
| 1448 | 1448 | */ |
| 1449 | -void fileedit_ajax_filelist(void){ | |
| 1449 | +static void fileedit_ajax_filelist(void){ | |
| 1450 | 1450 | const char * zCi = PD("checkin",P("ci")); |
| 1451 | 1451 | Blob sql = empty_blob; |
| 1452 | 1452 | Stmt q = empty_Stmt; |
| 1453 | 1453 | int i = 0; |
| 1454 | 1454 | |
| @@ -1506,11 +1506,11 @@ | ||
| 1506 | 1506 | fileedit_ajax_error(500, "Unhandled URL argument."); |
| 1507 | 1507 | } |
| 1508 | 1508 | } |
| 1509 | 1509 | |
| 1510 | 1510 | /* |
| 1511 | -** WEBPAGE: fileedit_commit | |
| 1511 | +** AJAX route /fileedit?ajax=commit | |
| 1512 | 1512 | ** |
| 1513 | 1513 | ** Required query parameters: |
| 1514 | 1514 | ** |
| 1515 | 1515 | ** filename=FILENAME |
| 1516 | 1516 | ** checkin=Parent checkin UUID |
| @@ -1534,20 +1534,20 @@ | ||
| 1534 | 1534 | ** } |
| 1535 | 1535 | ** |
| 1536 | 1536 | ** On error it produces a JSON response as documented for |
| 1537 | 1537 | ** fileedit_ajax_error(). |
| 1538 | 1538 | */ |
| 1539 | -void fileedit_ajax_commit(void){ | |
| 1539 | +static void fileedit_ajax_commit(void){ | |
| 1540 | 1540 | Blob err = empty_blob; /* Error messages */ |
| 1541 | 1541 | Blob manifest = empty_blob; /* raw new manifest */ |
| 1542 | 1542 | CheckinMiniInfo cimi; /* checkin state */ |
| 1543 | 1543 | int rc; /* generic result code */ |
| 1544 | 1544 | int newVid = 0; /* new version's RID */ |
| 1545 | 1545 | char * zNewUuid = 0; /* newVid's UUID */ |
| 1546 | 1546 | |
| 1547 | 1547 | if(!fileedit_ajax_boostrap()){ |
| 1548 | - goto end_cleanup; | |
| 1548 | + return; | |
| 1549 | 1549 | } |
| 1550 | 1550 | db_begin_transaction(); |
| 1551 | 1551 | CheckinMiniInfo_init(&cimi); |
| 1552 | 1552 | rc = fileedit_setup_cimi_from_p(&cimi, &err); |
| 1553 | 1553 | if(0!=rc){ |
| @@ -1613,19 +1613,35 @@ | ||
| 1613 | 1613 | combined into a single JS |
| 1614 | 1614 | function call, thus each |
| 1615 | 1615 | entry must end with a |
| 1616 | 1616 | semicolon. */ |
| 1617 | 1617 | Stmt stmt = empty_Stmt; |
| 1618 | + const char *zAjax = P("ajax"); | |
| 1618 | 1619 | |
| 1620 | + if(0!=zAjax){ | |
| 1621 | + if(0==strcmp("content",zAjax)){ | |
| 1622 | + fileedit_ajax_content(); | |
| 1623 | + }else if(0==strcmp("preview",zAjax)){ | |
| 1624 | + fileedit_ajax_preview(); | |
| 1625 | + }else if(0==strcmp("filelist",zAjax)){ | |
| 1626 | + fileedit_ajax_filelist(); | |
| 1627 | + }else if(0==strcmp("diff",zAjax)){ | |
| 1628 | + fileedit_ajax_diff(); | |
| 1629 | + }else if(0==strcmp("commit",zAjax)){ | |
| 1630 | + fileedit_ajax_commit(); | |
| 1631 | + }else{ | |
| 1632 | + fileedit_ajax_error(500, "Unhandled 'ajax' value."); | |
| 1633 | + } | |
| 1634 | + return; | |
| 1635 | + } | |
| 1619 | 1636 | login_check_credentials(); |
| 1620 | 1637 | if( !g.perm.Write ){ |
| 1621 | 1638 | login_needed(g.anon.Write); |
| 1622 | 1639 | return; |
| 1623 | 1640 | } |
| 1624 | 1641 | db_begin_transaction(); |
| 1625 | 1642 | CheckinMiniInfo_init(&cimi); |
| 1626 | - | |
| 1627 | 1643 | style_header("File Editor"); |
| 1628 | 1644 | /* As of this point, don't use return or fossil_fatal(). Write any |
| 1629 | 1645 | ** error in (&err) and goto end_footer instead so that we can be |
| 1630 | 1646 | ** sure to do any cleanup and end the transaction cleanly. |
| 1631 | 1647 | */ |
| 1632 | 1648 |
| --- src/fileedit.c | |
| +++ src/fileedit.c | |
| @@ -1162,11 +1162,11 @@ | |
| 1162 | } |
| 1163 | return 1; |
| 1164 | } |
| 1165 | |
| 1166 | /* |
| 1167 | ** WEBPAGE: fileedit_content |
| 1168 | ** |
| 1169 | ** Query parameters: |
| 1170 | ** |
| 1171 | ** filename=FILENAME |
| 1172 | ** checkin=CHECKIN_NAME |
| @@ -1174,11 +1174,11 @@ | |
| 1174 | ** User must have Write access to use this page. |
| 1175 | ** |
| 1176 | ** Responds with the raw content of the given page. On error it |
| 1177 | ** produces a JSON response as documented for fileedit_ajax_error(). |
| 1178 | */ |
| 1179 | void fileedit_ajax_content(void){ |
| 1180 | const char * zFilename = 0; |
| 1181 | const char * zRev = 0; |
| 1182 | int vid, frid; |
| 1183 | Blob content = empty_blob; |
| 1184 | const char * zMime; |
| @@ -1201,11 +1201,11 @@ | |
| 1201 | cgi_set_content_type(zMime); |
| 1202 | cgi_set_content(&content); |
| 1203 | } |
| 1204 | |
| 1205 | /* |
| 1206 | ** WEBPAGE: fileedit_preview |
| 1207 | ** |
| 1208 | ** Required query parameters: |
| 1209 | ** |
| 1210 | ** filename=FILENAME |
| 1211 | ** content=text |
| @@ -1223,11 +1223,11 @@ | |
| 1223 | ** User must have Write access to use this page. |
| 1224 | ** |
| 1225 | ** Responds with the HTML content of the preview. On error it produces |
| 1226 | ** a JSON response as documented for fileedit_ajax_error(). |
| 1227 | */ |
| 1228 | void fileedit_ajax_preview(void){ |
| 1229 | const char * zFilename = 0; |
| 1230 | const char * zContent = P("content"); |
| 1231 | int renderMode = atoi(PD("render_mode","0")); |
| 1232 | int ln = atoi(PD("ln","0")); |
| 1233 | int iframeHeight = atoi(PD("iframe_height","40")); |
| @@ -1244,11 +1244,11 @@ | |
| 1244 | ln ? FE_PREVIEW_LINE_NUMBERS : 0, |
| 1245 | renderMode, iframeHeight); |
| 1246 | } |
| 1247 | |
| 1248 | /* |
| 1249 | ** WEBPAGE: fileedit_diff |
| 1250 | ** |
| 1251 | ** Required query parameters: |
| 1252 | ** |
| 1253 | ** filename=FILENAME |
| 1254 | ** content=text |
| @@ -1261,11 +1261,11 @@ | |
| 1261 | ** User must have Write access to use this page. |
| 1262 | ** |
| 1263 | ** Responds with the HTML content of the diff. On error it produces a |
| 1264 | ** JSON response as documented for fileedit_ajax_error(). |
| 1265 | */ |
| 1266 | void fileedit_ajax_diff(void){ |
| 1267 | /* |
| 1268 | ** Reminder: we only need the filename to perform valdiation |
| 1269 | ** against fileedit_is_editable(), else this route could be |
| 1270 | ** abused to get diffs against content disallowed by the |
| 1271 | ** whitelist. |
| @@ -1418,11 +1418,11 @@ | |
| 1418 | fossil_free(zFileUuid); |
| 1419 | return rc ? rc : 500; |
| 1420 | } |
| 1421 | |
| 1422 | /* |
| 1423 | ** WEBPAGE: fileedit_filelist |
| 1424 | ** |
| 1425 | ** Fetches a JSON-format list of leaves and/or filenames for use in |
| 1426 | ** creating a file selection list in /fileedit. It has different modes |
| 1427 | ** of operation depending on its arguments: |
| 1428 | ** |
| @@ -1444,11 +1444,11 @@ | |
| 1444 | ** } |
| 1445 | ** |
| 1446 | ** On error it produces a JSON response as documented for |
| 1447 | ** fileedit_ajax_error(). |
| 1448 | */ |
| 1449 | void fileedit_ajax_filelist(void){ |
| 1450 | const char * zCi = PD("checkin",P("ci")); |
| 1451 | Blob sql = empty_blob; |
| 1452 | Stmt q = empty_Stmt; |
| 1453 | int i = 0; |
| 1454 | |
| @@ -1506,11 +1506,11 @@ | |
| 1506 | fileedit_ajax_error(500, "Unhandled URL argument."); |
| 1507 | } |
| 1508 | } |
| 1509 | |
| 1510 | /* |
| 1511 | ** WEBPAGE: fileedit_commit |
| 1512 | ** |
| 1513 | ** Required query parameters: |
| 1514 | ** |
| 1515 | ** filename=FILENAME |
| 1516 | ** checkin=Parent checkin UUID |
| @@ -1534,20 +1534,20 @@ | |
| 1534 | ** } |
| 1535 | ** |
| 1536 | ** On error it produces a JSON response as documented for |
| 1537 | ** fileedit_ajax_error(). |
| 1538 | */ |
| 1539 | void fileedit_ajax_commit(void){ |
| 1540 | Blob err = empty_blob; /* Error messages */ |
| 1541 | Blob manifest = empty_blob; /* raw new manifest */ |
| 1542 | CheckinMiniInfo cimi; /* checkin state */ |
| 1543 | int rc; /* generic result code */ |
| 1544 | int newVid = 0; /* new version's RID */ |
| 1545 | char * zNewUuid = 0; /* newVid's UUID */ |
| 1546 | |
| 1547 | if(!fileedit_ajax_boostrap()){ |
| 1548 | goto end_cleanup; |
| 1549 | } |
| 1550 | db_begin_transaction(); |
| 1551 | CheckinMiniInfo_init(&cimi); |
| 1552 | rc = fileedit_setup_cimi_from_p(&cimi, &err); |
| 1553 | if(0!=rc){ |
| @@ -1613,19 +1613,35 @@ | |
| 1613 | combined into a single JS |
| 1614 | function call, thus each |
| 1615 | entry must end with a |
| 1616 | semicolon. */ |
| 1617 | Stmt stmt = empty_Stmt; |
| 1618 | |
| 1619 | login_check_credentials(); |
| 1620 | if( !g.perm.Write ){ |
| 1621 | login_needed(g.anon.Write); |
| 1622 | return; |
| 1623 | } |
| 1624 | db_begin_transaction(); |
| 1625 | CheckinMiniInfo_init(&cimi); |
| 1626 | |
| 1627 | style_header("File Editor"); |
| 1628 | /* As of this point, don't use return or fossil_fatal(). Write any |
| 1629 | ** error in (&err) and goto end_footer instead so that we can be |
| 1630 | ** sure to do any cleanup and end the transaction cleanly. |
| 1631 | */ |
| 1632 |
| --- src/fileedit.c | |
| +++ src/fileedit.c | |
| @@ -1162,11 +1162,11 @@ | |
| 1162 | } |
| 1163 | return 1; |
| 1164 | } |
| 1165 | |
| 1166 | /* |
| 1167 | ** AJAX route /fileedit?ajax=content |
| 1168 | ** |
| 1169 | ** Query parameters: |
| 1170 | ** |
| 1171 | ** filename=FILENAME |
| 1172 | ** checkin=CHECKIN_NAME |
| @@ -1174,11 +1174,11 @@ | |
| 1174 | ** User must have Write access to use this page. |
| 1175 | ** |
| 1176 | ** Responds with the raw content of the given page. On error it |
| 1177 | ** produces a JSON response as documented for fileedit_ajax_error(). |
| 1178 | */ |
| 1179 | static void fileedit_ajax_content(void){ |
| 1180 | const char * zFilename = 0; |
| 1181 | const char * zRev = 0; |
| 1182 | int vid, frid; |
| 1183 | Blob content = empty_blob; |
| 1184 | const char * zMime; |
| @@ -1201,11 +1201,11 @@ | |
| 1201 | cgi_set_content_type(zMime); |
| 1202 | cgi_set_content(&content); |
| 1203 | } |
| 1204 | |
| 1205 | /* |
| 1206 | ** AJAX route /fileedit?ajax=preview |
| 1207 | ** |
| 1208 | ** Required query parameters: |
| 1209 | ** |
| 1210 | ** filename=FILENAME |
| 1211 | ** content=text |
| @@ -1223,11 +1223,11 @@ | |
| 1223 | ** User must have Write access to use this page. |
| 1224 | ** |
| 1225 | ** Responds with the HTML content of the preview. On error it produces |
| 1226 | ** a JSON response as documented for fileedit_ajax_error(). |
| 1227 | */ |
| 1228 | static void fileedit_ajax_preview(void){ |
| 1229 | const char * zFilename = 0; |
| 1230 | const char * zContent = P("content"); |
| 1231 | int renderMode = atoi(PD("render_mode","0")); |
| 1232 | int ln = atoi(PD("ln","0")); |
| 1233 | int iframeHeight = atoi(PD("iframe_height","40")); |
| @@ -1244,11 +1244,11 @@ | |
| 1244 | ln ? FE_PREVIEW_LINE_NUMBERS : 0, |
| 1245 | renderMode, iframeHeight); |
| 1246 | } |
| 1247 | |
| 1248 | /* |
| 1249 | ** AJAX route /fileedit?ajax=diff |
| 1250 | ** |
| 1251 | ** Required query parameters: |
| 1252 | ** |
| 1253 | ** filename=FILENAME |
| 1254 | ** content=text |
| @@ -1261,11 +1261,11 @@ | |
| 1261 | ** User must have Write access to use this page. |
| 1262 | ** |
| 1263 | ** Responds with the HTML content of the diff. On error it produces a |
| 1264 | ** JSON response as documented for fileedit_ajax_error(). |
| 1265 | */ |
| 1266 | static void fileedit_ajax_diff(void){ |
| 1267 | /* |
| 1268 | ** Reminder: we only need the filename to perform valdiation |
| 1269 | ** against fileedit_is_editable(), else this route could be |
| 1270 | ** abused to get diffs against content disallowed by the |
| 1271 | ** whitelist. |
| @@ -1418,11 +1418,11 @@ | |
| 1418 | fossil_free(zFileUuid); |
| 1419 | return rc ? rc : 500; |
| 1420 | } |
| 1421 | |
| 1422 | /* |
| 1423 | ** AJAX route /fileedit?ajax=filelist |
| 1424 | ** |
| 1425 | ** Fetches a JSON-format list of leaves and/or filenames for use in |
| 1426 | ** creating a file selection list in /fileedit. It has different modes |
| 1427 | ** of operation depending on its arguments: |
| 1428 | ** |
| @@ -1444,11 +1444,11 @@ | |
| 1444 | ** } |
| 1445 | ** |
| 1446 | ** On error it produces a JSON response as documented for |
| 1447 | ** fileedit_ajax_error(). |
| 1448 | */ |
| 1449 | static void fileedit_ajax_filelist(void){ |
| 1450 | const char * zCi = PD("checkin",P("ci")); |
| 1451 | Blob sql = empty_blob; |
| 1452 | Stmt q = empty_Stmt; |
| 1453 | int i = 0; |
| 1454 | |
| @@ -1506,11 +1506,11 @@ | |
| 1506 | fileedit_ajax_error(500, "Unhandled URL argument."); |
| 1507 | } |
| 1508 | } |
| 1509 | |
| 1510 | /* |
| 1511 | ** AJAX route /fileedit?ajax=commit |
| 1512 | ** |
| 1513 | ** Required query parameters: |
| 1514 | ** |
| 1515 | ** filename=FILENAME |
| 1516 | ** checkin=Parent checkin UUID |
| @@ -1534,20 +1534,20 @@ | |
| 1534 | ** } |
| 1535 | ** |
| 1536 | ** On error it produces a JSON response as documented for |
| 1537 | ** fileedit_ajax_error(). |
| 1538 | */ |
| 1539 | static void fileedit_ajax_commit(void){ |
| 1540 | Blob err = empty_blob; /* Error messages */ |
| 1541 | Blob manifest = empty_blob; /* raw new manifest */ |
| 1542 | CheckinMiniInfo cimi; /* checkin state */ |
| 1543 | int rc; /* generic result code */ |
| 1544 | int newVid = 0; /* new version's RID */ |
| 1545 | char * zNewUuid = 0; /* newVid's UUID */ |
| 1546 | |
| 1547 | if(!fileedit_ajax_boostrap()){ |
| 1548 | return; |
| 1549 | } |
| 1550 | db_begin_transaction(); |
| 1551 | CheckinMiniInfo_init(&cimi); |
| 1552 | rc = fileedit_setup_cimi_from_p(&cimi, &err); |
| 1553 | if(0!=rc){ |
| @@ -1613,19 +1613,35 @@ | |
| 1613 | combined into a single JS |
| 1614 | function call, thus each |
| 1615 | entry must end with a |
| 1616 | semicolon. */ |
| 1617 | Stmt stmt = empty_Stmt; |
| 1618 | const char *zAjax = P("ajax"); |
| 1619 | |
| 1620 | if(0!=zAjax){ |
| 1621 | if(0==strcmp("content",zAjax)){ |
| 1622 | fileedit_ajax_content(); |
| 1623 | }else if(0==strcmp("preview",zAjax)){ |
| 1624 | fileedit_ajax_preview(); |
| 1625 | }else if(0==strcmp("filelist",zAjax)){ |
| 1626 | fileedit_ajax_filelist(); |
| 1627 | }else if(0==strcmp("diff",zAjax)){ |
| 1628 | fileedit_ajax_diff(); |
| 1629 | }else if(0==strcmp("commit",zAjax)){ |
| 1630 | fileedit_ajax_commit(); |
| 1631 | }else{ |
| 1632 | fileedit_ajax_error(500, "Unhandled 'ajax' value."); |
| 1633 | } |
| 1634 | return; |
| 1635 | } |
| 1636 | login_check_credentials(); |
| 1637 | if( !g.perm.Write ){ |
| 1638 | login_needed(g.anon.Write); |
| 1639 | return; |
| 1640 | } |
| 1641 | db_begin_transaction(); |
| 1642 | CheckinMiniInfo_init(&cimi); |
| 1643 | style_header("File Editor"); |
| 1644 | /* As of this point, don't use return or fossil_fatal(). Write any |
| 1645 | ** error in (&err) and goto end_footer instead so that we can be |
| 1646 | ** sure to do any cleanup and end the transaction cleanly. |
| 1647 | */ |
| 1648 |
+16
-9
| --- src/fossil.page.fileedit.js | ||
| +++ src/fossil.page.fileedit.js | ||
| @@ -22,12 +22,12 @@ | ||
| 22 | 22 | }, |
| 23 | 23 | loadLeaves: function(){ |
| 24 | 24 | D.append(D.clearElement(this.e.ciListLabel),"Loading leaves..."); |
| 25 | 25 | D.disable(this.e.btnLoadFile, this.e.selectFiles, this.e.selectCi); |
| 26 | 26 | const self = this; |
| 27 | - F.fetch('fileedit_filelist',{ | |
| 28 | - urlParams:'leaves', | |
| 27 | + F.fetch('fileedit',{ | |
| 28 | + urlParams:'ajax=filelist&leaves', | |
| 29 | 29 | responseType: 'json', |
| 30 | 30 | onload: function(list){ |
| 31 | 31 | D.append(D.clearElement(self.e.ciListLabel),"Open leaves:"); |
| 32 | 32 | self.cache.checkins = list; |
| 33 | 33 | D.clearElement(D.enable(self.e.selectCi)); |
| @@ -72,12 +72,12 @@ | ||
| 72 | 72 | } |
| 73 | 73 | D.disable(selFiles,this.e.btnLoadFile); |
| 74 | 74 | D.clearElement(selFiles); |
| 75 | 75 | D.append(D.clearElement(this.e.fileListLabel), |
| 76 | 76 | "Loading files for "+F.hashDigits(ciUuid)+"..."); |
| 77 | - F.fetch('fileedit_filelist',{ | |
| 78 | - urlParams:{checkin: ciUuid}, | |
| 77 | + F.fetch('fileedit',{ | |
| 78 | + urlParams:{ajax:'filelist', checkin: ciUuid}, | |
| 79 | 79 | responseType: 'json', |
| 80 | 80 | onload |
| 81 | 81 | }); |
| 82 | 82 | return this; |
| 83 | 83 | }, |
| @@ -336,12 +336,16 @@ | ||
| 336 | 336 | rev = this.finfo.checkin; |
| 337 | 337 | } |
| 338 | 338 | delete this.finfo; |
| 339 | 339 | const self = this; |
| 340 | 340 | F.message("Loading content..."); |
| 341 | - F.fetch('fileedit_content',{ | |
| 342 | - urlParams: {filename:file,checkin:rev}, | |
| 341 | + F.fetch('fileedit',{ | |
| 342 | + urlParams: { | |
| 343 | + ajax: 'content', | |
| 344 | + filename:file, | |
| 345 | + checkin:rev | |
| 346 | + }, | |
| 343 | 347 | onload:(r)=>{ |
| 344 | 348 | F.message('Loaded content.'); |
| 345 | 349 | self.e.taEditor.value = r; |
| 346 | 350 | self.updateVersion(file,rev); |
| 347 | 351 | self.tabs.switchToTab(self.e.tabs.content); |
| @@ -388,11 +392,12 @@ | ||
| 388 | 392 | fd.append('ln',E('[name=preview_ln]').checked ? 1 : 0); |
| 389 | 393 | fd.append('iframe_height', E('[name=preview_html_ems]').value); |
| 390 | 394 | fd.append('content',content || ''); |
| 391 | 395 | F.message( |
| 392 | 396 | "Fetching preview..." |
| 393 | - ).fetch('fileedit_preview',{ | |
| 397 | + ).fetch('fileedit',{ | |
| 398 | + urlParams: {ajax: 'preview'}, | |
| 394 | 399 | payload: fd, |
| 395 | 400 | onload: (r)=>{ |
| 396 | 401 | callback(r); |
| 397 | 402 | F.message('Updated preview.'); |
| 398 | 403 | }, |
| @@ -425,11 +430,12 @@ | ||
| 425 | 430 | fd.append('checkin', this.finfo.checkin); |
| 426 | 431 | fd.append('sbs', sbs ? 1 : 0); |
| 427 | 432 | fd.append('content',content); |
| 428 | 433 | F.message( |
| 429 | 434 | "Fetching diff..." |
| 430 | - ).fetch('fileedit_diff',{ | |
| 435 | + ).fetch('fileedit',{ | |
| 436 | + urlParams: {ajax: 'diff'}, | |
| 431 | 437 | payload: fd, |
| 432 | 438 | onload: function(c){ |
| 433 | 439 | f.target.innerHTML = [ |
| 434 | 440 | "<div>Diff <code>[", |
| 435 | 441 | self.finfo.checkin, |
| @@ -512,15 +518,16 @@ | ||
| 512 | 518 | console.error("Missing checkbox? name =",name); |
| 513 | 519 | } |
| 514 | 520 | }); |
| 515 | 521 | F.message( |
| 516 | 522 | "Checking in..." |
| 517 | - ).fetch('fileedit_commit',{ | |
| 523 | + ).fetch('fileedit',{ | |
| 524 | + urlParams: {ajax: 'commit'}, | |
| 518 | 525 | payload: fd, |
| 519 | 526 | responseType: 'json', |
| 520 | 527 | onload: f.updateView |
| 521 | 528 | }); |
| 522 | 529 | return this; |
| 523 | 530 | }; |
| 524 | 531 | |
| 525 | 532 | |
| 526 | 533 | })(window.fossil); |
| 527 | 534 |
| --- src/fossil.page.fileedit.js | |
| +++ src/fossil.page.fileedit.js | |
| @@ -22,12 +22,12 @@ | |
| 22 | }, |
| 23 | loadLeaves: function(){ |
| 24 | D.append(D.clearElement(this.e.ciListLabel),"Loading leaves..."); |
| 25 | D.disable(this.e.btnLoadFile, this.e.selectFiles, this.e.selectCi); |
| 26 | const self = this; |
| 27 | F.fetch('fileedit_filelist',{ |
| 28 | urlParams:'leaves', |
| 29 | responseType: 'json', |
| 30 | onload: function(list){ |
| 31 | D.append(D.clearElement(self.e.ciListLabel),"Open leaves:"); |
| 32 | self.cache.checkins = list; |
| 33 | D.clearElement(D.enable(self.e.selectCi)); |
| @@ -72,12 +72,12 @@ | |
| 72 | } |
| 73 | D.disable(selFiles,this.e.btnLoadFile); |
| 74 | D.clearElement(selFiles); |
| 75 | D.append(D.clearElement(this.e.fileListLabel), |
| 76 | "Loading files for "+F.hashDigits(ciUuid)+"..."); |
| 77 | F.fetch('fileedit_filelist',{ |
| 78 | urlParams:{checkin: ciUuid}, |
| 79 | responseType: 'json', |
| 80 | onload |
| 81 | }); |
| 82 | return this; |
| 83 | }, |
| @@ -336,12 +336,16 @@ | |
| 336 | rev = this.finfo.checkin; |
| 337 | } |
| 338 | delete this.finfo; |
| 339 | const self = this; |
| 340 | F.message("Loading content..."); |
| 341 | F.fetch('fileedit_content',{ |
| 342 | urlParams: {filename:file,checkin:rev}, |
| 343 | onload:(r)=>{ |
| 344 | F.message('Loaded content.'); |
| 345 | self.e.taEditor.value = r; |
| 346 | self.updateVersion(file,rev); |
| 347 | self.tabs.switchToTab(self.e.tabs.content); |
| @@ -388,11 +392,12 @@ | |
| 388 | fd.append('ln',E('[name=preview_ln]').checked ? 1 : 0); |
| 389 | fd.append('iframe_height', E('[name=preview_html_ems]').value); |
| 390 | fd.append('content',content || ''); |
| 391 | F.message( |
| 392 | "Fetching preview..." |
| 393 | ).fetch('fileedit_preview',{ |
| 394 | payload: fd, |
| 395 | onload: (r)=>{ |
| 396 | callback(r); |
| 397 | F.message('Updated preview.'); |
| 398 | }, |
| @@ -425,11 +430,12 @@ | |
| 425 | fd.append('checkin', this.finfo.checkin); |
| 426 | fd.append('sbs', sbs ? 1 : 0); |
| 427 | fd.append('content',content); |
| 428 | F.message( |
| 429 | "Fetching diff..." |
| 430 | ).fetch('fileedit_diff',{ |
| 431 | payload: fd, |
| 432 | onload: function(c){ |
| 433 | f.target.innerHTML = [ |
| 434 | "<div>Diff <code>[", |
| 435 | self.finfo.checkin, |
| @@ -512,15 +518,16 @@ | |
| 512 | console.error("Missing checkbox? name =",name); |
| 513 | } |
| 514 | }); |
| 515 | F.message( |
| 516 | "Checking in..." |
| 517 | ).fetch('fileedit_commit',{ |
| 518 | payload: fd, |
| 519 | responseType: 'json', |
| 520 | onload: f.updateView |
| 521 | }); |
| 522 | return this; |
| 523 | }; |
| 524 | |
| 525 | |
| 526 | })(window.fossil); |
| 527 |
| --- src/fossil.page.fileedit.js | |
| +++ src/fossil.page.fileedit.js | |
| @@ -22,12 +22,12 @@ | |
| 22 | }, |
| 23 | loadLeaves: function(){ |
| 24 | D.append(D.clearElement(this.e.ciListLabel),"Loading leaves..."); |
| 25 | D.disable(this.e.btnLoadFile, this.e.selectFiles, this.e.selectCi); |
| 26 | const self = this; |
| 27 | F.fetch('fileedit',{ |
| 28 | urlParams:'ajax=filelist&leaves', |
| 29 | responseType: 'json', |
| 30 | onload: function(list){ |
| 31 | D.append(D.clearElement(self.e.ciListLabel),"Open leaves:"); |
| 32 | self.cache.checkins = list; |
| 33 | D.clearElement(D.enable(self.e.selectCi)); |
| @@ -72,12 +72,12 @@ | |
| 72 | } |
| 73 | D.disable(selFiles,this.e.btnLoadFile); |
| 74 | D.clearElement(selFiles); |
| 75 | D.append(D.clearElement(this.e.fileListLabel), |
| 76 | "Loading files for "+F.hashDigits(ciUuid)+"..."); |
| 77 | F.fetch('fileedit',{ |
| 78 | urlParams:{ajax:'filelist', checkin: ciUuid}, |
| 79 | responseType: 'json', |
| 80 | onload |
| 81 | }); |
| 82 | return this; |
| 83 | }, |
| @@ -336,12 +336,16 @@ | |
| 336 | rev = this.finfo.checkin; |
| 337 | } |
| 338 | delete this.finfo; |
| 339 | const self = this; |
| 340 | F.message("Loading content..."); |
| 341 | F.fetch('fileedit',{ |
| 342 | urlParams: { |
| 343 | ajax: 'content', |
| 344 | filename:file, |
| 345 | checkin:rev |
| 346 | }, |
| 347 | onload:(r)=>{ |
| 348 | F.message('Loaded content.'); |
| 349 | self.e.taEditor.value = r; |
| 350 | self.updateVersion(file,rev); |
| 351 | self.tabs.switchToTab(self.e.tabs.content); |
| @@ -388,11 +392,12 @@ | |
| 392 | fd.append('ln',E('[name=preview_ln]').checked ? 1 : 0); |
| 393 | fd.append('iframe_height', E('[name=preview_html_ems]').value); |
| 394 | fd.append('content',content || ''); |
| 395 | F.message( |
| 396 | "Fetching preview..." |
| 397 | ).fetch('fileedit',{ |
| 398 | urlParams: {ajax: 'preview'}, |
| 399 | payload: fd, |
| 400 | onload: (r)=>{ |
| 401 | callback(r); |
| 402 | F.message('Updated preview.'); |
| 403 | }, |
| @@ -425,11 +430,12 @@ | |
| 430 | fd.append('checkin', this.finfo.checkin); |
| 431 | fd.append('sbs', sbs ? 1 : 0); |
| 432 | fd.append('content',content); |
| 433 | F.message( |
| 434 | "Fetching diff..." |
| 435 | ).fetch('fileedit',{ |
| 436 | urlParams: {ajax: 'diff'}, |
| 437 | payload: fd, |
| 438 | onload: function(c){ |
| 439 | f.target.innerHTML = [ |
| 440 | "<div>Diff <code>[", |
| 441 | self.finfo.checkin, |
| @@ -512,15 +518,16 @@ | |
| 518 | console.error("Missing checkbox? name =",name); |
| 519 | } |
| 520 | }); |
| 521 | F.message( |
| 522 | "Checking in..." |
| 523 | ).fetch('fileedit',{ |
| 524 | urlParams: {ajax: 'commit'}, |
| 525 | payload: fd, |
| 526 | responseType: 'json', |
| 527 | onload: f.updateView |
| 528 | }); |
| 529 | return this; |
| 530 | }; |
| 531 | |
| 532 | |
| 533 | })(window.fossil); |
| 534 |