Skip to content

Commit

Permalink
Merge pull request #154 from leonopulos/Delegate-+-Staff-Crash-Course
Browse files Browse the repository at this point in the history
Delegate + Staff crash course Markdown files
  • Loading branch information
viroulep authored Jun 10, 2020
2 parents 005b4fc + 200e83e commit 61849cd
Show file tree
Hide file tree
Showing 23 changed files with 990 additions and 10 deletions.
5 changes: 3 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@ addons:
- worldcubeassociation.org
- staging.worldcubeassociation.org
before_install:
# Decrypt the RSA key file.
- openssl aes-256-cbc -K $encrypted_d2c91d5e690a_key -iv $encrypted_d2c91d5e690a_iv -in .travis/deploy_rsa.enc -out /tmp/deploy_rsa -d
- sudo bin/install_dependencies.sh
script: bin/build.sh
before_deploy:
# Decrypt the RSA key file.
- openssl aes-256-cbc -K $encrypted_d2c91d5e690a_key -iv $encrypted_d2c91d5e690a_iv -in .travis/deploy_rsa.enc -out /tmp/deploy_rsa -d
deploy:
- provider: pages
skip_cleanup: true
Expand Down
119 changes: 119 additions & 0 deletions assets/WCAlogo_notext.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 11 additions & 0 deletions assets/edudoc-header.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!DOCTYPE html>
<html>
<head></head>
<body>
<div style="border-bottom:1px solid black; text-align:center; width:100%; height:100%">
<div style="float:left; text-align:left">DOCUMENT_TITLE</div>
<div style="display:inline-block; margin:0 auto"><img src="../../assets/WCAlogo_notext.svg" height="50" alt="WCA logo" /></div>
<div style="float:right; text-align:right">Version: DATE</div>
</div>
<div style="padding-bottom:10px"> </div>
</body></html>
58 changes: 58 additions & 0 deletions assets/edudoc-style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
body {
margin 0;
padding 0;
font-family: arial;
font-size: 18px;
}

h1 {
text-align: center;
}

img.logo {
float: left;
padding: 20px;
}

li {
padding: 5px 0 5px 0;
}

.box {
border-style: solid;
font-weight: bold;
text-align: center;
margin: 20px;
padding: 5px;
}

.attention {
background: #fbe5a3;
}

.important {
background: #d26d6a;
}

.important p::before {
font-family: monospace;
content: 'IMPORTANT: ';
}

.centered {
margin-left: auto;
margin-right: auto;
display: block;
}

.page-break-before {
page-break-before: always;
}

.page-break-after {
page-break-after: always;
}

.text-right {
text-align: right;
}
53 changes: 46 additions & 7 deletions bin/build.sh
Original file line number Diff line number Diff line change
@@ -1,18 +1,57 @@
#!/bin/bash

set -x

wca_url="https://worldcubeassociation.org/"

# Find all Markdown files and build PDFs out of them.
# Find formal and legal Markdown files and build PDFs out of them.
find 'documents' -name '*.md' | while read file; do
echo "Processing $file, vanilla style"

html_name="${file%.md}.html"
pdf_name="${file%.md}.pdf"

# deliberately NOT using the pipe | operator here because wkhtml tries to resolve image links
# based on the location of its input file. If piping is used, wkhtml assumes /tmp as location
# and links like "./dummy-image.png" become "/tmp/dummy-image.png" instead of "edudoc/$project/dummy-image.png"
sed -r "s#wca\{([^}]*)\}#$wca_url\1#g" "$file" | # Replace wca{...} with absolute WCA URL.
pandoc | # Markdown -> HTML
wkhtmltopdf --encoding 'utf-8' --user-style-sheet 'assets/style.css' -T 15mm -B 15mm -R 15mm -L 15mm --quiet - "$pdf_name" # HTML -> PDF
pandoc -o "$html_name" # Markdown -> HTML
wkhtmltopdf --encoding 'utf-8' --user-style-sheet 'assets/style.css' -T 15mm -B 15mm -R 15mm -L 15mm --quiet "$html_name" "$pdf_name" # HTML -> PDF
done

compile_date=$(date '+%Y-%m-%d')

# Find educational Markdown files and build PDFs out of them.
find 'edudoc' -name '*.md' | while read file; do
echo "Processing $file, edudoc style"

pdf_name="${file%.md}.pdf"
html_name="${file%.md}.html"

header_html="${file%.md}-header.html"

file_headline=$(head -n 1 "$file")
document_title=$(echo "$file_headline" | sed -E "s/#+\s*//")

sed -E "s#DOCUMENT_TITLE#$document_title#g" "assets/edudoc-header.html" |
sed -E "s#DATE#$compile_date#g" > "$header_html"

pandoc -s --from markdown --to html5 --metadata pagetitle="$document_title" "$file" -o "$html_name" # Markdown -> HTML
wkhtmltopdf --encoding 'utf-8' --user-style-sheet 'assets/edudoc-style.css' -T 15mm -B 15mm -R 15mm -L 15mm --header-html "$header_html" --footer-center "[page]" --quiet "$html_name" "$pdf_name" # HTML -> PDF
done

# Move pdf files to build directory
# Remove potentially cached PDFs from last build run
rm -rf build
cp -r documents build
find build -name '*.md' -exec rm {} +
find documents -name '*.pdf' -exec rm {} +
# Create build dir so that the following cp operations maintain folder structure
mkdir build
# Copy generated content into build folder
cp -r documents build/
cp -r edudoc build/
# Remove source files from target build and trim empty directories
find build/ -type f -not -name "*.pdf" -delete
find build/ -type d -empty -delete
# Remove target PDF from source folder
find documents/ -name "*.pdf" -delete
find edudoc/ -name "*.pdf" -delete
find documents/ -name "*.html" -delete
find edudoc/ -name "*.html" -delete
2 changes: 1 addition & 1 deletion documents/WCA Bylaws.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<div style="margin: 200px auto; font-size: 1.8em;">
# World Cube Association
</div>
<img src="https://www.worldcubeassociation.org/files/WCAlogo_notext.svg" style="width: 60%; margin: auto;">
<img src="../assets/WCAlogo_notext.svg" style="width: 60%; margin: auto;">
</div>

<div class="page-break"></div>
Expand Down
Binary file added edudoc/competitor-tutorial/images/.DS_Store
Binary file not shown.
Binary file added edudoc/competitor-tutorial/images/DNF2moves.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added edudoc/competitor-tutorial/images/DNFslice.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added edudoc/competitor-tutorial/images/RegA4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added edudoc/competitor-tutorial/images/RegA6.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added edudoc/competitor-tutorial/images/cover.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added edudoc/competitor-tutorial/images/mat.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added edudoc/competitor-tutorial/images/nopenalty.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added edudoc/competitor-tutorial/images/plus2.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added edudoc/competitor-tutorial/images/scoresheet.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added edudoc/competitor-tutorial/images/stopwatch.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added edudoc/competitor-tutorial/images/unclear.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 61849cd

Please sign in to comment.