Skip to content

Commit 99f6947

Browse files
authored
Merge pull request #1419 from GeotrekCE/mfu-improve-doc
[Documentation] Add main section blocks in homepage and widget examples
2 parents 6cf57fe + 460c0d2 commit 99f6947

8 files changed

Lines changed: 150 additions & 76 deletions

File tree

β€Ždocs/changelog.mdβ€Ž

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Changelog
22

3+
## 3.25.2+dev (XXXX-XX-XX)
4+
5+
**Documentation**
6+
7+
- Add main section blocks in homepage and widget examples (#1419)
8+
39
## 3.25.2 (2025-06-23)
410

511
**✨ Improvements**

β€Ždocs/customization/customization-htmlscripts.mdβ€Ž

Lines changed: 106 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
## HTML templates
44

5-
You can include some HTML parts in different sections of the layout application.
6-
These templates can be translated by using the language code as a suffix (e.g. `homeTop-en.html` will be rendered only for the English interface). The application tries to find the localized template first, otherwise it tries the non-localized template, otherwise it displays nothing.
5+
You can include some HTML parts in different sections of the layout application.
6+
These templates can be translated by using the language code as a suffix (e.g. `homeTop-en.html` will be rendered only for the English interface). The application tries to find the localized template first, otherwise it tries the non-localized template, otherwise it displays nothing.
77

88
!!! note
99

@@ -27,11 +27,11 @@ See examples in [customization file](https://github.com/GeotrekCE/Geotrek-rando-
2727

2828
You can create your own templates to display practical information or widgets in different parts of the details page. There are 3 steps to follow:
2929

30-
1. Create a new file suffixed with `.html` in `customization/html/details/` (e.g. `example.html`) and fill the the content with html tags
30+
**Step 1:** Create a new file suffixed with `.html` in `customization/html/details/` (e.g. `example.html`) and fill the the content with html tags
3131

32-
```html
33-
<div>The id of this {{ type }} is {{ id }}</div>
34-
```
32+
```html
33+
<div>The id of this {{ type }} is {{ id }}</div>
34+
```
3535

3636
You can define variables in "mustache templates" (meaning between brackets `{{ variable }}`) that will be converted once rendered. For the moment, there are 4 variables available:
3737

@@ -40,47 +40,68 @@ You can define variables in "mustache templates" (meaning between brackets `{{ v
4040
- The code of the (departure) city `{{ cityCode }}`: useful for widgets such as forecast.
4141
- The language code `{{ language }}` The current language of the page.
4242

43-
When choosing a template name, care must be taken not to select a reserved name used by sections defined by the application (e.g `presentation`, see [example](https://github.com/GeotrekCE/Geotrek-rando-v3/blob/main/frontend/config/details.json)).
44-
If you do, the customized template will not be displayed.
45-
46-
2. Copy the template name without the `.html` suffix into the `customization/html/details.json` file.
47-
For example I want to display it in treks and outdoor sites details page:
48-
49-
```json
50-
{
51-
"sections": {
52-
"trek": [
53-
{
54-
"name": "example",
55-
"display": true,
56-
"anchor": true,
57-
"order": 11
58-
}
59-
],
60-
"outdoorSite": [
61-
{
62-
"name": "example",
63-
"display": true,
64-
"anchor": true,
65-
"order": 11
66-
}
67-
]
68-
}
69-
}
70-
```
71-
72-
3. Copy the section title/anchor into the translations files.
73-
For example in `customization/translations/en.json`:
74-
```json
75-
{
76-
"details": {
77-
"example": "My example"
78-
}
79-
}
80-
```
81-
82-
You can take a look at `customization/html/details/forecastWidget.html` which shows the implementation.
83-
By default the "forecast widget" is enabled for all content types; if you want to remove it, you need to write it explicitly in the `customization/html/details.json` file.
43+
When choosing a template name, care must be taken not to select a reserved name used by sections defined by the application (e.g `presentation`, see [example](https://github.com/GeotrekCE/Geotrek-rando-v3/blob/main/frontend/config/details.json)).
44+
If you do, the customized template will not be displayed.
45+
46+
**Step 2:** Copy the template name without the `.html` suffix into the `customization/html/details.json` file.
47+
For example I want to display it in treks and outdoor sites details page:
48+
49+
```json
50+
{
51+
"sections": {
52+
"trek": [
53+
{
54+
"name": "example",
55+
"display": true,
56+
"anchor": true,
57+
"order": 11
58+
}
59+
],
60+
"outdoorSite": [
61+
{
62+
"name": "example",
63+
"display": true,
64+
"anchor": true,
65+
"order": 11
66+
}
67+
]
68+
}
69+
}
70+
```
71+
72+
**Step 3:**. Copy the section title/anchor into the translations files.
73+
For example in `customization/translations/en.json`:
74+
75+
```json
76+
{
77+
"details": {
78+
"example": "My example"
79+
}
80+
}
81+
```
82+
83+
#### Widgets examples
84+
85+
You can embed third-party widgets into Geotrek-rando detail pages by adding their HTML code in the appropriate **`customization.html/details/`** subfolder.
86+
87+
The widget can exploit data from the geotrek page to customize the displayed information (departure city, trek geometry, trek name, etc.).
88+
89+
Here is some examples but there is a lot more that can be done, your imagination is your limit !
90+
91+
##### **Weather Forecast (MΓ©tΓ©o-France)**
92+
93+
!!! tip "This widget exists by default in Geotrek-rando"
94+
95+
![weather-widget](../img/widget-meteofrance.png)
96+
97+
**File location:**
98+
`customization.html/details/forecastWidget.html` ([see code](https://github.com/GeotrekCE/Geotrek-rando-v3/blob/main/frontend/customization/html/details/forecastWidget.html))
99+
100+
**Widget page:** [MΓ©tΓ©o-France Widgets](https://meteofrance.com/widgets)
101+
102+
!!! note
103+
104+
By default the **forecast widget** is enabled for all content types; if you want to remove it, you need to write it explicitly in the `customization/html/details.json` file.
84105

85106
```json
86107
{
@@ -119,14 +140,41 @@ By default the "forecast widget" is enabled for all content types; if you want t
119140
}
120141
```
121142

143+
##### **Air Quality (Atmo)**
144+
145+
![air-quality-widget](../img/widget-atmo.png)
146+
147+
**Configuration** [Check this comment](https://github.com/GeotrekCE/Geotrek-rando-v3/issues/914#issuecomment-1779758757)
148+
149+
##### **Sustainable transport route planner**
150+
151+
Multiple widgets can be added to help citizens plan their trip using sustainable transports. Here is some examples but we advise you to look for local solutions, there is a good chance your country / state / city may have an existing widget that you can integrate on your website.
152+
153+
- [SNCF Connect widget (train)](https://www.sncf-connect.com/outils/widget)
154+
- [Regional public transportation (Occitanie State)](https://www.lio-occitanie.fr/actualites/widget-lio/)
155+
- [Regional public transportation (Auvergne RhΓ΄ne Alpes state)](https://sim.oura.com/fr/cobranding/demo/trip-planner)
156+
- [CarSharing platforms (example with Blablacar)](https://blog.fr.blablacar.be/blablalife/lp/widgets)
157+
158+
**Example with local public transportation route planner**
159+
160+
![lio-widget](../img/widget-lio.png)
161+
162+
##### **Meteorology risk prevention**
163+
164+
A lot of data could be added. Some widgets already exists, other could be created and could help users get information about :
165+
166+
- [Fire hazard level (example in Quebec)](https://www.sopfeu.qc.ca/widget/)
167+
- Avalanche risks
168+
- Flooding alerts
169+
122170
## External scripts
123171

124172
You can inject additional scripts into your app by creating the following files:
125173

126174
- `customization/html/scriptsHeader.html`: scripts injected in the `<head>` of the document.
127175
- `customization/html/scriptsFooter.html`: scripts injected just before the `</body>` end tag.
128176

129-
The scripts templates are intended for third party scripts. Unlike the HTML parts, there is not possibility of translations.
177+
The scripts templates are intended for third party scripts. Unlike the HTML parts, there is not possibility of translations.
130178

131179
Within each of these templates you need you can write one or more `<script>` tags.
132180

@@ -158,34 +206,34 @@ If you need to execute the script on every page change you need to attach an eve
158206

159207
If you want to display articles from another website, you can do so using custom HTML templates.
160208

161-
**Demo Screenshot**
162-
209+
**Demo Screenshot**
210+
163211
![image](https://github.com/GeotrekCE/Geotrek-rando-v3/assets/1926041/f3e8518f-6a74-4647-b485-a8eefeca8796)
164212

165213
**JSON Feed**
166214

167215
To retrieve data from another website, the well-known feeds are RSS or Atom, but the best format for communicating remains JSON, so we decided to develop a script that uses them all: [JSON Feed](https://www.jsonfeed.org/).
168-
216+
169217
So, if you wish to copy/paste the following codes into your customization but with your own feed, it must be formatted in JSON Feed or you must edit the following script to adapt it.
170218

171219
**Template**
172-
220+
173221
<ins>Common<ins>
174-
222+
175223
Let's try the following code and copy it into a template file like `customization/html/homeTop.html`:
176-
224+
177225
```html
178226
<div
179227
data-widget="feed"
180228
data-url="https://www.ecrins-parcnational.fr/flux_actus.json"
181229
data-limit="6"
182230
data-title="Découvrir les dernières actualités"
183231
></div>
184-
```
232+
```
185233
- `data-widget="feed"` (mandatory): all HTML tags with this data attribute and the value β€œfeed” will be parsed by the corresponding script.
186234
- `data-url` (mandatory): this is the feed source. If left blank, nothing happens.
187235
- `data-limit` (optional - default `Infinity`): is the number of elements to be displayed.
188-
- `data-title` (optional): allows to add a title to the section
236+
- `data-title` (optional): allows to add a title to the section
189237

190238

191239
<ins>Internationalization<ins>
@@ -199,7 +247,7 @@ If you need to execute the script on every page change you need to attach an eve
199247
data-widget="feed"
200248
data-url="https://www.ecrins-parcnational.fr/{{ language }}/flux_actus.json"
201249
></div>
202-
```
250+
```
203251

204252
<ins>Widget in details page<ins>
205253

@@ -213,7 +261,7 @@ If you need to execute the script on every page change you need to attach an eve
213261
></div>
214262

215263
```
216-
Don't forget to call the `feedWidget` in the desired details page in `customization/config/details.json`.
264+
Don't forget to call the `feedWidget` in the desired details page in `customization/config/details.json`.
217265
```json
218266
{
219267
"sections": {
@@ -363,5 +411,3 @@ If you need to execute the script on every page change you need to attach an eve
363411
- If there is no `data-url` defined, or if there is an error when retrieving the data, or if the data returns 0 elements, the script stops execution and nothing is displayed.
364412
- The source URL must provide a JSON feed format, otherwise it will try to loop inside as if the response were the contents of the `items` key of the JSON feed. **No other checks are made**, so if your JSON is not properly formatted, errors may occur.
365413
- For the card content, it tries to get the value of `summary`, if this key has no value, it tries the value of `content_text`. And if this key also has no value, it finally tries with `content_html`. Be careful with the last property: you have to trust the source because it executes a `innerHTML`.
366-
367-

β€Ždocs/img/widget-atmo.pngβ€Ž

48.4 KB
Loading

β€Ždocs/img/widget-lio.pngβ€Ž

28.6 KB
Loading
19.1 KB
Loading

β€Ždocs/index.mdβ€Ž

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,30 @@
11
# Geotrek-rando
22

3+
<div class="grid cards" markdown>
4+
5+
- :material-lightbulb:{ .lg .middle } **[Presentation]** – Everything you need to know about Geotrek-rando
6+
- :material-rocket:{ .lg .middle } **[Installation]** – Learn how to build, setup and deploy your application
7+
- :material-palette-outline:{ .lg .middle } **[Customization]** – Configure and design the website to fit your needs
8+
- :material-tools:{ .lg .middle } **[Developers]** – Run in development mode and contribute to this project
9+
10+
</div>
11+
12+
[Presentation]: presentation-fr.md
13+
[Installation]: installation.md
14+
[Customization]: ./customization/customization-introduction.md
15+
[Developers]: ./development/installation.md
16+
17+
## What is Geotrek-rando ?
18+
319
![Search](img/home_ecrins.png)
420

5-
Geotrek-rando is the public web application displaying the interface you can use to value your territory treks and tourism products!
21+
Geotrek-rando is the public web application displaying the interface you can use to value your territory treks and tourism products!
622
Demo available at [gtr3demo.ecrins-parcnational.fr](https://gtr3demo.ecrins-parcnational.fr).
723

824
The third version is a full redesign and rewriting of Geotrek-rando with React, and NextJS for Server side rendering (SSR) and SEO.
925

1026
Geotrek-rando is directly connected to [Geotrek-admin](https://github.com/GeotrekCE/Geotrek-admin) v2 API.
1127

28+
## Where can I find examples of Geotrek-rando ?
29+
30+
This [GitHub page](https://github.com/GeotrekCE/Geotrek-website/wiki/Liste-des-Geotrek-connus) lists all known Geotrek-rando instances to date.

β€Žmkdocs/mkdocs.ymlβ€Ž

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
# Project information
2-
site_name: Geotrek-rando v3 documentation
2+
site_name: Geotrek-rando documentation
33
site_url: https://geotrek-rando-v3.readthedocs.io/latest/
4-
site_description: Geotrek-rando v3 documentation
4+
site_description: Geotrek-rando documentation
55
site_author: Geotrek's community
66
edit_uri: blob/main/docs/
77

88
# Repository
99
repo_name: GeotrekCE/Geotrek-rando-v3/
1010
repo_url: https://github.com/GeotrekCE/Geotrek-rando-v3/
11-
docs_dir: ../docs
11+
docs_dir: ../docs
1212

1313
# Configuration
1414
theme:
@@ -36,15 +36,15 @@ theme:
3636
- toc.follow
3737
# toc.integrate
3838
palette:
39-
# - Dark Mode
39+
# - Dark Mode
4040
- media: "(prefers-color-scheme: dark)"
4141
scheme: slate
4242
toggle:
4343
icon: material/weather-sunny
4444
name: Light mode
4545
primary: blue
4646
accent: light blue
47-
# Light Mode
47+
# Light Mode
4848
- media: "(prefers-color-scheme: light)"
4949
scheme: default
5050
toggle:
@@ -59,6 +59,7 @@ theme:
5959
logo: img/logo.svg
6060
icon:
6161
icon:
62+
repo: fontawesome/brands/github
6263
admonition:
6364
note: octicons/tag-16
6465
abstract: octicons/checklist-16
@@ -137,37 +138,38 @@ markdown_extensions:
137138
plugins:
138139
- git-revision-date-localized:
139140
enable_creation_date: true
141+
type: timeago
142+
- git-committers:
143+
repository: GeotrekCE/Geotrek-rando-v3
144+
branch: main
140145
- search:
141146
separator: '[\s\u200b\-_,:!=\[\]()"`/]+|\.(?!\d)|&[lg]t;|(?!\b)(?=[A-Z][a-z])'
142147

143148
# Page tree
144149
nav:
145150
- Home: index.md
146-
- πŸ’‘ PrΓ©sentation:
147-
- PrΓ©sentation gΓ©nΓ©rale: presentation-fr.md
148-
- πŸš€ Installation:
149-
- Production setup: installation.md
150-
- 🎨 Customization:
151+
- πŸ’‘ Presentation: presentation-fr.md
152+
- πŸš€ Installation: installation.md
153+
- 🎨 Customization:
151154
- Introduction: customization/customization-introduction.md
152155
- Homepage: customization/customization-homepage.md
153156
- Settings: customization/customization-settings.md
154157
- Theme and style: customization/customization-themestyles.md
155-
- Icons : customization/customization-icons.md
158+
- Icons: customization/customization-icons.md
156159
- Translation: customization/customization-translation.md
157160
- HTML and scripts: customization/customization-htmlscripts.md
158161
- GDPR: customization/customization-gdpr.md
159162
- Media management: customization/customization-mediamanagement.md
160-
- πŸ”§ Development:
163+
- πŸ”§ Development:
161164
- Installation: development/installation.md
162165
- Deployment: development/deployment.md
163166
- Contributing: development/contributing.md
164-
- ✨ Knowledge:
167+
- ✨ Knowledge:
165168
- Caching: knowledge/caching.md
166169
- Debug: knowledge/debug.md
167170
- Pages and navigation: knowledge/pages-and-navigation.md
168171
- Server side rendering: knowledge/server-side-rendering.md
169172
- 🧱 Architecture decision record:
170173
- Main framework: adrs/main_framework.md
171174
- Deployment solution: adrs/deployment_solution.md
172-
- πŸ“ Changelog:
173-
- Release notes: changelog.md
175+
- πŸ“ Changelog: changelog.md

β€Žmkdocs/requirements.txtβ€Ž

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,4 @@ paginate~=0.5
3434
regex>=2022.4
3535
requests~=2.26
3636
mkdocs-git-revision-date-localized-plugin~=1.3.0
37+
mkdocs-git-committers-plugin-2~=2.5.0

0 commit comments

Comments
Β (0)