forked from Hostea/website
feat: init
commit
fb6a1c2f1c
|
@ -0,0 +1,2 @@
|
||||||
|
public/
|
||||||
|
bin/
|
|
@ -0,0 +1,14 @@
|
||||||
|
default: ## Build the website
|
||||||
|
./scripts/zola.sh build
|
||||||
|
|
||||||
|
clean: ## Clean build assets
|
||||||
|
./scripts/zola.sh clean
|
||||||
|
|
||||||
|
env: ## Download build dependencies and setup dev environement
|
||||||
|
./scripts/zola.sh install
|
||||||
|
|
||||||
|
help: ## Prints help for targets with comments
|
||||||
|
@cat $(MAKEFILE_LIST) | grep -E '^[a-zA-Z_-]+:.*?## .*$$' | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
|
||||||
|
|
||||||
|
serve: ## Serve website during development
|
||||||
|
./scripts/zola.sh zola -- serve
|
|
@ -0,0 +1,16 @@
|
||||||
|
# The URL the site will be built for
|
||||||
|
base_url = "https://hostea.org"
|
||||||
|
|
||||||
|
# Whether to automatically compile all Sass files in the sass directory
|
||||||
|
compile_sass = true
|
||||||
|
|
||||||
|
# Whether to build a search index to be used later on by a JavaScript library
|
||||||
|
build_search_index = true
|
||||||
|
|
||||||
|
[markdown]
|
||||||
|
# Whether to do syntax highlighting
|
||||||
|
# Theme can be customised by setting the `highlight_theme` variable to a theme supported by Zola
|
||||||
|
highlight_code = true
|
||||||
|
|
||||||
|
[extra]
|
||||||
|
# Put all your custom variables here
|
|
@ -0,0 +1,32 @@
|
||||||
|
#!/bin/bash
|
||||||
|
# Copyright © 2021 Aravinth Manivannan <realaravinth@batsense.net>
|
||||||
|
#
|
||||||
|
# This program is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU Affero General Public License as
|
||||||
|
# published by the Free Software Foundation, either version 3 of the
|
||||||
|
# License, or (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU Affero General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU Affero General Public License
|
||||||
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
check_arg(){
|
||||||
|
if [ -z $1 ]
|
||||||
|
then
|
||||||
|
help
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
match_arg() {
|
||||||
|
if [ $1 == $2 ] || [ $1 == $3 ]
|
||||||
|
then
|
||||||
|
return 0
|
||||||
|
else
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
}
|
|
@ -0,0 +1,95 @@
|
||||||
|
#!/bin/bash
|
||||||
|
# Used in CI workflow: install and check for spelling errors
|
||||||
|
# Copyright © 2021 Aravinth Manivannan <realaravinth@batsense.net>
|
||||||
|
#
|
||||||
|
# This program is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU Affero General Public License as
|
||||||
|
# published by the Free Software Foundation, either version 3 of the
|
||||||
|
# License, or (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU Affero General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU Affero General Public License
|
||||||
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
readonly MISSPELL_DOWNLOAD="https://github.com/client9/misspell/releases/download/v0.3.4/misspell_0.3.4_linux_64bit.tar.gz"
|
||||||
|
readonly TMP_DIR=$(pwd)/tmp
|
||||||
|
readonly PROJECT_ROOT=$(pwd)
|
||||||
|
readonly MISSPELL_TARBALL="$TMP_DIR/misspell.tar.bz2"
|
||||||
|
readonly MISSPELL="$TMP_DIR/misspell"
|
||||||
|
|
||||||
|
set -Eeuo pipefail
|
||||||
|
|
||||||
|
source $(pwd)/scripts/lib.sh
|
||||||
|
|
||||||
|
FLAGS=""
|
||||||
|
|
||||||
|
help() {
|
||||||
|
cat << EOF
|
||||||
|
spellcheck.sh: Check for spelling errors
|
||||||
|
USAGE:
|
||||||
|
spellcheck.sh <options>
|
||||||
|
OPTIONS:
|
||||||
|
c --check check for spelling erros
|
||||||
|
h --help print this help menu
|
||||||
|
w --write check and fix spelling errors
|
||||||
|
EOF
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
download() {
|
||||||
|
if [ ! -e $MISSPELL ];
|
||||||
|
then
|
||||||
|
echo "[*] Downloading misspell"
|
||||||
|
wget --quiet --output-doc=$MISSPELL_TARBALL $MISSPELL_DOWNLOAD;
|
||||||
|
cd $TMP_DIR
|
||||||
|
tar -xf $MISSPELL_TARBALL;
|
||||||
|
cd $PROJECT_ROOT
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
spell_check_codespell() {
|
||||||
|
_check(){
|
||||||
|
codespell $FLAGS --ignore-words-list=$1 $PROJECT_ROOT/$2 || true
|
||||||
|
}
|
||||||
|
_check README.md
|
||||||
|
_check contents
|
||||||
|
}
|
||||||
|
|
||||||
|
spell_check_misspell() {
|
||||||
|
mkdir $TMP_DIR || true
|
||||||
|
download
|
||||||
|
|
||||||
|
_check(){
|
||||||
|
$MISSPELL $FLAGS -i $1 $PROJECT_ROOT/$2
|
||||||
|
}
|
||||||
|
|
||||||
|
_check contents
|
||||||
|
_check README.md
|
||||||
|
}
|
||||||
|
|
||||||
|
check_arg $1
|
||||||
|
|
||||||
|
if match_arg $1 'w' '--write'
|
||||||
|
then
|
||||||
|
echo "[*] checking and correcting spellings"
|
||||||
|
FLAGS="-w"
|
||||||
|
spell_check_misspell
|
||||||
|
spell_check_codespell
|
||||||
|
elif match_arg $1 'c' '--check'
|
||||||
|
then
|
||||||
|
echo "[*] checking spellings"
|
||||||
|
spell_check_misspell
|
||||||
|
spell_check_codespell
|
||||||
|
elif match_arg $1 'h' '--help'
|
||||||
|
then
|
||||||
|
help
|
||||||
|
else
|
||||||
|
echo "undefined option"
|
||||||
|
help
|
||||||
|
exit 1
|
||||||
|
fi
|
|
@ -0,0 +1,110 @@
|
||||||
|
#!/bin/bash
|
||||||
|
# Used in CI workflow: install Zola binary from GitHub
|
||||||
|
# Copyright © 2021 Aravinth Manivannan <realaravinth@batsense.net>
|
||||||
|
#
|
||||||
|
# This program is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU Affero General Public License as
|
||||||
|
# published by the Free Software Foundation, either version 3 of the
|
||||||
|
# License, or (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU Affero General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU Affero General Public License
|
||||||
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
readonly TARBALL=zola.tar.gz
|
||||||
|
readonly SOURCE="https://github.com/getzola/zola/releases/download/v0.15.3/zola-v0.15.3-x86_64-unknown-linux-gnu.tar.gz"
|
||||||
|
|
||||||
|
readonly BIN_PATH=bin
|
||||||
|
readonly BIN=$BIN_PATH/zola
|
||||||
|
|
||||||
|
readonly DIST=public
|
||||||
|
|
||||||
|
source $(pwd)/scripts/lib.sh
|
||||||
|
|
||||||
|
help() {
|
||||||
|
cat << EOF
|
||||||
|
zola.sh: Zola build script
|
||||||
|
USAGE:
|
||||||
|
zola.sh <options>
|
||||||
|
OPTIONS:
|
||||||
|
b build build website
|
||||||
|
c clean clean dependencies and build artifacts
|
||||||
|
h help print this help menu
|
||||||
|
i install install build dependencies
|
||||||
|
u url make urls relative
|
||||||
|
z zola invoke zola
|
||||||
|
EOF
|
||||||
|
}
|
||||||
|
|
||||||
|
download() {
|
||||||
|
echo "Downloading Zola"
|
||||||
|
wget --quiet --output-document=$TARBALL $SOURCE
|
||||||
|
tar -xvzf $TARBALL > /dev/null
|
||||||
|
rm $TARBALL
|
||||||
|
echo "Downloaded zola into $BIN"
|
||||||
|
}
|
||||||
|
|
||||||
|
init() {
|
||||||
|
if [ ! -d $BIN_PATH ]
|
||||||
|
then
|
||||||
|
mkdir $BIN_PATH
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ ! -f $BIN ]
|
||||||
|
then
|
||||||
|
cd $BIN_PATH
|
||||||
|
download
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
run() {
|
||||||
|
$BIN "${@:1}"
|
||||||
|
}
|
||||||
|
|
||||||
|
build() {
|
||||||
|
run build
|
||||||
|
}
|
||||||
|
|
||||||
|
no_absolute_url() {
|
||||||
|
sed -i 's/https:\/\/hostea.org//g' $(find public -type f | grep html)
|
||||||
|
}
|
||||||
|
|
||||||
|
clean() {
|
||||||
|
rm -rf $BIN_PATH || true
|
||||||
|
rm -rf $DIST || true
|
||||||
|
echo "Workspace cleaned"
|
||||||
|
}
|
||||||
|
|
||||||
|
check_arg $1
|
||||||
|
|
||||||
|
if match_arg $1 'i' 'install'
|
||||||
|
then
|
||||||
|
init
|
||||||
|
elif match_arg $1 'c' 'clean'
|
||||||
|
then
|
||||||
|
clean
|
||||||
|
elif match_arg $1 'b' 'build'
|
||||||
|
then
|
||||||
|
build
|
||||||
|
elif match_arg $1 'h' 'help'
|
||||||
|
then
|
||||||
|
help
|
||||||
|
elif match_arg $1 'u' 'url'
|
||||||
|
then
|
||||||
|
no_absolute_url
|
||||||
|
elif match_arg $1 'z' 'zola'
|
||||||
|
then
|
||||||
|
$BIN "${@:3}"
|
||||||
|
else
|
||||||
|
echo "Error: $1 is not an option"
|
||||||
|
help
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
exit 0
|
Loading…
Reference in New Issue