-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmakefile
122 lines (101 loc) · 4.23 KB
/
makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
CONFIG=content/structure-new.yaml
GLOSSARY=content/glossary.yaml
SOURCE=content/src
TMPFOLDER=tmp
LOC=content/localization.po
PRJ=config/project.yaml
MKTPL=mdslides template
# get language specific parameters
include config/make-conf
define update-make-conf
# update the make conf file from translations
$(MKTPL) templates/make-conf config/make-conf $(LOC) $(PRJ)
endef
define prepare-ebook
# render intro, chapters and appendix to separate md files
mdslides build ebook $(CONFIG) $(SOURCE) $(TMPFOLDER)/ebook/ --glossary=$(GLOSSARY) --section-prefix="$(SECTIONPREFIX)"
endef
site:
# build jekyll site
$(update-make-conf)
# build singe page version
$(MKTPL) templates/single-page--master.md $(TMPFOLDER)/ebook/single-page--master.md $(LOC) $(PRJ)
# render intro, chapters and appendix to separate md files
mdslides build ebook $(CONFIG) $(SOURCE) $(TMPFOLDER)/ebook/ --glossary=$(GLOSSARY)
# transclude all to one file
cd $(TMPFOLDER)/ebook; multimarkdown --to=mmd --output=../../docs/all.md single-page--master.md
# prepare templates
$(MKTPL) templates/website/_layouts/default.html docs/_layouts/default.html $(LOC) $(PRJ)
$(MKTPL) templates/website/_config.yml docs/_config.yml $(LOC) $(PRJ)
$(MKTPL) templates/website/CNAME docs/CNAME $(LOC) $(PRJ)
$(MKTPL) content/website/_includes/footer.html docs/_includes/footer.html $(LOC) $(PRJ)
cp templates/website/map.md docs/map.md
$(MKTPL) templates/website/pattern-map.html docs/_includes/pattern-map.html $(LOC) $(PRJ)
cp content/website/_includes/header.html docs/_includes/header.html
cp content/website/_templates/404.md docs/404.md
mdslides build jekyll $(CONFIG) $(SOURCE) docs/ --glossary=$(GLOSSARY) --template=content/website/_templates/index.md --section-index-template=content/website/_templates/pattern-index.md --introduction-template=content/website/_templates/introduction.md
cd docs;jekyll build
wordpress:
# join each pattern group into one md file to be used in wordpress
$(update-make-conf)
ifeq ("$(wildcard $(TMPFOLDER)/web-out)","")
mkdir $(TMPFOLDER)/web-out
endif
mdslides compile $(CONFIG) $(SOURCE) $(TMPFOLDER) --chapter-title=none --glossary=$(GLOSSARY) --section-prefix="$(SECTIONPREFIX)"
mdslides build wordpress $(CONFIG) $(TMPFOLDER) $(TMPFOLDER)/web-out/ --footer=templates/wordpress-footer.md --glossary=$(GLOSSARY)
epub:
# render an ebook as epub
$(update-make-conf)
$(prepare-ebook)
# prepare and copy template
$(MKTPL) templates/epub--master.md $(TMPFOLDER)/ebook/epub--master.md $(LOC) $(PRJ)
# transclude all to one file
cd $(TMPFOLDER)/ebook; multimarkdown --to=mmd --output=epub-compiled.md epub--master.md
# render to epub
cd $(TMPFOLDER)/ebook; pandoc epub-compiled.md --variable=dir:rtl -f markdown -t epub3 -s -o ../../$(TARGETFILE).epub
ebook:
# render an ebook as pdf (via LaTEX)
$(update-make-conf)
$(prepare-ebook)
# copy md and LaTEX templates
$(MKTPL) templates/ebook--master.md $(TMPFOLDER)/ebook/ebook--master.md $(LOC) $(PRJ)
$(MKTPL) config/ebook.tex $(TMPFOLDER)/ebook/ebook.tex $(LOC) $(PRJ)
$(MKTPL) config/ebook-style.sty $(TMPFOLDER)/ebook/ebook-style.sty $(LOC) $(PRJ)
# transclude all to one file
cd $(TMPFOLDER)/ebook; multimarkdown --to=mmd --output=tmp-ebook-compiled.md ebook--master.md
cd $(TMPFOLDER)/ebook; multimarkdown --to=latex --output=tmp-ebook-compiled.tex tmp-ebook-compiled.md
cd $(TMPFOLDER)/ebook; latexmk -pdf -silent ebook.tex
cd $(TMPFOLDER)/ebook; mv ebook.pdf ../../$(TARGETFILE)-ebook.pdf
# clean up
cd $(TMPFOLDER)/ebook; latexmk -C
gitbook:
mdslides build gitbook $(CONFIG) $(SOURCE) gitbook/ --glossary=$(GLOSSARY)
update:
$(update-make-conf)
clean:
# clean all generated content
-rm -r docs/img
-rm -r docs/_site
-rm docs/*.md
-rm -r $(TMPFOLDER)
setup:
# prepare temp folders and jekyll site
$(update-make-conf)
# prepare temp folders
echo "this might produce error output if folders already exist"
-mkdir -p $(TMPFOLDER)/ebook
-mkdir -p $(TMPFOLDER)/web-out
-mkdir docs/_site
# -mkdir gitbook
ifeq ("$(wildcard $(TMPFOLDER)/ebook/img)","")
cd $(TMPFOLDER)/ebook; ln -s ../../img
endif
# clean up and copy images do to docs folder
ifneq ("$(wildcard docs/img)","")
rm -r docs/img
endif
cp -r img docs/img
ifneq ("$(wildcard gitbook/img)","")
rm -r gitbook/img
endif
cp -r img gitbook/img