Compare commits
No commits in common. "d353f2e5e6c134eaaffa674bf80ef8d131346e50" and "bfb6544b097e8682fa0d64d3f44378d98e16a047" have entirely different histories.
d353f2e5e6
...
bfb6544b09
4 changed files with 3 additions and 56 deletions
53
README.md
53
README.md
|
@ -1,53 +0,0 @@
|
|||
# Jocelyns HSMW website
|
||||
|
||||
This repository contains the generator, static files and source files for my [HSMW website](https://www.student.hs-mittweida.de/~jotto5)
|
||||
|
||||
## Build
|
||||
|
||||
To build this website you need:
|
||||
|
||||
* GNU Bash (5.2.32)
|
||||
* GNU awk (1.3.4)
|
||||
* sed (4.9)
|
||||
* Pandoc (3.1.11.1)
|
||||
|
||||
Any half-recent version should suffice, I added a tested version in parentheses. To run the build, execute the `build.sh` script from the root directory. This will:
|
||||
|
||||
* Delete the `dist` folder if it exists
|
||||
* Create a dist folder
|
||||
* Copy over all static files
|
||||
* Compile the website from `src` into `dist`
|
||||
|
||||
## Templates
|
||||
|
||||
Templates use a custom template language heavily inspired by the one used by `werc`. It works by embedding bash code directly into the html skeleton used to build the pages. There are two ways of doing so:
|
||||
|
||||
### Escaped lines
|
||||
|
||||
If a line starts with an arbitrary amount of whitespace (even 0) followed by a percent sign, the rest of the line will be treated as a shell command, and the commands output will be inserted in its place. For example:
|
||||
|
||||
```
|
||||
<h1>
|
||||
% echo 'Hallo Mittweida!'
|
||||
</h1>
|
||||
```
|
||||
|
||||
will be evaluated to
|
||||
|
||||
```
|
||||
<h1>
|
||||
Hallo Mittweida!
|
||||
</h1>
|
||||
```
|
||||
|
||||
> NOTE: Keep control over your templates, as they could expose information about your system!
|
||||
|
||||
### Inline expressions
|
||||
|
||||
Inline expressions can be written by encasing the expression in `%(` and `%)`. Those expressions will be evaluated as if put in double quotes, and the result will be inserted in their place. Example:
|
||||
|
||||
```
|
||||
<a href="%($LINK%)">link</a>
|
||||
```
|
||||
|
||||
will put the contents of the shell variable `LINK` in the `href`-attribute field of the link object.
|
4
build.sh
4
build.sh
|
@ -5,12 +5,12 @@ source_to_target() { sed -E -e 's:\.\./src/:\./:' -e 's/.md$/.html/'; }
|
|||
shopt -s globstar
|
||||
rm -rf dist/
|
||||
mkdir dist&&cd dist
|
||||
cp -r ../static/* .
|
||||
cp ../style.css .
|
||||
for file in $(du -a ../src/ | cut -f2 | grep -E '.md$'); do
|
||||
target="$(echo $file | source_to_target)"
|
||||
export CONTENT="$(pandoc --from markdown+emoji --wrap=none -i $file)"
|
||||
export PREFIX=$(realpath --relative-to $(dirname $target) .)
|
||||
export SIDEBAR=$(for x in ../src/**/*.md; do echo "<li><a href=\"$(echo $PREFIX/$x | source_to_target)\">$(realpath --relative-to ../src/ $x | sed -e 's/.md$//')</a></li>"; done)
|
||||
mkdir -p $(dirname $target)
|
||||
awk -f ../template.awk ../template.tpl | bash > $target
|
||||
cat ../template.tpl | awk -f ../template.awk | bash > $target
|
||||
done
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
This is a place for me to put links to friendly websites!
|
||||
|
||||
* Emilian's site: [~emarche](https://www.student.hs-mittweida.de/~emarche)
|
||||
* Emil's site: [~emarche](https://www.student.hs-mittweida.de/~emarche)
|
||||
* My private homepage at [jossco.de](https://jossco.de)
|
||||
|
||||
If you want to be here, contact me :grin:
|
||||
|
|
Loading…
Reference in a new issue