Fossil SCM
Replaced /fileedit?ajax=blah with /fileedit/blah. This simplifies the passing of URL arguments, eliminating it in several cases, and just looks nicer.
Commit
2c4e7c3785d1bfcda429161743721f6a693031569ab4d49a7616e869680569b8
Parent
25f5f592d175694…
2 files changed
+10
-4
+8
-12
+10
-4
| --- src/fileedit.c | ||
| +++ src/fileedit.c | ||
| @@ -1728,15 +1728,21 @@ | ||
| 1728 | 1728 | ** checkin=VERSION Checkin version, using any unambiguous |
| 1729 | 1729 | ** supported symbolic version name. |
| 1730 | 1730 | ** |
| 1731 | 1731 | ** Internal-use parameters: |
| 1732 | 1732 | ** |
| 1733 | -** ajax=string The name of a page-specific AJAX operation. | |
| 1733 | +** name=string The name of a page-specific AJAX operation. | |
| 1734 | +** | |
| 1735 | +** Noting that fossil internally stores all URL path components after | |
| 1736 | +** the first as the "name" value. Thus /fileedit?name=blah is | |
| 1737 | +** equivalent to /fileedit/blah. The latter is the preferred | |
| 1738 | +** form. This means, however, that no fileedit ajax routes may make | |
| 1739 | +** use of the name parameter. | |
| 1734 | 1740 | ** |
| 1735 | 1741 | ** Which additional parameters are used by each distinct ajax value is |
| 1736 | 1742 | ** an internal implementation detail and may change with any given |
| 1737 | -** build of this code. An unknown ajax value triggers an error, as | |
| 1743 | +** build of this code. An unknown "name" value triggers an error, as | |
| 1738 | 1744 | ** documented for fileedit_ajax_error(). |
| 1739 | 1745 | */ |
| 1740 | 1746 | void fileedit_page(void){ |
| 1741 | 1747 | const char * zFilename = 0; /* filename. We'll accept 'name' |
| 1742 | 1748 | because that param is handled |
| @@ -1751,11 +1757,11 @@ | ||
| 1751 | 1757 | end. This content will be |
| 1752 | 1758 | combined into a single JS |
| 1753 | 1759 | function call, thus each |
| 1754 | 1760 | entry must end with a |
| 1755 | 1761 | semicolon. */ |
| 1756 | - const char *zAjax = P("ajax"); | |
| 1762 | + const char *zAjax = P("name"); | |
| 1757 | 1763 | |
| 1758 | 1764 | if(0!=zAjax){ |
| 1759 | 1765 | if(0==strcmp("content",zAjax)){ |
| 1760 | 1766 | fileedit_ajax_content(); |
| 1761 | 1767 | }else if(0==strcmp("preview",zAjax)){ |
| @@ -1765,11 +1771,11 @@ | ||
| 1765 | 1771 | }else if(0==strcmp("diff",zAjax)){ |
| 1766 | 1772 | fileedit_ajax_diff(); |
| 1767 | 1773 | }else if(0==strcmp("commit",zAjax)){ |
| 1768 | 1774 | fileedit_ajax_commit(); |
| 1769 | 1775 | }else{ |
| 1770 | - fileedit_ajax_error(500, "Unhandled 'ajax' value."); | |
| 1776 | + fileedit_ajax_error(500, "Unhandled ajax route name."); | |
| 1771 | 1777 | } |
| 1772 | 1778 | return; |
| 1773 | 1779 | } |
| 1774 | 1780 | login_check_credentials(); |
| 1775 | 1781 | if( !g.perm.Write ){ |
| 1776 | 1782 |
| --- src/fileedit.c | |
| +++ src/fileedit.c | |
| @@ -1728,15 +1728,21 @@ | |
| 1728 | ** checkin=VERSION Checkin version, using any unambiguous |
| 1729 | ** supported symbolic version name. |
| 1730 | ** |
| 1731 | ** Internal-use parameters: |
| 1732 | ** |
| 1733 | ** ajax=string The name of a page-specific AJAX operation. |
| 1734 | ** |
| 1735 | ** Which additional parameters are used by each distinct ajax value is |
| 1736 | ** an internal implementation detail and may change with any given |
| 1737 | ** build of this code. An unknown ajax value triggers an error, as |
| 1738 | ** documented for fileedit_ajax_error(). |
| 1739 | */ |
| 1740 | void fileedit_page(void){ |
| 1741 | const char * zFilename = 0; /* filename. We'll accept 'name' |
| 1742 | because that param is handled |
| @@ -1751,11 +1757,11 @@ | |
| 1751 | end. This content will be |
| 1752 | combined into a single JS |
| 1753 | function call, thus each |
| 1754 | entry must end with a |
| 1755 | semicolon. */ |
| 1756 | const char *zAjax = P("ajax"); |
| 1757 | |
| 1758 | if(0!=zAjax){ |
| 1759 | if(0==strcmp("content",zAjax)){ |
| 1760 | fileedit_ajax_content(); |
| 1761 | }else if(0==strcmp("preview",zAjax)){ |
| @@ -1765,11 +1771,11 @@ | |
| 1765 | }else if(0==strcmp("diff",zAjax)){ |
| 1766 | fileedit_ajax_diff(); |
| 1767 | }else if(0==strcmp("commit",zAjax)){ |
| 1768 | fileedit_ajax_commit(); |
| 1769 | }else{ |
| 1770 | fileedit_ajax_error(500, "Unhandled 'ajax' value."); |
| 1771 | } |
| 1772 | return; |
| 1773 | } |
| 1774 | login_check_credentials(); |
| 1775 | if( !g.perm.Write ){ |
| 1776 |
| --- src/fileedit.c | |
| +++ src/fileedit.c | |
| @@ -1728,15 +1728,21 @@ | |
| 1728 | ** checkin=VERSION Checkin version, using any unambiguous |
| 1729 | ** supported symbolic version name. |
| 1730 | ** |
| 1731 | ** Internal-use parameters: |
| 1732 | ** |
| 1733 | ** name=string The name of a page-specific AJAX operation. |
| 1734 | ** |
| 1735 | ** Noting that fossil internally stores all URL path components after |
| 1736 | ** the first as the "name" value. Thus /fileedit?name=blah is |
| 1737 | ** equivalent to /fileedit/blah. The latter is the preferred |
| 1738 | ** form. This means, however, that no fileedit ajax routes may make |
| 1739 | ** use of the name parameter. |
| 1740 | ** |
| 1741 | ** Which additional parameters are used by each distinct ajax value is |
| 1742 | ** an internal implementation detail and may change with any given |
| 1743 | ** build of this code. An unknown "name" value triggers an error, as |
| 1744 | ** documented for fileedit_ajax_error(). |
| 1745 | */ |
| 1746 | void fileedit_page(void){ |
| 1747 | const char * zFilename = 0; /* filename. We'll accept 'name' |
| 1748 | because that param is handled |
| @@ -1751,11 +1757,11 @@ | |
| 1757 | end. This content will be |
| 1758 | combined into a single JS |
| 1759 | function call, thus each |
| 1760 | entry must end with a |
| 1761 | semicolon. */ |
| 1762 | const char *zAjax = P("name"); |
| 1763 | |
| 1764 | if(0!=zAjax){ |
| 1765 | if(0==strcmp("content",zAjax)){ |
| 1766 | fileedit_ajax_content(); |
| 1767 | }else if(0==strcmp("preview",zAjax)){ |
| @@ -1765,11 +1771,11 @@ | |
| 1771 | }else if(0==strcmp("diff",zAjax)){ |
| 1772 | fileedit_ajax_diff(); |
| 1773 | }else if(0==strcmp("commit",zAjax)){ |
| 1774 | fileedit_ajax_commit(); |
| 1775 | }else{ |
| 1776 | fileedit_ajax_error(500, "Unhandled ajax route name."); |
| 1777 | } |
| 1778 | return; |
| 1779 | } |
| 1780 | login_check_credentials(); |
| 1781 | if( !g.perm.Write ){ |
| 1782 |
+8
-12
| --- src/fossil.page.fileedit.js | ||
| +++ src/fossil.page.fileedit.js | ||
| @@ -300,12 +300,12 @@ | ||
| 300 | 300 | this.e.selectCi, |
| 301 | 301 | this.e.selectFiles |
| 302 | 302 | ),"Loading leaves..."); |
| 303 | 303 | D.disable(this.e.btnLoadFile, this.e.selectFiles, this.e.selectCi); |
| 304 | 304 | const self = this; |
| 305 | - F.fetch('fileedit',{ | |
| 306 | - urlParams:'ajax=filelist&leaves', | |
| 305 | + F.fetch('fileedit/filelist',{ | |
| 306 | + urlParams:'leaves', | |
| 307 | 307 | responseType: 'json', |
| 308 | 308 | onload: function(list){ |
| 309 | 309 | D.append(D.clearElement(self.e.ciListLabel), |
| 310 | 310 | "Open leaves (newest first):"); |
| 311 | 311 | self.cache.checkins = list; |
| @@ -364,12 +364,12 @@ | ||
| 364 | 364 | } |
| 365 | 365 | D.disable(selFiles,this.e.btnLoadFile); |
| 366 | 366 | D.clearElement(selFiles); |
| 367 | 367 | D.append(D.clearElement(this.e.fileListLabel), |
| 368 | 368 | "Loading files for "+F.hashDigits(ciUuid)+"..."); |
| 369 | - F.fetch('fileedit',{ | |
| 370 | - urlParams:{ajax:'filelist', checkin: ciUuid}, | |
| 369 | + F.fetch('fileedit/filelist',{ | |
| 370 | + urlParams:{checkin: ciUuid}, | |
| 371 | 371 | responseType: 'json', |
| 372 | 372 | onload |
| 373 | 373 | }); |
| 374 | 374 | return this; |
| 375 | 375 | }, |
| @@ -998,13 +998,12 @@ | ||
| 998 | 998 | stashFinfo.filename); |
| 999 | 999 | return this; |
| 1000 | 1000 | } |
| 1001 | 1001 | F.message( |
| 1002 | 1002 | "Loading content..." |
| 1003 | - ).fetch('fileedit',{ | |
| 1003 | + ).fetch('fileedit/content',{ | |
| 1004 | 1004 | urlParams: { |
| 1005 | - ajax: 'content', | |
| 1006 | 1005 | filename:file, |
| 1007 | 1006 | checkin:rev |
| 1008 | 1007 | }, |
| 1009 | 1008 | responseHeaders: [ |
| 1010 | 1009 | 'x-fileedit-file-perm', |
| @@ -1054,12 +1053,11 @@ | ||
| 1054 | 1053 | fd.append('ln',E('[name=preview_ln]').checked ? 1 : 0); |
| 1055 | 1054 | fd.append('iframe_height', E('[name=preview_html_ems]').value); |
| 1056 | 1055 | fd.append('content',content || ''); |
| 1057 | 1056 | F.message( |
| 1058 | 1057 | "Fetching preview..." |
| 1059 | - ).fetch('fileedit',{ | |
| 1060 | - urlParams: {ajax: 'preview'}, | |
| 1058 | + ).fetch('fileedit/preview',{ | |
| 1061 | 1059 | payload: fd, |
| 1062 | 1060 | responseHeaders: 'x-fileedit-render-mode', |
| 1063 | 1061 | onload: (r,header)=>{ |
| 1064 | 1062 | P.selectPreviewMode(P.previewModes[header]); |
| 1065 | 1063 | if('wiki'===header) P.baseHrefForFile(); |
| @@ -1097,12 +1095,11 @@ | ||
| 1097 | 1095 | fd.append('sbs', sbs ? 1 : 0); |
| 1098 | 1096 | fd.append('content',content); |
| 1099 | 1097 | if(this.e.selectDiffWS) fd.append('ws',this.e.selectDiffWS.value); |
| 1100 | 1098 | F.message( |
| 1101 | 1099 | "Fetching diff..." |
| 1102 | - ).fetch('fileedit',{ | |
| 1103 | - urlParams: {ajax: 'diff'}, | |
| 1100 | + ).fetch('fileedit/diff',{ | |
| 1104 | 1101 | payload: fd, |
| 1105 | 1102 | onload: function(c){ |
| 1106 | 1103 | target.innerHTML = [ |
| 1107 | 1104 | "<div>Diff <code>[", |
| 1108 | 1105 | self.finfo.checkin, |
| @@ -1193,12 +1190,11 @@ | ||
| 1193 | 1190 | console.error("Missing checkbox? name =",name); |
| 1194 | 1191 | } |
| 1195 | 1192 | }); |
| 1196 | 1193 | F.message( |
| 1197 | 1194 | "Checking in..." |
| 1198 | - ).fetch('fileedit',{ | |
| 1199 | - urlParams: {ajax: 'commit'}, | |
| 1195 | + ).fetch('fileedit/commit',{ | |
| 1200 | 1196 | payload: fd, |
| 1201 | 1197 | responseType: 'json', |
| 1202 | 1198 | onload: f.onload |
| 1203 | 1199 | }); |
| 1204 | 1200 | return this; |
| 1205 | 1201 |
| --- src/fossil.page.fileedit.js | |
| +++ src/fossil.page.fileedit.js | |
| @@ -300,12 +300,12 @@ | |
| 300 | this.e.selectCi, |
| 301 | this.e.selectFiles |
| 302 | ),"Loading leaves..."); |
| 303 | D.disable(this.e.btnLoadFile, this.e.selectFiles, this.e.selectCi); |
| 304 | const self = this; |
| 305 | F.fetch('fileedit',{ |
| 306 | urlParams:'ajax=filelist&leaves', |
| 307 | responseType: 'json', |
| 308 | onload: function(list){ |
| 309 | D.append(D.clearElement(self.e.ciListLabel), |
| 310 | "Open leaves (newest first):"); |
| 311 | self.cache.checkins = list; |
| @@ -364,12 +364,12 @@ | |
| 364 | } |
| 365 | D.disable(selFiles,this.e.btnLoadFile); |
| 366 | D.clearElement(selFiles); |
| 367 | D.append(D.clearElement(this.e.fileListLabel), |
| 368 | "Loading files for "+F.hashDigits(ciUuid)+"..."); |
| 369 | F.fetch('fileedit',{ |
| 370 | urlParams:{ajax:'filelist', checkin: ciUuid}, |
| 371 | responseType: 'json', |
| 372 | onload |
| 373 | }); |
| 374 | return this; |
| 375 | }, |
| @@ -998,13 +998,12 @@ | |
| 998 | stashFinfo.filename); |
| 999 | return this; |
| 1000 | } |
| 1001 | F.message( |
| 1002 | "Loading content..." |
| 1003 | ).fetch('fileedit',{ |
| 1004 | urlParams: { |
| 1005 | ajax: 'content', |
| 1006 | filename:file, |
| 1007 | checkin:rev |
| 1008 | }, |
| 1009 | responseHeaders: [ |
| 1010 | 'x-fileedit-file-perm', |
| @@ -1054,12 +1053,11 @@ | |
| 1054 | fd.append('ln',E('[name=preview_ln]').checked ? 1 : 0); |
| 1055 | fd.append('iframe_height', E('[name=preview_html_ems]').value); |
| 1056 | fd.append('content',content || ''); |
| 1057 | F.message( |
| 1058 | "Fetching preview..." |
| 1059 | ).fetch('fileedit',{ |
| 1060 | urlParams: {ajax: 'preview'}, |
| 1061 | payload: fd, |
| 1062 | responseHeaders: 'x-fileedit-render-mode', |
| 1063 | onload: (r,header)=>{ |
| 1064 | P.selectPreviewMode(P.previewModes[header]); |
| 1065 | if('wiki'===header) P.baseHrefForFile(); |
| @@ -1097,12 +1095,11 @@ | |
| 1097 | fd.append('sbs', sbs ? 1 : 0); |
| 1098 | fd.append('content',content); |
| 1099 | if(this.e.selectDiffWS) fd.append('ws',this.e.selectDiffWS.value); |
| 1100 | F.message( |
| 1101 | "Fetching diff..." |
| 1102 | ).fetch('fileedit',{ |
| 1103 | urlParams: {ajax: 'diff'}, |
| 1104 | payload: fd, |
| 1105 | onload: function(c){ |
| 1106 | target.innerHTML = [ |
| 1107 | "<div>Diff <code>[", |
| 1108 | self.finfo.checkin, |
| @@ -1193,12 +1190,11 @@ | |
| 1193 | console.error("Missing checkbox? name =",name); |
| 1194 | } |
| 1195 | }); |
| 1196 | F.message( |
| 1197 | "Checking in..." |
| 1198 | ).fetch('fileedit',{ |
| 1199 | urlParams: {ajax: 'commit'}, |
| 1200 | payload: fd, |
| 1201 | responseType: 'json', |
| 1202 | onload: f.onload |
| 1203 | }); |
| 1204 | return this; |
| 1205 |
| --- src/fossil.page.fileedit.js | |
| +++ src/fossil.page.fileedit.js | |
| @@ -300,12 +300,12 @@ | |
| 300 | this.e.selectCi, |
| 301 | this.e.selectFiles |
| 302 | ),"Loading leaves..."); |
| 303 | D.disable(this.e.btnLoadFile, this.e.selectFiles, this.e.selectCi); |
| 304 | const self = this; |
| 305 | F.fetch('fileedit/filelist',{ |
| 306 | urlParams:'leaves', |
| 307 | responseType: 'json', |
| 308 | onload: function(list){ |
| 309 | D.append(D.clearElement(self.e.ciListLabel), |
| 310 | "Open leaves (newest first):"); |
| 311 | self.cache.checkins = list; |
| @@ -364,12 +364,12 @@ | |
| 364 | } |
| 365 | D.disable(selFiles,this.e.btnLoadFile); |
| 366 | D.clearElement(selFiles); |
| 367 | D.append(D.clearElement(this.e.fileListLabel), |
| 368 | "Loading files for "+F.hashDigits(ciUuid)+"..."); |
| 369 | F.fetch('fileedit/filelist',{ |
| 370 | urlParams:{checkin: ciUuid}, |
| 371 | responseType: 'json', |
| 372 | onload |
| 373 | }); |
| 374 | return this; |
| 375 | }, |
| @@ -998,13 +998,12 @@ | |
| 998 | stashFinfo.filename); |
| 999 | return this; |
| 1000 | } |
| 1001 | F.message( |
| 1002 | "Loading content..." |
| 1003 | ).fetch('fileedit/content',{ |
| 1004 | urlParams: { |
| 1005 | filename:file, |
| 1006 | checkin:rev |
| 1007 | }, |
| 1008 | responseHeaders: [ |
| 1009 | 'x-fileedit-file-perm', |
| @@ -1054,12 +1053,11 @@ | |
| 1053 | fd.append('ln',E('[name=preview_ln]').checked ? 1 : 0); |
| 1054 | fd.append('iframe_height', E('[name=preview_html_ems]').value); |
| 1055 | fd.append('content',content || ''); |
| 1056 | F.message( |
| 1057 | "Fetching preview..." |
| 1058 | ).fetch('fileedit/preview',{ |
| 1059 | payload: fd, |
| 1060 | responseHeaders: 'x-fileedit-render-mode', |
| 1061 | onload: (r,header)=>{ |
| 1062 | P.selectPreviewMode(P.previewModes[header]); |
| 1063 | if('wiki'===header) P.baseHrefForFile(); |
| @@ -1097,12 +1095,11 @@ | |
| 1095 | fd.append('sbs', sbs ? 1 : 0); |
| 1096 | fd.append('content',content); |
| 1097 | if(this.e.selectDiffWS) fd.append('ws',this.e.selectDiffWS.value); |
| 1098 | F.message( |
| 1099 | "Fetching diff..." |
| 1100 | ).fetch('fileedit/diff',{ |
| 1101 | payload: fd, |
| 1102 | onload: function(c){ |
| 1103 | target.innerHTML = [ |
| 1104 | "<div>Diff <code>[", |
| 1105 | self.finfo.checkin, |
| @@ -1193,12 +1190,11 @@ | |
| 1190 | console.error("Missing checkbox? name =",name); |
| 1191 | } |
| 1192 | }); |
| 1193 | F.message( |
| 1194 | "Checking in..." |
| 1195 | ).fetch('fileedit/commit',{ |
| 1196 | payload: fd, |
| 1197 | responseType: 'json', |
| 1198 | onload: f.onload |
| 1199 | }); |
| 1200 | return this; |
| 1201 |