Welcome | Get started | Dive | Contribute | Topics | Reference | Changes | More

blogs : Blogging functionality

The lino_xl.lib.blogs plugin adds blogging functionality.

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 *

Which means that code snippets in this document are tested using the lino_book.projects.noi2 demo project.

class lino_xl.lib.blogs.Blog

The Django model to represent a blog.

class lino_xl.lib.blogs.Entry

The Django model to represent a blog entry.

pub_date

The publication date.

user

The author.

blog

The blog to which this entry belongs.

This is a foreign key pointing to Blog.

title
body

Blog

>>> obj = blogs.Entry.objects.get(id=2)
>>> obj.body_short_preview
...
'<img src="/media/thumbs/uploads/2024/05/crossroads.jpg"  title="Crossroads,
Kilham West Field - geograph.org.uk - 2097672 (Source: Crossroads, Kilham West
Field by Christine Johnstone)"
style="max-height:10em;max-width:10em;width:auto;height:auto;padding:1pt;"/>Let\'s
choose one or the other of the either roads (or NOT)! And the hesitation, does
it comes rarely(?), Nooo!, we are very frequently and suddenly put to situations
where we must choose between roads. Of course, how to choose and what to choose
are the questions. But did we ever a...'

When a blog entry is rendered as a list item, the whole thing is clickable and leads to the page of that individual blog entry. The list_style argument not yet stable, currently it is used to compute the heading level.

>>> ar = rt.login("robin")
>>> print(beautiful_soup(obj.as_list_item(ar, list_style=1)).prettify())
...
<html>
 <body>
  <a href="…" style="text-decoration:none;color:inherit;">
   <h3>
    At the fork of the cross roads
   </h3>
   <p style="font-size:70%;font-style:oblique;">
    Published 2024-05-12 by Luc
   </p>
   <div>
    <p style="text-align:justify;">
     <img src="/media/thumbs/uploads/2024/05/crossroads.jpg" style="max-height:10em;max-width:10em;width:auto;height:auto;padding:1pt;" title="Crossroads, Kilham West Field - geograph.org.uk - 2097672 (Source: Crossroads, Kilham West Field by Christine Johnstone)"/>
     Let's choose one or the other of the either roads (or NOT)! And the hesitation, does it comes rarely(?), Nooo!, we are very frequently and suddenly put to situations where we must choose between roads. Of course, how to choose and what to choose are the questions. But did we ever a...
    </p>
   </div>
  </a>
 </body>
</html>