add ba_log entry 2019-10-07
s-ol
3 years ago
0 | Today I started working on the HTTP server that finds, converts and serves content stored in the (SQL) backend just-in-time (later the server could also cache content). | |
1 | ||
2 | The server can handle these types of requests: | |
3 | ||
4 | ## Fileder Index Requests | |
5 | A request like `GET /path/to/fileder/` (note the trailing slash) is used to query the contents of a fileder. | |
6 | It solicits a JSON-encoded response that contains the full paths to all children of this fileder, as well as all facets currently stored, e.g: | |
7 | ||
8 | { | |
9 | "children": [ | |
10 | "/projects/vcv_mods", | |
11 | "/projects/HowDoIOS", | |
12 | "/projects/iii-telefoni", | |
13 | "/projects/btrktrl", | |
14 | "/projects/demoloops", | |
15 | "/projects/VJmidiKit", | |
16 | "/projects/gayngine", | |
17 | "/projects/themer", | |
18 | "/projects/chimpanzee_bukkaque" | |
19 | ], | |
20 | "facets": [ | |
21 | ["", "text/moonscript -> fn -> mmm/dom"], | |
22 | ["name", "alpha"], | |
23 | ["title", "text/plain"] | |
24 | ] | |
25 | } | |
26 | ||
27 | ## Facet Requests | |
28 | A request like `GET /path/to/fileder/facet_name` is used to query a facet. | |
29 | To differentiate a request for the 'unnamed' facet from an index request, unnamed facets are represented as a `:` character instead. | |
30 | The type to ask for can be specified in a `MMM-Accept` header separately, it defaults to `text/html`. | |
31 | ||
32 | The server either sends back the (possibly converted) facet with a `200 OK` status, | |
33 | or a `406 Not Acceptable` error if no conversion was possible. | |
34 | ||
35 | I also restructured the code a bit and moved some of the HTML-rendering code into the main mmmfs code. | |
36 | Then I renamed the `text/html` type to `text/html+frag`, since it refers to only a fragment of HTML code, not a whole document, | |
37 | and added a new *convert* from `text/html+frag` to `text/html` that wraps the fragment in the HTML template and style. | |
38 | ||
39 | the full code change is in commits [81e143f](https://git.s-ol.nu/mmm/commit/81e143fa8181a6adb58d7fba632bd31a13164410/) and [ad26c7c](https://git.s-ol.nu/mmm/commit/ad26c7c4e374f66a978f9946bbb083377f2224a6/) |