Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/datasektionen/styrdokument-bawang
styrdokument bawang
https://github.com/datasektionen/styrdokument-bawang
Last synced: about 2 months ago
JSON representation
styrdokument bawang
- Host: GitHub
- URL: https://github.com/datasektionen/styrdokument-bawang
- Owner: datasektionen
- Created: 2021-11-09T20:21:36.000Z (about 3 years ago)
- Default Branch: master
- Last Pushed: 2024-07-08T16:24:31.000Z (6 months ago)
- Last Synced: 2024-07-08T20:52:35.677Z (6 months ago)
- Language: JavaScript
- Size: 74.2 KB
- Stars: 0
- Watchers: 19
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# gloo
"View over the wire"An app for taking data from Taitan (or similar) and rendering it according to templates, returns html to the user.
### What it does:
1. We listen for e.g. `GET gloo.datasektionen.se/stuff/abc`
2. We `GET taitan.datasektionen.se/stuff/abc`, this is the data that will be rendered.
3. Determine which template we should use. First look for `/templates/gloo/stuff/abc.*` (where * ~~are all our supported engine extensions~~ is the rendering engine extension specified in config.js).
1. If this template file exists, use it and continue.
2. Else, try `/templates/gloo/stuff/_default.*`.
3. Else, try `/templates/gloo/_default.*` and so on, climbing until you reach the top of the templates folder.
4. **Note:** If the subdomain is not specified it is presumed to be `www`.
4. Render the data with the given template.
5. Send back the rendered html to the user.### Setup
Before running, you have to create file `config.js` and directory `templates`. Feel free to copy `config.example.js` and `templates_example`.
## Development
#### Writing templates
The variables passed to the template engine are the same ones that [Taitan](https://github.com/datasektionen/taitan) sends, with no processing applied.
So look there for documentation.#### Adding a template engine
1. Go to [consolidatejs](https://www.npmjs.com/package/consolidate) and make sure the engine is supported.
2. Add the engine to `package.json`
3. Add the engine name in consolidate and extension to `config.js`
4. Do `npm install` to install the new engine.
5. Done.