annotate sat/__init__.py @ 2671:0fa217fafabf

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
author Goffi <goffi@goffi.org>
date Mon, 10 Sep 2018 08:58:18 +0200
parents 20bf6887d1ed
children 003b8b4b56a7
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2571
4aca060075b7 setup: version is now set in SAT/VERSION, sat is not imported anymore in setup
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
1 #!/usr/bin/env python2
4aca060075b7 setup: version is now set in SAT/VERSION, sat is not imported anymore in setup
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
2 # -*- coding: utf-8 -*-
4aca060075b7 setup: version is now set in SAT/VERSION, sat is not imported anymore in setup
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
3
4aca060075b7 setup: version is now set in SAT/VERSION, sat is not imported anymore in setup
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
4 # SàT: a XMPP client
4aca060075b7 setup: version is now set in SAT/VERSION, sat is not imported anymore in setup
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
5 # Copyright (C) 2009-2018 Jérôme Poisson (goffi@goffi.org)
4aca060075b7 setup: version is now set in SAT/VERSION, sat is not imported anymore in setup
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
6
4aca060075b7 setup: version is now set in SAT/VERSION, sat is not imported anymore in setup
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
7 # This program is free software: you can redistribute it and/or modify
4aca060075b7 setup: version is now set in SAT/VERSION, sat is not imported anymore in setup
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
8 # it under the terms of the GNU Affero General Public License as published by
4aca060075b7 setup: version is now set in SAT/VERSION, sat is not imported anymore in setup
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
9 # the Free Software Foundation, either version 3 of the License, or
4aca060075b7 setup: version is now set in SAT/VERSION, sat is not imported anymore in setup
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
10 # (at your option) any later version.
1470
8bfbf5cb0e28 core: moved __version__ to __init__.py, so we can check version by doing "import sat;print(sat.__version__)"
Goffi <goffi@goffi.org>
parents: 224
diff changeset
11
2571
4aca060075b7 setup: version is now set in SAT/VERSION, sat is not imported anymore in setup
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
12 # This program is distributed in the hope that it will be useful,
4aca060075b7 setup: version is now set in SAT/VERSION, sat is not imported anymore in setup
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
4aca060075b7 setup: version is now set in SAT/VERSION, sat is not imported anymore in setup
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
4aca060075b7 setup: version is now set in SAT/VERSION, sat is not imported anymore in setup
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
15 # GNU Affero General Public License for more details.
4aca060075b7 setup: version is now set in SAT/VERSION, sat is not imported anymore in setup
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
16
4aca060075b7 setup: version is now set in SAT/VERSION, sat is not imported anymore in setup
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
17 # You should have received a copy of the GNU Affero General Public License
4aca060075b7 setup: version is now set in SAT/VERSION, sat is not imported anymore in setup
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
18 # along with this program. If not, see <http://www.gnu.org/licenses/>.
4aca060075b7 setup: version is now set in SAT/VERSION, sat is not imported anymore in setup
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
19 import os.path
4aca060075b7 setup: version is now set in SAT/VERSION, sat is not imported anymore in setup
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
20
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2607
diff changeset
21 version_file = os.path.join(os.path.dirname(__file__), "VERSION")
2607
4c086cf7af66 core (version): added workaround for Pyjamas, avoiding crash when reading VERSION
Goffi <goffi@goffi.org>
parents: 2571
diff changeset
22 try:
4c086cf7af66 core (version): added workaround for Pyjamas, avoiding crash when reading VERSION
Goffi <goffi@goffi.org>
parents: 2571
diff changeset
23 with open(version_file) as f:
4c086cf7af66 core (version): added workaround for Pyjamas, avoiding crash when reading VERSION
Goffi <goffi@goffi.org>
parents: 2571
diff changeset
24 __version__ = f.read().strip()
4c086cf7af66 core (version): added workaround for Pyjamas, avoiding crash when reading VERSION
Goffi <goffi@goffi.org>
parents: 2571
diff changeset
25 except NotImplementedError:
4c086cf7af66 core (version): added workaround for Pyjamas, avoiding crash when reading VERSION
Goffi <goffi@goffi.org>
parents: 2571
diff changeset
26 # pyjamas workaround
2665
20bf6887d1ed core: minor version fix for pyjamas workaround
Goffi <goffi@goffi.org>
parents: 2624
diff changeset
27 __version__ = "0.7.0D"