Fossil SCM

A few internal cosmetic cleanups, added json_get_wiki_page_by_rid().

stephan 2011-10-05 06:42 UTC json-multitag-test
Commit afb3c89fe6beee621a18d212eee9be83f7cbf73d
--- ajax/index.html
+++ ajax/index.html
@@ -183,25 +183,32 @@
183183
TheApp.cgi.onLogout = function(){
184184
TheApp.jqe.taResponse.val( "Logged out!" );
185185
TheApp.jqe.currentAuthToken.text("Not logged in");
186186
};
187187
TheApp.cgi.whoami();
188
+ jQuery('#headerArea').click(function(){
189
+ jQuery(this).slideUp('fast',function(){
190
+ jQuery(this).remove();
191
+ });
192
+ });
188193
});
189194
190195
</script>
191196
192197
</head>
193198
194199
<body>
195200
<span id='ajaxNotification'></span>
201
+<div id='headerArea'>
196202
<h1>You know, for sending raw JSON requests to Fossil...</h1>
197203
198204
If you're actually using this page, then you know what you're doing and don't
199205
need help text, hoverhelp, and a snazzy interface.
200206
201207
<br><br>
202208
See also: <a href='wiki-editor.html'>prototype wiki editor</a>.
209
+</div><!-- #headerArea -->
203210
204211
<h2>Request...</h2>
205212
206213
Path: <input type='text' size='40' id='textPath' value='/json/HAI'/>
207214
<input type='button' value='Send...' id='btnSend' onclick='TheApp.sendRequest()' /><br/>
@@ -221,11 +228,13 @@
221228
<input type='button' value='timeline/ticket' onclick='TheApp.cgi.sendCommand("/json/timeline/ticket")' />
222229
<input type='button' value='wiki/list' onclick='TheApp.cgi.sendCommand("/json/wiki/list")' />
223230
<input type='button' value='wiki/get Fossil' onclick='TheApp.cgi.sendCommand("/json/wiki/get",{page:"Fossil"})' />
224231
<input type='button' value='user/list' onclick='TheApp.cgi.sendCommand("/json/user/list")' />
225232
<input type='button' value='user/get' onclick='TheApp.cgi.sendCommand("/json/user/get?name=anonymous")' />
233
+<!-- not yet ready...
226234
<input type='button' value='artifact/XYZ' onclick='TheApp.cgi.sendCommand("/json/artifact?uuid=json")' />
235
+-->
227236
228237
<!--
229238
<input type='button' value='get whiki' onclick='TheApp.cgi.getPages("whiki")' />
230239
<input type='button' value='get more' onclick='TheApp.cgi.getPages("HelloWorld/WhikiNews")' />
231240
<input type='button' value='get client data' onclick='TheApp.cgi.getPageClientData("HelloWorld/whiki/WhikiCommands")' />
232241
--- ajax/index.html
+++ ajax/index.html
@@ -183,25 +183,32 @@
183 TheApp.cgi.onLogout = function(){
184 TheApp.jqe.taResponse.val( "Logged out!" );
185 TheApp.jqe.currentAuthToken.text("Not logged in");
186 };
187 TheApp.cgi.whoami();
 
 
 
 
 
188 });
189
190 </script>
191
192 </head>
193
194 <body>
195 <span id='ajaxNotification'></span>
 
196 <h1>You know, for sending raw JSON requests to Fossil...</h1>
197
198 If you're actually using this page, then you know what you're doing and don't
199 need help text, hoverhelp, and a snazzy interface.
200
201 <br><br>
202 See also: <a href='wiki-editor.html'>prototype wiki editor</a>.
 
203
204 <h2>Request...</h2>
205
206 Path: <input type='text' size='40' id='textPath' value='/json/HAI'/>
207 <input type='button' value='Send...' id='btnSend' onclick='TheApp.sendRequest()' /><br/>
@@ -221,11 +228,13 @@
221 <input type='button' value='timeline/ticket' onclick='TheApp.cgi.sendCommand("/json/timeline/ticket")' />
222 <input type='button' value='wiki/list' onclick='TheApp.cgi.sendCommand("/json/wiki/list")' />
223 <input type='button' value='wiki/get Fossil' onclick='TheApp.cgi.sendCommand("/json/wiki/get",{page:"Fossil"})' />
224 <input type='button' value='user/list' onclick='TheApp.cgi.sendCommand("/json/user/list")' />
225 <input type='button' value='user/get' onclick='TheApp.cgi.sendCommand("/json/user/get?name=anonymous")' />
 
226 <input type='button' value='artifact/XYZ' onclick='TheApp.cgi.sendCommand("/json/artifact?uuid=json")' />
 
