-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Current version of Markdown handout and exercise scripts
Includes rendering and running, delivery, and an example handout.
- Loading branch information
Showing
15 changed files
with
4,197 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
.DS_Store |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
|
||
<title>Example Handout</title> | ||
|
||
<link href="../../web/handout/handout-style.css" rel="stylesheet"></link> | ||
</head> | ||
<body> | ||
<header>6.HANDX — Handouts + Exercises</header> | ||
<!-- optional: nav.table-of-contents becomes a table of contents --> | ||
<nav class="table-of-contents"></nav> | ||
<main> | ||
|
||
<div class="markdown"> | ||
|
||
The page title is automatically added as a page heading. | ||
|
||
## Section | ||
|
||
Use `##` for sections. | ||
|
||
### Subsection | ||
|
||
Use `###` for subsections. | ||
Use `####` if necessary. | ||
|
||
**Bold**, *italic*, and `code` inline styles. | ||
|
||
+ Bulleted lists | ||
+ with `+` | ||
+ or `-` | ||
+ or `*` | ||
|
||
```java | ||
public static void main(String[] args) { | ||
System.out.println("Syntax-highlighted code"); | ||
} | ||
``` | ||
|
||
You must escape `<` characters. | ||
Sorry. | ||
|
||
<pre> | ||
Fixed-width block with **inline** *styles*. | ||
</pre> | ||
|
||
<div class="exercises"> | ||
|
||
# Exercise 1 | ||
|
||
Exercises are in a `<div class="exercises">`. | ||
|
||
Use `#` for exercise titles. | ||
|
||
Highlight questions using `##`: | ||
|
||
## What is the airspeed velocity of an unladen swallow? | ||
|
||
[x] Checkboxes | ||
[x] *with* **styles** | ||
[ ] `and code` | ||
|
||
( ) Radio buttons | ||
(x) *with* **styles** | ||
( ) `and code` | ||
|
||
Use Markdown blockquote (`>`) for explanations. | ||
|
||
> The answer is: 42. | ||
|
||
--- | ||
|
||
# Exercise 2 | ||
|
||
Separate multiple exercises with a Markdown horizontal rule (`---`). | ||
|
||
[x] OK | ||
|
||
Dropdowns and text fields have normal and `code` versions: | ||
|
||
[[ Drop, (down) ]] | ||
|
||
[[` code, (correct()), incorrect), (incorrect, incorrect() `]] | ||
|
||
= text field | ||
|
||
= `code text field` | ||
|
||
> Explanation with `inline_code` and a code block: | ||
> | ||
> ```java | ||
> public void blockOfCode() { } | ||
> ``` | ||
|
||
--- | ||
|
||
# Exercise 3 | ||
|
||
Text fields can also be checked against a regular expression: | ||
|
||
= /regular expression|regexp?/ regex | ||
|
||
= `/a +b +c/ a b c` | ||
|
||
</div> | ||
|
||
## Another section | ||
|
||
And so on, and so on. | ||
|
||
</div> | ||
|
||
</main> | ||
<!-- optional: footer containing © becomes a copyright message --> | ||
<footer>©</footer> | ||
<footer>MIT EECS</footer> | ||
<script src="../../web/handout/handout-render.js"></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
#!/bin/bash | ||
|
||
# | ||
# Handout Delivery | ||
# | ||
|
||
webmaster= # TODO [email protected] | ||
phantomjs="${PHANTOMJS:-/default/path/to/phantomjs-2.0}" # TODO | ||
deliver=web/handout/deliver/deliver.phantom.js | ||
home=home # special home page handout | ||
|
||
set -e | ||
set -u | ||
|
||
path="${1:?Must specify path}" | ||
src="${2:?Must specify source location}" | ||
www="${3:?Must specify www location}" | ||
handx="${4:?Must specify handx location}" | ||
|
||
abssrc="$(cd "$src" && pwd)" | ||
|
||
from="$src/$path/handout" | ||
deploy="$www/$path" | ||
if [ "$path" == "$home" ]; then | ||
# deploy home page to root | ||
deploy="$www" | ||
fi | ||
|
||
if [ ! -d "$from" ]; then | ||
echo -e "[no handouts] $path in $src" | ||
exit | ||
fi | ||
|
||
if [ ! -d "$deploy" ]; then | ||
echo -e "\033[1;31m[deploy skipped]\033[0m $path directory does not exist in $www" | ||
exit | ||
fi | ||
|
||
echo "[deploy] $path" | ||
|
||
[ -n "$webmaster" ] && sendmail "$webmaster" <<EOM | ||
Subject: [handx] updating $path | ||
$path updated by $USER | ||
$from -> $deploy | ||
EOM | ||
|
||
(cd "$from" && find . -mindepth 1 -type d) | # find directories | ||
sed 's/^.\///' | # relative dir names | ||
(cd "$deploy" && xargs -I DIR mkdir -p DIR) # create in www | ||
|
||
(cd "$from" && find . -type f) | # find files | ||
sed 's/^.\///' | # relative file names | ||
while read -r file; do # for each file... | ||
# handouts are HTML files that reference the handout script | ||
if [[ "$file" == *.html ]] && fgrep -q handout-render.js "$from/$file"; then | ||
# pre-render the handout | ||
echo " render $file" | ||
IFS=/ read -r kind handout part <<< "$path/${file%.html}" | ||
part="${part%index}"; part="${part%/}" | ||
[ -f "$deploy/$file" ] && rm "$deploy/$file" | ||
"$phantomjs" "$src/$deliver" "$from/$file" "$deploy/$file" "$handx" "$kind" "$handout" "$part" | ||
else | ||
# just copy the file | ||
echo " copy $file" | ||
cp "$from/$file" "$deploy/$file" | ||
fi | ||
case "$file" in | ||
*.html|*.svg) | ||
# fix paths to site CSS & JavaScript | ||
# ="../../../web/handout/handout-file" -> ="../../web/handout-file" | ||
perl -pi -e 's#(="[^"]*)/\.\./([^"]*)/handout/([^"]*")#\1/\2/\3#g' "$deploy/$file" | ||
if [ "$path" == "$home" ]; then | ||
# fix relative paths from home page | ||
# ="../web/something" -> ="web/something" | ||
perl -pi -e 's#(=")\.\./([^"]*")#\1\2#g' "$deploy/$file" | ||
fi | ||
;; | ||
esac | ||
done | ||
|
||
echo -e "\033[1;32m[deployed]\033[0m $path" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#!/bin/bash | ||
|
||
# | ||
# Athena Handout Delivery Wrapper | ||
# | ||
|
||
# TODO www=/mit/6.HANDX/www | ||
# TODO handx=/mit/6.HANDX/web_scripts/handx | ||
|
||
set -e | ||
set -u | ||
|
||
path="${1:?Must specify path}" | ||
|
||
scripts="$(dirname "$0")" # scripts directory | ||
scripts="$(cd "$scripts" && pwd)" # full path | ||
|
||
src="$(dirname "$scripts")" # semester directory | ||
|
||
semester="${src##*/}" # long semester name | ||
shortsem="${semester/#fall/fa}" # short semester name | ||
shortsem="${shortsem/#spring/sp}" | ||
|
||
from="$src/$path/handout" | ||
deploy="$www/$shortsem/$path" | ||
|
||
if [ ! -d "$from" ]; then | ||
echo -e "[no handouts] $path" | ||
exit | ||
fi | ||
|
||
if [ ! -d "$deploy" ]; then | ||
echo -e "\033[1;31m[deploy skipped]\033[0m $path directory does not exist in www. Create it:" | ||
echo "$ mkdir $deploy" | ||
echo 'Then push again or:' | ||
echo "$ $scripts/${0##*/} $path" | ||
exit | ||
fi | ||
|
||
"$scripts/deliver-handouts" "$path" "$src" "$www/$shortsem" "$handx/$shortsem/data" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
#!/bin/bash | ||
|
||
# | ||
# Repository Post-Receive Hook | ||
# | ||
|
||
# TODO snapshotdir=/mit/6.HANDX/path/to/repo-snapshot | ||
|
||
set -e | ||
set -u | ||
|
||
# meta-hook supplies original script name | ||
self="$1" | ||
|
||
semester="${self%/scripts/repo-post-receive-hook}" | ||
|
||
# be helpful to someone debugging this script | ||
if [ -z "$GIT_DIR" -o -z "$self" ]; then | ||
echo "Usage: echo <oldrev> <newrev> <branch> | GIT_DIR=<dir> $0 <path/to/self>" | ||
exit 1 | ||
fi | ||
|
||
master="refs/heads/master" | ||
|
||
while read -r oldrev newrev branch; do | ||
if [ "$branch" == "$master" ]; then | ||
break | ||
fi | ||
done | ||
|
||
if [ "$branch" != "$master" -o -z "$newrev" ]; then | ||
exit 0 | ||
fi | ||
|
||
# update our snapshot of master | ||
echo Updating snapshot in $snapshotdir | ||
GIT_WORK_TREE="$snapshotdir" git checkout -f | ||
|
||
# deploy handouts to the web | ||
git diff --name-only "$oldrev" "$newrev" | | ||
perl -lne "/$semester"'\/(.*)\/handout\// && print $1' | | ||
sort | uniq | | ||
while read -r dir; do | ||
"$snapshotdir/$semester/scripts/deliver-handouts-athena" "$dir" | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
/* | ||
* Course Handout Configuration | ||
* | ||
* Customize me! | ||
*/ | ||
|
||
HANDOUT_SEMESTER = 'IAP 2000'; | ||
HANDOUT_AUTHORS = 'Copyright Alice and Bob, all imaginary rights reserved.'; | ||
HANDOUT_HOME = 'http://example.com/6.HANDX/www/ia00/'; | ||
// optional: handx server for server-checked exercises | ||
// HANDOUT_EXERCISES = 'https://example.com/handx/ia00/'; |
Oops, something went wrong.