Summary Files Commits Branches @commit @diff @stats
path: root / generate.sh
blob: 4af6c01264dd68b9960c2600193e23af1c3ab6e5 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#! /bin/sh

# Make sure this script is ran as www-data!
# Also, the syndamiadotcom folder MUST be owned by www-data!

if [ ! -d "website" ]; then
  mkdir website
fi

# Remove record of previously generated files
rm -f website/.files

# Generate files
ssg src website "Syndamia" "https://syndamia.com"

allnormfiles=$(find './website' -type f -name "*.html")

find './awk-edits' -type f -name "#*.awk"     -exec cat {} +  > /tmp/syndamiadotcom-awk
find './awk-edits' -type f -name "[A-Z]*.awk" -exec cat {} + >> /tmp/syndamiadotcom-awk
find './awk-edits' -type f -name "_*.awk"     -exec cat {} + >> /tmp/syndamiadotcom-awk
find './awk-edits' -type f -name "[a-z]*.awk" -exec cat {} + >> /tmp/syndamiadotcom-awk

for file in $(find './website' -type f -name "*.html"); do
	awk -f '/tmp/syndamiadotcom-awk' "$file" > tmp && mv -f tmp "$file"
done

#
# Tiny version
#

if [ ! -d "tiny.website" ]; then
	mkdir tiny.website
fi

# Just take what is already made, no need to regenerate everything
cp -r website/* tiny.website/

# Remove unnecessary files
rm -f tiny.website/*.css
rm -rf tiny.website/fonts/
rm -f tiny.website/.files

# Remove references to stylesheets in all files
for file in $(find "tiny.website" -type f -name "*.html"); do
	sed -i -E 's/^.*(rel="stylesheet|\<script|btn).*//g' $file
	sed -i 's/<span>Content/<br><span>Content/g' $file
	sed -i 's/<\/head>/\t<style>img[src$="svg"] { max-height: 1em; } #index-contents-img { max-width: 7.6em; }<\/style>\n<\/head>/' $file
done