227
228 <!--
229 <input type='button' value='get whiki' onclick='TheApp.cgi.getPages("whiki")' />
230 <input type='button' value='get more' onclick='TheApp.cgi.getPages("HelloWorld/WhikiNews")' />
231 <input type='button' value='get client data' onclick='TheApp.cgi.getPageClientData("HelloWorld/whiki/WhikiCommands")' />
232
--- ajax/index.html
+++ ajax/index.html
@@ -183,25 +183,32 @@
183 TheApp.cgi.onLogout = function(){
184 TheApp.jqe.taResponse.val( "Logged out!" );
185 TheApp.jqe.currentAuthToken.text("Not logged in");
186 };
187 TheApp.cgi.whoami();
188 jQuery('#headerArea').click(function(){
189 jQuery(this).slideUp('fast',function(){
190 jQuery(this).remove();
191 });
192 });
193 });
194
195 </script>
196
197 </head>
198
199 <body>
200 <span id='ajaxNotification'></span>
201 <div id='headerArea'>
202 <h1>You know, for sending raw JSON requests to Fossil...</h1>
203
204 If you're actually using this page, then you know what you're doing and don't
205 need help text, hoverhelp, and a snazzy interface.
206
207 <br><br>
208 See also: <a href='wiki-editor.html'>prototype wiki editor</a>.
209 </div><!-- #headerArea -->
210
211 <h2>Request...</h2>
212
213 Path: <input type='text' size='40' id='textPath' value='/json/HAI'/>
214 <input type='button' value='Send...' id='btnSend' onclick='TheApp.sendRequest()' /><br/>
@@ -221,11 +228,13 @@
228 <input type='button' value='timeline/ticket' onclick='TheApp.cgi.sendCommand("/json/timeline/ticket")' />
229 <input type='button' value='wiki/list' onclick='TheApp.cgi.sendCommand("/json/wiki/list")' />
230 <input type='button' value='wiki/get Fossil' onclick='TheApp.cgi.sendCommand("/json/wiki/get",{page:"Fossil"})' />
231 <input type='button' value='user/list' onclick='TheApp.cgi.sendCommand("/json/user/list")' />
232 <input type='button' value='user/get' onclick='TheApp.cgi.sendCommand("/json/user/get?name=anonymous")' />
233 <!-- not yet ready...
234 <input type='button' value='artifact/XYZ' onclick='TheApp.cgi.sendCommand("/json/artifact?uuid=json")' />
235 -->
236
237 <!--
238 <input type='button' value='get whiki' onclick='TheApp.cgi.getPages("whiki")' />
239 <input type='button' value='get more' onclick='TheApp.cgi.getPages("HelloWorld/WhikiNews")' />
240 <input type='button' value='get client data' onclick='TheApp.cgi.getPageClientData("HelloWorld/whiki/WhikiCommands")' />
241
--- ajax/js/whajaj.js
+++ ajax/js/whajaj.js
@@ -207,12 +207,10 @@
207207
WhAjaj.Connector = function(opt)
208208
{
209209
if(WhAjaj.isObject(opt)) this.options = opt;
210210
//TODO?: this.$cache = {};
211211
};
212
-WhAjaj.Connector.prototype.callbacks = {};
213
-WhAjaj.Connector.prototype.options = {};
214212
215213
/**
216214
The core options used by WhAjaj.Connector instances for performing
217215
network operations. These options can (and some _should_)
218216
be changed by a client application. They can also be changed
@@ -262,11 +260,11 @@
262260
pretty prevelant in the source tree, so i can't globally
263261
swap it out.
264262
*/
265263
ajax: {
266264
/**
267
- URL of the whiki back-end CGI binary.
265
+ URL of the back-end server/CGI.
268266
*/
269267
url: '/some/path',
270268
271269
/**
272270
Connection method. Some connection-related functions might
@@ -406,10 +404,39 @@
406404
instead of a response object parsed from JSON.
407405
*/
408406
jsonp:undefined
409407
}
410408
};
409
+
410
+
411
+/**
412
+ WhAjaj.Connector.prototype.callbacks defines callbacks analog
413
+ to the onXXX callbacks defined in WhAjaj.Connector.options.ajax,
414
+ with two notable differences:
415
+
416
+ 1) these callbacks, if set, are called in addition to any
417
+ request-specific callback. The intention is to allow a framework to set
418
+ "framework-level" callbacks which should be called independently of the
419
+ request-specific callbacks (without interfering with them, e.g.
420
+ requiring special re-forwarding features).
421
+
422
+ 2) The 'this' object in these callbacks is the Connector instance
423
+ associated with the callback, whereas the "other" onXXX form has its
424
+ "ajax options" object as its this.
425
+
426
+ When this API says that an onXXX callback will be called for a request,
427
+ both the request's onXXX (if set) and this one (if set) will be called.
428
+*/
429
+WhAjaj.Connector.prototype.callbacks = {};
430
+/**
431
+ Instance-specific values for AJAJ-level properties (as opposed to
432
+ application-level request properties). Options set here "override" those
433
+ specified in WhAjaj.Connector.options.ajax and are "overridden" by
434
+ options passed to sendRequest().
435
+*/
436
+WhAjaj.Connector.prototype.options = {};
437
+
411438
412439
/**
413440
Tries to find the given key in any of the following, returning
414441
the first match found: opt, this.options, WhAjaj.Connector.options.ajax.
415442
@@ -421,10 +448,11 @@
421448
else v = this.options[key];
422449
if( undefined !== v ) return v;
423450
else v = WhAjaj.Connector.options.ajax[key];
424451
return v;
425452
};
453
+
426454
/**
427455
Returns a unique string on each call containing a generic
428456
reandom request identifier string. This is not used by the core
429457
API but can be used by client code to generate unique IDs for
430458
each request (if needed).
@@ -532,10 +560,13 @@
532560
The opt object should be the normalized AJAX options used
533561
for the connection.
534562
535563
The resp argument may be either a plain Object or a string
536564
(in which case it is assumed to be JSON).
565
+
566
+ The 'this' object for this call MUST be a WhAjaj.Connector
567
+ instance in order for callback processing to work properly.
537568
538569
This function takes care of the following:
539570
540571
- Calling opt.afterSend()
541572
@@ -621,10 +652,13 @@
621652
properties are followed.
622653
623654
The request argument must be the original request passed to
624655
the sendImpl() function. It may legally be null for GET
625656
requests.
657
+
658
+ The 'this' object for this call MUST be a WhAjaj.Connector
659
+ instance in order for callback processing to work properly.
626660
627661
The opt object should be the normalized AJAX options used
628662
for the connection. By convention, the caller of this
629663
function "should" set opt.errorMessage to contain a
630664
human-readable description of the error.
631665
--- ajax/js/whajaj.js
+++ ajax/js/whajaj.js
@@ -207,12 +207,10 @@
207 WhAjaj.Connector = function(opt)
208 {
209 if(WhAjaj.isObject(opt)) this.options = opt;
210 //TODO?: this.$cache = {};
211 };
212 WhAjaj.Connector.prototype.callbacks = {};
213 WhAjaj.Connector.prototype.options = {};
214
215 /**
216 The core options used by WhAjaj.Connector instances for performing
217 network operations. These options can (and some _should_)
218 be changed by a client application. They can also be changed
@@ -262,11 +260,11 @@
262 pretty prevelant in the source tree, so i can't globally
263 swap it out.
264 */
265 ajax: {
266 /**
267 URL of the whiki back-end CGI binary.
268 */
269 url: '/some/path',
270
271 /**
272 Connection method. Some connection-related functions might
@@ -406,10 +404,39 @@
406 instead of a response object parsed from JSON.
407 */
408 jsonp:undefined
409 }
410 };
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
411
412 /**
413 Tries to find the given key in any of the following, returning
414 the first match found: opt, this.options, WhAjaj.Connector.options.ajax.
415
@@ -421,10 +448,11 @@
421 else v = this.options[key];
422 if( undefined !== v ) return v;
423 else v = WhAjaj.Connector.options.ajax[key];
424 return v;
425 };
 
426 /**
427 Returns a unique string on each call containing a generic
428 reandom request identifier string. This is not used by the core
429 API but can be used by client code to generate unique IDs for
430 each request (if needed).
@@ -532,10 +560,13 @@
532 The opt object should be the normalized AJAX options used
533 for the connection.
534
535 The resp argument may be either a plain Object or a string
536 (in which case it is assumed to be JSON).
 
 
 
537
538 This function takes care of the following:
539
540 - Calling opt.afterSend()
541
@@ -621,10 +652,13 @@
621 properties are followed.
622
623 The request argument must be the original request passed to
624 the sendImpl() function. It may legally be null for GET
625 requests.
 
 
 
626
627 The opt object should be the normalized AJAX options used
628 for the connection. By convention, the caller of this
629 function "should" set opt.errorMessage to contain a
630 human-readable description of the error.
631
--- ajax/js/whajaj.js
+++ ajax/js/whajaj.js
@@ -207,12 +207,10 @@
207 WhAjaj.Connector = function(opt)
208 {
209 if(WhAjaj.isObject(opt)) this.options = opt;
210 //TODO?: this.$cache = {};
211 };
 
 
212
213 /**
214 The core options used by WhAjaj.Connector instances for performing
215 network operations. These options can (and some _should_)
216 be changed by a client application. They can also be changed
@@ -262,11 +260,11 @@
260 pretty prevelant in the source tree, so i can't globally
261 swap it out.
262 */
263 ajax: {
264 /**
265 URL of the back-end server/CGI.
266 */
267 url: '/some/path',
268
269 /**
270 Connection method. Some connection-related functions might
@@ -406,10 +404,39 @@
404 instead of a response object parsed from JSON.
405 */
406 jsonp:undefined
407 }
408 };
409
410
411 /**
412 WhAjaj.Connector.prototype.callbacks defines callbacks analog
413 to the onXXX callbacks defined in WhAjaj.Connector.options.ajax,
414 with two notable differences:
415
416 1) these callbacks, if set, are called in addition to any
417 request-specific callback. The intention is to allow a framework to set
418 "framework-level" callbacks which should be called independently of the
419 request-specific callbacks (without interfering with them, e.g.
420 requiring special re-forwarding features).
421
422 2) The 'this' object in these callbacks is the Connector instance
423 associated with the callback, whereas the "other" onXXX form has its
424 "ajax options" object as its this.
425
426 When this API says that an onXXX callback will be called for a request,
427 both the request's onXXX (if set) and this one (if set) will be called.
428 */
429 WhAjaj.Connector.prototype.callbacks = {};
430 /**
431 Instance-specific values for AJAJ-level properties (as opposed to
432 application-level request properties). Options set here "override" those
433 specified in WhAjaj.Connector.options.ajax and are "overridden" by
434 options passed to sendRequest().
435 */
436 WhAjaj.Connector.prototype.options = {};
437
438
439 /**
440 Tries to find the given key in any of the following, returning
441 the first match found: opt, this.options, WhAjaj.Connector.options.ajax.
442
@@ -421,10 +448,11 @@
448 else v = this.options[key];
449 if( undefined !== v ) return v;
450 else v = WhAjaj.Connector.options.ajax[key];
451 return v;
452 };
453
454 /**
455 Returns a unique string on each call containing a generic
456 reandom request identifier string. This is not used by the core
457 API but can be used by client code to generate unique IDs for
458 each request (if needed).
@@ -532,10 +560,13 @@
560 The opt object should be the normalized AJAX options used
561 for the connection.
562
563 The resp argument may be either a plain Object or a string
564 (in which case it is assumed to be JSON).
565
566 The 'this' object for this call MUST be a WhAjaj.Connector
567 instance in order for callback processing to work properly.
568
569 This function takes care of the following:
570
571 - Calling opt.afterSend()
572
@@ -621,10 +652,13 @@
652 properties are followed.
653
654 The request argument must be the original request passed to
655 the sendImpl() function. It may legally be null for GET
656 requests.
657
658 The 'this' object for this call MUST be a WhAjaj.Connector
659 instance in order for callback processing to work properly.
660
661 The opt object should be the normalized AJAX options used
662 for the connection. By convention, the caller of this
663 function "should" set opt.errorMessage to contain a
664 human-readable description of the error.
665
--- ajax/wiki-editor.html
+++ ajax/wiki-editor.html
@@ -139,26 +139,26 @@
139139
end:function(){
140140
this._tend = (new Date()).getTime();
141141
return this.duration = this._tend - this._tstart;
142142
}
143143
};
144
- var opt = TheApp.cgi.ajaj.options;
145
- opt.beforeSend = TheApp.beforeSend = function(req,opt) {
144
+ var ajcb = TheApp.cgi.ajaj.callbacks;
145
+ ajcb.beforeSend = TheApp.beforeSend = function(req,opt) {
146146
TheApp.timer.start();
147147
var val =
148148
req ?
149149
(('string'===typeof req) ? req : WhAjaj.stringify(req))
150150
: '';
151151
TheApp.jqe.taResponse.val('');
152152
TheApp.startAjaxNotif();
153153
};
154
- opt.afterSend = TheApp.afterSend = function(req,opt) {
154
+ ajcb.afterSend = TheApp.afterSend = function(req,opt) {
155155
TheApp.timer.end();
156156
TheApp.endAjaxNotif();
157157
TheApp.jqe.timer.text( "(Round-trip time: "+TheApp.timer.duration+'ms)' );
158158
};
159
- opt.onResponse = TheApp.onResponse = function(resp,req) {
159
+ ajcb.onResponse = TheApp.onResponse = function(resp,req) {
160160
var val;
161161
try {
162162
val = WhAjaj.stringify(resp);
163163
}
164164
catch(e) {
@@ -165,17 +165,13 @@
165165
val = WhAjaj.stringify(e)
166166
}
167167
if(resp.resultCode){
168168
alert("Response contains error info:\n"+val);
169169
}
170
- //alert("onResponse this:"+WhAjaj.stringify(this));
171
- //alert("val="+val);
172
- // FIXME: this.url is hosed for login because of how i overload onResponse()
173
- if( this.url ) TheApp.jqe.textPath.val(this.url.replace(WhAjaj.Connector.options.ajax.url,''));
174170
TheApp.jqe.taResponse.val( val );
175171
};
176
- opt.onError = function(req,opt) {
172
+ ajcb.onError = function(req,opt) {
177173
TheApp.jqe.taResponse.val( "ERROR SENDING REQUEST:\n"+WhAjaj.stringify(opt) );
178174
};
179175
180176
TheApp.jqe.taPageContent.blur(function(){
181177
var p = TheApp.currentPage;
@@ -182,12 +178,12 @@
182178
if(! p ) return;
183179
p.content = TheApp.jqe.taPageContent.val();
184180
});
185181
186182
TheApp.cgi.onLogin = function(){
187
- TheApp.jqe.taResponse.val( "Logged in. Auth token =\n"+this.authToken );
188
- TheApp.jqe.currentAuthToken.text("Auth token: "+(this.authToken || "not logged in"));
183
+ TheApp.jqe.taResponse.val( "Logged in: "+WhAjaj.stringify(this.auth));
184
+ TheApp.jqe.currentAuthToken.text("Logged in: "+WhAjaj.stringify(this.auth));
189185
};
190186
TheApp.cgi.onLogout = function(){
191187
TheApp.jqe.taResponse.val( "Logged out!" );
192188
TheApp.jqe.currentAuthToken.text("");
193189
};
@@ -308,10 +304,12 @@
308304
}
309305
});
310306
*/
311307
};
312308
309
+ TheApp.cgi.whoami();
310
+
313311
});
314312
315313
</script>
316314
317315
</head>
@@ -336,14 +334,12 @@
336334
<span id='currentAuthToken' style='font-family:monospaced'></span>
337335
338336
<hr/>
339337
<strong>Quick-posts:</strong><br/>
340338
<input type='button' value='HAI' onclick='TheApp.cgi.HAI()' />
341
-<input type='button' value='version' onclick='TheApp.cgi.sendCommand("/json/version")' />
342339
<input type='button' value='stat' onclick='TheApp.cgi.sendCommand("/json/stat")' />
343340
<input type='button' value='whoami' onclick='TheApp.cgi.sendCommand("/json/whoami")' />
344
-<input type='button' value='cap' onclick='TheApp.cgi.sendCommand("/json/cap")' />
345341
<input type='button' value='wiki/list' onclick='TheApp.loadPageList()' />
346342
<!--
347343
<input type='button' value='timeline/ci' onclick='TheApp.cgi.sendCommand("/json/timeline/ci")' />
348344
-->
349345
350346
--- ajax/wiki-editor.html
+++ ajax/wiki-editor.html
@@ -139,26 +139,26 @@
139 end:function(){
140 this._tend = (new Date()).getTime();
141 return this.duration = this._tend - this._tstart;
142 }
143 };
144 var opt = TheApp.cgi.ajaj.options;
145 opt.beforeSend = TheApp.beforeSend = function(req,opt) {
146 TheApp.timer.start();
147 var val =
148 req ?
149 (('string'===typeof req) ? req : WhAjaj.stringify(req))
150 : '';
151 TheApp.jqe.taResponse.val('');
152 TheApp.startAjaxNotif();
153 };
154 opt.afterSend = TheApp.afterSend = function(req,opt) {
155 TheApp.timer.end();
156 TheApp.endAjaxNotif();
157 TheApp.jqe.timer.text( "(Round-trip time: "+TheApp.timer.duration+'ms)' );
158 };
159 opt.onResponse = TheApp.onResponse = function(resp,req) {
160 var val;
161 try {
162 val = WhAjaj.stringify(resp);
163 }
164 catch(e) {
@@ -165,17 +165,13 @@
165 val = WhAjaj.stringify(e)
166 }
167 if(resp.resultCode){
168 alert("Response contains error info:\n"+val);
169 }
170 //alert("onResponse this:"+WhAjaj.stringify(this));
171 //alert("val="+val);
172 // FIXME: this.url is hosed for login because of how i overload onResponse()
173 if( this.url ) TheApp.jqe.textPath.val(this.url.replace(WhAjaj.Connector.options.ajax.url,''));
174 TheApp.jqe.taResponse.val( val );
175 };
176 opt.onError = function(req,opt) {
177 TheApp.jqe.taResponse.val( "ERROR SENDING REQUEST:\n"+WhAjaj.stringify(opt) );
178 };
179
180 TheApp.jqe.taPageContent.blur(function(){
181 var p = TheApp.currentPage;
@@ -182,12 +178,12 @@
182 if(! p ) return;
183 p.content = TheApp.jqe.taPageContent.val();
184 });
185
186 TheApp.cgi.onLogin = function(){
187 TheApp.jqe.taResponse.val( "Logged in. Auth token =\n"+this.authToken );
188 TheApp.jqe.currentAuthToken.text("Auth token: "+(this.authToken || "not logged in"));
189 };
190 TheApp.cgi.onLogout = function(){
191 TheApp.jqe.taResponse.val( "Logged out!" );
192 TheApp.jqe.currentAuthToken.text("");
193 };
@@ -308,10 +304,12 @@
308 }
309 });
310 */
311 };
312
 
 
313 });
314
315 </script>
316
317 </head>
@@ -336,14 +334,12 @@
336 <span id='currentAuthToken' style='font-family:monospaced'></span>
337
338 <hr/>
339 <strong>Quick-posts:</strong><br/>
340 <input type='button' value='HAI' onclick='TheApp.cgi.HAI()' />
341 <input type='button' value='version' onclick='TheApp.cgi.sendCommand("/json/version")' />
342 <input type='button' value='stat' onclick='TheApp.cgi.sendCommand("/json/stat")' />
343 <input type='button' value='whoami' onclick='TheApp.cgi.sendCommand("/json/whoami")' />
344 <input type='button' value='cap' onclick='TheApp.cgi.sendCommand("/json/cap")' />
345 <input type='button' value='wiki/list' onclick='TheApp.loadPageList()' />
346 <!--
347 <input type='button' value='timeline/ci' onclick='TheApp.cgi.sendCommand("/json/timeline/ci")' />
348 -->
349
350
--- ajax/wiki-editor.html
+++ ajax/wiki-editor.html
@@ -139,26 +139,26 @@
139 end:function(){
140 this._tend = (new Date()).getTime();
141 return this.duration = this._tend - this._tstart;
142 }
143 };
144 var ajcb = TheApp.cgi.ajaj.callbacks;
145 ajcb.beforeSend = TheApp.beforeSend = function(req,opt) {
146 TheApp.timer.start();
147 var val =
148 req ?
149 (('string'===typeof req) ? req : WhAjaj.stringify(req))
150 : '';
151 TheApp.jqe.taResponse.val('');
152 TheApp.startAjaxNotif();
153 };
154 ajcb.afterSend = TheApp.afterSend = function(req,opt) {
155 TheApp.timer.end();
156 TheApp.endAjaxNotif();
157 TheApp.jqe.timer.text( "(Round-trip time: "+TheApp.timer.duration+'ms)' );
158 };
159 ajcb.onResponse = TheApp.onResponse = function(resp,req) {
160 var val;
161 try {
162 val = WhAjaj.stringify(resp);
163 }
164 catch(e) {
@@ -165,17 +165,13 @@
165 val = WhAjaj.stringify(e)
166 }
167 if(resp.resultCode){
168 alert("Response contains error info:\n"+val);
169 }
 
 
 
 
170 TheApp.jqe.taResponse.val( val );
171 };
172 ajcb.onError = function(req,opt) {
173 TheApp.jqe.taResponse.val( "ERROR SENDING REQUEST:\n"+WhAjaj.stringify(opt) );
174 };
175
176 TheApp.jqe.taPageContent.blur(function(){
177 var p = TheApp.currentPage;
@@ -182,12 +178,12 @@
178 if(! p ) return;
179 p.content = TheApp.jqe.taPageContent.val();
180 });
181
182 TheApp.cgi.onLogin = function(){
183 TheApp.jqe.taResponse.val( "Logged in: "+WhAjaj.stringify(this.auth));
184 TheApp.jqe.currentAuthToken.text("Logged in: "+WhAjaj.stringify(this.auth));
185 };
186 TheApp.cgi.onLogout = function(){
187 TheApp.jqe.taResponse.val( "Logged out!" );
188 TheApp.jqe.currentAuthToken.text("");
189 };
@@ -308,10 +304,12 @@
304 }
305 });
306 */
307 };
308
309 TheApp.cgi.whoami();
310
311 });
312
313 </script>
314
315 </head>
@@ -336,14 +334,12 @@
334 <span id='currentAuthToken' style='font-family:monospaced'></span>
335
336 <hr/>
337 <strong>Quick-posts:</strong><br/>
338 <input type='button' value='HAI' onclick='TheApp.cgi.HAI()' />
 
