Changeset 10662
- Timestamp:
- 02/07/11 04:56:31 (2 years ago)
- Location:
- trunk/RestPlugin
- Files:
-
- 5 deleted
- 2 edited
-
data/Sandbox/TestRestPlugin.txt (modified) (1 diff)
-
data/System/RestPlugin.txt (modified) (7 diffs)
-
lib/Foswiki/UI/Query.pm.bak (deleted)
-
test/unit/RestPlugin/RestPluginCurlTests.pm.bak (deleted)
-
test/unit/RestPlugin/RestPluginSeleniumTests.pm.bak (deleted)
-
test/unit/RestPlugin/RestPluginSuite.pm.bak (deleted)
-
test/unit/RestPlugin/RestPluginTests.pm.bak (deleted)
Legend:
- Unmodified
- Added
- Removed
-
trunk/RestPlugin/data/Sandbox/TestRestPlugin.txt
r10585 r10662 48 48 $('#query_output').text('SUBMITTING'); 49 49 50 //this is equivalent to :50 //this is equivalent to (but with valid strikeone validation): 51 51 //curl -X PATCH -H "Content-Type:text/json" -d '{"_text": "curl is it"}' http://x61/f/bin/query/Sandbox/TestTopic0/topic.json 52 52 -
trunk/RestPlugin/data/System/RestPlugin.txt
r10583 r10662 33 33 5 more serialisations - including www-form.. 34 34 6 make =OPTIONS= response contextural 35 ---+++ Resource s35 ---+++ Resource types (/web,/topic,/attachment) 36 36 ---++++ Web 37 37 | *Verb* | *Implemented* | *URI* | *Use* | 38 | =GET= | yes | =http://x61/bin/query /[{Webname}/]webs[.json]= | get web resource information, currently a list of subwebs to the resource (if no Webname is specified, list all webs) |39 | =POST= | yes | =http://x61/bin/query /[{Webname}/]webs[.json]= | create a new web in the uri's container web - parameters in payload as for the manage=createWeb |38 | =GET= | yes | =http://x61/bin/query[/{Webname}]/webs[.json]= | get web resource information, currently a list of subwebs to the resource (if no Webname is specified, list all webs) | 39 | =POST= | yes | =http://x61/bin/query[/{Webname}]/webs[.json]= | create a new web in the uri's container web - parameters in payload as for the manage=createWeb | 40 40 | =PUT= | no | =http://x61/bin/query/{Webname}/webs[.json]= | update a web resource (=nop= until define some web specific info, like permissions, settings etc), or maybe for renaming a web?) | 41 41 | =PATCH= | no | =http://x61/bin/query/{Webname}/webs[.json]= | same as PUT? | … … 43 43 ---++++ Topic 44 44 | *Verb* | *Implemented* | *URI* | *Use* | 45 | =GET= | yes | =http://x61/bin/query/{Webname} /[{TopicName/}]topic[.json]= | get topic's meta (if no TopicName is specified, list of all topics in a web. (array of names only?)) |45 | =GET= | yes | =http://x61/bin/query/{Webname}[/{TopicName}]/topic[.json]= | get topic's meta (if no TopicName is specified, array of all topic names in a web.) | 46 46 | =POST= | yes | =http://x61/bin/query/{Webname}/topic[.json]= | (TODO: might rejig to use UI::Manage::_create) create a new topic in the web container using the payload as topic data, and respecting AUTOINC name requests | 47 47 | =PUT= | no | =http://x61/bin/query/{Webname}/{TopicName}/topic[.json]= | update/create a topic resource completely with the payload - anything missing from the sent structure will be removed in the new revision, will not respect AUTOINC, and will use the topic name in the URI, not the payload. | … … 50 50 ---++++ Attachments 51 51 | *Verb* | *Implemented* | *URI* | *Use* | 52 | =GET= | yes | =http://x61/bin/query/{Webname}/{TopicName} /[{attachmentname}/]attachments[.json]= | get attachment resource information, currently a list of subwebs to the resource (if no Webname is specified, list all webs)|52 | =GET= | yes | =http://x61/bin/query/{Webname}/{TopicName}[/{attachmentname}]/attachments[.json]= | get attachment resource information, currently a list of subwebs to the resource | 53 53 | =POST= | no | =http://x61/bin/query/{Webname}/{TopicName}/attachments[.json]= | create a new attachment - can I just decode the payload and push to UI::Upload? | 54 54 | =PUT= | no | =http://x61/bin/query/{Webname}/{TopicName}/{attachmentname}/attachments[.json]= | update a attachment resource (=nop= until define some web specific info, like permissions, settings etc), or maybe for renaming a web?) | … … 67 67 will give simple docco about what requests are supported 68 68 ---++++ GET 69 retreives a resource, or an array of resource names 69 70 ---++++ PUT 71 not implemented yet 70 72 ---++++ POST 71 73 Creates a new element in a container. So if you want to create a new topic, the URI is that of the web you want to place it, and the payload will contain a value that has a =_topic= … … 73 75 modifies an existing item, changing only the elements sent in the payload - thus allowing you to modify just the topic text, the value of one 'named' FIELD, or one Attachement's data. 74 76 ---++++ DELETE 77 delete the specified resource 78 ---+++ Examples: 79 ---++++ Using the built in =foswiki.RestPlugin= javascript helper 80 <verbatim class="tml"> 81 %ADDTOZONE{"script" text="<script type='text/javascript' src='%PUBURLPATH%/%SYSTEMWEB%/RestPlugin/json2.js'></script>" id="json2.js"}% 82 %ADDTOZONE{"script" 83 text="<script type='text/javascript' src='%PUBURLPATH%/%SYSTEMWEB%/RestPlugin/foswikiRestPlugin.js'></script>" id="foswikiRestPlugin.js" 84 requires="json2.js, JavascriptFiles/foswikiPref, JavascriptFiles/strikeone" 85 }% 86 var query = 'Sandbox/TestTopic0'; 87 var element = 'topic'; 88 var encoding = 'json'; 89 foswiki.RestPlugin.get(query, {element:element, encoding:encoding, success_callback:showResponse}); 90 //you need at least one 'get' query to ensure you have a valid strikeone nonce loaded before you can use it to do a change operation 91 foswiki.RestPlugin.patch(query, { 92 _text: newtext, 93 FORM: [{name: 'BugItemTemplate'}], 94 FIELD : [{name:'Summary', value:'oh. i have to fill it in?'}] 95 }, 96 { 97 element:element, 98 encoding:encoding, 99 success_callback:showResponse 100 }); 101 // post-success callback 102 function showResponse(responseText, statusText, xhr) { 103 var text = ''; 104 if ((typeof responseText) == 'string') { 105 text = responseText; 106 } else { 107 text = responseText._text; 108 } 75 109 76 ---+++ Examples: 110 var nonce = ''; 111 //show the nonce changes for debugging 112 if ((typeof(foswiki.RestPlugin.nonce) == 'undefined') || (foswiki.RestPlugin.nonce == '')) { 113 nonce = 'nonce not found'; 114 } else { 115 nonce = foswiki.RestPlugin.nonce; 116 } 117 alert('nonce = '+nonce + ' text = ' + text); 118 } 119 </verbatim> 120 ---++++ using =curl= to get topic data. 121 <verbatim> 122 curl -X GET -H "Content-Type:text/json" http://x61/f/bin/query/Sandbox/TestTopic0/topic.json 123 </verbatim> 124 <div style="display:none;"> 125 BROKEN when strikeone is on 77 126 ---++++ using =curl= to update topic data. 78 127 __now that the strikeone support is added, these example only work with Validation=none__ fix to come … … 85 134 curl -X PATCH -H "Content-Type:text/json" -d @- 'http://x61/f/bin/query/Main/SvenDowideit/topic.json' 86 135 </verbatim> 87 136 </div> 88 137 ---++ Installation Instructions 89 138 … … 91 140 92 141 ---++ Plugin Info 142 143 Many thanks to the following sponsors for supporting this work: 144 * [[http://www.taxonomy.org.au][TRIN]], The Taxonomy Research & Information Network with the [[http://www.anbg.gov.au/cpbr/][Centre for Australian National Biodiversity Research]] 145 93 146 94 147
Note: See TracChangeset
for help on using the changeset viewer.
