Commit graph libervia-backend/sat/tools/common/template.py
Author SHA1 Message Date
Goffi
820fa05d49 tools (common/template): use to_json instead of json + added missing args to date_fmt 2020-07-16 09:07:26 +02:00
Goffi
4b0d91cb2e common (template): better json dumping:
default method is set for json dumping (the `tojson` filter), if the object has a `json`
attribute, it will be called, otherwise it is replaced by None, this avoids crash when
rendering the template.
2020-06-19 15:45:57 +02:00
Goffi
205bd5cdb4 tools (common/template): new icon_from_client method:
this method is available from template, and returns the name of the icon to use according
to disco client data.
2020-05-18 23:41:36 +02:00
Goffi
19a9e38983 tools (common/template): theme settings with possibility to disable default fallback for CSS:
- themes can now have a `settings.json` file at their root to modify the renderer
  behaviour
- the `css_default_fallback` boolean (true by default) can be used to disable the fallback
  mechanism when CSS files are checked. Useful when a theme doesn't follow the CSS naming of
  default theme.
- introduced some type hints
2020-05-03 17:01:39 +02:00
Goffi
2908be8898 tools (common/template): typos 2020-05-03 13:40:04 +02:00
Goffi
3f735d406e tools (common/template): list themes and parse their browser data, available through new getThemesData method 2020-05-01 16:26:39 +02:00
Goffi
e1a44cf4e4 fixed shebangs 2020-01-29 10:07:00 +01:00
Goffi
a39349fe64 dates update 2020-01-29 09:50:54 +01:00
Goffi
ed73fd8bf8 tools (common/template): removed warning catches, jinja2>=2.10.3 now handles them correctly 2019-10-18 17:51:44 +02:00
Goffi
e87c07b200 common (template): suppress jinja2 depreaction warning (to be removed once 2.10.1 is released) 2019-09-25 08:41:36 +02:00
Goffi
fbfe96c505 Python 3 port:
/!\ this is a huge commit
/!\ starting from this commit, SàT is needs Python 3.6+
/!\ SàT maybe be instable or some feature may not work anymore, this will improve with time

This patch port backend, bridge and frontends to Python 3.

Roughly this has been done this way:

- 2to3 tools has been applied (with python 3.7)
- all references to python2 have been replaced with python3 (notably shebangs)
- fixed files not handled by 2to3 (notably the shell script)
- several manual fixes
- fixed issues reported by Python 3 that where not handled in Python 2
- replaced "async" with "async_" when needed (it's a reserved word from Python 3.7)
- replaced zope's "implements" with @implementer decorator
- temporary hack to handle data pickled in database, as str or bytes may be returned,
  to be checked later
- fixed hash comparison for password
- removed some code which is not needed anymore with Python 3
- deactivated some code which needs to be checked (notably certificate validation)
- tested with jp, fixed reported issues until some basic commands worked
- ported Primitivus (after porting dependencies like urwid satext)
- more manual fixes
2019-08-13 19:08:41 +02:00
Goffi
0edb94b0a2 tools (common/template): fixed theme parsing when there is no "/" in parenthesis 2019-05-25 15:13:35 +02:00
Goffi
bc061ee885 template (filters): set locale when using "date_fmt" 2019-04-14 08:21:51 +02:00
Goffi
e1ff10bf77 template (i18n): activate ext.i18n.trimmed policy, to have clean translation strings. Set minimal jinja2 version to 2.10 2019-04-14 08:21:51 +02:00
Goffi
4ab939c46a template: added "locales" variables to templates:
"locales" contains an ordered tuple of locales of all available translations. This can be used by templates to diplay language/locale menu.
2019-04-10 21:04:51 +02:00
Goffi
c83ac61e1d tools (common/template): always use highlight.css if present. 2019-03-25 18:40:11 +01:00
Goffi
8e338bf913 date update 2019-01-12 12:25:31 +01:00
Goffi
bcab68049a template: better css files order 2018-10-03 20:38:10 +02:00
Goffi
2d37dc64e9 template: fixed by variable used in css_files_noscript 2018-09-27 08:50:38 +02:00
Goffi
1887d4d733 template: overriden get_template to always have full template name:
Environment.get_template has been overriden to have always full template name (i.e. template with (site/theme) prefix or absolute template).
This is needed to correctly handle cache, so "base/base.html" is converted to "(some_site/some_theme)base/base.html" and won't conflict with an other theme "base/base.html".
2018-09-18 20:59:34 +02:00
Goffi
0a7a2a0902 template: import contextfilter as module attribute 2018-09-18 20:55:58 +02:00
Goffi
e70405cfc2 tools (common/template), jp: refactoring to handle multiple sites:
- site can now be specified in template header before theme, for instance: (some_site/some_theme)path/to/template.ext
- absolute template paths are now implemented, but Renderer must be instanciated with trusted to True for security reason (it's the case for jp)
- a new "front_url_filter" callable can be given to Renderer, which will convert template path to URL seen by end-user (default to real path).
- the "front_url_filter" can be used in templates with… "front_url" filter
- template_data is a new named tuple available in templates, which give site, theme and template relative URL
- search order is site/theme, site/default_theme, and default/default_theme where default link to sat_pubsub templates
- when loading CSS files, files with _noscript suffixes are now loaded, and used when javascript is not available
- "styles_extra.css" is also loaded before "styles.css", useful when a theme want to reuse default style, and just override some rules
- new site can be specified in sat.conf [DEFAULT] section, using sites_path_public_dict or sites_path_private_dict (where sites_path_private_dict won't be used in public frontends, like Libervia)
- "private" argument of Renderer tells the renderer to load private sites or not
- templates are now loaded from "templates" subdirectory, to differenciate them from other data like i18n
- jp template output has been updated to handle those changes, and to manage absolute templates
2018-09-10 08:58:18 +02:00
Goffi
744cb0c503 code style reformatting using black 2018-06-27 20:14:46 +02:00
Goffi
785af76bc0 tools (common): moved date_fmt function from template filters to new date_utils module, so it can be used everywhere. 2018-06-01 12:04:06 +02:00
Goffi
80ef13612b core, setup: huge cleaning:
- moved directories from src and frontends/src to sat and sat_frontends, which is the recommanded naming convention
- move twisted directory to root
- removed all hacks from setup.py, and added missing dependencies, it is now clean
- use https URL for website in setup.py
- removed "Environment :: X11 Applications :: GTK", as wix is deprecated and removed
- renamed sat.sh to sat and fixed its installation
- added python_requires to specify Python version needed
- replaced glib2reactor which use deprecated code by gtk3reactor

sat can now be installed directly from virtualenv without using --system-site-packages anymore \o/
2018-04-02 19:44:50 +02:00
Renamed from src/tools/common/template.py (Browse further)