Liking cljdoc? Tell your friends :D

dk.simongray.micropub

Micropub entries and actions as data, and a client that discovers an endpoint and sends it actions and queries.

An entry is microformats2 JSON as microformats-clj parses it: a map of its :type, e.g. ["h-entry"], and its :properties, a map of keywords to vectors of values. An action is a Micropub request in the same shape, as the server namespace reads it, e.g.

{:action  :update
 :url     "https://simon.grays.blog/posts/2026/hello"
 :replace {:content ["Hello again"]}
 :delete  [:location]}

The code follows the W3C Recommendation of 23 May 2017 at https://www.w3.org/TR/micropub/ and cites its sections.

Micropub entries and actions as data, and a client that discovers an
endpoint and sends it actions and queries.

An entry is microformats2 JSON as microformats-clj parses it: a map of
its :type, e.g. ["h-entry"], and its :properties, a map of keywords to
vectors of values. An action is a Micropub request in the same shape, as
the server namespace reads it, e.g.

    {:action  :update
     :url     "https://simon.grays.blog/posts/2026/hello"
     :replace {:content ["Hello again"]}
     :delete  [:location]}

The code follows the W3C Recommendation of 23 May 2017 at
https://www.w3.org/TR/micropub/ and cites its sections.
raw docstring

apply-updateclj/s

(apply-update
  entry
  {replacements :replace additions :add deletions :delete :as action})

The entry with the update action applied: its :replace first, then its :add and then its :delete, an order that Micropub 3.4 leaves open. A property left without values is removed.

The `entry` with the update `action` applied: its :replace first, then
its :add and then its :delete, an order that Micropub 3.4 leaves open. A
property left without values is removed.
sourceraw docstring

call!clj/s

(call! request)
(call! request opts)

Send the request of an action or a query with opts, and return the server's answer: a map of its :status, the :url of a post that was created or moved, and the JSON :body of a query. In ClojureScript, it returns a promise.

A status that isn't a success returns a map of the :error, with the :status and Micropub's :code and :reason (3.8). A request that fails returns the :error from http/failure. The opts are those of default-options and http/send!.

Send the `request` of an action or a query with `opts`, and return the
server's answer: a map of its :status, the :url of a post that was
created or moved, and the JSON :body of a query. In ClojureScript, it
returns a promise.

A status that isn't a success returns a map of the :error, with the
:status and Micropub's :code and :reason (3.8). A request that fails
returns the :error from http/failure. The `opts` are those of
default-options and http/send!.
sourceraw docstring

default-optionsclj/s

The defaults of the client's options:

  • :body-links?, false: discovery reads only the head of a page, since anyone who can write in its body could name another endpoint and get your posts and your token
  • :send, http/send-public!, which sends only to the public internet
  • :timeout-seconds, 10, and :max-bytes, 2 MB, which limit each request
The defaults of the client's options:

- :body-links?, false: discovery reads only the head of a page, since
  anyone who can write in its body could name another endpoint and get
  your posts and your token
- :send, http/send-public!, which sends only to the public internet
- :timeout-seconds, 10, and :max-bytes, 2 MB, which limit each request
sourceraw docstring

discoverclj/s

(discover response)
(discover response opts)

The Micropub endpoint that the response to a profile URL names, as a map of the :endpoint, or nil when it names none. The opts are those of default-options, e.g. :body-links?.

Micropub sets no order, so the Link headers come before the page, as in IndieAuth and Webmention. A relative URL resolves against the URL of the response or the base of the page.

The Micropub endpoint that the `response` to a profile URL names, as a
map of the :endpoint, or nil when it names none. The `opts` are those of
default-options, e.g. :body-links?.

Micropub sets no order, so the Link headers come before the page, as in
IndieAuth and Webmention. A relative URL resolves against the URL of the
response or the base of the page.
sourceraw docstring

discover!clj/s

(discover! url)
(discover! url opts)

Fetch the profile page at url with opts and return a map of its :status and the :endpoint that discover finds. A failed fetch returns a map of the :error from http/failure. In ClojureScript, it returns a promise.

The opts are those of default-options and http/send!.

Fetch the profile page at `url` with `opts` and return a map of its
:status and the :endpoint that discover finds. A failed fetch returns a
map of the :error from http/failure. In ClojureScript, it returns a
promise.

The `opts` are those of default-options and http/send!.
sourceraw docstring

query-requestclj/s

(query-request endpoint token q)
(query-request endpoint token q params)

The request map that sends the query q, e.g. :config or :source, with the params and the access token to the Micropub endpoint.

The params are a map, e.g. of the :url and :properties of a source query. A vector becomes one parameter for each value, with [] after the name.

The request map that sends the query `q`, e.g. :config or :source, with
the `params` and the access `token` to the Micropub `endpoint`.

The `params` are a map, e.g. of the :url and :properties of a source
query. A vector becomes one parameter for each value, with [] after the
name.
sourceraw docstring

requestclj/s

(request endpoint token action)
(request endpoint
         token
         {kind :action :keys [url files] :or {kind :create} :as action}
         {:keys [json?] :as opts})

The request map that posts the action to the Micropub endpoint with the access token and opts.

An action without :action is a create, as in Micropub 3.3, so you can post an entry as it is. The body is:

  • form-encoded for a create with one type and only strings as values, since every server accepts that (2.1.3), unless :json? is true in opts
  • JSON for any other create and for an update (3.3.2, 3.4)
  • form-encoded for a delete or an undelete (3.5)

You can hide the token with wary-fetch's secret/hide. The Authorization header is hidden either way.

The request map that posts the `action` to the Micropub `endpoint` with
the access `token` and `opts`.

An action without :action is a create, as in Micropub 3.3, so you can
post an entry as it is. The body is:

- form-encoded for a create with one type and only strings as values,
  since every server accepts that (2.1.3), unless :json? is true in
  `opts`
- JSON for any other create and for an update (3.3.2, 3.4)
- form-encoded for a delete or an undelete (3.5)

You can hide the token with wary-fetch's secret/hide. The Authorization
header is hidden either way.
sourceraw docstring

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
←Move to previous article
→Move to next article
Ctrl+/Jump to the search field
× close