annals.tools#
The operations, as plain functions: JSON-able arguments in, JSON-able dicts out.
This module is the single source of truth for what a annals can do. The CLI
(annals.__main__, via cw), the MCP server (py2mcp over string refs to these
names) and the shipped skill all describe the same functions, so there is nothing to keep
in parity. Nothing here prints or exits; the surfaces do that.
Functions
|
Write the publisher config (where to publish, what link to print) and show it. |
|
Make a group (one URL for a set of documents) from existing document ids. |
|
List groups, newest first. |
|
List documents (newest first), optionally filtered by words or showing the bin. |
|
The page's html shell, for a host that serves the API under its own prefix. |
|
Publish one document and print its link; several paths become several documents. |
|
Bring documents back from the recycle bin. |
|
Serve the annals page and API (needs |
|
A document's metadata and link. |
|
Move documents to the recycle bin (restorable). |
- annals.tools.configure(*, target=None, base_url=None)[source]#
Write the publisher config (where to publish, what link to print) and show it.
- Return type:
Example
annals configure --target tw:/root/.local/share/annals --base-url https://apps.example.com/annals. With no arguments, shows the resolved settings without writing.
- annals.tools.group(title, doc_ids, *, target=None, base_url=None)[source]#
Make a group (one URL for a set of documents) from existing document ids.
- Return type:
- annals.tools.ls(q='', *, trash=False, limit=50, target=None, base_url=None)[source]#
List documents (newest first), optionally filtered by words or showing the bin.
- Return type:
- annals.tools.page_shell(*, api='/api/annals', base='/annals', title='annals')[source]#
The page’s html shell, for a host that serves the API under its own prefix.
An enlace app writes it once as its frontend:
annals page-shell --api /api/annals --base /annals > frontend/index.html. The shell only names the two paths; the page’s code loads from the API, so it upgrades with the package.- Return type:
- annals.tools.publish(paths, *, title=None, tags='', group=None, add_to=None, session=None, all_files=False, target=None, base_url=None)[source]#
Publish one document and print its link; several paths become several documents.
paths: files of any kind (markdown, html, images, video, audio, pdf, text), a directory (one document: anindex.htmlor single page with its assets, else a gallery of everything in it), or-for stdin (markdown).tagsis comma separated.groupnames a group to create from the published documents; the reply then carriesgroup_urltoo.add_toappends them to an existing group instead (its id, as printed in a group link), so a second batch lands under the link the owner already has.sessionrecords who published (the source shown on the page). A directory skips hidden files and caches (.*,__pycache__,*.pyc) unlessall_files.- Return type:
- annals.tools.restore(doc_ids, *, target=None)[source]#
Bring documents back from the recycle bin.
- Return type:
- annals.tools.serve(*, host='127.0.0.1', port=8765, data_dir=None, base_path='/annals')[source]#
Serve the annals page and API (needs
pip install 'annals[server]').Auth comes from the environment:
ANNALS_WHOAMI_URL+ANNALS_ALLOWED_USERSto sit behind an existing login,ANNALS_BASIC_USER+ANNALS_BASIC_PASSWORDfor HTTP Basic, nothing for an open server on localhost.- Return type: