Skip to content

Commit

Permalink
Update build scripts to deploy new shiny Jekyll site linking to cours…
Browse files Browse the repository at this point in the history
…e assets
  • Loading branch information
benhylau committed Sep 24, 2018
1 parent 4ff8352 commit dbce526
Show file tree
Hide file tree
Showing 10 changed files with 175 additions and 18 deletions.
6 changes: 3 additions & 3 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ done

# Go through each module
for mod in module-*; do
# Create folder for each module
# Create folder for module
mkdir "$mod"

# Generate lesson plans .pdf
# Generate lesson plan .pdf
doc="$mod/README.md"
if [ -f $doc ]; then
out="output/$mod/$mod.pdf"
Expand All @@ -44,7 +44,7 @@ for mod in module-*; do
fi
done

# Generate presentation GitBooks
# Generate presentation GitBook
book="$mod/presentation"
if [ -d $book ]; then
out="output/$mod/presentation"
Expand Down
12 changes: 11 additions & 1 deletion module-1/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@
# 1: What is mesh?
---
layout: page
title: "What is mesh?"
module: "1"
contents:
- _articles/module-1/presentation.md
- _articles/module-1/pdf-assets.md
following: _articles/module-1/presentation.md
---

# Module 1: What is mesh?

| **Section** | **Length** |
|------------------------------------------------------------------------------------|------------|
Expand Down
12 changes: 11 additions & 1 deletion module-2/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@
# 2: Setting up your first node
---
layout: page
title: "Setting up your first node "
module: "2"
contents:
- _articles/module-2/presentation.md
- _articles/module-2/pdf-assets.md
following: _articles/module-2/presentation.md
---

# Module 2: Setting up your first node

| **Section** | **Length** |
|------------------------------------------------------------------------------------|------------|
Expand Down
12 changes: 11 additions & 1 deletion module-3/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@
# 3: Building nodes (hardware)
---
layout: page
title: "Building nodes (hardware)"
module: "3"
contents:
- _articles/module-3/presentation.md
- _articles/module-3/pdf-assets.md
following: _articles/module-3/presentation.md
---

# Module 3: Building nodes (hardware)

| **Section** | **Length** |
|------------------------------------------------------------------------------------|------------|
Expand Down
12 changes: 11 additions & 1 deletion module-4/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@
# 4: Planning a network
---
layout: page
title: "Planning a network"
module: "4"
contents:
- _articles/module-4/presentation.md
- _articles/module-4/pdf-assets.md
following: _articles/module-4/presentation.md
---

# Module 4: Planning a network

| **Section** | **Length** |
|------------------------------------------------------------------------------------------------------|------------|
Expand Down
12 changes: 11 additions & 1 deletion module-5/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@
# 5: Measuring networks
---
layout: page
title: "Measuring networks"
module: "5"
contents:
- _articles/module-5/presentation.md
- _articles/module-5/pdf-assets.md
following: _articles/module-5/presentation.md
---

# Module 5: Measuring networks

| **Section** | **Length** |
|------------------------------------------------------------------------------------|------------|
Expand Down
12 changes: 11 additions & 1 deletion module-6/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@
# 6: Living on a decentralized network
---
layout: page
title: "Living on a decentralized network"
module: "6"
contents:
- _articles/module-6/presentation.md
- _articles/module-6/pdf-assets.md
following: _articles/module-6/presentation.md
---

# Module 6: Living on a decentralized network

| **Section** | **Length** |
|------------------------------------------------------------------------------------|------------|
Expand Down
111 changes: 104 additions & 7 deletions package.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,113 @@

RELEASE_VERSION=$1

###################################################
# Package archives for releasing to GitHub Release
###################################################

# Create directory for release assets ready to be published
rm -rf publish
mkdir publish
#rm -rf publish
#mkdir publish

