-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupdate_docs.sh
executable file
·94 lines (75 loc) · 2.49 KB
/
update_docs.sh
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#!/bin/bash
VENV_NAME=env_employment_map_Georgia
NOTEBOOK_NAME="Employment.ipynb"
NOTEBOOK_NAME_KA="დასაქმების რუკა.ipynb"
SELF=$(python3 -c "import os; print(os.path.realpath('${BASH_SOURCE[0]}'))")
SCRIPT_DIR="$(dirname "${SELF}")"
ENV_BIN="${SCRIPT_DIR}/${VENV_NAME}/bin/"
export JUPYTER_CONFIG_DIR="${SCRIPT_DIR}/.jupyter"
DOCS_DIR="${SCRIPT_DIR}/docs"
DOCS_DIR_KA="${SCRIPT_DIR}/docs/ka"
##
# Generate HTML
##
"${ENV_BIN}jupyter-nbconvert" "${NOTEBOOK_NAME}" \
--config "${JUPYTER_CONFIG_DIR}/jupyter_lab_config.py" \
--to html --output-dir="${DOCS_DIR}" --output="index" --template OGP_classic
##
# Generate HTML (ka_GE)
##
"${ENV_BIN}jupyter-nbconvert" "${NOTEBOOK_NAME_KA}" \
--config "${JUPYTER_CONFIG_DIR}/jupyter_lab_config.py" \
--to html --output-dir="${DOCS_DIR_KA}" --output="index" --template OGP_classic_ka
##
# Update the map.png
##
cp -f map.png "${DOCS_DIR}"
cp -f map.png "${DOCS_DIR_KA}"
##
# Generate PDF
##
"${ENV_BIN}jupyter-nbconvert" "${NOTEBOOK_NAME}" \
--embed-images --to pdf --output-dir="${DOCS_DIR}"
##
# Update custom 404 page
##
UPDATED_404_TODAY=$(python3 <<EOF
import os
from datetime import datetime as dt
from datetime import timedelta as td
print((dt.now() - dt.fromtimestamp(os.path.getctime("docs/404.html"))) < td(days=1))
EOF
)
# Rate limiting to one download per day:
if [ "${UPDATED_404_TODAY}" != "True" ];then
echo "Updating custom 404 page"
rm -f "${DOCS_DIR}/404.html"
curl --output "${DOCS_DIR}/404.html" "https://raw.githubusercontent.com/sentinel-1/sentinel-1.github.io/master/docs/404.html"
else
echo "SKIPPING custom 404 page update"
fi
##
# Commit the "Generate updated docs" if requested
##
if [ "${1}" == "commit" ];then
echo
echo "** You requested to make the \"Generate updated docs\" commit in addition."
echo
while true;do
read -p "Do you want to continue? [Y/n] " yn
case ${yn} in
[Yy]*) break ;;
[Nn]*) echo "Abort."; exit -1 ;;
esac
done
echo " - Resetting the git staging area"
git reset
echo " - Adding the ./docs/ directory to the git staging area"
git add ./docs/
echo " - Making the \"Generate updated docs\" commit"
git commit -m "Generate updated docs"
echo " - done commiting the \"Generate updated docs\""
else
echo "** You did NOT request to make the \"Generate updated docs\" commit in addition."
echo " - Pass the \"commit\" as an argument to this script in order to request the commit."
fi