This repository contains a prototype for a [dnsmanager](https://github.com/KaneRoot/dnsmanager) homepage. Below, you will find instructions on how to use it and how to contribute to it.
On a high-level, this website is made for [Zola](https://getzola.org) using the [water.css](https://kognise.github.io/water.css/) stylesheet to decorate the semantic HTML on all pages. Currently this website does:
If you want to contribute to this website, you first need to setup the [Zola](https://getzola.org) static site generator. You can either download a pre-compiled package, or compile the program from source using a [Rust](https://rust-lang.org) compiler.
## Package setup
For GNU/Linux users, there's a [snap](https://snapcraft.io/) package available (no Flatpack yet):
```
$ snap install --edge zola
```
On Mac, you can install zola using [Homebrew](https://brew.sh):
```
$ brew install zola
```
Alternatively, you can install a precompiled binary from the [Github releases](https://github.com/getzola/zola/releases):
If you don't have rustc (the official Rust compiler) and cargo (the related package manager) setup, you can either install them through your distribution, or get the latest version directly from the Rust project using rustup. If you're using Nix or [GNU Guix](https://guix.gnu.org) for package management, you can also use those to setup cargo and rustc.
If you're running Debian buster or later, you can simply do:
```
$ sudo apt install cargo rustc
```
If your distribution does not have a package for Rust, you can download [rustup](https://www.rust-lang.org/tools/install) and use it to setup a stable compiler.
Once Rust is setup, we can download Zola's source and compile it. Make sure you have git installed (`sudo apt install git`) before you proceed:
```
$ git clone https://github.com/getzola/zola
$ git checkout v0.10.1
$ cargo install --path=.
```
The last command (`cargo install`) not only compiles the project, but copies the generated binary to ~/.cargo/bin, which should already be in your `$PATH` after setting up Rust. You can check that zola is correctly setup by running it with the --version argument:
```
$ zola --version
zola 0.10.1
```
If you have an error message such as `bash: zola: command not found`, it is neither a problem with the Zola project or this website. It means the cargo bin directory is not in your $PATH for executable programs. A few things you can try:
- logging out then logging back in, if you've just setup rust, could apply changes to your $PATH
- appending `export PATH="$HOME/.cargo/bin:$PATH"` to your ~/.profile
If you still fail at running zola, you should read your distro's documentation or ask a friend.
## Compiling the site
Now that zola is up and running, we can use it to build our website. When building a site, zola needs to know about its final address in order to generate links.
zola will then place all the generated files in the public/ folder. Note that zola needs to know about its base URL in order to generate links. By default, the base_url is defined in config.toml for the website's current address. You can pass another base URL as an argument to zola using the -u flag, and a different output folder using the -o flag:
Listening for changes in /home/user/Desktop/Sites/dnsmanager/{content, config.toml, static, templates, themes, sass}
Press Ctrl+C to stop
```
You can then access the website at the address zola will output, usually [127.0.0.1:1111](http://127.0.0.1:1111).
Note that this live reload feature does not entirely play well with the macro system at the moment, so if you see some changes in your work are not reflected on the preview, don't hesitate to kill zola using `Ctrl-c` and then start it again.
In this section, we explain how to get started contributing to this website. We will introduce how to edit content for the website ([edition](#edition)), how to translate the website ([translation](#translation)), and how to hack on the templates ([webdesign](#webdesign)).
It is assumed you are familiar with the git ecosystem and you can submit a patch either through a pull request on the project's forge or via email to one of the maintainers. If you are not at ease with git, please ask a friend to teach you so we can cooperate and build awesome things together!
Create a new folder in the content/ folder. In this folder, place an index.md file for the English page, and one file per translation like index.fr.md (see [translating pages](#translating-pages)).
Each post has some TOML metadata attached. This is called a frontmatter, and the available variables are described in the [Zola documentation](https://www.getzola.org/documentation/content/page/#front-matter). The frontmatter is mandatory although it can be empty, and should contain at least the title of the page:
Creating a blogpost is very similar to creating any page, but it is important that a blogpost has a `date` frontmatter key set following the format `year-month-day` like so:
Blogposts are organized per year to ensure the `blog/` folder does not become too bloated. So in 2020, your posts should go inside content/blog/2020/your-article/ folder.
The post summary is taken from the first part of the article. If you add a `<-- more -->` tag, everything before that will be treated as the post summary.
As previously explained, every page has its own folder. Any file you place inside that is not a Markdown file will be copied alongside the generated page. [Asset colocation](https://www.getzola.org/documentation/content/overview/#asset-colocation) is further discussed in the Zola documentation.
A link to another page can use the @ sign to signify the link target is found in the content folder, as explained in the docs on [internal links](https://www.getzola.org/documentation/content/linking/#internal-links):
If a new year is starting, you may want to create a new folder for the year and copy the placeholder section files from the past year into the new folder (one file per available language):
Adding a language is not hard, but it takes a few steps. The example here takes `fr` as language code for french translations, just replace it with your own language.
In config.toml:
- declare the language in the languages variable: `{code = "fr", rss = true}`
- translate the basic template strings in the translations section:
If you want to translate a page in the content folder, the translated page should have the language code before the .md extension, like `index.fr.md`. The homepage is translated from content/_index.md, and some common parts (such as the navigation bar) are located in the content/_common folder.
Note: don't forget to copy the section file for year-folders in the blog, otherwise no article will appear on your language's blog. You can safely copy content/2020/_index.md to, say, content/2020/_index.fr.md.
As a webdesigner, you should look at the files in sass/ folder (for the style sources), and templates/ folder (for [tera](https://tera.netlify.com) templates.
If you would like to change the `water.css` stylesheet, refer to the [water.css README](https://github.com/kognise/water.css#runtime-theming). Also, if you need to make deeper changes to water.css, please fork water.css instead of applying local changes here.
Apart from the upstream water.css, there are two stylesheets for the website, with `style.scss` being the main one. `_mobile.scss` is imported into style.scss, then both are rendered to style.css.
The stylesheets are written in the SCSS language, which is a superset of CSS that compiles to bare CSS. [Here is](https://gist.github.com/martensonbj/d9c4ac31959e1b5a9611a9986d8f8c67) a quick introduction to SASS/SCSS styling.
If you want to make changes for different viewports (such as mobile phones), please use a dedicated stylesheet. All changes for mobile-related responsiveness should live in `_mobile.scss`.
### Templates
The templates for Zola use the [tera](https://tera.netlify.com) template engine. If you are familiar with jinja templates, they are very similar systems.
You may be looking for how to use [control structures](https://tera.netlify.com/docs/#control-structures) such as conditions, loops, macros and includes.
index.html is the main template that gets rendered for everypage. It renders the global page skeleton according to the language requested. In addition, it defines a few blocks that are overriden by children templates:
Both page.html and section.html extend index.html. They are children of index.html, one for rendering individual pieces of content, the other for rendering lists of content.
#### Custom macros
The widgets.html file contains a few useful macros. The macros related to translation/localization are documented later in the [translations in templates](#translations-in-templates) section.
##### menu macro
The menu macro builds a menu from a Markdown file, where each entry is separated by a thematic break. This pattern for static site generators is explained in [this article](https://staticadventures.netlib.re/blog/multi-column-layout/). The menu macro assumes that the HTML generated by every entry will have it wrapped by paragraph tags (`<p>...</p>`) and will strip that.
Here's an example menu file in `content/menu.md`:
```
+++
+++
First entry
---
Second entry
---
Third entry
```
You can then summon this menu like this:
```
{% import 'widgets.html' as widgets %}
{{ widgets::menu(content="menu.md") }}
```
#### Translations in templates
##### Localized string
If you want to use a translation string defined in the translations section of the config, you can use the [trans](https://www.getzola.org/documentation/templates/overview/#trans) function, like so:
In case you need to interact with a localized page, you will need to replace the last .md with .LANG.md. There is a widgets::i18n_path for that. You can use it like this:
If you need to get the localized URI for path on the website, you can use the i18n_url macro which acts as a wrapper around the [get_url](https://www.getzola.org/documentation/templates/overview/#get-url) function: