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 root_page language", display_mode="grid")
===== =============================== =============== ==========
ID Title Root page Language
----- ------------------------------- --------------- ----------
1 Home en
2 হোম bn
3 Startseite de
4 About us Home en
5 About us হোম bn
6 Über uns Startseite de
7 Terms and conditions Home en
8 Terms and conditions হোম bn
9 Allgemeine Geschäftsbediungen Startseite de
10 Privacy policy Home en
11 Privacy policy হোম bn
12 Datenschutz Startseite de
13 Cookie settings Home en
14 Cookie settings হোম bn
15 Cookie settings Startseite de
16 Copyright Home en
17 Copyright হোম bn
18 Autorenrecht Startseite de
19 Root pages Home en
20 Root pages হোম bn
21 Root pages Startseite de
22 Blog Home en
23 Blog হোম bn
24 Blog Startseite de
25 Calendar Home en
26 Calendar হোম bn
27 Kalender Startseite de
28 Laundry en
29 Services Laundry en
30 Washing Laundry en
31 Drying Laundry en
32 Air drying Laundry en
33 Machine drying Laundry en
34 Drying foos Laundry en
35 Drying bars Laundry en
36 Drying bazes Laundry en
37 Ironing Laundry en
38 Prices Laundry en
39 Photos Laundry en
40 Referring to database content Laundry en
41 New formatting Laundry en
42 Default formatting Laundry en
43 Default formatting Laundry en
44 Thumbnail Laundry en
45 Thumbnail left Laundry en
46 Tiny thumbnail Laundry en
47 Tiny thumbnail left Laundry en
48 Wide Laundry en
49 Gallery Laundry en
50 About us Laundry en
51 Team Laundry en
52 History Laundry en
53 Contact Laundry en
54 Terms & conditions Laundry en
55 Laundry bn
56 Services Laundry bn
57 Washing Laundry bn
58 Drying Laundry bn
59 Air drying Laundry bn
60 Machine drying Laundry bn
61 Drying foos Laundry bn
62 Drying bars Laundry bn
63 Drying bazes Laundry bn
64 Ironing Laundry bn
65 Prices Laundry bn
66 Photos Laundry bn
67 Referring to database content Laundry bn
68 New formatting Laundry bn
69 Default formatting Laundry bn
70 Default formatting Laundry bn
71 Thumbnail Laundry bn
72 Thumbnail left Laundry bn
73 Tiny thumbnail Laundry bn
74 Tiny thumbnail left Laundry bn
75 Wide Laundry bn
76 Gallery Laundry bn
77 About us Laundry bn
78 Team Laundry bn
79 History Laundry bn
80 Contact Laundry bn
81 Terms & conditions Laundry bn
82 Laundry de
83 Dienstleistungen Laundry de
84 Washing Laundry de
85 Drying Laundry de
86 Air drying Laundry de
87 Machine drying Laundry de
88 Drying foos Laundry de
89 Drying bars Laundry de
90 Drying bazes Laundry de
91 Ironing Laundry de
92 Prices Laundry de
93 Photos Laundry de
94 Referring to database content Laundry de
95 New formatting Laundry de
96 Default formatting Laundry de
97 Default formatting Laundry de
98 Thumbnail Laundry de
99 Thumbnail left Laundry de
100 Tiny thumbnail Laundry de
101 Tiny thumbnail left Laundry de
102 Wide Laundry de
103 Gallery Laundry de
104 Über uns Laundry de
105 Team Laundry de
106 History Laundry de
107 Kontakt Laundry de
108 Nutzungsbestimmungen Laundry de
109 Flying Circus en
110 Places Flying Circus en
111 Programme Flying Circus en
112 Mission Flying Circus en
113 Blog Flying Circus en
114 Comments Flying Circus en
115 About us Flying Circus en
116 Team Flying Circus en
117 History Flying Circus en
118 Contact Flying Circus en
119 Terms & conditions Flying Circus en
120 Flying Circus bn
121 স্থান Flying Circus bn
122 Programme Flying Circus bn
123 Mission Flying Circus bn
124 Blog Flying Circus bn
125 Comments Flying Circus bn
126 About us Flying Circus bn
127 Team Flying Circus bn
128 History Flying Circus bn
129 Contact Flying Circus bn
130 Terms & conditions Flying Circus bn
131 Flying Circus de
132 Orte Flying Circus de
133 Programme Flying Circus de
134 Mission Flying Circus de
135 Blog Flying Circus de
136 Kommentare Flying Circus de
137 Über uns Flying Circus de
138 Team Flying Circus de
139 History Flying Circus de
140 Kontakt Flying Circus de
141 Nutzungsbestimmungen Flying Circus de
142 FlyingCon Home en
143 Cascaded Continuous Voting Home en
144 Liquid democracy Home en
145 Digital vs analog Home en
146 Software should be free Home en
147 Synodality Home en
===== =============================== =============== ==========
>>> rt.show('publisher.RootPages', column_names="id title", display_mode="grid")
===== ===============
ID Title
----- ---------------
1 Home
28 Laundry
109 Flying 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 the corresponding page in German:
>>> publisher.Page.objects.get(pk=1).language
'en'
>>> publisher.Page.objects.get(pk=3).language
'de'
>>> test_client.get("/p/1?ul=de")
<HttpResponseRedirect status_code=302, "text/html; charset=utf-8", url="/p/3?ul=de">
But there is no redirect when asking with ul=de for a page that is already German:
>>> 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 About us Home
7 Terms and conditions About us
10 Privacy policy Terms and conditions
13 Cookie settings Privacy policy
16 Copyright Cookie settings
19 Root pages Copyright
22 Blog Root pages
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 Calendar
143 Cascaded Continuous Voting FlyingCon
144 Liquid democracy Cascaded Continuous Voting
145 Digital vs analog Liquid democracy
146 Software should be free Digital vs analog
147 Synodality Software should be free
===== =============================== ===============================
Classes reference¶
- class lino.modlib.publisher.Page¶
The Django model that represents a content page.
Inherits from
PublishableContent
,TranslatableContent
.- title¶
- body¶
- language¶
- parent¶
- seqno¶
- root_page¶
The page that defines the top of the menu tree containing this page.
- special_page¶
If this page implements a “special page”, then this field points to a choice in
SpecialPages
.
- pub_date¶
- pub_time¶
- publishing_state¶
See
PublishingStates
- 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.PublisherBuildMethod¶
This deserves better documentation. Maybe useless.
- 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 <…>`__ about About us `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 <…>`__ roots roots `en <…>`__ | `bn <…>`__ | `de <…>`__ blog blog `en <…>`__ | `bn <…>`__ | `de <…>`__ events events `en <…>`__ | `bn <…>`__ | `de <…>`__ =========== ====================== ======================================
Configuration¶
- lino.modlib.publisher.with_trees¶
Whether this site supports multiple publisher trees.
- 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), ('r', lino.modlib.publisher.ui.RootPages), ('p', lino.modlib.publisher.ui.Pages), ('f', lino.modlib.uploads.ui.Uploads), ('s', lino_xl.lib.sources.models.Sources), ('e', lino_xl.lib.cal.ui.UpcomingEvents), ('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.