feat: Static wiki generation

Along with multiple translations.
This commit is contained in:
Leo Gavilieau 2023-05-19 23:35:51 +02:00
parent b57bde3abc
commit 7a0de5dced
No known key found for this signature in database
GPG Key ID: 9F86E792898BD16B
8 changed files with 161 additions and 0 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
output/

59
Makefile Normal file
View File

@ -0,0 +1,59 @@
# if someone can come up with something better then i'd appreciate that.
# For now this is a bit complex but it gets the job done.
# It's still a ticking time bomb and I hope we can fix it before it explodes.
# Even if it explodes, it won't be that big of a deal.
# Input dir describes the directory that has the markdown we want to convert
# Static dir describes the directory that has files we should simply copy as-is
# Output dir describes the directory that we want our final result to be in.
INPUT_DIR=content
STATIC_DIR=static
OUTPUT_DIR=output
# The pandoc template to use
TEMPLATE=template.html
## You should not need to change anything beyond this line
# The pandoc lua filter to use
# The language code and file extension will be appended later
FILTER=filters/link-filter.
STATIC=$(patsubst $(STATIC_DIR)/%,$(OUTPUT_DIR)/%,$(shell find $(STATIC_DIR) -type f))
OUTPUT=$(patsubst $(INPUT_DIR)/%.md,$(OUTPUT_DIR)/%/index.html,$(shell find $(INPUT_DIR) -type f))
site: $(OUTPUT) $(STATIC)
$(OUTPUT_DIR)/%/index.html: $(INPUT_DIR)/%.md $(TEMPLATE)
mkdir -p $(dir $@)
pandoc --from markdown+smart+yaml_metadata_block+auto_identifiers --lua-filter=$(FILTER)$(shell echo $@ | cut -d / -f 2).lua --to html --template $(TEMPLATE) $< -o $@
@# Pandoc indenting causes too many issues. From https://stackoverflow.com/a/68633114
sed -i 's/^\s*<span/<span/g' "$@"
sed -i 's/^\s*\([^<]\)/\1/g' "$@"
$(eval DIRNAME != dirname $(subst index.html,,$@))
@if [ -d "$(DIRNAME)/_index/" ]; then \
mv $(DIRNAME)/_index/index.html $(DIRNAME); \
rmdir $(DIRNAME)/_index/; \
fi
# Copy straight from static dir
$(OUTPUT_DIR)/%: $(STATIC_DIR)/%
mkdir -p $(dir $@)
cp $< $@
# Remove everything in the output dir
clean:
if [ -d "$(OUTPUT_DIR)" ]; then \
rm -r "$(OUTPUT_DIR)"; \
fi
## These rules are not used for wiki generation at all...
# So don't use them!
test:
cd $(OUTPUT_DIR); python3 -m http.server 9000
mon:
@echo "find $(INPUT_DIR)/ $(STATIC_DIR)/ $(dir $(TEMPLATE))/ -type f | entr make"
.PHONY: clean test

23
content/en/_index.md Normal file
View File

@ -0,0 +1,23 @@
---
title: "Welcome to ~vern Wiki"
---
This wiki houses many informational articles and entries, but mainly it's used to write and archive info about Vern itself, for example, how to connect to its services.
If you are a user, then you will appreciate this set of info about Vern:
* [~vern's Matrix Instance](/matrix/)
* [~vern's SSH Server](/ssh/)
* [~vern's Mastodon Instance](/mastodon/)
* [~vern's Email server](/email/)
* [~vern Administrators](/admins/)
If you are a new user or someone who wants a ~vern membership then you will appreciate these guides:
* [How to register over at ~vern](/guides/register/)
* [How to use SSH](/guides/ssh/)
* [How to use Matrix](/guides/matrix/)
* [How to use Mastodon](/guides/mastodon/)
* [How to host webpages on ~vern](/guides/usersites/)
* [How to host Gemini capsules](/guides/usersites/#gemini)
* [How to do package management on the pubnix](/guides/pkgman/)

View File

@ -0,0 +1,6 @@
lang = "da"
function Link(el)
el.target = "/" .. lang .. el.target
return el
end

View File

@ -0,0 +1,6 @@
lang = "en"
function Link(el)
el.target = "/" .. lang .. el.target
return el
end

View File

@ -0,0 +1,6 @@
lang = "pt-BR"
function Link(el)
el.target = "/" .. lang .. el.target
return el
end

28
static/index.html Normal file
View File

@ -0,0 +1,28 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="/style.css">
<meta name="generator" content="pandoc">
<title>A redirect to the english homepage</title>
<meta http-equiv = "refresh" content = "2; url = https://wiki.vern.cc/en/" />
</head>
<body>
<header>
<nav>
<a href="/">Homepage</a>
<a href="http://git.vern.cc/vern/wiki/commits/branch/master">Recent changes</a>
<a href="http://git.vern.cc/vern/wiki">Source</a>
</nav>
</header>
<main>
<p>If this redirect does not work then please click on <a href="/en/">this link</a></p>
</main>
<footer>
<p>Copyright © Vern.CC and contributors 2022-2023, made with love.</p>
<p>Licensed under the <a href="https://creativecommons.org/licenses/by-sa/4.0/deed.en">CC Attribution-ShareAlike 4.0 International license</a></p>
<p>Get the source <a href="http://git.vern.cc/vern/wiki">here</a></p>
</footer>
</body>
</html>

32
template.html Normal file
View File

@ -0,0 +1,32 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="/style.css">
<meta name="generator" content="pandoc">
$if(title)$
<title>$title$</title>
$endif$
$if(redirect)$
<meta http-equiv = "refresh" content = "2; url = https://wiki.vern.cc$redirect$" />
$endif$
</head>
<body>
<header>
<nav>
<a href="/">Homepage</a>
<a href="http://git.vern.cc/vern/wiki/commits/branch/master">Recent changes</a>
<a href="http://git.vern.cc/vern/wiki">Source</a>
</nav>
</header>
<main>
$body$
</main>
<footer>
<p>Copyright © Vern.CC and contributors 2022-2023, made with love.</p>
<p>Licensed under the <a href="https://creativecommons.org/licenses/by-sa/4.0/deed.en">CC Attribution-ShareAlike 4.0 International license</a></p>
<p>Get the source <a href="http://git.vern.cc/vern/wiki">here</a></p>
</footer>
</body>
</html>