Coverage for gws-app/gws/base/application/templates/__init__.py: 100%
0 statements
« prev ^ index » next coverage.py v7.16.2, created at 2026-10-05 13:35 +0200
« prev ^ index » next coverage.py v7.16.2, created at 2026-10-05 13:35 +0200
1"""Standard templates.
3All templates are written in the CX template language and live alongside this
4package. The package contains no code.
6These templates are added to the application templates by default, after the
7configured ones, and can be overridden with custom templates.
8The ``subject`` property of each template is used to identify it, and is documented below.
10Example::
12 templates+ {
13 subject "project.home"
14 type html
15 path "/data/templates/my_project_home.cx.html"
16 }
18Every template receives the following context variables automatically:
20- ``app`` (`gws.Application`) - the running application instance.
21- ``project`` (`gws.Project`) - active project, if any.
22- ``user`` (`gws.User`) - the currently authenticated (or guest) user.
23- ``locale`` (`gws.Locale`) - the active locale, carrying language,
24 number and date formatting helpers.
26Some templates expect additional context variables, which are documented below.
28Localised UI strings are loaded from ``strings.ini`` in this directory and
29exposed to templates as the ``STRINGS`` mapping.
31----
33Complete HTML templates
34-----------------------
36Complete HTML templates render a full ``<!doctype html>`` page and are
37served directly in response to an HTTP request (e.g. the home page).
39``application_home.cx.html`` (subject ``application.home``)
40 The application's root (``/``) page. Displays the application title,
41 optionally a sign-in / sign-out form (when ``app.templateOptions.withLogin``
42 is set), and a list of projects the current user may access.
44 Extra context variable: ``projects`` (list of `gws.Project`) - all projects accessible to the
45 current user.
47``application_error.cx.html`` (subject ``application.error``)
48 Rendered whenever a request results in an HTTP error. Picks an
49 appropriate heading and message from ``STRINGS`` based on the status code.
51 Extra context variable: ``status`` (``int``) - the HTTP status code (e.g. ``404``, ``500``).
53``project_home.cx.html`` (subject ``project.home``)
54 The shell page that bootstraps the interactive map viewer for a specific
55 project. Outputs a minimal HTML skeleton and embeds ``projectUid`` and
56 ``localeUid`` as a JSON block so the JavaScript application can
57 initialise itself.
59 Extra context variable: ``projects`` (list of `gws.Project`) - all projects accessible to the
60 current user (available for custom navigation).
62``project_print.cx.html`` (attached to the default printer object)
63 A print-ready A4-landscape layout used when the user exports the current
64 map view. Renders the project title, a full-bleed map area (``@map``),
65 and a legend panel (``@legend``).
67Feature templates
68-----------------
70Feature templates that render specific aspects of a map feature.
71They receive a ``feature`` context variable (``gws.Feature``) in addition to the standard context variables.
72Additionally, feature attributes are available as context variables.
74``feature_description.cx.html`` (subject ``feature.description``)
75 An HTML ``<table>`` listing all attributes of a feature.
77``feature_label.cx.html`` (subject ``feature.label``)
78 A brief inline label rendered next to a feature on the map (e.g. inside
79 an SVG text element or a map overlay).
81``feature_title.cx.html`` (subject ``feature.title``)
82 A short display title for a feature, used in pop-ups and result lists.
84Other templates
85---------------
87``layer_description.cx.html`` (subject ``layer.description``)
88 An info panel for a map layer.
90 Extra context variable: ``layer`` (`gws.Layer`) - the layer being described.
92``project_description.cx.html`` (subject ``project.description``)
93 An info panel for a project.
95Support files
96-------------
98``parts.cx.html``
99 Defines shared macros used by application templates above.
100 These macros can also be used in custom templates to ensure consistent layout and behaviour.
102``strings.ini``
103 Localised UI strings for the home and error pages, keyed by locale.
105``home.css`` / ``home.js``
106 Static assets bundled with the home page.
108Template options
109----------------
111The behaviour of the standard templates is controlled by `gws.TemplateOptions`,
112configured in the ``templateOptions`` property of the application config and
113available to every template as ``app.templateOptions``:
115``withLogin`` (``bool``)
116 Render the sign-in / sign-out form on the application home page.
117 Defaults to ``true`` if the `auth` action is configured.
119``footerText`` (``str``)
120 Text for the footer of the application home page. May contain HTML,
121 which is inserted as is. The footer is only rendered if this option is set.
123``withGws`` (``bool``)
124 Render the GWS logo, linking to the GBD WebSuite website, in the footer
125 of the application home page. Defaults to ``true``. Requires ``footerText``,
126 since the footer is not rendered without it.
128``homeResources`` (list of ``str``)
129 Additional resource URLs injected into the ``<head>`` of the application
130 home page.
132``projectResources`` (list of ``str``)
133 Additional resource URLs injected into the ``<head>`` of the project home
134 page.
136If resources are not configured and the file ``style.css`` exists
137in the static root of the web site,
138``/style.css`` is used as the default resource.
139"""