Compare commits

..

No commits in common. "c4038b34cf6e20150e85bdf2eee32d9c81d7b04e" and "4f983647f1912ef80b81dd92ef3a88e90f4ae536" have entirely different histories.

27 changed files with 4337 additions and 2251 deletions

View file

@ -2,8 +2,3 @@
examples
exercises
node_modules
.drone.yml
docs/*.md
docs/**/*.md
slides/*.md
slides/**/*.md

View file

@ -1,59 +0,0 @@
---
kind: pipeline
type: docker
name: default
steps:
- name: debug
image: alpine
environment:
commands:
- 'echo "Repository: glenux/docmachine"'
- 'echo "Git commit: ${DRONE_COMMIT_SHA:0:8}"'
- name: publish:commit_branch
image: plugins/docker
# volumes:
# - name: cache
# path: /stupid
settings:
username:
from_secret: DOCKERHUB_USERNAME
password:
from_secret: DOCKERHUB_PASSWORD
cache_from: "glenux/docmachine:latest_${DRONE_BRANCH/\\//-}"
context: .
dockerfile: docker/Dockerfile
repo: glenux/docmachine
tags:
- "latest_${DRONE_BRANCH/\\//-}"
- "${DRONE_COMMIT_SHA:0:8}"
purge: false
when:
branch:
- "master"
- "develop"
- "feature/*"
- name: publish:latest
image: plugins/docker
settings:
username:
from_secret: DOCKERHUB_USERNAME
password:
from_secret: DOCKERHUB_PASSWORD
cache_from: "glenux/docmachine:latest_${DRONE_BRANCH/\\//-}"
context: .
dockerfile: docker/Dockerfile
repo: glenux/docmachine
tags: latest
purge: false
when:
branch:
- master
# volumes:
# - name: cache
# temp: {}
#

1
.gitignore vendored
View file

