Skip to content

Commit

Permalink
add
Browse files Browse the repository at this point in the history
  • Loading branch information
tmorrell committed Feb 2, 2017
1 parent 8199662 commit 6ad359d
Show file tree
Hide file tree
Showing 4 changed files with 94 additions and 0 deletions.
60 changes: 60 additions & 0 deletions mk-website.bash
@@ -0,0 +1,60 @@
#!/bin/bash

function checkApp() {
APP_NAME=$1
if [ "$APP_NAME" = "" ]; then
echo "Missing $APP_NAME"
exit 1
fi
}

function softwareCheck() {
for APP_NAME in $@; do
checkApp $APP_NAME
done
}

function mkPage () {
nav="$1"
content="$2"
html="$3"

echo "Rendering $html"
mkpage \
"nav=$nav" \
"content=$content" \
page.tmpl > $html
}

function mkSite() {
FOLDER=$1

echo "Generating HTML content for $FOLDER"
find . -type f | grep -v .git | grep -E ".md$" | while read ITEM; do
FNAME=$(basename "$ITEM")
FOLDER=$(dirname "$ITEM")
if [ -f "$FOLDER/$FNAME" ] && [ "$FNAME" != "nav.md" ]; then
EXT=${FNAME:(-3)}
if [ "$EXT" = ".md" ]; then
HTML_FNAME=$(basename $FNAME .md).html
if [ "$HTML_FNAME" = "README.html" ]; then
HTML_FNAME=index.html
fi
# Prefer the local directory's nav.md to the root level one.
if [ -f "$FOLDER/nav.md" ]; then
mkPage "$FOLDER/nav.md" "$FOLDER/$FNAME" "$FOLDER/$HTML_FNAME"
else
mkPage "nav.md" "$FOLDER/$FNAME" "$FOLDER/$HTML_FNAME"
fi
git add "$FOLDER/$FNAME" "$FOLDER/$HTML_FNAME"
fi
fi
done
}

echo "Checking necessary software is installed"
softwareCheck mkpage
echo "Generating website"
mkSite "."


5 changes: 5 additions & 0 deletions nav.md
@@ -0,0 +1,5 @@

+ [Lesson](.)
+ [Topic 1](00-getting-started.html)
+ [Topic 2](01-working-with-openrefine.html)

26 changes: 26 additions & 0 deletions page.tmpl
@@ -0,0 +1,26 @@
<!DOCTYPE html>
<html>
<head>
<title>Author Carpentry</title>
<link rel="stylesheet" href="/css/site.css">
</head>
<body>
<header>
<a href="http://authorcarpentry.github.io"><img src="img/AClogo.jpg" alt="Author Carpentry logo"></a>
</header>
<nav>
{{ .nav }}
</nav>

<section>
{{ .content }}
</section>

<footer>
<span>&copy; 2017 <a href="http://library.caltech.edu/CLS_Copyright.htm">Caltech Library</a></span>
<address>1200 E California Blvd, Mail Code 1-32, Pasadena, CA 91125-3200</address>
<span><a href="mailto:library@caltech.edu">Email Us</a></span>
<span>Phone: <a href="tel:+1-626-395-3405">(626)395-3405</a></span>
</footer>
</body>
</html>
3 changes: 3 additions & 0 deletions publish.bash
@@ -0,0 +1,3 @@
#!/bin/bash
git commit -am snapshot
git push origin gh-pages

0 comments on commit 6ad359d

Please sign in to comment.