| | @@ -0,0 +1,301 @@ |
| 1 | +# JSON API: /wiki
|
| 2 | +([⬑JSON API Index](index.md))
|
| 3 | +
|
| 4 | +Jump to:
|
| 5 | +
|
| 6 | +* [Page List](#list)
|
| 7 | +* [Fetch a Page](#get)
|
| 8 | +* [Create or Save Page](#create-save)
|
| 9 | +* [Wiki Diffs](#diffs)
|
| 10 | +* [Preview](#preview)
|
| 11 | +* [Notes and TODOs](#todo)
|
| 12 | +
|
| 13 | +---
|
| 14 | +
|
| 15 | +<a id="list"></a>
|
| 16 | +# Page List
|
| 17 | +
|
| 18 | +Returns a list of all pages, not including their content (which can be
|
| 19 | +arbitrarily large).
|
| 20 | +
|
| 21 | +**Status:** implemented 201109xx
|
| 22 | +
|
| 23 | +**Required privileges:** "j" or "o"
|
| 24 | +
|
| 25 | +**Request:** `/json/wiki/list`
|
| 26 | +
|
| 27 | +**Options:**
|
| 28 | +
|
| 29 | +- `bool verbose` (=false) Changes the results to return much more
|
| 30 | + information. Added 20120219.
|
| 31 | +- `glob=wildcard` string (default=`*`). If set, only page names
|
| 32 | + matching the given wildcard are returned. Added 20120325.\
|
| 33 | + CLI: `--glob|-g STRING`
|
| 34 | +- `like=SQL LIKE string` (default=`%`). If set, only page names matching
|
| 35 | + the given SQL LIKE string are returned. Note that this match is
|
| 36 | + case-INsensitive. If both glob and like are given then only one will
|
| 37 | + work and which one takes precedence is unspecified. Added 20120325.\
|
| 38 | + CLI: `--like|-l STRING`
|
| 39 | +- `invert=bool` (default=false). If set to a true value, the glob/like
|
| 40 | + filter has a reverse meaning (pages *not* matching the wildcard are
|
| 41 | + returned). Added 20120329.\
|
| 42 | + CLI: `-i/--invert`
|
| 43 | +
|
| 44 | +**Response payload: format depends on "verbose" option**
|
| 45 | +
|
| 46 | +Non-verbose mode:
|
| 47 | +
|
| 48 | +```json
|
| 49 | +["PageName1",..."PageNameN"]
|
| 50 | +```
|
| 51 | +
|
| 52 | +In verbose mode:
|
| 53 | +
|
| 54 | +```json
|
| 55 | +[{
|
| 56 | +"name":"Apache On Windows XP",
|
| 57 | +"uuid":"a7e68df71b95d35321b9d9aeec3c8068f991926c",
|
| 58 | +"user":"jeffrimko",
|
| 59 | +"timestamp":1310227825,
|
| 60 | +"size":793 /* in bytes */
|
| 61 | +},...]
|
| 62 | +```
|
| 63 | +
|
| 64 | +The verbose-mode output is the same as the [`/json/wiki/get`](#get) output, but
|
| 65 | +without the content. The size property of each reflects the *byte*
|
| 66 | +length of the raw (non-HTMLized) page content.
|
| 67 | +
|
| 68 | +**Potential TODOs:**
|
| 69 | +
|
| 70 | +- Allow specifying (in the request) a list/array of names, as opposed
|
| 71 | + to listing all pages. The page count is rarely very high, though, so
|
| 72 | + an "overload" is very unlikely. (i have one wiki with about 47 pages
|
| 73 | + in it.)
|
| 74 | +
|
| 75 | +<a id="get"></a>
|
| 76 | +# Fetch a Page
|
| 77 | +
|
| 78 | +Fetches a single wiki page, including content and significant metadata.
|
| 79 | +
|
| 80 | +**Status:** implemented 20110922, but response format may change.
|
| 81 | +
|
| 82 | +**Required privileges:** "j" or "o"
|
| 83 | +
|
| 84 | +**Request:**
|
| 85 | +
|
| 86 | +- GET: `/json/wiki/get?name=PageName`
|
| 87 | +- GET: `/json/wiki/get/PageName`
|
| 88 | +- POST: `/json/wiki/get` with page name as `POST.payload` or
|
| 89 | + `POST.payload.name`.
|
| 90 | +
|
| 91 | +**Response payload example:**
|
| 92 | +
|
| 93 | +```json
|
| 94 | +{
|
| 95 | +"name": "Fossil",
|
| 96 | +"uuid": "...hex string...",
|
| 97 | +"parent": "uuid of parent (not set for first version of page)",
|
| 98 | +"user": "anonymous",
|
| 99 | +"timestamp": 1286143975,
|
| 100 | +"size": 1906, /* In bytes, not UTF8 characters!
|
| 101 | + Affected by format option! */
|
| 102 | +"content": "..."
|
| 103 | +}
|
| 104 | +```
|
| 105 | +
|
| 106 | +**FIXME:** it's missing the mimetype (that support was added to fossil
|
| 107 | +after this was implemented).
|
| 108 | +
|
| 109 | +If given no page to load, or if asked to get a page which does not
|
| 110 | +exist, an error response is generated (a usage- or resource-not-found
|
| 111 | +error, respectively).
|
| 112 | +
|
| 113 | +**Options (via CLI/GET/`POST.payload`):**
|
| 114 | +
|
| 115 | +- `name=string`. The page to fetch. The latest version is fetched
|
| 116 | +unless the uuid paramter is supplied (in which case name is ignored). \
|
| 117 | +CLI: `--name|-n string`\
|
| 118 | +Optionally, the name may be the 4th positional argument/request path element.
|
| 119 | +- `uuid=string`. Fetches a specific version. The name parameter is
|
| 120 | +ignored when this is specified.\
|
| 121 | +CLI: `--uid|-u string`
|
| 122 | +- `format=string ("raw"|"html"|"none")` (default="raw"). Specifies the
|
| 123 | +format of the "content" payload value.\
|
| 124 | +CLI: `--format|-f string` \
|
| 125 | +The "none" format means to return no content. In that case the size
|
| 126 | +refers to the same size as the "raw" format.
|
| 127 | +
|
| 128 | +**TODOs:**
|
| 129 | +
|
| 130 | +- Support passing an array of names in the request (and change
|
| 131 | + response to return an array).
|
| 132 | +
|
| 133 | +<a id="create-save"></a>
|
| 134 | +# Create or Save Page
|
| 135 | +
|
| 136 | +**Status:** implemented 20110922.
|
| 137 | +
|
| 138 | +**Required privileges:** "k" (save) or "f" (create)
|
| 139 | +
|
| 140 | +**Request:**
|
| 141 | +
|
| 142 | +- `/json/wiki/create`
|
| 143 | +- `/json/wiki/save`
|
| 144 | +
|
| 145 | +These work only in HTTP mode, not CLI mode. (FIXME: now that we can
|
| 146 | +simulate POST from a file, these could be used in CLI mode.)
|
| 147 | +
|
| 148 | +The semantic differences between save and create are:
|
| 149 | +
|
| 150 | +- Save will fail if the page doesn't already exist whereas create will
|
| 151 | + fail if it does. The createIfNotExists option (described below) can
|
| 152 | + be used to create new pages using the save operation.
|
| 153 | +- The content property is optional for the create request, whereas it
|
| 154 | + is required to be a string for save requests (but it *may* be an
|
| 155 | + empty string). This requirement for save is *almost* arbitrary, and
|
| 156 | + is intended to prevent accidental erasing of existing page content
|
| 157 | + via API misuse.
|
| 158 | +
|
| 159 | +**Response payload example:**
|
| 160 | +
|
| 161 | +The same as for [`/json/wiki/get`](#get) but the page content is not
|
| 162 | +included in the response (only the metadata).
|
| 163 | +
|
| 164 | +**Request options** (via GET or `POST.payload` object):
|
| 165 | +
|
| 166 | +- `name=string` specifies the page name.
|
| 167 | +- `content=string` is the body text.\
|
| 168 | + Content is required for save (unless `createIfNotExists` is true *and*
|
| 169 | + the page does not exist), optional for create. It *may* bSave (not create) supports a `createIfNotExists` boolean option which
|
| 170 | + makes it a functional superset of the create/save features. i.e. it
|
| 171 | + will create if needed, else it will update. If createIfNotExists is
|
| 172 | + false (the default) then save will fail if given a page name which
|
| 173 | + does not refer to an existing page.
|
| 174 | +- **TODO:** add `commitMessage` string property. The fossil internals
|
| 175 | + don't have a way to do this at the moment (they can as of late 2019).
|
| 176 | + Since fossil wiki commits have always had the same default commit message, this is not a
|
| 177 | + high-priority addition. See:\
|
| 178 | + [](/doc/trunk/www/fileformat.wiki#wikichng)
|
| 179 | +- **Potential TODO:** we *could* optionally also support
|
| 180 | + multi-page saving using an array of pages in the request payload:\
|
| 181 | + `… page objects … ]`
|
| 182 | +
|
| 183 | +
|
| 184 | +
|
| 185 | +<a id="diffs"></a>
|
| 186 | +# Wiki Diffs
|
| 187 | +
|
| 188 | +**Status:** implemented 20120304
|
| 189 | +
|
| 190 | +**Required privileges:** "h"
|
| 191 | +
|
| 192 | +**Request:**
|
| 193 | +
|
| 194 | +- `/json/wiki/diff[/version1_UUID/version2_UUID]`
|
| 195 | +
|
| 196 | +**Response payload example:**
|
| 197 | +
|
| 198 | +```json
|
| 199 | +{
|
| 200 | + "v1":"e32ccdcda59e930c77c1e01cebace5d71253f621",
|
| 201 | + "v2":"e15992f475760cdf3a9564d8f88cacb659ab4b07",
|
| 202 | + "diff":"@@ -1,4 +1,9 @@...<SNIP>..."
|
| 203 | +}
|
| 204 | +```
|
| 205 | +
|
| 206 | +**Options:**
|
| 207 | +
|
| 208 | +- `v1=uuid` and `v2=uuid` specify the two versions to diff, and are
|
| 209 | + required parameters. They may optionally be specified as the two
|
| 210 | + URL/CLI parameters following the "diff" sub-command/path.
|
| 211 | +
|
| 212 | +This command does not verify that both UUIDs actually refer to the same
|
| 213 | +page name, but do verify that they refer to wiki content.
|
| 214 | +
|
| 215 | +Trivia: passing the same UUIDs to the `/json/diff` command will produce
|
| 216 | +very different results - that one diffs the manifests of the commits.
|
| 217 | +
|
| 218 | +**TODOs:**
|
| 219 | +
|
| 220 | +- Add options for changing the format of the diff, e.g. side-by-side
|
| 221 | + and enabling the HTML markup supported by the main fossil HTML GUI.
|
| 222 | +- Potentially do a name comparison to verify that the diff is against
|
| 223 | + the same page. That said, when "renaming" pages it might be useful
|
| 224 | + to diff two different pages.
|
| 225 | +
|
| 226 | +<a id="preview"></a>
|
| 227 | +# Preview
|
| 228 | +
|
| 229 | +**Status:** implemented 20120310
|
| 230 | +
|
| 231 | +**Required privileges:** "k" (to limit its use to only those who can
|
| 232 | +edit wiki pages). This limitation is up for debate/reconsideration.
|
| 233 | +
|
| 234 | +**Request:**
|
| 235 | +
|
| 236 | +- `/json/wiki/preview`
|
| 237 | +
|
| 238 | +This command wiki-processes arbitrary text sent from the client. To help
|
| 239 | +curb potential abuse, its use is restricted to those with "k" access
|
| 240 | +rights.
|
| 241 | +
|
| 242 | +The `POSTart
|
| 243 | + multi-page saving using
|
| 244 | +markup. UUID]`
|
| 245 | +
|
| 246 | +**Response payloalso a string, but contains the
|
| 247 | +HTML-processed form of the string. Whether 0c77c1e01cebace5d71253f621",
|
| 248 | +564d8f88cacb659ab4b07",
|
| 249 | + "diff":"@ acb659ab4b07",
|
| 250 | + "diff":"@@ -1,4
|
| 251 | + JSON API: /wiki
|
| 252 | +([⬑JSON API Index](index.md))
|
| 253 | +
|
| 254 | +Jump to:
|
| 255 | +
|
| 256 | +* [Page List](#list)
|
| 257 | +* [Fetch a Page](#get)
|
| 258 | +* [Create or Save Page](#create-save)
|
| 259 | +* [Wiki Diffs](#diffs)
|
| 260 | +* [Preview](#preview)
|
| 261 | +* [Notes and TODOs](#todo)
|
| 262 | +
|
| 263 | +---
|
| 264 | +
|
| 265 | +<a id="list"></a>
|
| 266 | +# Page List
|
| 267 | +
|
| 268 | +Returns a list of all pages, not including their content (which can be
|
| 269 | +arbib11;JSON API Index](index.md))
|
| 270 | +
|
| 271 | +Jump to:
|
| 272 | +
|
| 273 | +* [Page List](#list)
|
| 274 | +* [Fetch a Page](#get)
|
| 275 | +* [Create or Save Page](#create-save)
|
| 276 | +* [Wiki Diffs](#diffs)
|
| 277 | +* [Preview](#preview)
|
| 278 | +* [Notes and TODOs](#todo)
|
| 279 | +
|
| 280 | +---
|
| 281 | +
|
| 282 | +<a id="list"></a>
|
| 283 | +# Page List
|
| 284 | +
|
| 285 | +Returns a list of all pages, not including their content (which can be
|
| 286 | +arbitrarily large).
|
| 287 | +
|
| 288 | +**Status:** a JSON-capable page handler.
|
| 289 | +
|
| 290 | +
|
| 291 | +<a id="todo"></a>
|
| 292 | +# Notes and TODOs
|
| 293 | +
|
| 294 | +- When server-parsing the wiki content, the generated
|
| 295 | + intra-wiki/intra-site links will only be useful in the context of
|
| 296 | + the original fossil UI (or a work-alike), not arbitrary JSON
|
| 297 | + client apps.
|
| 298 | +
|
| 299 | +Potential TODOs:
|
| 300 | +
|
| 301 | +- `/wiki/history` analog to the [](/whistory) page.
|