-
Notifications
You must be signed in to change notification settings - Fork 1
/
test
executable file
·64 lines (54 loc) · 1.43 KB
/
test
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
59
60
61
62
63
64
#!/bin/bash
#
# Validate HTML
# Stop on errors
set -Eeuo pipefail
# Check if we're in the right directory
PROJECT_HOME=$(cd $(dirname $0) && pwd -P)
if [ $(pwd) != "$PROJECT_HOME" ]; then
echo "Error: not in project root directory ${PROJECT_HOME}"
exit 1
fi
# Make sure publications list is up-to-date
cp docs/index.html tmp.html
./build tmp.html
if ! diff -q docs/index.html tmp.html > /dev/null; then
echo "Error: publications list is out-of-date"
rm -f tmp.html
exit 1
else
echo "Publications list is up-to-date"
rm -f tmp.html
fi
# Verify images are optimized for the web
IMAGES=$(ls docs/assets/images/*)
# File sizes should not be too big
for IMAGE in $IMAGES; do
SIZE=$(du "$IMAGE" | awk '{print $1}')
if [ "$SIZE" -ge 100 ]; then
echo "Error: size exceeds 100 kB ${IMAGE} ${SIZE}"
exit 1
fi
done
# Images should not contain EXIF data. It can reveal personal details like GPS
# location and cell phone serial number.
for IMAGE in $IMAGES; do
EXIF=$(identify -format '%[EXIF:*]' "$IMAGE")
if [ -n "$EXIF" ]; then
echo "Error: EXIF data not allowed (try ImageOptim) ${IMAGE}"
exit 1
fi
done
# Print commands
set -x
# Make sure copyright year is up-to-date
YEAR=$(date '+%Y')
grep -q "© 2009 - ${YEAR} Andrew DeOrio" docs/index.html
# Validate HTML
html5validator --root docs
# Check for bad links
linkchecker \
--check-extern \
--threads 100 \
--ignore-url=https://umich.instructure.com/ \
docs