339 <input type='button' value='stat' onclick='TheApp.cgi.sendCommand("/json/stat")' />
340 <input type='button' value='whoami' onclick='TheApp.cgi.sendCommand("/json/whoami")' />
 
341 <input type='button' value='wiki/list' onclick='TheApp.loadPageList()' />
342 <!--
343 <input type='button' value='timeline/ci' onclick='TheApp.cgi.sendCommand("/json/timeline/ci")' />
344 -->
345
346
+1 -1
--- src/json.c
+++ src/json.c
@@ -1337,11 +1337,11 @@
13371337
tmp = json_new_string(json_rc_cstr(resultCode));
13381338
SET(FossilJsonKeys.resultCode);
13391339
}
13401340
13411341
if( pMsg && *pMsg ){
1342
- tmp = cson_value_new_string(pMsg, strlen(pMsg));
1342
+ tmp = json_new_string(pMsg);
13431343
SET(FossilJsonKeys.resultText);
13441344
}
13451345
13461346
if(g.json.cmd.commandStr){
13471347
tmp = json_new_string(g.json.cmd.commandStr);
13481348
--- src/json.c
+++ src/json.c
@@ -1337,11 +1337,11 @@
1337 tmp = json_new_string(json_rc_cstr(resultCode));
1338 SET(FossilJsonKeys.resultCode);
1339 }
1340
1341 if( pMsg && *pMsg ){
1342 tmp = cson_value_new_string(pMsg, strlen(pMsg));
1343 SET(FossilJsonKeys.resultText);
1344 }
1345
1346 if(g.json.cmd.commandStr){
1347 tmp = json_new_string(g.json.cmd.commandStr);
1348
--- src/json.c
+++ src/json.c
@@ -1337,11 +1337,11 @@
1337 tmp = json_new_string(json_rc_cstr(resultCode));
1338 SET(FossilJsonKeys.resultCode);
1339 }
1340
1341 if( pMsg && *pMsg ){
1342 tmp = json_new_string(pMsg);
1343 SET(FossilJsonKeys.resultText);
1344 }
1345
1346 if(g.json.cmd.commandStr){
1347 tmp = json_new_string(g.json.cmd.commandStr);
1348
--- src/json_artifact.c
+++ src/json_artifact.c
@@ -153,10 +153,13 @@
153153
}
154154
db_finalize(&q);
155155
return v;
156156
}
157157
158
+/*
159
+** Very incomplete/incorrect impl of /json/artifact/TICKET_ID.
160
+*/
158161
cson_value * json_artifact_ticket( int rid ){
159162
cson_value * payV = NULL;
160163
cson_object * pay = NULL;
161164
Manifest *pTktChng = NULL;
162165
static cson_value * eventTypeLabel = NULL;
@@ -195,16 +198,12 @@
195198
return json_artifact_for_ci(rid, 1);
196199
}
197200
}
198201
199202
/*
200
-** Permissions callback func for ArtifactDispatchEntry.
203
+** Internal mapping of /json/artifact/FOO commands/callbacks.
201204
*/
202
-static char perms_can_read(){
203
- return g.perm.Read ? 1 : 0;
204
-}
205
-
206205
static ArtifactDispatchEntry ArtifactDispatchList[] = {
207206
{"checkin", json_artifact_ci},
208207
{"tag", NULL},
209208
{"ticket", json_artifact_ticket},
210209
{"wiki", NULL},
211210
--- src/json_artifact.c
+++ src/json_artifact.c
@@ -153,10 +153,13 @@
153 }
154 db_finalize(&q);
155 return v;
156 }
157
 
 
 