@ -3,7 +3,6 @@
.bundle
*.docx
*.epub
/slides/autoslide.md
/images/*.circo.svg
/images/*.dot.svg
/images/*.ora.png

View file

@ -5,10 +5,8 @@ build: theme.css
%.css: %.scss
cd .. \
&& npx sass --no-error-css --no-source-map .marp/$<:.marp/$@ \
&& npx node-sass --output-style compressed .marp/$< > .marp/$@ \
|| ( rm -f .marp/$@ && exit 1 )
.PHONY: build
clean:
rm -f theme.css

View file

@ -1,7 +1,6 @@
// engine.js
// You have to run `npm i @marp-team/marp-core` at first.
const { Marp } = require('@marp-team/marp-core')
const highlightLines = require('markdown-it-highlight-lines')
module.exports = opts => {
@ -11,12 +10,11 @@ module.exports = opts => {
opts.html = true
// console.log(opts)
const marp = new Marp(opts)
// Disable parsing fragmented list
marp.markdown.core.ruler.disable('marpit_fragment')
// Enable code lines highlighting
// ref. https://github.com/marp-team/marp-vscode/issues/146
return marp.use(highlightLines)
return marp
}

View file

@ -2,15 +2,14 @@
@import-theme 'default';
$primaryColor: #662d91;
$secondaryColor: #f60;
$tertiaryColor: #241c1c;
$secondaryColor: #241c1c;
$tertiaryColor: #111111;
$textColor: #111111;
body {
--primary-color: $primaryColor;
--secondary-color: $secondaryColor;
--tertiary-color: $tertiaryColor;
--text-color: $textColor;
--text-color: $tertiaryColor;
}
section {
@ -19,14 +18,6 @@ section {
padding: 120px 80px 80px 80px;
}
// https://github.com/marp-team/marp-vscode/issues/146
.highlighted-line {
background-color: #ff0;
display: block;
margin: 0 -16px;
padding: 0 16px;
}
section footer {
opacity: 0.75;
color: $textColor; }
@ -140,23 +131,6 @@ section > h6:first-child::before
section:not(.chapter) > h2:first-child {
font-size: 100%; }
section.draft {
box-shadow: inset 20px 20px 0px red, inset -20px 20px 0px red, inset 20px -20px 0px red, inset -20px -20px 0px red;
}
section.draft::before {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%) rotate(-30deg);
font-size: 100px;
display: block;
content: "DRAFT";
color: darkred;
opacity: 0.25;
}
a {
color: inherit;
text-decoration: underline; }
@ -185,22 +159,10 @@ bc-row > bc-column {
flex: 1 1 0;
}
bc-row > bc-column[bc-margin-small] {
margin-left: 50px;
}
bc-row > bc-column[bc-margin-tiny] {
margin-left: 25px;
}
bc-row > bc-column[bc-text-small] {
font-size: 90%;
}
bc-row > bc-column[bc-text-tiny] {
font-size: 80%;
}
bc-row > bc-column[bc-width-large] {
flex: 2 1 0;
}
@ -217,12 +179,6 @@ bc-row > bc-column[bc-secondary] {
padding: 24px;
}
bc-row > bc-column[bc-tertiary] {
background-color: $tertiaryColor;
color: white;
padding: 24px;
}
bc-row > bc-column[bc-grey] {
background-color: #eeeeee;
padding: 24px;
@ -238,10 +194,6 @@ bc-row > bc-column:first-of-type {
margin-left: 0px;
}
bc-row > bc-column p:only-child {
margin-bottom: 0px;
}
bc-row > bc-column > h1:first-child,
bc-row > bc-column > h2:first-child,
bc-row > bc-column > h3:first-child,
@ -251,7 +203,7 @@ bc-row > bc-column > h6:first-child {
margin-top: 0;
}
p img:only-child[alt*="center"] {
p img:first-child:last-child[alt*="center"] {
display: block;
margin-left: auto;
margin-right: auto;

183
Makefile
View file

@ -29,35 +29,33 @@ DOCS_PORT=5100
SLIDES_PORT=5200
## Find .md slides
SLIDES_MDPP=$(shell find -L $(SLIDES_DIR) -regextype sed \( -name '*.mdpp' ! -regex '.*/_.*' \))
SLIDES_MDPP=$(shell find $(SLIDES_DIR) \( -name '*.mdpp' ! -name '_*' \))
SLIDES_MDPP_MD=$(patsubst $(SLIDES_DIR)/%.mdpp,$(CACHE_SLIDES_DIR)/%.mdpp.md,$(SLIDES_MDPP))
SLIDES_MDPP_MD_PDF=$(patsubst $(CACHE_SLIDES_DIR)/%.mdpp.md,$(BUILD_SLIDES_DIR)/%.pdf,$(SLIDES_MDPP_MD))
SLIDES_MDPP_MD_PPTX=$(patsubst $(CACHE_SLIDES_DIR)/%.mdpp.md,$(BUILD_SLIDES_DIR)/%.pptx,$(SLIDES_MDPP_MD))
SLIDES_MD=$(shell find -L $(SLIDES_DIR) -regextype sed \( -name '*.md' ! -regex '.*/_.*' \)) $(SLIDES_MDPP_MD)
SLIDES_MD=$(shell find $(SLIDES_DIR) \( -name '*.md' ! -name '_*' \)) $(SLIDES_MDPP_MD)
SLIDES_MD_PDF=$(patsubst $(SLIDES_DIR)/%.md,$(BUILD_SLIDES_DIR)/%.pdf,$(SLIDES_MD))
SLIDES_MD_PPTX=$(patsubst $(SLIDES_DIR)/%.md,$(BUILD_SLIDES_DIR)/%.pptx,$(SLIDES_MD))
SLIDES_MD_ALL=$(SLIDES_MDPP_MD) $(SLIDES_MD) $(SLIDES_DIR)/autoslide.md
SLIDES_PDF_ALL=$(SLIDES_MDPP_MD_PDF) $(SLIDES_MD_PDF) $(BUILD_SLIDES_DIR)/autoslide.pdf
SLIDES_PPTX_ALL=$(SLIDES_MDPP_MD_PPTX) $(SLIDES_MD_PPTX) $(BUILD_SLIDES_DIR)/autoslide.pptx
DOCS_MD=$(shell find -L $(DOCS_DIR) -regextype sed \( -name '*.md' ! -regex '.*/_.*' \))
SLIDES_MD_ALL=$(SLIDES_MDPP_MD) $(SLIDES_MD)
SLIDES_PDF_ALL=$(SLIDES_MDPP_MD_PDF) $(SLIDES_MD_PDF)
SLIDES_PPTX_ALL=$(SLIDES_MDPP_MD_PPTX) $(SLIDES_MD_PPTX)
## Find .uml graphs
DOCS_IMAGES_UML=$(shell find -L $(IMAGES_DIR) -regextype sed \( -name '*.uml' ! -regex '.*/_.*' \))
DOCS_IMAGES_UML=$(shell find $(IMAGES_DIR) \( -name '*.uml' ! -name '_*' \))
DOCS_IMAGES_UML_SVG=$(patsubst $(IMAGES_DIR)/%.uml,$(BUILD_IMAGES_DIR)/%.uml.svg,$(DOCS_IMAGES_UML))
## Find .dot graphs
DOCS_IMAGES_DOT=$(shell find -L $(IMAGES_DIR) -regextype sed \( -name '*.dot' ! -regex '.*/_.*' \))
DOCS_IMAGES_DOT=$(shell find $(IMAGES_DIR) \( -name '*.dot' ! -name '_*' \))
DOCS_IMAGES_DOT_SVG=$(patsubst $(IMAGES_DIR)/%.dot,$(BUILD_IMAGES_DIR)/%.dot.svg,$(DOCS_IMAGES_DOT))
## Find .circo graphs
DOCS_IMAGES_CIRCO=$(shell find -L $(IMAGES_DIR) -regextype sed \( -name '*.circo' ! -regex '.*/_.*' \))
DOCS_IMAGES_CIRCO=$(shell find $(IMAGES_DIR) \( -name '*.circo' ! -name '_*' \))
DOCS_IMAGES_CIRCO_SVG=$(patsubst $(IMAGES_DIR)/%.circo,$(BUILD_IMAGES_DIR)/%.circo.svg,$(DOCS_IMAGES_CIRCO))
## Find .ora images
DOCS_IMAGES_ORA=$(shell find -L $(IMAGES_DIR) -regextype sed \( -name '*.ora' ! -regex '.*/_.*' \))
DOCS_IMAGES_ORA=$(shell find $(IMAGES_DIR) \( -name '*.ora' ! -name '_*' \))
DOCS_IMAGES_ORA_PNG=$(patsubst $(IMAGES_DIR)/%.ora,$(BUILD_IMAGES_DIR)/%.ora.png,$(DOCS_IMAGES_ORA))
## Merge all lists
@ -70,8 +68,21 @@ all: help
## Install prerequisites
##
.PHONY: prepare
prepare:
prepare: prepare-slides prepare-docs ## install prerequisites
prepare-slides: ## install prerequisites for PDF slides only
npm install
npx browserslist@latest --update-db
prepare-docs: ## install prerequisites for static docs site only
pipenv install
# if [ "$(SYSTEM_INSTALL)" -eq 1 ]; then \
# pipenv install --deploy --system ; \
#else \
# pipenv install ; \
#fi
.PHONY: prepare prepare-slides prepare-docs
images: $(DOCS_IMAGES_SVG) $(DOCS_IMAGES_PNG) ## build images
@echo "Source:"
@ -80,9 +91,6 @@ images: $(DOCS_IMAGES_SVG) $(DOCS_IMAGES_PNG) ## build images
@echo " dot: $(DOCS_IMAGES_DOT)"
@echo " circo: $(DOCS_IMAGES_CIRCO)"
@echo "Built: $(DOCS_IMAGES_SVG) $(DOCS_IMAGES_PNG)"
for dir in $$(find -L $(DOCS_DIR) -type d -regextype sed -regex '.*/[0-9][^/]*/images$$') $(DOCS_DIR)/images ; do \
rsync -av $$dir/ $(SLIDES_DIR)/images/ || exit 1 ; \
done
.PHONY: images
@ -106,16 +114,80 @@ $(CACHE_SLIDES_DIR)/%.mdpp.md: $(SLIDES_DIR)/%.mdpp
m4 -d -I$(SLIDES_DIR) -I$(CACHE_SLIDES_DIR) $< > $@ \
|| ( rm -f $@ && exit 1 )
.marp/theme.css:
cd .marp && $(MAKE) theme.css
watch: ## run development server
$(MAKE) autoslide
pipenv run honcho start
pipenv run honcho start
autoslide:
find $(DOCS_DIR) -regextype sed -regex '.*/[0-9][^/]*\.md' -print0 \
| sort -z |xargs -0 cat \
> $(SLIDES_DIR)/autoslide.md
watch-autoslide-internal:
while inotifywait -q -e move -e modify -e create -e attrib -e delete -e moved_to -r $(DOCS_DIR) ; do \
sleep 0.25 ; \
$(MAKE) autoslide ; \
done
watch-tocupdate-internal:
while inotifywait -q -e move -e modify -e create -e attrib -e delete -e moved_to -r $(DOCS_DIR) ; do \
sleep 2 ; \
$(MAKE) images ; \
done
watch-docs-internal:
pipenv run mkdocs serve --dev-addr 0.0.0.0:$(DOCS_PORT)
watch-slides-internal: .marp/theme.css
PORT=$(SLIDES_PORT) \
npx marp \
--engine $$(pwd)/.marp/engine.js \
--html \
--theme $$(pwd)/.marp/theme.css \
-w $(SLIDES_DIR) \
-s
watch-slides: ## run development server for PDF slides
pipenv run honcho start slides autoslide
watch-docs: ## run development server for static docs site
pipenv run honcho start docs toc
serve: watch
serve-slides: watch-slides
serve-docs: watch-docs
.PHONY: watch serve
.PHONY: watch-docs serve-docs
.PHONY: watch-docs-internal
.PHONY: watch watch-slides watch-docs watch-slides-internal watch-docs-internal serve serve-docs serve-slides
$(BUILD_SLIDES_DIR)/%.pdf: $(CACHE_SLIDES_DIR)/%.mdpp.md | $(BUILD_SLIDES_DIR) .marp/theme.css
npx marp --allow-local-files \
--engine $$(pwd)/.marp/engine.js \
--html \
--theme $$(pwd)/.marp/theme.css \
$< \
-o $@
$(BUILD_SLIDES_DIR)/%.pdf: $(SLIDES_DIR)/%.md | $(BUILD_SLIDES_DIR) .marp/theme.css
npx marp --allow-local-files \
--engine $$(pwd)/.marp/engine.js \
--html \
--theme $$(pwd)/.marp/theme.css \
$< \
-o $@
$(BUILD_SLIDES_DIR)/%.pptx: $(SLIDES_DIR)/%.md | $(BUILD_SLIDES_DIR) .marp/theme.css
npx marp --allow-local-files \
--engine $$(pwd)/.marp/engine.js \
--html \
--theme $$(pwd)/.marp/theme.css \
$< \
-o $@
$(BUILD_SLIDES_DIR):
mkdir -p $(BUILD_SLIDES_DIR)
##
## Build final documents
@ -134,7 +206,37 @@ build-html: build-docs-html build-slides-html ## build both docs and slides as
build-docs: build-docs-pdf build-docs-html ## build only docs as PDF and HTML
.PHONY: build
build-slides: build-slides-pdf build-slides-html ## build only slides as PDF and HTML
build-slides-pptx: $(SLIDES_PPTX_ALL) $(SLIDES_PPTX_ALL) ## build PDF slides only
build-slides-pdf: $(SLIDES_PDF_ALL) $(SLIDES_MD_ALL) ## build PDF slides only
build-slides-html: $(SLIDES_HTML_ALL) ## build HTML slides only
merge-slides: $(SLIDES_MDPP_MD) $(SLIDES_MD_ALL)
build-docs-pdf: ## build pdf docs only
mkdir -p $(BUILD_DOCS_DIR)
rm -f $(BUILD_DOCS_DIR)/combined.pdf
PYTHONUTF8=1 \
ENABLE_PDF_EXPORT=1 \
pipenv run mkdocs build \
--site-dir $(BUILD_DOCS_DIR)
pdftk \
$$(find $(BUILD_DOCS_DIR) -name *.pdf -not -name index.pdf |sort ) \
cat output $(BUILD_DOCS_DIR)/combined.pdf
build-docs-html: ## build static docs site only
mkdir -p $(BUILD_DOCS_DIR)
pipenv run mkdocs build \
--site-dir $(BUILD_DOCS_DIR)
.PHONY: build build-slides
deploy-docs: ## deploy static docs site to github
git push $(DEPLOY_REPO)
pipenv run mkdocs gh-deploy $(DEPLOY_OPTS)
help: ## print this help
@echo "Usage: make <target>"
@ -153,13 +255,36 @@ help: ## print this help
## Clean
##
clean: # remove generated documents
clean: clean-slides clean-docs # remove generated documents
.PHONY: clean
clean-slides:
rm -fr $(BUILD_SLIDES_DIR) # remove generated PDF slides
include tasks/docs.mk
include tasks/slides.mk
include tasks/docker.mk
include tasks/utils.mk
include tasks/images.mk
clean-docs:
rm -fr $(BUILD_DOCS_DIR) # remove generated static docs site
.PHONY: clean clean-slides clean-docs
##
## Utilities
##
fixme:
@egrep --color -rni '(fixme)' $(DOCS_DIR) $(SLIDES_DIR)
.PHONY: fixme
docker-build: ## build docker image
docker build \
--file docker/Dockerfile \
--tag glenux/teaching-boilerplate:$(BUILD_VERSION) \
.
docker tag \
glenux/teaching-boilerplate:$(BUILD_VERSION) \
glenux/teaching-boilerplate:latest
docker-push: ## push docker image
env docker push glenux/teaching-boilerplate:latest
docker-pull: ## download docker image
env docker pull glenux/teaching-boilerplate:latest

