Skip to content

Commit a537014

Browse files
committed
fixed website building python script
1 parent 8bbf00d commit a537014

File tree

3 files changed

+14
-8
lines changed

3 files changed

+14
-8
lines changed

make.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,12 @@ echo "$(date +'%0Y-%0m-%0d %0R:%0S'): Finished printing all installed packages."
3636
echo "$(date +'%0Y-%0m-%0d %0R:%0S'): We now execute the pdflatex compiler script."
3737
"$scriptDir/pdflatex.sh" "book.tex"
3838

39+
echo "$(date +'%0Y-%0m-%0d %0R:%0S'): We now execute the website building script."
40+
"$scriptDir/website.sh"
41+
3942
echo "$(date +'%0Y-%0m-%0d %0R:%0S'): Deactivating virtual environment."
4043
deactivate
4144
echo "$(date +'%0Y-%0m-%0d %0R:%0S'): Deleting virtual environment."
4245
rm -rf "$tempDir"
4346

44-
echo "$(date +'%0Y-%0m-%0d %0R:%0S'): We now execute the website building script."
45-
"$scriptDir/website.sh"
46-
4747
echo "$(date +'%0Y-%0m-%0d %0R:%0S'): We have finished the book building process."

scripts/pdflatex.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@ echo "$(date +'%0Y-%0m-%0d %0R:%0S'): We will use '$bibProgram' to process bibli
3030
"$bibProgram" --version
3131

3232
if [[ $(declare -p PYTHON_INTERPRETER) == declare\ ?x* ]]; then
33-
echo "Found python interpreter as: '$PYTHON_INTERPRETER'"
33+
echo "$(date +'%0Y-%0m-%0d %0R:%0S'): Found python interpreter as: '$PYTHON_INTERPRETER'"
3434
else
3535
export PYTHON_INTERPRETER="$(readlink -f "$(which python3)")"
36-
echo "Setting up python interpreter as '$PYTHON_INTERPRETER'."
36+
echo "$(date +'%0Y-%0m-%0d %0R:%0S'): Setting up python interpreter as '$PYTHON_INTERPRETER'."
3737
fi
3838

3939
latexGitProgram=("$PYTHON_INTERPRETER" "-m" "latexgit.aux")

scripts/website.sh

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,13 @@ echo "$(date +'%0Y-%0m-%0d %0R:%0S'): The script directory is '$scriptDir'."
1616
currentDir="$(pwd)"
1717
echo "$(date +'%0Y-%0m-%0d %0R:%0S'): We are working in directory: '$currentDir'."
1818

19+
if [[ $(declare -p PYTHON_INTERPRETER) == declare\ ?x* ]]; then
20+
echo "$(date +'%0Y-%0m-%0d %0R:%0S'): Found python interpreter as: '$PYTHON_INTERPRETER'"
21+
else
22+
export PYTHON_INTERPRETER="$(readlink -f "$(which python3)")"
23+
echo "$(date +'%0Y-%0m-%0d %0R:%0S'): Setting up python interpreter as '$PYTHON_INTERPRETER'."
24+
fi
25+
1926
websiteDir="$currentDir/website"
2027
echo "$(date +'%0Y-%0m-%0d %0R:%0S'): We will build the website into: '$websiteDir'."
2128

@@ -44,7 +51,7 @@ PART_A='<!DOCTYPE html><html><title>'
4451
PART_B='</title><style>code {background-color:rgb(204 210 95 / 0.3);white-space:nowrap;border-radius:3px}</style><body style="margin-left:5%;margin-right:5%">'
4552
PART_C='</body></html>'
4653
BASE_URL='https\:\/\/thomasweise\.github\.io\/programmingWithPython\/'
47-
echo "${PART_A}Programming with Python${PART_B}$(python3 -m markdown -o html ./README.md)$PART_C" > "$websiteDir/index.html"
54+
echo "${PART_A}Programming with Python${PART_B}$("$PYTHON_INTERPRETER" -m markdown -o html ./README.md)$PART_C" > "$websiteDir/index.html"
4855
sed -i "s/\"$BASE_URL/\".\//g" "$websiteDir/index.html"
4956
sed -i "s/=$BASE_URL/=.\//g" "$websiteDir/index.html"
5057
sed -i "s/<\/h1>/<\/h1><h2>built on\&nbsp;$(date +'%0Y-%0m-%0d %0R:%0S')<\/h2>/g" "$websiteDir/index.html"
@@ -53,10 +60,9 @@ echo "$(date +'%0Y-%0m-%0d %0R:%0S'): Finished copying README.md to index.html."
5360

5461
cd "$websiteDir"
5562
echo "$(date +'%0Y-%0m-%0d %0R:%0S'): Now minifying website."
56-
find -type f -name "*.html" -exec python3 -c "print('{}');import minify_html;f=open('{}','r');s=f.read();f.close();s=minify_html.minify(s,do_not_minify_doctype=True,ensure_spec_compliant_unquoted_attribute_values=True,keep_html_and_head_opening_tags=False,minify_css=True,minify_js=True,remove_bangs=True,remove_processing_instructions=True);f=open('{}','w');f.write(s);f.close()" \;
63+
find -type f -name "*.html" -exec "$PYTHON_INTERPRETER" -c "print('{}');import minify_html;f=open('{}','r');s=f.read();f.close();s=minify_html.minify(s,do_not_minify_doctype=True,ensure_spec_compliant_unquoted_attribute_values=True,keep_html_and_head_opening_tags=False,minify_css=True,minify_js=True,remove_bangs=True,remove_processing_instructions=True);f=open('{}','w');f.write(s);f.close()" \;
5764
echo "$(date +'%0Y-%0m-%0d %0R:%0S'): Done minifying website."
5865

5966
cd "$currentDir"
6067

6168
echo "$(date +'%0Y-%0m-%0d %0R:%0S'): The website building script has successfully completed."
62-

0 commit comments

Comments
 (0)