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 page contains code snippets (lines starting with >>>
), which are
being tested during our development workflow. The following
snippet initializes the demo project used throughout this page.
>>> from lino_book.projects.noi2.startup import *
>>> from django.db.models import Q
Content pages¶
- content page¶
The basic building unit of a website or book, consisting of a title and a body.
>>> rt.show('publisher.Pages', column_names="id title publisher_tree", display_mode="grid", filter=Q(parent=None))
===== =============================== =========
ID Title Tree
----- ------------------------------- ---------
1 Home index
2 হোম index
3 Startseite index
4 Terms and conditions index
5 Terms and conditions index
6 Allgemeine Geschäftsbediungen index
7 Privacy policy index
8 Privacy policy index
9 Datenschutz index
10 Cookie settings index
11 Cookie settings index
12 Cookie settings index
13 Copyright index
14 Copyright index
15 Autorenrecht index
16 About us index
17 About us index
18 Über uns index
28 Laundry laundry
55 Laundry laundry
82 Laundry laundry
109 Flying Circus circus
120 Flying Circus circus
131 Flying Circus circus
142 FlyingCon circus
143 Cascaded Continuous Voting circus
144 Liquid democracy circus
145 Digital vs analog circus
146 Software should be free circus
147 Synodality circus
===== =============================== =========
>>> home = publisher.Page.objects.get(pk=1)
>>> rt.show('publisher.TranslationsByPage', master_instance=home)
`⏏ <…>`__ | (bn) `হোম <…>`__, (de) `Startseite <…>`__
>>> rt.show('publisher.TranslationsByPage', master_instance=home, nosummary=True)
============ ========== ====
Title Language ID
------------ ---------- ----
হোম bn 2
Startseite de 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="/?ul=de">
The same happens when I am on the French home page:
>>> test_client.get("/p/3?ul=de")
<HttpResponse status_code=200, "text/html;charset="utf-8"">
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
7 Privacy policy
10 Cookie settings
13 Copyright
16 About us
19 Publisher trees Home
22 Blog Publisher trees
25 Calendar Blog
28 Laundry
29 Services Laundry
30 Washing Services
31 Drying Washing
32 Air drying Drying
33 Machine drying Air drying
34 Drying foos Machine drying
35 Drying bars Drying foos
36 Drying bazes Drying bars
37 Ironing Drying bazes
38 Prices Ironing
39 Photos Prices
40 Referring to database content Photos
41 New formatting Referring to database content
42 Default formatting New formatting
43 Default formatting Default formatting
44 Thumbnail Default formatting
45 Thumbnail left Thumbnail
46 Tiny thumbnail Thumbnail left
47 Tiny thumbnail left Tiny thumbnail
48 Wide Tiny thumbnail left
49 Gallery Wide
50 About us Gallery
51 Team About us
52 History Team
53 Contact History
54 Terms & conditions Contact
109 Flying Circus
110 Places Flying Circus
111 Programme Places
112 Mission Programme
113 Blog Mission
114 Comments Blog
115 About us Comments
116 Team About us
117 History Team
118 Contact History
119 Terms & conditions Contact
142 FlyingCon
143 Cascaded Continuous Voting
144 Liquid democracy
145 Digital vs analog
146 Software should be free
147 Synodality
===== =============================== ===============================
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.SpecialPages¶
A choicelist with the special pages available on this site.
>>> rt.show(publisher.SpecialPages, language="en") =========== ====================== ====================================== name text Pages ----------- ---------------------- -------------------------------------- home Home `en <…>`__ | `bn <…>`__ | `de <…>`__ terms Terms and conditions `en <…>`__ | `bn <…>`__ | `de <…>`__ privacy Privacy policy `en <…>`__ | `bn <…>`__ | `de <…>`__ cookies Cookie settings `en <…>`__ | `bn <…>`__ | `de <…>`__ copyright Copyright `en <…>`__ | `bn <…>`__ | `de <…>`__ about About us `en <…>`__ | `bn <…>`__ | `de <…>`__ pages pages `en <…>`__ | `bn <…>`__ | `de <…>`__ blog blog `en <…>`__ | `bn <…>`__ | `de <…>`__ events events `en <…>`__ | `bn <…>`__ | `de <…>`__ =========== ====================== ======================================
Configuration¶
- lino.modlib.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), ('f', lino.modlib.uploads.ui.Uploads), ('s', lino_xl.lib.sources.models.Sources), ('t', lino_xl.lib.tickets.ui.Tickets), ('tp', lino_xl.lib.topics.models.Topics))
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')))
- lino.modlib.publisher.skin¶
Which skin to use. Default value is ‘boots’.
Currently the only alternative to ‘boots’ is ‘silly’, which is there just to show an alternative. You can see it by activating a line in the
noi2
demo projectsettings.py
file.
- lino.modlib.publisher.use_markup¶
(Deprecated)
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.