Skip to content
Permalink
Browse files

Merge branch 'master' of file:///home/seanho/Documents/sermons/reveal…

…-skel
  • Loading branch information
seanho00 committed Jun 22, 2020
2 parents 2409bac + 681ae18 commit 0c65f21c49e0270ab011c526b88d48fa1bd5480d
@@ -0,0 +1,76 @@
#! /bin/sh
# Run node.js script
# Link this script to .git/hooks/

repo=$PWD
name=$(basename $repo)
work=/tmp/$name
prod=/var/www/$name

extrepo=/home/git/$name
extbranch=site
extname=$(basename $extrepo)

unset GIT_DIR
export GIT_AUTHOR_EMAIL=git@seanho.com
export GIT_AUTHOR_NAME="Sean Ho"

while read oldrev newrev ref; do
[[ $ref =~ .*/master$ ]] || continue

export TRAVIS_COMMIT=$newrev

if [ -d $work/.git ]; then
echo "Using existing working dir $work..."
cd $work
git pull || exit 1
else
echo "Creating local checkout..."
mkdir $work && cd $work || exit 1
git clone $repo . || exit 1
fi

echo "Running npm install..."
npm install || exit 1

if [ -d $extname/.git ]; then
echo "Updating existing external repo $extname/$extbranch..."
cd $extname
git pull || exit 1
cd ..
else
echo "Cloning external repo $extname/$extbranch..."
git clone -b $extbranch $extrepo || exit 1
fi

