Welcome | Get started | Dive | Contribute | Topics | Reference | Changes | More
publisher
: render database content as styled html¶
The lino.modlib.publisher
plugin adds the notion of content pages used to produce the pages of websites or books.
It doesn’t add any database model, but a choicelist, a model mixin and an
action. It also adds a printing build method
(lino.modlib.printing.BuildMethods
).
This document contains code snippets (lines starting with >>>
) that get
tested as part of our development workflow.
>>> from lino import startup
>>> startup('lino_book.projects.cms1.settings')
>>> from lino.api.doctest import *
>>> from django.db.models import Q
Configuration¶
- publisher.use_markup¶
Whether to use markup (instead of wysiwyg) for editing content.
When this is False, the body of pages gets edited using a wysiwyg editor and stored as (bleached) html.
Content pages¶
- content page¶
The basic building unit of a website or book, consisting of a title and a body.
>>> rt.show('publisher.Pages', filter=Q(parent=None))
=========== ====================== ====
Reference Title ID
----------- ---------------------- ----
index Home 1
index Startseite 2
index Départ 3
Terms and conditions 4
Terms and conditions 5
Terms and conditions 6
Privacy policy 7
Privacy policy 8
Privacy policy 9
Cookie settings 10
Cookie settings 11
Cookie settings 12
Copyright 13
Copyright 14
Copyright 15
About us 16
Über uns 17
À propos 18
=========== ====================== ====
>>> home = publisher.Page.objects.get(pk=1)
>>> rt.show('publisher.TranslationsByPage', master_instance=home)
(de) `Startseite <…>`__, (fr) `Départ <…>`__
>>> rt.show('publisher.TranslationsByPage', master_instance=home, nosummary=True)
=========== ============ ========== ====
Reference Title Language ID
----------- ------------ ---------- ----
index Startseite de 2
index Départ fr 3
=========== ============ ========== ====
When I am on the English home page, the link to translation DE will redirect me to page #25:
>>> test_client.get("/p/1?ul=de")
<HttpResponseRedirect status_code=302, "text/html; charset=utf-8", url="/p/2?ul=de">
The same happens when I am on the French home page:
>>> test_client.get("/p/3?ul=de")
<HttpResponseRedirect status_code=302, "text/html; charset=utf-8", url="/p/2?ul=de">
The previous_page fields have been updated:
>>> rt.show(publisher.Pages, column_names="id title previous_page",
... display_mode="grid", filter=Q(language="en"), language="en")
...
==== ====================== ======================
ID Title Previous page
---- ---------------------- ----------------------
1 Home
4 Terms and conditions Conditions générales
7 Privacy policy Terms and conditions
10 Cookie settings Privacy policy
13 Copyright Cookie settings
16 About us Copyright
19 Services Home
20 Prices Services
21 Photos Prices
22 Default formatting Photos
23 Thumbnail Default formatting
24 Thumbnail left Thumbnail
25 Wide Thumbnail left
26 Gallery Wide
27 About us Gallery
28 Team About us
29 History Team
30 Contact History
31 Terms & conditions Contact
58 Blog Terms & conditions
==== ====================== ======================
Classes reference¶
- class lino.modlib.publisher.Page¶
The Django model that represents a content page.
- class lino.modlib.publisher.PublisherBuildMethod¶
This deserves better documentation.
- class lino.modlib.publisher.Publishable¶
Model mixin to add to models that are potentially publishable.
- publisher_template¶
The name of the template to use when rendering a database row via the publisher interface.
“publisher/page.pub.html”
- preview_publication¶
Show this database row via the publisher interface.
Icon: 🌐
- class lino.modlib.publisher.PublishableContent¶
Model mixin to add to models that are potentially publishable.
Inherits from
Publishable
.- language¶
The language of this content.
- publishing_state¶
Default value is ‘draft’
Pointer to
PublishingStates
- filler¶
Pointer to
PageFillers
- class lino.modlib.publisher.PublishingStates¶
A choicelist with the possible states of a publisher page.
>>> rt.show(publisher.PublishingStates, language="en") ======= =========== ========= ============= ======== value name text Button text public ------- ----------- --------- ------------- -------- 10 draft Draft No 20 ready Ready No 30 published Public Yes 40 removed Removed No ======= =========== ========= ============= ========
- class lino.modlib.publisher.PageFillers¶
A choicelist with the page fillers that are available for this application.
A page filler is a hard-coded method to produce dynamic web content.
>>> rt.show(publisher.PageFillers, language="en") ========================= ====== ========================= ========================= value name text Data table ------------------------- ------ ------------------------- ------------------------- blogs.LatestEntries blogs.LatestEntries blogs.LatestEntries comments.RecentComments comments.RecentComments comments.RecentComments ========================= ====== ========================= =========================
- class lino.modlib.publisher.SpecialPages¶
A choicelist with the special pages available on this site.
>>> rt.show(publisher.SpecialPages, language="en") =========== ====================== ====================================== name text Pages ----------- ---------------------- -------------------------------------- home Home `en <…>`__ | `de <…>`__ | `fr <…>`__ terms Terms and conditions `en <…>`__ | `de <…>`__ | `fr <…>`__ privacy Privacy policy `en <…>`__ | `de <…>`__ | `fr <…>`__ cookies Cookie settings `en <…>`__ | `de <…>`__ | `fr <…>`__ copyright Copyright `en <…>`__ | `de <…>`__ | `fr <…>`__ about About us `en <…>`__ | `de <…>`__ | `fr <…>`__ =========== ====================== ======================================
Configuration¶
- publisher.locations¶
A tuple of 2-tuples (loc, cls) where loc is a location string and cls a data table.
>>> pprint(dd.plugins.publisher.locations) (('b', lino_xl.lib.blogs.models.LatestEntries), ('p', lino.modlib.publisher.ui.Pages), ('r', lino.modlib.uploads.models.Uploads), ('s', lino_xl.lib.sources.models.Sources), ('t', lino_xl.lib.topics.models.Topics), ('u', lino.modlib.users.ui.Users))
When setting this setting (usually in a
get_plugin_configs()
method), the application developer should specify the data tables using their names. The above locations have been set inlino_cms.lib.cms.settings
as follows:yield ('publisher', 'locations', ( ('b', 'blogs.LatestEntries'), ('p', 'publisher.Pages'), ('t', 'topics.Topics'), ('u', 'users.Users')))