Skip to content
Snippets Groups Projects
Commit 7a7f49ff authored by jurgenhaas's avatar jurgenhaas
Browse files

Initial commit

parents
No related branches found
No related tags found
No related merge requests found
Pipeline #33742 passed
before_script:
- docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
build-master:
stage: build
script:
- docker build -t $CI_REGISTRY_IMAGE .
- docker push $CI_REGISTRY_IMAGE
only:
- master
FROM ubuntu:20.04
ARG VERSION=0.9.0
LABEL com.example.vendor="LakeDrops" \
maintainer="juergen.haas@lakedrops.com" \
version="${VERSION}" \
description="An image for running mdshow based on reveal.js."
RUN echo "Adding system components" && \
apt-get update -y && \
DEBIAN_FRONTEND=noninteractive \
apt-get install -y -q \
autoconf automake curl g++ gcc jq make npm unzip && \
curl -L -o pandoc.deb https://github.com/jgm/pandoc/releases/download/2.9.2.1/pandoc-2.9.2.1-1-amd64.deb && \
dpkg -i pandoc.deb && \
rm pandoc.deb
ADD bin/* /usr/local/bin/
RUN echo "Setup MdShow" && \
mdshow setup && \
ln -s /opt/mdshow/reveal.js/node_modules/gulp/bin/gulp.js /usr/bin/gulp && \
chmod -R a+rwx /opt/mdshow && \
\
echo "Cleanup" && \
apt-get clean && \
rm -rf /root/.cache && \
rm -rf /var/cache/* && \
rm -rf /var/lib/apt/lists/* && \
rm -rf /var/log/* && \
rm -rf /root/.npm && \
echo "Completed"
ENTRYPOINT ["docker-entrypoint.sh"]
CMD ["/bin/bash"]
#!/bin/sh
set -e
# first arg is `-f` or `--some-option`
if [ "${1#-}" != "$1" ]; then
set -- docker "$@"
fi
# if our command is a valid Docker subcommand, let's invoke it through Docker instead
# (this allows for "docker run docker ps", etc)
if docker help "$1" > /dev/null 2>&1; then
set -- docker "$@"
fi
# if we have "--link some-docker:docker" and not DOCKER_HOST, let's set DOCKER_HOST automatically
if [ -z "$DOCKER_HOST" -a "$DOCKER_PORT_2375_TCP" ]; then
export DOCKER_HOST='tcp://docker:2375'
fi
if [ "$1" = 'dockerd' ]; then
cat >&2 <<-'EOW'
📎 Hey there! It looks like you're trying to run a Docker daemon.
You probably should use the "dind" image variant instead, something like:
docker run --privileged --name some-overlay-docker -d docker:stable-dind --storage-driver=overlay
See https://hub.docker.com/_/docker/ for more documentation and usage examples.
EOW
sleep 3
fi
exec "$@"
#!/usr/bin/make -f
# TODO: newer versions of env support this: !/usr/bin/env -S make -f
# NOTE JH: switched for yarn npm, because yarn does not install node_modules/node-jp/bin
# Author: Jan Christoph Ebersbach <jceb@e-jc.de>
# Copyright (c) 2020 Jan Christoph Ebersbach
# License: Apache-2.0
SHELL := /bin/bash
MDSHOW_CONFIG = /opt/mdshow
SLIDES = slides.md
BUILD_DIR = .build_$(basename $(SLIDES))
PORT = 3000
VERSION := v0.1
# {{{1 help
help:
@echo "mdshow: the simple markdown to reveal.js converter"
@echo "$(VERSION)"
@echo ""
@echo "Commands:"
@echo " build: build presentation"
@echo " html: convert presentation to a single HTML file"
@echo " pdf: convert presentation to PDF"
@echo " scaffold: create an empty presentation in the current folder"
@echo " serve: the HTML presentation at http://localhost:3000/"
@echo " setup: test and download dependencies"
@echo " themes: list all installed themes"
@echo " upgrade: upgrade mdshow to it's latest version"
@echo " version: prints the current version"
@echo ""
@echo "Variables:"
@echo " PORT=3000, defines the port"
@echo " SLIDES=slides.md, defines the filename"
@echo " Example: make serve PORT=3001 SLIDES=myslides.md"
@echo ""
@echo "Dependencies:"
@echo " curl, pandoc, unzip, npm"
# {{{1 version
version:
@echo "$(VERSION)"
# {{{1 upgrade
upgrade:
curl -L https://raw.githubusercontent.com/jceb/mdshow/master/mdshow -o $(realpath $(firstword $(MAKEFILE_LIST)))
chmod a+x $(realpath $(firstword $(MAKEFILE_LIST)))
# {{{1 setup
setup: programs \
sass \
$(MDSHOW_CONFIG)/defaults.css \
$(MDSHOW_CONFIG)/defaults.yaml \
$(MDSHOW_CONFIG)/pandoc/filters/fontawesome.lua \
$(MDSHOW_CONFIG)/pandoc/templates/default.revealjs \
$(MDSHOW_CONFIG)/pandoc/templates/metadata.extract \
$(MDSHOW_CONFIG)/reveal.js \
$(MDSHOW_CONFIG)/reveal.js/dist/fontawesome \
$(MDSHOW_CONFIG)/reveal.js/dist/plugin/highlight/styles/nord.css \
$(MDSHOW_CONFIG)/reveal.js/dist/Chart.bundle.min.js \
$(MDSHOW_CONFIG)/reveal.js/mdshow-gulp.js \
$(MDSHOW_CONFIG)/scaffold.md
programs:
@echo "Testing depedencies"
@type curl || echo "curl is not installed, required in the setup process"
@type pandoc || echo "pandoc is not installed, reqiured for converting markdown into a HTML presentation"
@type unzip || echo "unzip is not installed, required in the setup process"
@type npm || echo "npm is not installed, required for serving the presentation"
@type monolith || echo "(optional) monolith is not installed, needed for creating a single file HTML presentation"
$(BUILD_DIR)/reveal.js/defaults.css: $(MDSHOW_CONFIG)/defaults.css
ln -s $< $@
$(MDSHOW_CONFIG)/defaults.css:
@[ ! -e $(dir $@) ] && mkdir -p $(dir $@) || true
[ ! -e $@ ] && \
curl -L https://raw.githubusercontent.com/jceb/mdshow/master/assets/defaults.css -o $@
$(MDSHOW_CONFIG)/defaults.yaml:
@[ ! -e $(dir $@) ] && mkdir -p $(dir $@) || true
[ ! -e $@ ] && \
curl -L https://raw.githubusercontent.com/jceb/mdshow/master/assets/defaults.yaml -o $@
$(MDSHOW_CONFIG)/reveal.js/dist/fontawesome:
curl -L https://use.fontawesome.com/releases/v5.15.1/fontawesome-free-5.15.1-web.zip -o $(dir $@)/fontawesome-free-web.zip
unzip $(dir $@)/fontawesome-free-web.zip -d $(dir $@)
mv $(dir $@)/fontawesome-free-5.15.1-web $@
rm $(dir $@)/fontawesome-free-web.zip
$(MDSHOW_CONFIG)/reveal.js:
mkdir -p $@
curl -L https://github.com/hakimel/reveal.js/archive/4.1.0.zip -o $@/revealjs.zip
unzip $@/revealjs.zip -d $@
rm $@/revealjs.zip
mv $@/reveal.js-4.1.0/.??* $@/reveal.js-4.1.0/* $@
rmdir $@/reveal.js-4.1.0
cd $@ && \
npm install && npm add node-jq decktape gulp
# workarounds for the new reveal-js release
cd $@/dist && \
ln -s ../plugin .
$(MDSHOW_CONFIG)/reveal.js/dist: $(MDSHOW_CONFIG)/reveal.js
$(MDSHOW_CONFIG)/pandoc/filters/fontawesome.lua:
@[ ! -e $(dir $@) ] && mkdir -p $(dir $@) || true
[ ! -e $@ ] && \
curl -L https://raw.githubusercontent.com/jceb/mdshow/master/assets/pandoc/filters/fontawesome.lua -o $@
$(MDSHOW_CONFIG)/pandoc/templates/metadata.extract:
@[ ! -e $(dir $@) ] && mkdir -p $(dir $@) || true
echo '$$meta-json$$' > $@
$(MDSHOW_CONFIG)/pandoc/templates/default.revealjs:
@[ ! -e $(dir $@) ] && mkdir -p $(dir $@) || true
[ ! -e $@ ] && \
curl -L https://raw.githubusercontent.com/jceb/mdshow/master/assets/pandoc/templates/default.revealjs -o $@
$(MDSHOW_CONFIG)/reveal.js/dist/Chart.bundle.min.js:
@[ ! -e $(dir $@) ] && mkdir -p $(dir $@) || true
[ ! -e $@ ] && \
curl -L https://github.com/chartjs/Chart.js/releases/download/v2.9.3/Chart.bundle.min.js -o $@
$(MDSHOW_CONFIG)/reveal.js/dist/plugin/highlight/styles/nord.css:
[ ! -e $@ ] && \
cd $(shell dirname $(shell dirname $@)) && \
curl -L https://github.com/highlightjs/highlight.js/archive/10.2.1.tar.gz -o - | tar xz && \
mv highlight.js-10.2.1/src/styles . && \
rm -rf highlight.js-10.2.1
# {{{1 sass / theme builder
sass: $(MDSHOW_CONFIG)/reveal.js \
.sync-custom-themes \
.link-theme-assets \
.build-themes
.sync-custom-themes: $(wildcard $(MDSHOW_CONFIG)/theme/*/source/*.scss)
@[ -n "$^" ] && rsync -u $^ $(MDSHOW_CONFIG)/reveal.js/css/theme/source/ || true
.SECONDEXPANSION:
.build-themes: $$(addprefix $(MDSHOW_CONFIG)/reveal.js/dist/theme/,$$(addsuffix .css,$$(basename $$(notdir $$(wildcard $(MDSHOW_CONFIG)/reveal.js/css/theme/source/*.scss)))))
.SECONDEXPANSION:
.link-theme-assets: $$(addprefix $(MDSHOW_CONFIG)/reveal.js/dist/theme/,$$(basename $$(notdir $$(wildcard $(MDSHOW_CONFIG)/reveal.js/css/theme/source/*.scss))))
$(MDSHOW_CONFIG)/reveal.js/dist/theme/%.css: $(MDSHOW_CONFIG)/reveal.js/css/theme/source/%.scss
cd $(MDSHOW_CONFIG)/reveal.js && gulp css-themes
$(MDSHOW_CONFIG)/theme/%/assets:
mkdir -p $@
$(MDSHOW_CONFIG)/reveal.js/dist/theme/%: $(MDSHOW_CONFIG)/theme/%/assets
ln -s $< $@
# {{{1 themes
themes: $(MDSHOW_CONFIG)/reveal.js/dist $(wildcard $(MDSHOW_CONFIG)/reveal.js/dist/theme/*.css)
@ls -1 $(MDSHOW_CONFIG)/reveal.js/dist/theme/*.css | sed -ne 's/^.*\/\([^\/]*\).css$$/\1/p'
@echo "Change theme by adding the option 'theme: <name>' between the two --- .. --- delimiters at the top of $(SLIDES)."
# {{{1 scaffold
$(MDSHOW_CONFIG)/scaffold.md:
@[ ! -e $(dir $@) ] && mkdir -p $(dir $@) || true
[ ! -e $@ ] && \
curl -L https://raw.githubusercontent.com/jceb/mdshow/master/examples/$(SLIDES) -o $@
scaffold: $(MDSHOW_CONFIG)/scaffold.md
@([ -e $(SLIDES) ] && [ -e assets ] && \
echo "'$(SLIDES)' and or 'assets' already exists, nothing to do here.") || \
([ ! -e $(SLIDES) ] && \
cp $< $(SLIDES) && \
echo "Created slideshow template '$(SLIDES)'." || true) && \
([ ! -e assets ] && \
mkdir assets && \
echo "Created 'assets' folder." || true) && \
(echo "- Start editing your slides in '$(SLIDES)'" && \
echo "- Run 'mdshow serve' to live-preview the slides in the browser" && \
echo "- Run 'mdshow pdf' to store the slideshow in a PDF document") || true\
# {{{1 html
html: $(basename $(SLIDES)).html
$(basename $(SLIDES)).html: serving build
@type monolith
@echo "WARNING: images aren't included in the output when they're referred to as slide backgrounds, background-image=/data-background-image=!"
monolith -o $@ http://localhost:$(PORT)
# {{{1 build
build: $(BUILD_DIR)/config.json sass $(MDSHOW_CONFIG)/reveal.js/dist/fontawesome $(BUILD_DIR)/index.html
# {{{1 pdf
pdf: $(basename $(SLIDES)).pdf
$(basename $(SLIDES)).pdf: serving build
pdf_size="$$($(MDSHOW_CONFIG)/reveal.js/node_modules/node-jq/bin/jq -r '.pdf_size' < $(BUILD_DIR)/config.json)"; \
pdf_delay="$$($(MDSHOW_CONFIG)/reveal.js/node_modules/node-jq/bin/jq -r '.pdf_delay' < $(BUILD_DIR)/config.json)"; \
$(MDSHOW_CONFIG)/reveal.js/node_modules/.bin/decktape -p $${pdf_delay} -s $${pdf_size} http://localhost:$(PORT)/ $@ || \
echo "Failed to create $@. Is the mdshow server running? mdshow serve"
# {{{1 serve
$(MDSHOW_CONFIG)/reveal.js/mdshow-gulp.js:
@[ ! -e $(dir $@) ] && mkdir -p $(dir $@) || true
[ ! -e $@ ] && \
curl -L https://raw.githubusercontent.com/jceb/mdshow/master/assets/mdshow-gulp.js -o $@
serve: build $(MDSHOW_CONFIG)/reveal.js/mdshow-gulp.js
cd $(MDSHOW_CONFIG)/reveal.js && gulp -f mdshow-gulp.js --port=$(PORT) --slides="$(SLIDES)" --root="${PWD}/$(BUILD_DIR)"
serving:
@curl -s -I -o /dev/null http://localhost:$(PORT)
# {{{1 local directory
assets:
@[ ! -e $@ ] && mkdir $@
$(BUILD_DIR)/reveal.js: $(MDSHOW_CONFIG)/reveal.js/dist
@[ ! -e $(dir $@) ] && mkdir -p $(dir $@) || true
@[ ! -e $@ ] && ln -s $< $@ || true
$(BUILD_DIR)/.mdshow: $(MDSHOW_CONFIG)
@[ ! -e $@ ] && ln -s $< $@ || true
$(BUILD_DIR)/assets: assets
@[ ! -e $(dir $@) ] && mkdir -p $(dir $@) || true
@[ ! -e $@ ] && ln -s ../$< $@ || true
$(BUILD_DIR)/config.json: $(SLIDES) $(MDSHOW_CONFIG)/defaults.yaml $(MDSHOW_CONFIG)/pandoc/templates/metadata.extract
@[ ! -e $(dir $@) ] && mkdir -p $(dir $@) || true
pandoc --data-dir=$(MDSHOW_CONFIG)/pandoc --template=metadata.extract -f markdown+yaml_metadata_block $(MDSHOW_CONFIG)/defaults.yaml $< > $@
$(BUILD_DIR)/index.html: $(SLIDES) $(BUILD_DIR)/config.json $(BUILD_DIR)/reveal.js $(BUILD_DIR)/assets $(BUILD_DIR)/.mdshow $(BUILD_DIR)/reveal.js/defaults.css
PANDOC_ARGS=; \
theme="$$($(MDSHOW_CONFIG)/reveal.js/node_modules/node-jq/bin/jq -r '.theme' < $(BUILD_DIR)/config.json)"; \
[ -e "$(MDSHOW_CONFIG)/theme/$${theme}/include/in-header.html" ] && PANDOC_ARGS="$${PANDOC_ARGS} --include-in-header=$(MDSHOW_CONFIG)/theme/$${theme}/include/in-header.html"; \
[ -e "$(MDSHOW_CONFIG)/theme/$${theme}/include/before-body.html" ] && PANDOC_ARGS="$${PANDOC_ARGS} --include-before-body=$(MDSHOW_CONFIG)/theme/$${theme}/include/before-body.html"; \
[ -e "$(MDSHOW_CONFIG)/theme/$${theme}/include/after-body.html" ] && PANDOC_ARGS="$${PANDOC_ARGS} --include-after-body=$(MDSHOW_CONFIG)/theme/$${theme}/include/after-body.html"; \
pandoc \
$(MDSHOW_CONFIG)/defaults.yaml \
$(SLIDES) \
--data-dir=$(MDSHOW_CONFIG)/pandoc \
-f markdown+yaml_metadata_block \
-t revealjs \
--lua-filter fontawesome.lua \
--wrap=preserve \
--standalone \
--no-highlight \
--slide-level=2 \
-V revealjs-url=reveal.js \
-o $@ \
$${PANDOC_ARGS}
# {{{1 cleanup
clean:
rm -rf $(BUILD_DIR)
distclean:
[ -e $(MDSHOW_CONFIG)/defaults.yaml ] && mv $(MDSHOW_CONFIG)/defaults.yaml $(MDSHOW_CONFIG)/defaults.yaml.bak || true
[ -e $(MDSHOW_CONFIG)/scaffold.md ] && mv $(MDSHOW_CONFIG)/scaffold.md $(MDSHOW_CONFIG)/scaffold.md.bak || true
rm -rf $(MDSHOW_CONFIG)/reveal.js $(MDSHOW_CONFIG)/pandoc .build_*
# {{{1 .PHONY
.PHONY: \
.build-themes \
.link-theme-assets \
.sync-custom-themes \
build \
clean \
distclean \
help \
programs \
sass \
scaffold \
serve \
setup \
themes \
upgrade \
version
# vi: ft=make:tw=80:sw=4:ts=4:sts=0:noet:fdm=marker
mdshow 0 → 100755
#!/bin/bash
docker run --user=$(id -u) --rm --net=host --volume=$(pwd):/mdshow --workdir=/mdshow mdshow mdshow $@
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment