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.
Named pages¶
Named pages are pages with a user-given name in their Page name field. If this field is not empty, the page will have this name instead of its primary key in the url.
lino.core.actors.Actor.get_row_by_pk() uses a new class attribute
unique_keys, which defaults to ['id'], and on
lino.modlib.publisher.Pages it is overridden to ['id', 'ref']. And
a method lino.modlib.publisher.Publishable.get_publisher_pk(), which for
Pages returns self.ref or str(self.pk).
Root pages¶
>>> rt.show('publisher.RootPages', column_names="id title", display_mode="grid")
===== ===============
ID Title
----- ---------------
1 Home
28 Songbook
30 Laundry
111 Flying Circus
===== ===============
Note that the “New songbook” page is not listed. That’s because this page is in draft state:
>>> publisher.Page.objects.get(title="New songbook").publishing_state
<publisher.PublishingStates.draft:10>
You can see it only when you are authenticated as an OfficeStaff:
>>> ar = rt.login('robin')
>>> ar.show('publisher.RootPages', column_names="id title", display_mode="grid")
===== ===============
ID Title
----- ---------------
1 Home
28 Songbook
29 New songbook
30 Laundry
111 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/home?ul=de">
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:
>>> ar.show('publisher.Pages', display_mode="grid", language="en",
... column_names="id title language root_page previous_page")
...
===== =============================== ========== =============== ===============================
ID Title Language Root page Previous page
----- ------------------------------- ---------- --------------- -------------------------------
1 Home en
2 হোম bn
3 Startseite de
4 About us en Home Home
5 About us bn হোম হোম
6 Über uns de Startseite Startseite
7 Terms and conditions en Home About us
8 Terms and conditions bn হোম About us
9 Allgemeine Geschäftsbediungen de Startseite Über uns
10 Privacy policy en Home Terms and conditions
11 Privacy policy bn হোম Terms and conditions
12 Datenschutz de Startseite Allgemeine Geschäftsbediungen
13 Cookie settings en Home Privacy policy
14 Cookie settings bn হোম Privacy policy
15 Cookie settings de Startseite Datenschutz
16 Copyright en Home Cookie settings
17 Copyright bn হোম Cookie settings
18 Autorenrecht de Startseite Cookie settings
19 Root pages en Home Copyright
20 Root pages bn হোম Copyright
21 Root pages de Startseite Autorenrecht
22 Blog en Home Root pages
23 Blog bn হোম Root pages
24 Blog de Startseite Root pages
25 Calendar en Home Blog
26 Calendar bn হোম Blog
27 Kalender de Startseite Blog
28 Songbook en
29 New songbook en
30 Laundry en
31 Services en Laundry Laundry
32 Washing en Laundry Services
33 Drying en Laundry Washing
34 Air drying en Laundry Drying
35 Machine drying en Laundry Air drying
36 Drying foos en Laundry Machine drying
37 Drying bars en Laundry Drying foos
38 Drying bazes en Laundry Drying bars
39 Ironing en Laundry Drying bazes
40 Prices en Laundry Ironing
41 Photos en Laundry Prices
42 Referring to database content en Laundry Photos
43 New formatting en Laundry Referring to database content
44 Default formatting en Laundry New formatting
45 Default formatting en Laundry Default formatting
46 Thumbnail en Laundry Default formatting
47 Thumbnail left en Laundry Thumbnail
48 Tiny thumbnail en Laundry Thumbnail left
49 Tiny thumbnail left en Laundry Tiny thumbnail
50 Wide en Laundry Tiny thumbnail left
51 Gallery en Laundry Wide
52 About us en Laundry Gallery
53 Team en Laundry About us
54 History en Laundry Team
55 Contact en Laundry History
56 Terms & conditions en Laundry Contact
57 Laundry bn
58 Services bn Laundry Laundry
59 Washing bn Laundry Services
60 Drying bn Laundry Washing
61 Air drying bn Laundry Drying
62 Machine drying bn Laundry Air drying
63 Drying foos bn Laundry Machine drying
64 Drying bars bn Laundry Drying foos
65 Drying bazes bn Laundry Drying bars
66 Ironing bn Laundry Drying bazes
67 Prices bn Laundry Ironing
68 Photos bn Laundry Prices
69 Referring to database content bn Laundry Photos
70 New formatting bn Laundry Referring to database content
71 Default formatting bn Laundry New formatting
72 Default formatting bn Laundry Default formatting
73 Thumbnail bn Laundry Default formatting
74 Thumbnail left bn Laundry Thumbnail
75 Tiny thumbnail bn Laundry Thumbnail left
76 Tiny thumbnail left bn Laundry Tiny thumbnail
77 Wide bn Laundry Tiny thumbnail left
78 Gallery bn Laundry Wide
79 About us bn Laundry Gallery
80 Team bn Laundry About us
81 History bn Laundry Team
82 Contact bn Laundry History
83 Terms & conditions bn Laundry Contact
84 Laundry de
85 Dienstleistungen de Laundry Laundry
86 Washing de Laundry Dienstleistungen
87 Drying de Laundry Washing
88 Air drying de Laundry Drying
89 Machine drying de Laundry Air drying
90 Drying foos de Laundry Machine drying
91 Drying bars de Laundry Drying foos
92 Drying bazes de Laundry Drying bars
93 Ironing de Laundry Drying bazes
94 Prices de Laundry Ironing
95 Photos de Laundry Prices
96 Referring to database content de Laundry Photos
97 New formatting de Laundry Referring to database content
98 Default formatting de Laundry New formatting
99 Default formatting de Laundry Default formatting
100 Thumbnail de Laundry Default formatting
101 Thumbnail left de Laundry Thumbnail
102 Tiny thumbnail de Laundry Thumbnail left
103 Tiny thumbnail left de Laundry Tiny thumbnail
104 Wide de Laundry Tiny thumbnail left
105 Gallery de Laundry Wide
106 Über uns de Laundry Gallery
107 Team de Laundry Über uns
108 History de Laundry Team
109 Kontakt de Laundry History
110 Nutzungsbestimmungen de Laundry Kontakt
111 Flying Circus en
112 Places en Flying Circus Flying Circus
113 Programme en Flying Circus Places
114 Mission en Flying Circus Programme
115 Blog en Flying Circus Mission
116 Comments en Flying Circus Blog
117 About us en Flying Circus Comments
118 Team en Flying Circus About us
119 History en Flying Circus Team
120 Contact en Flying Circus History
121 Terms & conditions en Flying Circus Contact
122 Flying Circus bn
123 স্থান bn Flying Circus Flying Circus
124 Programme bn Flying Circus স্থান
125 Mission bn Flying Circus Programme
126 Blog bn Flying Circus Mission
127 Comments bn Flying Circus Blog
128 About us bn Flying Circus Comments
129 Team bn Flying Circus About us
130 History bn Flying Circus Team
131 Contact bn Flying Circus History
132 Terms & conditions bn Flying Circus Contact
133 Flying Circus de
134 Orte de Flying Circus Flying Circus
135 Programme de Flying Circus Orte
136 Mission de Flying Circus Programme
137 Blog de Flying Circus Mission
138 Kommentare de Flying Circus Blog
139 Über uns de Flying Circus Kommentare
140 Team de Flying Circus Über uns
141 History de Flying Circus Team
142 Kontakt de Flying Circus History
143 Nutzungsbestimmungen de Flying Circus Kontakt
144 FlyingCon en Home Calendar
145 Cascaded Continuous Voting en Home FlyingCon
146 Liquid democracy en Home Cascaded Continuous Voting
147 Digital vs analog en Home Liquid democracy
148 Software should be free en Home Digital vs analog
149 Synodality en Home 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), ('i', lino.modlib.publisher.ui.ItemsByPage), ('src', lino_xl.lib.sources.models.Sources), ('sng', lino_xl.lib.songs.ui.LatestSongs), ('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.settingsas 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
noi2demo projectsettings.pyfile.
- 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.