echo "Importing images from $extname..."
mkdir -p static/$extname
cp -a $extname/*_files/figure-html/* static/$extname/ || exit 1

echo "Running npm test..."
npm test || exit 1

if [ -d dist/.git ]; then
echo "Using existing site branch..."
else
echo "Checking out site branch..."
rm -fr dist
git clone -b site $repo dist || exit 1
fi
rm -fr dist/*

echo "Running npm run dist..."
npm run dist || exit 1

echo "Committing to site..."
cd dist
git config user.email "$GIT_AUTHOR_EMAIL" || exit 1
git config user.name "$GIT_AUTHOR_NAME" || exit 1
git add . || exit 1
git commit -m "update site" || exit 1
git push || exit 1

echo "Deploying dist to production..."
rm -fr $prod/*
git --work-tree=$prod --git-dir=$repo checkout -f site || exit 1
done
@@ -1,8 +1,3 @@
*.swp
*.swo
*.sw[op]
~*
*~
node_modules
dist
*.log
.sass-cache
@@ -3,9 +3,10 @@
# Install Travis gem:
# apt-get install gcc libffi-dev ruby ruby-dev
# gem install travis --no-rdoc --no-ri
# travis login --org
# travis login

# Usage: $0 [-r user/repo] [<other travis opts>]
# If repo is not specified, travis defaults to repo from current dir

# defaults
github_key=""
@@ -14,6 +15,6 @@ github_key=""
CONF=$HOME/.travis-key.conf
[ -r "$CONF" ] && . "$CONF"

travis sync --org
travis enable --org $@
travis sync
travis enable $@
travis env set github_key "$github_key" -p $@
@@ -1,23 +1,19 @@
language: node_js
node_js:
- "9"
- "node"
cache:
directories:
- "node_modules"
addons:
apt:
packages:
- ghostscript
before_deploy:
- npm run dist
deploy:
provider: pages
skip_cleanup: true
github_token: $github_key
local_dir: dist
committer_from_gh: true
edge:
branch: v1.8.47
on:
all_branches: true
condition: $TRAVIS_BRANCH =~ ^(master|release-.*)$
@@ -2,60 +2,61 @@ module.exports = (grunt) ->
grunt.initConfig
pkg: grunt.file.readJSON 'package.json'

connect:
serve:
options:
port: 9000
hostname: 'localhost'

sass:
options:
implementation: require('node-sass')
includePaths: ['node_modules/reveal.js/css/theme/']
outputStyle: 'compressed'
theme:
files:
'static/css/boldblack.css': 'scss/boldblack.scss'

exec:
print: 'decktape -s 1024x768 reveal "http://localhost:9000/" <%= pkg.pdf %> --no-sandbox; true'
thumbnail: 'decktape -s 800x600 --screenshots --screenshots-directory . --slides 1 reveal "http://localhost:9000/#/title" static/img/thumbnail.jpg --no-sandbox; true'
reducePDF: 'mv <%= pkg.pdf %> print.pdf; gs -q -dNOPAUSE -dBATCH -dSAFER -dPDFSETTINGS=/ebook -sDEVICE=pdfwrite -sOutputFile=<%= pkg.pdf %> print.pdf'
qr: 'echo https://<%= pkg.config.pretty_url %> | qrcode -o static/img/<%= pkg.shortname %>-qr.png'

copy:
index:
src: '_index.html'
dest: 'index.html'
static:
expand: true
dot: true
cwd: 'static'
src: '**'
dest: 'dist/'
template:
expand: true
cwd: 'template'
src: '**'
dest: 'dist/'
options:
process: (content, path) ->
return grunt.template.process content
plugin:
expand: true
flatten: true
src: 'node_modules/reveal.js/plugin/notes/*'
dest: 'static/js/'
dist:
dest: 'dist/js/'

sass:
options:
implementation: require('node-sass')
includePaths: ['node_modules/reveal.js/css/theme/']
outputStyle: 'compressed'
theme:
files: [{
expand: true
src: [
'static/**'
'index.html'
]
dest: 'dist/'
},{
expand: true
flatten: true
src: 'static/img/favicon.*'
dest: 'dist/'
cwd: 'scss'
src: '*.scss'
dest: 'dist/css/'
ext: '.css'
}]

# Generated grunt vars
connect:
serve:
options:
port: 9000
hostname: 'localhost'
base: 'dist'

exec:
print: 'decktape -s 1024x768 --chrome-arg=--no-sandbox reveal "http://localhost:9000/" print.pdf; true'
thumbnail: 'decktape -s 800x600 --screenshots --screenshots-directory . --slides 1 --chrome-arg=--no-sandbox reveal "http://localhost:9000/#/title" thumb.pdf; mv thumb*.png dist/img/<%= pkg.shortname %>.png; true'
reducePDF: 'gs -q -dNOPAUSE -dBATCH -dSAFER -dPDFSETTINGS=/ebook -sDEVICE=pdfwrite -sOutputFile=dist/<%= pkg.shortname %>.pdf print.pdf'
qr: 'echo https://<%= pkg.config.pretty_url %> | qrcode -o dist/img/<%= pkg.shortname %>-qr.png'

# Macros for convenience
grunt.config.merge
pkg:
shortname: grunt.config('pkg.name').replace(/.*\//, '')
pdf: 'static/<%= pkg.shortname %>.pdf'
commit: (process.env.TRAVIS_COMMIT || "testing").substr(0,7)
config:
pretty_url: grunt.config('pkg.config.cname') unless grunt.config('pkg.config.pretty_url')
img: (id) ->
'https://sermons.seanho.com/img/' + id
bg: (id) ->
@@ -68,18 +69,10 @@ module.exports = (grunt) ->
# Autoload tasks from grunt plugins
require('load-grunt-tasks')(grunt)

grunt.registerTask 'cname',
'Create CNAME for Github Pages', ->
if grunt.config 'pkg.config.cname'
grunt.file.write 'dist/CNAME', grunt.config 'pkg.config.cname'

grunt.registerTask 'nojekyll',
'Disable Jekyll processing on Github Pages', ->
grunt.file.write 'dist/.nojekyll', ''

grunt.registerTask 'install',
'*Compile* templates', [
'copy:index'
'*Build* site', [
'copy:static'
'copy:template'
'copy:plugin'
'sass:theme'
]
@@ -93,13 +86,6 @@ module.exports = (grunt) ->
'exec:qr'
]

grunt.registerTask 'dist',
'*Copy* site to dist/ for deployment', [
'copy:dist'
'cname'
'nojekyll'
]

# Define default task.
grunt.registerTask 'default', [
'test'
@@ -3,26 +3,30 @@
## Intro
Reveal-skel is a forkable template for a presentation based on the [Reveal.js](http://lab.hakim.se/reveal-js/) HTML framework.

[Travis integration](.travis.yml) deploys to Github Pages via an [NPM script](package.json), calling a [Grunt task](Gruntfile.coffee) to copy the rendered site
into a subdir and push to the gh-pages branch.
[Travis-CI config](.travis.yml)
runs a [Node.js project](package.json),
calling [Grunt tasks](Gruntfile.coffee) to
build [the presentation](template/index.html) as a website and
deploy it on Github Pages via the `gh-pages` branch.

## Usage
* **Fork** the [reveal-skel](https://github.com/sermons/reveal-skel) project
+ Or `git remote add upstream https://github.com/sermons/reveal-skel`
+ Or in your own git repo, run `git remote add upstream https://github.com/sermons/reveal-skel`
* Setup a **Github token** for Travis [(see below)](#github-token-for-travis)
* **Edit** [package.json](package.json):
+ Package name, git repo, cname/URL
+ Package name, git repo, CNAME
+ Change `sample.md` to `slides.md`
+ Generate a new **multiplex ID** [(see below)](#multiplex-remote-control)
* Your slide **content** goes in [slides/slides.md](slides/slides.md)
* You may also want to **customize**:
+ user name, email in [package.json](package.json)
+ [README](README.md), [favicon](static/img/favicon.ico)
+ `pretty_url` defaults to the CNAME if it exists
+ [README](README.md), [favicon](static/favicon.ico)
* Static **assets** (CSS, JS, images, etc) go in [`static`](static)
+ Grunt will copy this dir as-is to the deployed site
+ Grunt will copy this dir as-is to the root of the deployed site

## Github token for Travis
+ **Connect** [Travis](https://travis-ci.org) to your Github account, if you haven't already
+ **Connect** [Travis](https://travis-ci.com) to your Github account, if you haven't already
+ On Github, create an access token: *Settings* &rarr; *Developer Settings* &rarr; *Personal access tokens* &rarr; **Generate new token**
+ *Token description*: e.g., "Travis push to gh-pages"
+ *Select scopes*: check "**repo**"
@@ -32,7 +36,7 @@ into a subdir and push to the gh-pages branch.
+ [Install](https://github.com/travis-ci/travis.rb#installation) the Travis **gem**
+ See note in the [travis-key script](travis-key) for details
+ Run `./travis-key` to [securely store the token in Travis](https://docs.travis-ci.com/user/encrypting-files/):
+ Commit, **push**, and check the [build log](https://travis-ci.org/) for errors
+ Commit, **push**, and check the [build log](https://travis-ci.com/) for errors

## Bot user for Travis deploy
If you don't want Travis to have full write-access
@@ -1,6 +1,6 @@
# Science and the Bible

[![Build status](https://travis-ci.org/sermons/sci-bib.svg)](https://travis-ci.org/sermons/sci-bib)
[![Build status](https://api.travis-ci.com/sermons/sci-bib.svg)](https://travis-ci.com/github/sermons/sci-bib)
[![Node deps](https://david-dm.org/sermons/sci-bib.svg)](https://david-dm.org/sermons/sci-bib)
[![Node devDeps](https://david-dm.org/sermons/sci-bib/dev-status.svg)](https://david-dm.org/sermons/sci-bib?type=dev)

0 comments on commit 0c65f21

Please sign in to comment.
You can’t perform that action at this time.