site infastructure
This commit is contained in:
parent
31141ee3dd
commit
3a9c5df1c4
@ -5,5 +5,10 @@ end_of_line=lf
|
|||||||
trim_trailing_whitespace=true
|
trim_trailing_whitespace=true
|
||||||
insert_final_newline=true
|
insert_final_newline=true
|
||||||
[{Makefile,*.sass}]
|
[{Makefile,*.sass}]
|
||||||
indent_type=tab
|
indent_style=tab
|
||||||
indent_size=1
|
indent_size=1
|
||||||
|
[{ignore.txt,*.csv}]
|
||||||
|
insert_final_newline=false
|
||||||
|
[*.rb]
|
||||||
|
indent_style=space
|
||||||
|
indent_size=2
|
||||||
|
@ -1,3 +1,6 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
# gensimap.sh: Generate a sitemap for my website.
|
||||||
|
# v2.0p1
|
||||||
function r { echo $@ >> out/sitemap.xml; }
|
function r { echo $@ >> out/sitemap.xml; }
|
||||||
test -d out/sitemap.xml && sed -i d sitemap.xml
|
test -d out/sitemap.xml && sed -i d sitemap.xml
|
||||||
r '<?xml version="1.0" encoding="UTF-8"?>'
|
r '<?xml version="1.0" encoding="UTF-8"?>'
|
2
ignore.txt
Normal file
2
ignore.txt
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
css/extra.scss
|
||||||
|
dnd/template.org
|
5
pfiles.rb
Normal file
5
pfiles.rb
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
#!/usr/bin/ruby
|
||||||
|
ignore=!File.file?('ignore.txt') ? [] : File.readlines('ignore.txt')
|
||||||
|
switch $ARGV[1]
|
||||||
|
|
||||||
|
end
|
167
render.sh
167
render.sh
@ -1,12 +1,18 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
# render.sh: part of the tape-and-string framework.
|
# render.sh: part of the tape-and-string framework.
|
||||||
# v3.1
|
# v3.2-p1
|
||||||
|
#B: Load
|
||||||
enable -f /usr/lib/bash/csv csv
|
enable -f /usr/lib/bash/csv csv
|
||||||
declare -A title
|
declare -A title
|
||||||
while read -r ii; do
|
#E: Load
|
||||||
csv -a i "$ii"
|
#B: Definition
|
||||||
title[in/${i[0]}]=${i[1]}
|
|
||||||
done <title.csv
|
function in_arr {
|
||||||
|
for i in "${@:2}"; do
|
||||||
|
[[ "$i" = "$1" ]] && return 0
|
||||||
|
done
|
||||||
|
return 1
|
||||||
|
}
|
||||||
function inf { echo -e "\x1B[1;32mINF\x1B[0m: $*"; }
|
function inf { echo -e "\x1B[1;32mINF\x1B[0m: $*"; }
|
||||||
function wrn { echo -e "\x1B[1;93mWRN\x1B[0m: $*"; }
|
function wrn { echo -e "\x1B[1;93mWRN\x1B[0m: $*"; }
|
||||||
function err { echo -e "\x1B[1;31mERR\x1B[0m: $*"; }
|
function err { echo -e "\x1B[1;31mERR\x1B[0m: $*"; }
|
||||||
@ -23,35 +29,33 @@ function tape {
|
|||||||
*) pandoc --columns 168 -t html "$1" || echo "Skipping $i, unknown format" ;;
|
*) pandoc --columns 168 -t html "$1" || echo "Skipping $i, unknown format" ;;
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
function yn {
|
|
||||||
while true; do
|
|
||||||
read -p "$* [y/n]:" yn
|
|
||||||
case $yn in
|
|
||||||
[Yy]*) return 0;;
|
|
||||||
[Nn]*)
|
|
||||||
echo "Aborted."
|
|
||||||
return 1;;
|
|
||||||
*) echo "Please answer Yes or No.";;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
}
|
|
||||||
doc=(`find in -type f -name '*.txti' -o -name '*.org' -o -name '*.md'`)
|
|
||||||
sass=(`find in -type f -name '*.sass'`)
|
|
||||||
scss=(`find in -type f -name '*.scss'`)
|
|
||||||
rest=(`find in -type f ! \( -name '*.org' -o -name '*.txti' -o -name '*.md' -o -name .hg \)`)
|
|
||||||
dir=(`find in -type d`)
|
|
||||||
|
|
||||||
function dirs {
|
function dirs {
|
||||||
inf "Creating directory structure..."
|
if test -d out; then
|
||||||
echo ${dir[@]}
|
wrn "Directory 'out' already exists."
|
||||||
for i in ${dir[@]}; do
|
return 0
|
||||||
|
fi
|
||||||
|
local i o dir
|
||||||
|
dir=(`find in -type d`)
|
||||||
|
inf "Creating directory structure..."
|
||||||
|
echo ${dir[@]}
|
||||||
|
for i in ${dir[@]}; do
|
||||||
o="${i/in/out}"
|
o="${i/in/out}"
|
||||||
mkdir -pv $o
|
mkdir -pv $o
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
function docs {
|
function docs {
|
||||||
inf "Rendering document files..."
|
if ! test -d out; then
|
||||||
for i in ${doc[@]}; do
|
err "Cannot render, directory 'out' does not exist, run ./render.sh dir"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
local i o doc
|
||||||
|
doc=(`find in -type f -name '*.txti' -o -name '*.org' -o -name '*.md'`)
|
||||||
|
inf "Rendering document files..."
|
||||||
|
for i in ${doc[@]}; do
|
||||||
|
if in_arr $i ${ignore[@]}; then
|
||||||
|
inf "Skipping $i"
|
||||||
|
continue
|
||||||
|
fi
|
||||||
o="${i/in/out}"
|
o="${i/in/out}"
|
||||||
echo "$i => $o"
|
echo "$i => $o"
|
||||||
if test -z "${title[$i]}"; then
|
if test -z "${title[$i]}"; then
|
||||||
@ -59,50 +63,109 @@ for i in ${doc[@]}; do
|
|||||||
else
|
else
|
||||||
tape $i | m4 -DTITLE="${title[$i]}" m4/main.html.m4 > ${o%.*}.html
|
tape $i | m4 -DTITLE="${title[$i]}" m4/main.html.m4 > ${o%.*}.html
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
function sass {
|
function sass {
|
||||||
inf "Rendering sass files..."
|
if ! test -d out; then
|
||||||
if test -z "${sass[@]}"; then
|
err "Cannot render, directory 'out' does not exist, run ./render.sh dir"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
local i o sass scss
|
||||||
|
sass=(`find in -type f -name '*.sass'`)
|
||||||
|
scss=(`find in -type f -name '*.scss'`)
|
||||||
|
inf "Rendering sass files..."
|
||||||
|
if [ ${#sass[@]} -eq 0 ]; then
|
||||||
inf "No .sass files detected, skipping"
|
inf "No .sass files detected, skipping"
|
||||||
unset sass
|
unset sass
|
||||||
else
|
else
|
||||||
for i in ${sass[@]}; do
|
for i in ${sass[@]}; do
|
||||||
|
if in_arr $i ${ignore[@]}; then
|
||||||
|
inf "Skipping $i"
|
||||||
|
continue
|
||||||
|
fi
|
||||||
o="${i/in/out}"
|
o="${i/in/out}"
|
||||||
|
o="${o/.sa/.c}"
|
||||||
echo "$i => $o"
|
echo "$i => $o"
|
||||||
sassc -a $i ${o/sa/c}
|
sassc -a $i $o
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
if test -z "${scss[@]}"; then
|
if [ ${#scss[@]} -eq 0 ]; then
|
||||||
inf "No .scss files detected, skipping."
|
inf "No .scss files detected, skipping."
|
||||||
unset scss
|
unset scss
|
||||||
else
|
else
|
||||||
for i in ${scss[@]}; do
|
for i in ${scss[@]}; do
|
||||||
|
if in_arr $i ${ignore[@]}; then
|
||||||
|
inf "Skipping $i"
|
||||||
|
continue
|
||||||
|
fi
|
||||||
o="${i/in/out}"
|
o="${i/in/out}"
|
||||||
|
o="${o/\.s/.}"
|
||||||
echo "$i => $o"
|
echo "$i => $o"
|
||||||
sassc $i ${o#s}
|
sassc $i $o
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
function other {
|
function other {
|
||||||
inf "Copying other files..."
|
if ! test -d out; then
|
||||||
cp -rv 'in'/* out/
|
err "Cannot render, directory 'out' does not exist, run ./render.sh dir"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
inf "Copying other files..."
|
||||||
|
cp -rv 'in'/* out/
|
||||||
}
|
}
|
||||||
function all {
|
function all {
|
||||||
dirs
|
dirs
|
||||||
docs
|
docs
|
||||||
sass
|
sass
|
||||||
other
|
other
|
||||||
}
|
}
|
||||||
|
function info {
|
||||||
|
local i
|
||||||
|
echo "* \$ignore"
|
||||||
|
if [ ${#ignore[@]} -eq 0 ]; then
|
||||||
|
echo null
|
||||||
|
else
|
||||||
|
for i in ${ignore[@]}; do
|
||||||
|
echo "- $i"
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
echo "* \$titles"
|
||||||
|
for i in ${!title[@]}; do
|
||||||
|
echo " - $i :: ${title[$i]}"
|
||||||
|
done
|
||||||
|
}
|
||||||
|
#E: Definition
|
||||||
|
#B: Logic
|
||||||
|
#B: Logic/LoadDefs
|
||||||
|
#B: Logic/LoadDefs/title
|
||||||
|
while read -r ii; do
|
||||||
|
csv -a i "$ii"
|
||||||
|
title[in/${i[0]}]=${i[1]}
|
||||||
|
done < title.csv
|
||||||
|
#E: Logic/LoadDefs/title
|
||||||
|
unset ii
|
||||||
|
#B: Logic/LoadDefs/ignore
|
||||||
|
if test -f ignore.txt; then
|
||||||
|
while read -r i; do
|
||||||
|
ignore+=(in/$i)
|
||||||
|
done < ignore.txt
|
||||||
|
fi
|
||||||
|
#E: Logic/LoadDefs/ignore
|
||||||
|
#E: Logic/LoadDefs
|
||||||
if test -z "$*"; then
|
if test -z "$*"; then
|
||||||
all
|
all
|
||||||
exit 0
|
exit $?
|
||||||
fi
|
fi
|
||||||
case $1 in
|
case $1 in
|
||||||
dir) dirs;;
|
dir) dirs;;
|
||||||
doc) docs;;
|
doc) docs;;
|
||||||
s[ac]ss) sass;;
|
s[ac]ss) sass;;
|
||||||
other) other;;
|
other) other;;
|
||||||
all) all;;
|
rest) other;;
|
||||||
*) all;;
|
info) info;;
|
||||||
|
vall) info; all;;
|
||||||
|
all) all;;
|
||||||
|
*) all;;
|
||||||
esac
|
esac
|
||||||
|
#E: Logic
|
||||||
|
exit $?
|
||||||
|
Loading…
Reference in New Issue
Block a user