158 cson_value * json_artifact_ticket( int rid ){
159 cson_value * payV = NULL;
160 cson_object * pay = NULL;
161 Manifest *pTktChng = NULL;
162 static cson_value * eventTypeLabel = NULL;
@@ -195,16 +198,12 @@
195 return json_artifact_for_ci(rid, 1);
196 }
197 }
198
199 /*
200 ** Permissions callback func for ArtifactDispatchEntry.
201 */
202 static char perms_can_read(){
203 return g.perm.Read ? 1 : 0;
204 }
205
206 static ArtifactDispatchEntry ArtifactDispatchList[] = {
207 {"checkin", json_artifact_ci},
208 {"tag", NULL},
209 {"ticket", json_artifact_ticket},
210 {"wiki", NULL},
211
--- src/json_artifact.c
+++ src/json_artifact.c
@@ -153,10 +153,13 @@
153 }
154 db_finalize(&q);
155 return v;
156 }
157
158 /*
159 ** Very incomplete/incorrect impl of /json/artifact/TICKET_ID.
160 */
161 cson_value * json_artifact_ticket( int rid ){
162 cson_value * payV = NULL;
163 cson_object * pay = NULL;
164 Manifest *pTktChng = NULL;
165 static cson_value * eventTypeLabel = NULL;
@@ -195,16 +198,12 @@
198 return json_artifact_for_ci(rid, 1);
199 }
200 }
201
202 /*
203 ** Internal mapping of /json/artifact/FOO commands/callbacks.
204 */
 
 
 
 
205 static ArtifactDispatchEntry ArtifactDispatchList[] = {
206 {"checkin", json_artifact_ci},
207 {"tag", NULL},
208 {"ticket", json_artifact_ticket},
209 {"wiki", NULL},
210
+27 -2
--- src/json_wiki.c
+++ src/json_wiki.c
@@ -57,11 +57,11 @@
5757
** conventional wiki format, else it is not parsed.
5858
**
5959
** The returned value, if not NULL, is-a JSON Object owned by the
6060
** caller.
6161
*/
62
-cson_value * json_get_wiki_page(char const * zPageName, char doParse){
62
+cson_value * json_get_wiki_page_by_name(char const * zPageName, char doParse){
6363
int rid;
6464
Manifest *pWiki = 0;
6565
char const * zBody = NULL;
6666
char const * zFormat = NULL;
6767
char * zUuid = NULL;
@@ -117,10 +117,35 @@
117117
manifest_destroy(pWiki);
118118
return payV;
119119
}
120120
}
121121
122
+
123
+/*
124
+** UNTESTED!
125
+**
126
+** Searches for a wiki page with the given rid. If found it behaves
127
+** like json_get_wiki_page_by_name(pageName, doParse), else it returns
128
+** NULL.
129
+*/
130
+cson_value * json_get_wiki_page_by_rid(int rid, char doParse){
131
+ char * zPageName = NULL;
132
+ cson_value * rc = NULL;
133
+ zPageName = db_text(NULL,
134
+ "SELECT substr(t.tagname,6) AS name "
135
+ " FROM tag t, tagxref x, blob b "
136
+ " WHERE b.rid=%d "
137
+ " AND t.tagname GLOB 'wiki-*'"
138
+ " AND x.tagid=t.tagid AND b.rid=x.rid ",
139
+ rid);
140
+ if( zPageName ){
141
+ rc = json_get_wiki_page_by_name(zPageName, doParse);
142
+ free(zPageName);
143
+ }
144
+ return rc;
145
+}
146
+
122147
/*
123148
** Implementation of /json/wiki/get.
124149
**
125150
*/
126151
static cson_value * json_wiki_get(){
@@ -157,11 +182,11 @@
157182
zFormat = "raw";
158183
}
159184
if( 'r' != *zFormat ){
160185
zFormat = "html";
161186
}
162
- return json_get_wiki_page(zPageName, 'h'==*zFormat);
187
+ return json_get_wiki_page_by_name(zPageName, 'h'==*zFormat);
163188
}
164189
165190
/*
166191
** Internal impl of /wiki/save and /wiki/create. If createMode is 0
167192
** and the page already exists then a
168193
--- src/json_wiki.c
+++ src/json_wiki.c
@@ -57,11 +57,11 @@
57 ** conventional wiki format, else it is not parsed.
58 **
59 ** The returned value, if not NULL, is-a JSON Object owned by the
60 ** caller.
61 */
62 cson_value * json_get_wiki_page(char const * zPageName, char doParse){
63 int rid;
64 Manifest *pWiki = 0;
65 char const * zBody = NULL;
66 char const * zFormat = NULL;
67 char * zUuid = NULL;
@@ -117,10 +117,35 @@
117 manifest_destroy(pWiki);
118 return payV;
119 }
120 }
121
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
122 /*
123 ** Implementation of /json/wiki/get.
124 **
125 */
126 static cson_value * json_wiki_get(){
@@ -157,11 +182,11 @@
157 zFormat = "raw";
158 }
159 if( 'r' != *zFormat ){
160 zFormat = "html";
161 }
162 return json_get_wiki_page(zPageName, 'h'==*zFormat);
163 }
164
165 /*
166 ** Internal impl of /wiki/save and /wiki/create. If createMode is 0
167 ** and the page already exists then a
168
--- src/json_wiki.c
+++ src/json_wiki.c
@@ -57,11 +57,11 @@
57 ** conventional wiki format, else it is not parsed.
58 **
59 ** The returned value, if not NULL, is-a JSON Object owned by the
60 ** caller.
61 */
62 cson_value * json_get_wiki_page_by_name(char const * zPageName, char doParse){
63 int rid;
64 Manifest *pWiki = 0;
65 char const * zBody = NULL;
66 char const * zFormat = NULL;
67 char * zUuid = NULL;
@@ -117,10 +117,35 @@
117 manifest_destroy(pWiki);
118 return payV;
119 }
120 }
121
122
123 /*
124 ** UNTESTED!
125 **
126 ** Searches for a wiki page with the given rid. If found it behaves
127 ** like json_get_wiki_page_by_name(pageName, doParse), else it returns
128 ** NULL.
129 */
130 cson_value * json_get_wiki_page_by_rid(int rid, char doParse){
131 char * zPageName = NULL;
132 cson_value * rc = NULL;
133 zPageName = db_text(NULL,
134 "SELECT substr(t.tagname,6) AS name "
135 " FROM tag t, tagxref x, blob b "
136 " WHERE b.rid=%d "
137 " AND t.tagname GLOB 'wiki-*'"
138 " AND x.tagid=t.tagid AND b.rid=x.rid ",
139 rid);
140 if( zPageName ){
141 rc = json_get_wiki_page_by_name(zPageName, doParse);
142 free(zPageName);
143 }
144 return rc;
145 }
146
147 /*
148 ** Implementation of /json/wiki/get.
149 **
150 */
151 static cson_value * json_wiki_get(){
@@ -157,11 +182,11 @@
182 zFormat = "raw";
183 }
184 if( 'r' != *zFormat ){
185 zFormat = "html";
186 }
187 return json_get_wiki_page_by_name(zPageName, 'h'==*zFormat);
188 }
189
190 /*
191 ** Internal impl of /wiki/save and /wiki/create. If createMode is 0
192 ** and the page already exists then a
193

Keyboard Shortcuts

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