Themes for Libervia/en

De Goffiwiki
Aller à : navigation, rechercher

Libervia 0.6 introduced the use of Jinja2 templates and the ability to define your own HTML themes. A Jinja2 template is an HTML file with placeholders and a bit of logic for doing some loops and tests. It is processed together with a context (a set of attributes) that you pass to it. It looks very much like Django's syntax.

For now it only works with the static blog page, later we will make it possible to change the whole Libervia's display via your theme.

Theme structure

A theme is a directory that will be stored by default in /usr/share/libervia/themes or /usr/local/share/libervia/themes (depending of your distribution). Note that this directory must contain an file.

Libervia is shipped with at least one default theme that is called default.

Within a theme's directory, there are the following files and sub-directories:

  • images containing your theme images
  • styles containing your theme CSS files
  • static_blog.html is the Jinja2 template for the static blog page

Templates' contexts

For general information about Jinja2 templates, check the official website[1].

This page gives specific-only information about the contexts that are passed to Libervia's templates.

Context attributes and naming conventions

The attributes that are passed with the context can be of any type. Here some user-defined types that we use for Libervia, and their own attributes (when not specified, the attribute's type is always unicode):

attribute type description
url URL
style CSS classname
text text to display
attribute type description
url URL
alt alternative text to display
attribute type description
style CSS classname
date publication date
url URL of the message's static page
comments list of msg
comments_text textual information about the comments (e.g: "3 comments")
all_comments_link link to display all the comments
attribute type description
later_message link to display the later message (only one)
later_messages link to display the later messages (the next page)
older_message link to display the older message (only one)
older_messages link to display the older messages (the previous page)

Attributes names that are not of type unicode should use a suffix to indicate the actual type, like in comments_link that is of type link. But we sometimes prefer to not surcharge the attribute name, like in comments - in that case this documentation will explicitly inform you about the actual type.

Context for the static blog

The following attributes are passed to the Jinja2 template static_blog.html:

attribute type description
keywords HTML meta keywords
description HTML meta description
base_url URL of the blog page, e.g
styles URL of the styles directory containing your CSS files, e.g
favicon URL of the favicon (user avatar)
title page title
banner_img img the blog's banner (user avatar if no banner has been defined by the user)
navlinks navlinks
messages list of msg