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.

stephan 2020-05-17 04:08 fileedit-ajaxify
Commit 2c4e7c3785d1bfcda429161743721f6a693031569ab4d49a7616e869680569b8
+10 -4
--- src/fileedit.c
+++ src/fileedit.c
@@ -1728,15 +1728,21 @@
17281728
** checkin=VERSION Checkin version, using any unambiguous
17291729
** supported symbolic version name.
17301730
**
17311731
** Internal-use parameters:
17321732
**
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.
17341740
**
17351741
** Which additional parameters are used by each distinct ajax value is
17361742
** 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
17381744
** documented for fileedit_ajax_error().
17391745
*/
17401746
void fileedit_page(void){
17411747
const char * zFilename = 0; /* filename. We'll accept 'name'
17421748
because that param is handled
@@ -1751,11 +1757,11 @@
17511757
end. This content will be
17521758
combined into a single JS
17531759
function call, thus each
17541760
entry must end with a
17551761
semicolon. */
1756
- const char *zAjax = P("ajax");
1762
+ const char *zAjax = P("name");
17571763
17581764
if(0!=zAjax){
17591765
if(0==strcmp("content",zAjax)){
17601766
fileedit_ajax_content();
17611767
}else if(0==strcmp("preview",zAjax)){
@@ -1765,11 +1771,11 @@
17651771
}else if(0==strcmp("diff",zAjax)){
17661772
fileedit_ajax_diff();
17671773
}else if(0==strcmp("commit",zAjax)){
17681774
fileedit_ajax_commit();
17691775
}else{
1770
- fileedit_ajax_error(500, "Unhandled 'ajax' value.");
1776
+ fileedit_ajax_error(500, "Unhandled ajax route name.");
17711777
}
17721778
return;
17731779
}
17741780
login_check_credentials();
17751781
if( !g.perm.Write ){
17761782
--- 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
--- src/fossil.page.fileedit.js
+++ src/fossil.page.fileedit.js
@@ -300,12 +300,12 @@
300300
this.e.selectCi,
301301
this.e.selectFiles
302302
),"Loading leaves...");
303303
D.disable(this.e.btnLoadFile, this.e.selectFiles, this.e.selectCi);
304304
const self = this;
305
- F.fetch('fileedit',{
306
- urlParams:'ajax=filelist&leaves',
305
+ F.fetch('fileedit/filelist',{
306
+ urlParams:'leaves',
307307
responseType: 'json',
308308
onload: function(list){
309309
D.append(D.clearElement(self.e.ciListLabel),
310310
"Open leaves (newest first):");
311311
self.cache.checkins = list;
@@ -364,12 +364,12 @@
364364
}
365365
D.disable(selFiles,this.e.btnLoadFile);
366366
D.clearElement(selFiles);
367367
D.append(D.clearElement(this.e.fileListLabel),
368368
"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},
371371
responseType: 'json',
372372
onload
373373
});
374374
return this;
375375
},
@@ -998,13 +998,12 @@
998998
stashFinfo.filename);
999999
return this;
10001000
}
10011001
F.message(
10021002
"Loading content..."
1003
- ).fetch('fileedit',{
1003
+ ).fetch('fileedit/content',{
10041004
urlParams: {
1005
- ajax: 'content',
10061005
filename:file,
10071006
checkin:rev
10081007
},
10091008
responseHeaders: [
10101009
'x-fileedit-file-perm',
@@ -1054,12 +1053,11 @@
10541053
fd.append('ln',E('[name=preview_ln]').checked ? 1 : 0);
10551054
fd.append('iframe_height', E('[name=preview_html_ems]').value);
10561055
fd.append('content',content || '');
10571056
F.message(
10581057
"Fetching preview..."
1059
- ).fetch('fileedit',{
1060
- urlParams: {ajax: 'preview'},
1058
+ ).fetch('fileedit/preview',{
10611059
payload: fd,
10621060
responseHeaders: 'x-fileedit-render-mode',
10631061
onload: (r,header)=>{
10641062
P.selectPreviewMode(P.previewModes[header]);
10651063
if('wiki'===header) P.baseHrefForFile();
@@ -1097,12 +1095,11 @@
10971095
fd.append('sbs', sbs ? 1 : 0);
10981096
fd.append('content',content);
10991097
if(this.e.selectDiffWS) fd.append('ws',this.e.selectDiffWS.value);
11001098
F.message(
11011099
"Fetching diff..."
1102
- ).fetch('fileedit',{
1103
- urlParams: {ajax: 'diff'},
1100
+ ).fetch('fileedit/diff',{
11041101
payload: fd,
11051102
onload: function(c){
11061103
target.innerHTML = [
11071104
"<div>Diff <code>[",
11081105
self.finfo.checkin,
@@ -1193,12 +1190,11 @@
11931190
console.error("Missing checkbox? name =",name);
11941191
}
11951192
});
11961193
F.message(
11971194
"Checking in..."
1198
- ).fetch('fileedit',{
1199
- urlParams: {ajax: 'commit'},
1195
+ ).fetch('fileedit/commit',{
12001196
payload: fd,
12011197
responseType: 'json',
12021198
onload: f.onload
12031199
});
12041200
return this;
12051201
--- 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

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button