Summary Files Commits Branches @commit @diff @stats
path: root / generate-dev.sh
blob: 0fa85933b7352ec43f82a03a9a53b7d9b756be1e (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
49
50
51
52
53
54
55
56
57
58
#! /bin/sh

# Make folder if it doesn't exist
if [ ! -d "/var/www/synd" ]; then
	# User should be www-data (like in generate.sh), but I use Fedora and root is the default one
	mkdir /var/www/synd
fi

# Remove record of previously generated files
rm -f /var/www/synd/.files

# Generate files
ssg src /var/www/synd/ "Syndamia" "https://syndamia.com" > /dev/null

dur=0
startTimer () {
	dur="$(date +%s%N)"
}
endTimer () {
	dur="$(echo "scale=4 ; ($(date +%s%N) - $dur) / 1000000000" | bc -l)"
	printf "%.3fs    $1\n" $dur
}

startTimer
	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
endTimer "generation of /tmp/syndamiadotcom-awk"

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

#
# Tiny version
#

if [ ! -d "/var/www/tiny.synd" ]; then
	# User should be www-data (like in generate.sh), but I use Fedora and root is the default one
	mkdir /var/www/tiny.synd
fi

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

# Remove unnecessary files
rm -f /var/www/tiny.synd/*.css
rm -rf /var/www/tiny.synd/fonts/
rm -f /var/www/tiny.synd/.files

# Remove references to stylesheets in all files
for file in $(find "/var/www/tiny.synd" -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