Fossil SCM

/json/artifact/WIKI_UUID now supports the --format options from /json/wiki/get.

stephan 2012-03-02 17:52 trunk
Commit 2cbe686c30ddf66a9775a9bdfffadca48e2d8647
2 files changed +5 -3 +30 -10
--- src/json_artifact.c
+++ src/json_artifact.c
@@ -241,13 +241,15 @@
241241
if( ! g.perm.RdWiki ){
242242
json_set_err(FSL_JSON_E_DENIED,
243243
"Requires 'j' privileges.");
244244
return NULL;
245245
}else{
246
- char addContent = json_artifact_include_content_flag();
247
- /* todo: support format=(raw|html|none) like /wiki/get does. */
248
- return json_get_wiki_page_by_rid(rid, addContent ? -1 : 0);
246
+ char contentFormat = json_wiki_get_content_format_flag(-9);
247
+ if(-9 == contentFormat){
248
+ contentFormat = json_artifact_include_content_flag() ? -1 : 0;
249
+ }
250
+ return json_get_wiki_page_by_rid(rid, contentFormat);
249251
}
250252
}
251253
252254
cson_value * json_artifact_file(int rid){
253255
cson_object * pay = NULL;
254256
--- src/json_artifact.c
+++ src/json_artifact.c
@@ -241,13 +241,15 @@
241 if( ! g.perm.RdWiki ){
242 json_set_err(FSL_JSON_E_DENIED,
243 "Requires 'j' privileges.");
244 return NULL;
245 }else{
246 char addContent = json_artifact_include_content_flag();
247 /* todo: support format=(raw|html|none) like /wiki/get does. */
248 return json_get_wiki_page_by_rid(rid, addContent ? -1 : 0);
 
 
249 }
250 }
251
252 cson_value * json_artifact_file(int rid){
253 cson_object * pay = NULL;
254
--- src/json_artifact.c
+++ src/json_artifact.c
@@ -241,13 +241,15 @@
241 if( ! g.perm.RdWiki ){
242 json_set_err(FSL_JSON_E_DENIED,
243 "Requires 'j' privileges.");
244 return NULL;
245 }else{
246 char contentFormat = json_wiki_get_content_format_flag(-9);
247 if(-9 == contentFormat){
248 contentFormat = json_artifact_include_content_flag() ? -1 : 0;
249 }
250 return json_get_wiki_page_by_rid(rid, contentFormat);
251 }
252 }
253
254 cson_value * json_artifact_file(int rid){
255 cson_object * pay = NULL;
256
+30 -10
--- src/json_wiki.c
+++ src/json_wiki.c
@@ -147,10 +147,39 @@
147147
}
148148
return json_get_wiki_page_by_rid(rid, contentFormat);
149149
}
150150
151151
152
+/*
153
+** Searches json_find_option_ctr("format",NULL,"f") for a flag.
154
+** If not found it returns defaultValue else it returns a value
155
+** depending on the first character of the format option:
156
+**
157
+** [h]tml = 1
158
+** [n]one = 0
159
+** [r]aw = -1
160
+**
161
+** The return value is intended for use with
162
+** json_get_wiki_page_by_rid() and friends.
163
+*/
164
+char json_wiki_get_content_format_flag( char defaultValue ){
165
+ char contentFormat = defaultValue;
166
+ char const * zFormat = json_find_option_cstr("format",NULL,"f");
167
+ if( !zFormat || !*zFormat ){
168
+ return contentFormat;
169
+ }
170
+ else if('r'==*zFormat){
171
+ contentFormat = -1;
172
+ }
173
+ else if('h'==*zFormat){
174
+ contentFormat = 1;
175
+ }
176
+ else if('n'==*zFormat){
177
+ contentFormat = 0;
178
+ }
179
+ return contentFormat;
180
+}
152181
153182
/*
154183
** Implementation of /json/wiki/get.
155184
**
156185
*/
@@ -182,20 +211,11 @@
182211
json_set_err(FSL_JSON_E_MISSING_ARGS,
183212
"'name' argument is missing.");
184213
return NULL;
185214
}
186215
187
- zFormat = json_find_option_cstr("format",NULL,"f");
188
- if(!zFormat || !*zFormat || ('r'==*zFormat)){
189
- contentFormat = -1;
190
- }
191
- else if('h'==*zFormat){
192
- contentFormat = 1;
193
- }
194
- else if('n'==*zFormat){
195
- contentFormat = 0;
196
- }
216
+ contentFormat = json_wiki_get_content_format_flag(contentFormat);
197217
return json_get_wiki_page_by_name(zPageName, contentFormat);
198218
}
199219
200220
/*
201221
** Internal impl of /wiki/save and /wiki/create. If createMode is 0
202222
--- src/json_wiki.c
+++ src/json_wiki.c
@@ -147,10 +147,39 @@
147 }
148 return json_get_wiki_page_by_rid(rid, contentFormat);
149 }
150
151
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
152
153 /*
154 ** Implementation of /json/wiki/get.
155 **
156 */
@@ -182,20 +211,11 @@
182 json_set_err(FSL_JSON_E_MISSING_ARGS,
183 "'name' argument is missing.");
184 return NULL;
185 }
186
187 zFormat = json_find_option_cstr("format",NULL,"f");
188 if(!zFormat || !*zFormat || ('r'==*zFormat)){
189 contentFormat = -1;
190 }
191 else if('h'==*zFormat){
192 contentFormat = 1;
193 }
194 else if('n'==*zFormat){
195 contentFormat = 0;
196 }
197 return json_get_wiki_page_by_name(zPageName, contentFormat);
198 }
199
200 /*
201 ** Internal impl of /wiki/save and /wiki/create. If createMode is 0
202
--- src/json_wiki.c
+++ src/json_wiki.c
@@ -147,10 +147,39 @@
147 }
148 return json_get_wiki_page_by_rid(rid, contentFormat);
149 }
150
151
152 /*
153 ** Searches json_find_option_ctr("format",NULL,"f") for a flag.
154 ** If not found it returns defaultValue else it returns a value
155 ** depending on the first character of the format option:
156 **
157 ** [h]tml = 1
158 ** [n]one = 0
159 ** [r]aw = -1
160 **
161 ** The return value is intended for use with
162 ** json_get_wiki_page_by_rid() and friends.
163 */
164 char json_wiki_get_content_format_flag( char defaultValue ){
165 char contentFormat = defaultValue;
166 char const * zFormat = json_find_option_cstr("format",NULL,"f");
167 if( !zFormat || !*zFormat ){
168 return contentFormat;
169 }
170 else if('r'==*zFormat){
171 contentFormat = -1;
172 }
173 else if('h'==*zFormat){
174 contentFormat = 1;
175 }
176 else if('n'==*zFormat){
177 contentFormat = 0;
178 }
179 return contentFormat;
180 }
181
182 /*
183 ** Implementation of /json/wiki/get.
184 **
185 */
@@ -182,20 +211,11 @@
211 json_set_err(FSL_JSON_E_MISSING_ARGS,
212 "'name' argument is missing.");
213 return NULL;
214 }
215
216 contentFormat = json_wiki_get_content_format_flag(contentFormat);
 
 
 
 
 
 
 
 
 
217 return json_get_wiki_page_by_name(zPageName, contentFormat);
218 }
219
220 /*
221 ** Internal impl of /wiki/save and /wiki/create. If createMode is 0
222

Keyboard Shortcuts

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