# Package assets in tar.gz and zip formats
tar --create --gzip -f "publish/workshop-materials-${RELEASE_VERSION}.tar.gz" -C output .
cd output; zip --recurse-paths "../publish/workshop-materials-${RELEASE_VERSION}.zip" .; cd ..
#tar --create --gzip -f "publish/workshop-materials-${RELEASE_VERSION}.tar.gz" -C output .
#cd output; zip --recurse-paths "../publish/workshop-materials-${RELEASE_VERSION}.zip" .; cd ..

##########################################
# Generate hosted assets for GitHub Pages
##########################################

# Replace home page in site directory with repo README.md
homepage="site/index.md"
rm -f "$homepage"
{
echo "---"
echo "layout: home"
echo "---"
} > "$homepage"
cat "README.md" >> "$homepage"

# Create directory for release assets in site directory
art="site/_articles"
rm -rf "$art"
mkdir "$art"

# Create folder for general assets
dst="$art/general"
mkdir "$dst"

# Create .pdf assets index file
{
echo "---"
echo "layout: page"
echo "title: 'General'"
echo "---"
echo "## General PDF assets" >> "$dst.md"
} > "$dst.md"

# Copy .pdf assets
for doc in output/general/*.pdf; do
if [ -f $doc ]; then
cp "$doc" "$dst"
filename=$(basename $doc)
echo "* [$filename]($filename)" >> "$dst.md"
fi
done

# Go through each module
for mod in module-*; do
# Create folder for module
dst="$art/$mod"
mkdir "$dst"

# Copy .md lesson plan
cp "$mod/README.md" "$dst.md"

# Create presentation index file
{
echo "---"
echo "layout: page"
echo "title: 'Presentation slides'"
echo "module: '$(echo "$mod" | sed 's/module-/Module /')'"
echo "---"
echo "## $(echo "Presentation slides for $mod" | sed 's/module-/Module /')"
} > "$dst/presentation.md"

# Copy presentation
cp -r "output/$mod/presentation" "$dst/presentation"
echo "* [presentation](index.html)" >> "$dst/presentation.md"

# Create .pdf assets index file
{
echo "---"
echo "layout: page"
echo "title: 'PDF assets'"
echo "module: '$(echo "$mod" | sed 's/module-/Module /')'"
echo "---"
echo "## $(echo "PDF assets for $mod" | sed 's/module-/Module /')"
} > "$dst/pdf-assets.md"

# Copy .pdf assets
mkdir "$dst/pdf-assets"

echo "" >> "$dst/pdf-assets.md"
echo "### Lesson plan" >> "$dst/pdf-assets.md"
cp "output/$mod/$mod.pdf" "$dst/pdf-assets"
filename="$mod.pdf"
echo "* [$filename]($filename)" >> "$dst/pdf-assets.md"

# Copy hosted assets to site directory
cp -r output site/materials
if [ -f output/$mod/worksheet/*.pdf ]; then
echo "" >> "$dst/pdf-assets.md"
echo "### Class worksheets" >> "$dst/pdf-assets.md"
for doc in output/$mod/worksheet/*.pdf; do
if [ -f $doc ]; then
cp "$doc" "$dst/pdf-assets"
filename=$(basename $doc)
echo "* [$filename]($filename)" >> "$dst/pdf-assets.md"
fi
done
fi
done

# Build static website
cd site; bundle install; bundle exec jekyll build; cd ..
cd site; bundle install; bundle exec jekyll build; cd ..
2 changes: 1 addition & 1 deletion site/_layouts/home.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ <h2>{{ site.subtitle }}</h2>

<div class="lesson-content">
{{ content }}
<a class="btn btn-lg btn-default btn-next" href="articles/readme">
<a class="btn btn-lg btn-default btn-next" href="articles/module-1">
Get started &nbsp; <i class="fa fa-play" aria-hidden="true"></i>
</a>
</div>
2 changes: 1 addition & 1 deletion site/contents.html
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
---
layout: default
contents:
- _articles/general.md
- _articles/module-1.md
- _articles/module-2.md
- _articles/module-3.md
- _articles/module-4.md
- _articles/module-5.md
- _articles/module-6.md
- _articles/general.md
---

{% include contents.html %}

0 comments on commit dbce526

Please sign in to comment.