annals.share_page#
A share link’s page with its text in it, and no script, so every reader can read it.
A share link used to answer with a shell: a <title> and an empty <div> that the
viewer’s script filled, with an html document inside a frame. NotebookLM made a
twenty-minute audio overview of such a link’s title. Its fetcher does run script, so it saw
the viewer’s buttons, but a group shows only titles there and a frame is not read. So the
page a link opens is now the shared text itself, rendered on the server under the rules
every shared text already follows, and nothing on it runs. The owner asked for exactly that:
a person only needs the document. The script viewer (galleries, players, downloads) is one
link away, <link>/?viewer.
The same share also answers as one Markdown file and one PDF, with the same token, expiry
and revocation (the routes are annals.share_api’s); the page names them in
<link rel="alternate"> and in a line at its top:
<link>/ the page: every shared document's text (a group's, in order)
<link>/d/<id> the page of one document of the share
<link>/share.md the whole share as one Markdown file
<link>/share.pdf the whole share as one PDF (images included)
<link>/d/<id>.md|.pdf one document of it
<link>/?viewer the script viewer, as before
What goes in the page, per document: its markdown and html files (the notebook sources of
annals.notebook, numbered files first), markdown rendered with links and images
made safe by annals.notebook.render_source_body(), html reduced to its structure and
words by annals.combine.html_body() with a link to the page as designed; for a
document with no text, its images; its audio and video with the browser’s own players;
then links to its other files. Past STATIC_MAX_BYTES of text or
STATIC_MAX_FILES files, the remaining files and documents are links to their own pages, so a large group still answers quickly and every
document stays reachable. A document that is an html page (designed_page()) is
served as itself at its own link, filtered and sandboxed as /raw serves it, with a
<base> (with_base()) so its images and styles load.
Module Attributes
the page's text stops growing past this many bytes of html; later documents are links |
|
the text files rendered into one page at most; the rest are links (a page is made on every request, and anyone holding the link may make one) |
|
a document's file larger than this is linked, not put in the page |
|
images shown for a document without text (a gallery folder); the rest are listed |
|
audio and video players in one document's page; the rest are listed |
|
the length of the page's |
|
path suffix, media type, label |
|
the share's whole text, at |
|
|
Functions
|
The |
|
|
|
The first |
|
The html file a document's page is, when it is one, else |
|
The page's content and its description: |
|
|
Classes
|
What a page of one share may show and link to. |
- annals.share_page.ALTERNATES = (('md', 'text/plain', 'Markdown'), ('pdf', 'application/pdf', 'PDF'))#
path suffix, media type, label
- Type:
the alternate representations of a share
- annals.share_page.DESCRIPTION_CHARS = 280#
the length of the page’s
<meta name="description">
- annals.share_page.SHARE_FILE = 'share'#
the share’s whole text, at
<link>/<SHARE_FILE>.<ext>
- annals.share_page.STATIC_FILE_MAX_BYTES = 2000000#
a document’s file larger than this is linked, not put in the page
- annals.share_page.STATIC_MAX_BYTES = 1500000#
the page’s text stops growing past this many bytes of html; later documents are links
- annals.share_page.STATIC_MAX_FILES = 40#
the text files rendered into one page at most; the rest are links (a page is made on every request, and anyone holding the link may make one)
- annals.share_page.STATIC_MAX_IMAGES = 60#
images shown for a document without text (a gallery folder); the rest are listed
- annals.share_page.STATIC_MAX_PLAYERS = 20#
audio and video players in one document’s page; the rest are listed
- class annals.share_page.ShareScope(link, shared_ids, root_id='', private_hosts=())[source]#
Bases:
objectWhat a page of one share may show and link to.
linkis the share’s address (root-relative is fine: a fetcher resolves it against the page),shared_idsthe documents it includes,root_idits group (""for a document share),private_hoststhe owner’s hosts, never linked to.
- annals.share_page.VIEWER_PARAM = 'viewer'#
<link>/?vieweropens the script viewer (galleries, players, downloads) instead
- annals.share_page.alternate_links(link, doc_id=None)[source]#
The
<link rel="alternate">tags ofalternate_urls(), for the<head>.- Return type:
- annals.share_page.alternate_urls(link, doc_id=None)[source]#
(url, media type, label)of the share (or of one document of it) as files.
- annals.share_page.description_of(content, *, skip='', n=280)[source]#
The first
ncharacters of the page’s words (the title and alternates line left out).- Return type:
- annals.share_page.designed_page(meta, files)[source]#
The html file a document’s page is, when it is one, else
None.Such a document is served as itself at its link (filtered and sandboxed, as
/rawserves it): a person sees it as designed, and a fetcher, even one that runs script, reads it at the top level rather than inside a frame it does not open.
- annals.share_page.page_body(docs, *, title, read_text, scope, doc_id=None, viewer_url=None, max_bytes=None)[source]#
The page’s content and its description:
(html, plain text of ~280 chars).docsare the(meta, files)pairs to show, in order (one, for a document’s page);read_text(doc_id, rel)reads a file as it is on disk (the shared-text filters are applied here).doc_idnames the document a/d/<id>page is for, which picks the alternates the page offers;viewer_urlis where the script viewer opens it.max_bytes:STATIC_MAX_BYTES.
- annals.share_page.with_base(page, href)[source]#
pagewith<base href>as its first element, so its relative references (images, styles, its other pages) resolve where the share serves its files.The page’s own
<base>and referrer<meta>go: either would send its requests, or the link, elsewhere. The tag goes right after the doctype, where the parser puts it in the head whatever comes later (a<head>written in a comment, say).- Return type: