On Thu, Feb 16, 2012 at 6:39 PM, Thomas Stover <c...@thomasstover.com> wrote:

> Interesting. Once I figured out I needed to rebuild with --enable-json it
> worked.
>

i would have mentioned that if i hadn't been typing on my phone at the time
;).



> I wonder if it could be crafted to just return the the timestamp. Or is
> the idea to render then wiki page in-browser with java script once pulled
> over from that call?
>

It can't be told just to return the timestamp because the JSON API
inputs/outputs _only_ JSON (even in CLI mode). However... with just a bit
of jquery (or similar) you could do something like add a script tag to your
page header with something along the lines of:

jQuery(function($){
    $.ajax('/json/wiki', {
       data:{ name: 'PageName' },
       success: function(data){
           ...data might be a JSON string or a JSON object,
              depending on other ajax() options...
     });
});

(i'm going from memory there - those ajax() options might have different
names/signatures.)

In the success() callback, fish out data.payload.timestamp value and render
the information somewhere in your page. To make this work optimally you
might have to enable full HTML in your wiki so that you can easily place
HTML elements which can be used for output placement. e.g add <span
id='wiki-page-timestamp'/> and fetch it with $('#wiki-page-timestamp') in
the AJAX callback.

The JSON API also supports JSONP responses. Just add the
jsonp=callback_name parameter to your request, e.g.:

stephan@tiny ~/cvs/fossil/whio $ f json wiki get whio_rc -jsonp MyCallback
| head -2
MyCallback({
"fossil":"4272d03e324ea05ea7dfad67e2d481e6db003864",

All that having been said, you've inadvertently pointed out the need for a
"verbose" wiki-list command which returns a list of all pages plus their
metadata details (e.g. size, uuid, timestamp), but without the content
(which can be arbitrarily large). i originally skimped on that feature
because the HTML interface doesn't show that info (and i was copy/pasting
most of the queries from the HTML code).

Doh, i almost forgot a recently-added feature... try:

http://.../json/wiki/get/PAGENAME?format=none
Or:
fossil wiki get PAGENAME -format none

that will return a given page's metadata without its content:

{
"fossil":"4272d03e324ea05ea7dfad67e2d481e6db003864",
"timestamp":1329415928,
"command":"wiki/get",
"procTimeMs":12,
"payload":{
"name":"whio_vlbm",
"uuid":"4053d1e97499c9c9454f16d996b06ca88dca88e8",
"lastSavedBy":"stephan",
"timestamp":1306176658,
"contentLength":3991
}
}


-- 
----- stephan beal
http://wanderinghorse.net/home/stephan/
http://gplus.to/sgbeal
_______________________________________________
fossil-users mailing list
fossil-users@lists.fossil-scm.org
http://lists.fossil-scm.org:8080/cgi-bin/mailman/listinfo/fossil-users

Reply via email to