View file

@ -20,4 +20,4 @@ pymdown-extensions = "*"
mkdocs-pdf-export-plugin = "*"
[requires]
python_version = "3.11"
python_version = "3.9"

1257
Pipfile.lock generated

File diff suppressed because it is too large Load diff

View file

@ -1,7 +1,4 @@
# src-docs: make sync-docs-internal
# src-slides: make sync-slides-internal
src-autoslide: make watch-autoslide-internal
watch-docs: make watch-docs-internal
watch-slides: make watch-slides-internal
watch-toc: make watch-tocupdate-internal
# proxy: caddy
docs: make watch-docs-internal
slides: make watch-slides-internal
toc: make watch-tocupdate-internal
autoslide: make watch-autoslide-internal

View file

@ -1,26 +1,10 @@
<!--
# SPDX-License-Identifier: GPL-3.0-or-later
#
# SPDX-FileCopyrightText: 2023 Glenn Y. Rolland <glenux@glenux.net>
# Copyright © 2023 Glenn Y. Rolland <glenux@glenux.net>
-->
# Teaching-Boilerplate
[![Build Status](https://cicd.apps.glenux.net/api/badges/glenux/docmachine-containers/status.svg)](https://cicd.apps.glenux.net/glenux/docmachine-containers)
![License LGPL3.0-or-later](https://img.shields.io/badge/license-LGPL3.0--or--later-blue.svg)
[![Donate on patreon](https://img.shields.io/badge/patreon-donate-orange.svg)](https://patreon.com/glenux)
## Prerequisites :
> :information_source: This project is available on our self-hosted server and
> on CodeBerg and GitHub as mirrors. For the latest updates and comprehensive
> version of our project, please visit our primary repository at:
> <https://code.apps.glenux.net/glenux/docmachine-containers>.
Make sure you have docker installed
# DocMachine Containers
## Prerequisites
Make sure you have Docker installed.
## Writing content
## Usage
### Create your directory tree
@ -34,43 +18,33 @@ Make sure you have Docker installed.
|- ...
```
### Content for docs
### Write content for docs
FIXME: tree structure
FIXME: autoslide feature
### Write content for slides
### Content for slides
FIXME: tree structure
## Watch mode
### Watch mode
This mode allows you the result on-the-fly as you makea changes in the content.
To use watch mode, type:
docmachine -a watch
make watch
To use watch mode for slides only type:
docmachine -a watch-slides
make watch-slides
To use watch mode for docs only type:
docmachine -a watch-docs
make watch-docs
## Build mode
### Build mode
This mode builds final content for delivery (website, PDF files)
### Building HTML
To use build mode:
docmachine build
### Building PDF
make build

View file

@ -1,10 +0,0 @@
handle_path /docs* {
reverse_proxy 127.0.0.1:5100
}
handle_path /slides* {
reverse_proxy 127.0.0.1:5200
}

View file

@ -1,5 +1,5 @@
FROM node:18-bookworm-slim
LABEL maintainer="Glenn ROLLAND glenux@glenux.net"
FROM node:bullseye-slim
MAINTAINER Glenn ROLLAND <glenux@glenux.net>
RUN apt-get update \
&& apt-get install -y --no-install-recommends python3 python3-pip pipenv \
@ -9,7 +9,7 @@ RUN apt-get update \
# Tools for running the common parts
RUN apt-get update \
&& apt-get install -y --no-install-recommends make build-essential inotify-tools gosu unzip curl rsync \
&& apt-get install -y --no-install-recommends make build-essential inotify-tools gosu unzip curl \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* \
&& truncate -s 0 /var/log/*log
@ -28,7 +28,6 @@ RUN curl -sSL -o /usr/local/bin/yq \
&& chmod +x /usr/local/bin/yq
COPY . /app
COPY .marp /app/.marp
WORKDIR /app
ENV LANG=C.UTF-8 \

View file

@ -1,49 +0,0 @@
p > img[alt*="center"] {
display: block;
margin-left: auto;
margin-right: auto;
}
hr {
display: none;
}
@page {
size: a4 portrait;
margin: 25mm 10mm 25mm 10mm;
counter-increment: page;
font-family: "Noto", sans-serif;
white-space: pre;
color: grey;
@top-left {
font-size: 70%;
content: 'Formation « Cloud & Enjeux »';
}
/*
@top-center {
content: string(chapter);
}*/
@top-right {
font-size: 70%;
/* content: 'SQLI INSTITUT (ASTON)'; */
/* content: 'AELION'; */
content: '';
}
@bottom-left {
font-size: 70%;
content: '2017-2022 © Glenn ROLLAND - Ne pas diffuser';
}
/*
@bottom-center {
content: string(chapter);
}*/
/*
@bottom-right {
font-size: 70%;
content: 'Page ' counter(page);
}*/
}

View file

@ -1,18 +0,0 @@
window.MathJax = {
tex: {
inlineMath: [["\\(", "\\)"]],
displayMath: [["\\[", "\\]"]],
processEscapes: true,
processEnvironments: true
},
options: {
ignoreHtmlClass: ".*|",
processHtmlClass: "arithmatex"
}
};
document$.subscribe(() => {
MathJax.typesetPromise()
})

0
exercises/.empty Normal file
View file

0
mindmaps/.empty Normal file
View file

View file

@ -6,13 +6,12 @@ site_dir: _build/docs
# theme_dir: 'themes/mkdocs-material'
site_author: 'Glenn Y. Rolland'
site_url: 'https://glenux.net'
site_url: 'http://glenux.github.io/teaching-boilerplate'
# copyright: 'Copyright (c) 2016 Glenux'
repo_name: 'Source'
repo_url: ''
# https://bitbucket.com/glenux-corp/teaching-boilerplate'
repo_url: 'https://bitbucket.com/glenux-corp/teaching-boilerplate'
# site_favicon: 'favicon.ico'
theme:
@ -28,7 +27,6 @@ theme:
neutral: 'black'
features:
- navigation.sections
- navigation.footer
# - navigation.tabs
# - navigation.tabs.sticky
@ -38,16 +36,9 @@ i18n:
extra_css:
- css/extra.css
- ../docs.assets/css/extra.css
# - css/source.css
# - css/patch.css
extra_javascript:
- js/extra.js
- ../docs.assets/javascript/mathjax.js
- https://polyfill.io/v3/polyfill.min.js?features=es6
- https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js
# - ../docs.assets/javascript/extra.js
# author:
# github: 'glenux'
@ -64,8 +55,8 @@ markdown_extensions:
- pymdownx.highlight:
anchor_linenums: false
- pymdownx.inlinehilite
- codehilite:
guess_lang: true
# - codehilite:
# guess_lang: false
# pip install mdx_truly_sane_lists
- mdx_truly_sane_lists
@ -76,8 +67,6 @@ markdown_extensions:
#
# pip install pymdown-extensions
- pymdownx.superfences:
# - pymdownx.arithmatex:
# generic: true
# plugins: []
plugins:

4439
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -12,11 +12,12 @@
"author": "",
"license": "ISC",
"dependencies": {
"@marp-team/marp-cli": "^1.4.1",
"@marp-team/marp-core": "^3.9.0",
"@marp-team/marp-cli": "^1.5.0",
"foreman": "^3.0.1",
"markdown-it-footnote": "^3.0.2",
"markdown-it-highlight-lines": "^1.0.2",
"sass": "^1.79.3"
"node-sass": "^6.0.1"
},
"devDependencies": {
"@marp-team/marp-core": "^3.0.0",
"markdown-it-footnote": "^3.0.2"
}
}

86
scripts/gx-mkteaching Executable file
View file

@ -0,0 +1,86 @@
#!/usr/bin/env ruby
# frozen_string_literal: true
require 'fileutils'
require 'find'
require 'thor'
require 'colorize'
EXCLUDE_LIST = ['.git', 'node_modules'].freeze
SKEL_DIR = ENV['HOME'] + '/src/Glenux.Teaching/teaching-boilerplate'
if ! File.directory? SKEL_DIR
warn "ERROR: missing #{SKEL_DIR}"
exit 1
end
# TeachingCli
class TeachingCli < Thor
desc 'create PROJECT', 'Create PROJECT directory'
def create(target)
# Create dir
if target.empty?
warn 'Target not specified'
exit 1
end
puts "Creating project #{target}"
FileUtils.mkdir_p target
# Create structure
Find.find(SKEL_DIR) do |path|
if EXCLUDE_LIST.include? File.basename(path)
Find.prune
next
end
next unless File.directory?(path)
shortpath = path.gsub(SKEL_DIR, '').gsub(%r{^/}, '')
next if shortpath.empty?
targetpath = File.join(target, shortpath)
print "Creating directory #{shortpath}… "
FileUtils.mkdir_p targetpath
puts 'ok'.green
end
# Create files if possible
Find.find(SKEL_DIR) do |path|
if EXCLUDE_LIST.include? File.basename(path)
Find.prune
next
end
next if File.directory?(path)
shortpath = path.gsub(SKEL_DIR, '').gsub(%r{^/}, '')
next if shortpath.empty?
targetpath = File.join(target, shortpath)
print "Creating file #{shortpath}… "
# File does not exist => install it
unless File.exist? targetpath
FileUtils.cp path, targetpath
puts 'ok (installed)'.green
next
end
# File exist & different
unless system 'cmp', '--quiet', path, targetpath
if File.exist? targetpath + '.new'
puts 'error (pease solve previous conflict)'.red
else
puts 'warning (conflict when creating file)'.yellow
FileUtils.cp path, targetpath + '.new'
end
next
end
puts 'ok (identical)'.green
FileUtils.cp path, targetpath
end
end
end
TeachingCli.start(ARGV)

120
scripts/gx-teaching Executable file
View file

@ -0,0 +1,120 @@
#!/bin/sh
# vim: set ft=sh:
# Set defaults
BASEDIR="$(pwd)"
ACTION="watch"
VERBOSITY="0"
DOCKER_IMAGE=glenux/teaching-boilerplate:latest
DOCKER_OPT_TTY="-t"
gxt_usage() {
echo "Usage: $0 [options]"
echo ""
echo "-d, --data-dir DIR Content directory"
echo "-a, --action ACTION Action (watch, build, shell, etc.)"
echo "-t, --tty Enable TTY mode (needed for shell)"
echo "-v, --verbose Enable verbosity"
echo "-h, --help Show this help"
}
# Parse arguments
while [ $# -gt 0 ]; do
ARG="${1:-}"
OPT="${2:-}"
shift
# echo "DEBUG: ARG=$ARG OPT=$OPT"
case "$ARG" in
-a|--action)
shift # argument requires a parameter
if [ -z "$OPT" ]; then
>&2 echo "ERROR: missing argument for --action"
exit 1
fi
ACTION="$OPT"
;;
-d|--data-dir)
shift # argument requires a parameter
if [ -z "$OPT" ]; then
>&2 echo "ERROR: missing argument for --data-dir"
exit 1
fi
if [ ! -d "$OPT" ]; then
>&2 echo "ERROR: argument for --data-dir must be a directory"
exit 1
fi
BASEDIR="$(cd "$OPT" && pwd)"
;;
-h|--help)
>&2 gxt_usage
exit 0
;;
-T|--no-tty)
DOCKER_OPT_TTY=""
;;
-v|--verbosity)
VERBOSITY="$((VERBOSITY+1))"
;;
*)
>&2 gxt_usage
>&2 echo "ERROR: unknown option '$ARG'"
exit 1
;;
esac
done
echo "basedir = $BASEDIR"
echo "docker_image = $DOCKER_IMAGE"
echo "action = $ACTION"
if [ -f "$BASEDIR/.marp/theme.scss" ]; then
DOCKER_OPT_MARP_THEME="-v $BASEDIR/.marp:/app/.marp"
echo "Theme: detected Marp files. Adding option to command line ($DOCKER_OPT_MARP_THEME)"
else
echo "Theme: no theme detected. Using default files"
fi
if [ -f "$BASEDIR/mkdocs.yml" ]; then
>&2 echo "Mkdocs: detected mkdocs.yml file. Please rename to mkdocs-patch.yml"
exit 1
fi
if [ -f "$BASEDIR/mkdocs-patch.yml" ]; then
DOCKER_OPT_MKDOCS_CONFIG="-v $BASEDIR/mkdocs-patch.yml:/app/mkdocs-patch.yml"
echo "Mkdocs: detected mkdocs-patch.yml file. Adding option to command line ($DOCKER_OPT_MKDOCS_CONFIG)"
else
echo "Mkdocs: no mkdocs-patch.yml detected. Using default files"
fi
if [ -d "$BASEDIR/slides" ]; then
DOCKER_OPT_MARP_PORT="-p 5200:5200"
fi
if [ -d "$BASEDIR/docs" ]; then
DOCKER_OPT_MKDOCS_PORT="-p 5100:5100"
fi
if [ "$VERBOSITY" -gt 0 ]; then
set -x
fi
docker run -i $DOCKER_OPT_TTY \
--shm-size=1gb \
-e "EXT_UID=$(id -u)" \
-e "EXT_GID=$(id -g)" \
-v "$BASEDIR/docs:/app/docs" \
-v "$BASEDIR/slides:/app/slides" \
-v "$BASEDIR/images:/app/images" \
-v "$BASEDIR/_build:/app/_build" \
$DOCKER_OPT_MKDOCS_CONFIG \
$DOCKER_OPT_MARP_THEME \
$DOCKER_OPT_MKDOCS_PORT \
$DOCKER_OPT_MARP_PORT \
"$DOCKER_IMAGE" "$ACTION"
if [ "$VERBOSITY" -gt 0 ]; then
set +x
fi
# TODO: ask current user permissions
# TODO: fix permissions on generated files

View file

@ -1,16 +0,0 @@
# vim: set ft=make :
docker-build: ## build docker image
docker build \
--file docker/Dockerfile \
--tag glenux/docmachine:$(BUILD_VERSION) \
.
docker tag \
glenux/docmachine:$(BUILD_VERSION) \
glenux/docmachine:latest
docker-push: ## push docker image
env docker push glenux/docmachine:latest
docker-pull: ## download docker image
env docker pull glenux/docmachine:latest

View file

@ -1,60 +0,0 @@
# vim: set ft=make :
prepare-docs: ## install prerequisites for static docs site only
pipenv install
.PHONY: prepare-docs
prepare: prepare-docs
sync-docs-internal:
@>&2 echo "ERROR: not implemented"
exit 1
clean-docs: ## remove generated static docs site
rm -fr $(BUILD_DOCS_DIR)
.PHONY: clean-docs
clean: clean-docs
deploy-docs: ## deploy static docs site to github
git push $(DEPLOY_REPO)
pipenv run mkdocs gh-deploy $(DEPLOY_OPTS)
.PHONY: deploy-docs
deploy: deploy-docs
build-docs-pdf: ## build pdf docs only
mkdir -p $(BUILD_DOCS_DIR)
rm -f $(BUILD_DOCS_DIR)/combined.pdf
PYTHONUTF8=1 \
ENABLE_PDF_EXPORT=1 \
pipenv run mkdocs build \
--site-dir $(BUILD_DOCS_DIR)
pdftk \
$$(find -L $(BUILD_DOCS_DIR) -name *.pdf -not -name index.pdf |sort ) \
cat output $(BUILD_DOCS_DIR)/docs.pdf
.PHONY: build-docs-pdf
build-docs: build-docs-pdf
build-docs-html: ## build static docs site only
mkdir -p $(BUILD_DOCS_DIR)
pipenv run mkdocs build \
--site-dir $(BUILD_DOCS_DIR)
.PHONY: build-docs-html
build-docs: build-docs-html
build: build-docs
watch-docs-internal:
pipenv run mkdocs serve --dev-addr 0.0.0.0:$(DOCS_PORT)
.PHONY: watch-docs-internal
watch-docs: ## run development server for static docs site
pipenv run honcho start watch-docs watch-toc
.PHONY: watch-docs
watch: watch-docs

View file

@ -1,106 +0,0 @@
.PHONY: clean-slides
clean-slides:
rm -fr $(BUILD_SLIDES_DIR) # remove generated PDF slides
.PHONY: clean
clean: clean-slides
.PHONY: watch-slides-internal
watch-slides-internal: .marp/theme.css
PORT=$(SLIDES_PORT) \
npx marp \
--allow-local-files \
--engine $$(pwd)/.marp/engine.js \
--html \
--theme $$(pwd)/.marp/theme.css \
-w $(SLIDES_DIR) \
-s
.PHONY: watch-slides serve-slides
watch-slides: ## run development server for PDF slides
pipenv run honcho start watch-slides src-autoslide
.PHONY: prepare
prepare: prepare-slides
.PHONY: prepare-slides
prepare-slides: ## install prerequisites for PDF slides only
npm install
npm rebuild node-sass
npx browserslist@latest --update-db
$(BUILD_SLIDES_DIR)/%.pdf: $(CACHE_SLIDES_DIR)/%.mdpp.md | $(BUILD_SLIDES_DIR) .marp/theme.css
npx marp --allow-local-files \
--engine $$(pwd)/.marp/engine.js \
--html \
--theme $$(pwd)/.marp/theme.css \
$< \
-o $@
$(BUILD_SLIDES_DIR)/%.pdf: $(SLIDES_DIR)/%.md | $(BUILD_SLIDES_DIR) .marp/theme.css
npx marp --allow-local-files \
--engine $$(pwd)/.marp/engine.js \
--html \
--theme $$(pwd)/.marp/theme.css \
$< \
-o $@
$(BUILD_SLIDES_DIR)/%.pptx: $(SLIDES_DIR)/%.md | $(BUILD_SLIDES_DIR) .marp/theme.css
npx marp --allow-local-files \
--engine $$(pwd)/.marp/engine.js \
--html \
--theme $$(pwd)/.marp/theme.css \
$< \
-o $@
.marp/theme.css:
cd .marp && $(MAKE) theme.css
$(BUILD_SLIDES_DIR):
mkdir -p $(BUILD_SLIDES_DIR)
.PHONY: build-slides
build-slides: build-slides-pdf build-slides-html ## build only slides as PDF and HTML
.PHONY: build-slides-pptx
build-slides-pptx: $(SLIDES_PPTX_ALL) $(SLIDES_MD_ALL) ## build PPTX slides only
.PHONY: build-slides-pdf
build-slides-pdf: $(SLIDES_PDF_ALL) $(SLIDES_MD_ALL) ## build PDF slides only
.PHONY: build-slides-html
build-slides-html: $(SLIDES_HTML_ALL) ## build HTML slides only
.PHONY: merge-slides
merge-slides: $(SLIDES_MDPP_MD) $(SLIDES_MD_ALL)
.PHONY: watch-slides
serve-slides: watch-slides
.PHONY: autoslide
autoslide: $(SLIDES_DIR)/autoslide.md | $(BUILD_SLIDES_DIR)
$(SLIDES_DIR)/autoslide.md: $(DOCS_MD)
find -L $(DOCS_DIR) -regextype sed \( -regex '.*/[0-9][^/]*\.md' ! -regex '.*/_.*' \) -print0 \
| sort -z \
| xargs -0 sed '/^---$$/,/^---$$/d' \
> $(SLIDES_DIR)/autoslide.md
.PHONY: watch-autoslide-internal
watch-autoslide-internal:
# FIXME: use watchexec instead
while inotifywait -q -e move -e modify -e create -e attrib -e delete -e moved_to -r $(DOCS_DIR) ; do \
sleep 0.25 ; \
$(MAKE) autoslide ; \
done
.PHONY: watch-tocupdate-internal
watch-tocupdate-internal:
# FIXME: use watchexec instead
while inotifywait -q -e move -e modify -e create -e attrib -e delete -e moved_to -r $(DOCS_DIR) ; do \
sleep 2 ; \
$(MAKE) images ; \
done

View file

@ -1,13 +0,0 @@
# vim: set ft=make :
##
## Utilities
##
fixme:
@egrep --color -rni '(fixme)' $(DOCS_DIR) $(SLIDES_DIR)
debug:
echo $(PWD)
.PHONY: fixme