-
Notifications
You must be signed in to change notification settings - Fork 0
/
makefile
141 lines (115 loc) · 4.9 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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
CONFIG=content/structure.yaml
GLOSSARY=content/glossary.yaml
SOURCE=content/src
TMPFOLDER=tmp
TMPSUP = tmp/supporter-epub
EBOOK_TMP = tmp/ebook
DOCS_TMP = tmp/docs
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
site:
# build jekyll site
$(update-make-conf)
# build content files
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
# split introduction into intro and concepts/principles
awk '{print >out}; /<!-- split here -->/{out="$(DOCS_TMP)/concepts-and-principles-content.md"}' out=$(DOCS_TMP)/introduction-content.md docs/introduction.md
$(MKTPL) templates/website/introduction.md $(DOCS_TMP)/intro_tmpl.md $(LOC) $(PRJ)
cd $(DOCS_TMP); multimarkdown --to=mmd --output=../../docs/introduction.md intro_tmpl.md
$(MKTPL) content/website/_templates/concepts-and-principles.md $(DOCS_TMP)/concepts_tmpl.md $(LOC) $(PRJ)
cd $(DOCS_TMP); multimarkdown --to=mmd --output=../../docs/concepts-and-principles.md concepts_tmpl.md
# prepare templates
$(MKTPL) templates/website/_layouts/default.html docs/_layouts/default.html $(LOC) $(PRJ)
$(MKTPL) templates/website/_layouts/plain.html docs/_layouts/plain.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
# build the single page version
$(MKTPL) templates/single-page--master.md $(EBOOK_TMP)/single-page--master.md $(LOC) $(PRJ)
# render intro, chapters and appendix to separate md files
mdslides build ebook $(CONFIG) $(SOURCE) $(EBOOK_TMP)/ --glossary=$(GLOSSARY)
# transclude all to one file
cd $(EBOOK_TMP); multimarkdown --to=mmd --output=../../docs/all.md single-page--master.md
# build the site
cd docs;jekyll build
epub:
# render an ebook as epub
$(update-make-conf)
# render intro, chapters and appendix to separate md files
mdslides build ebook $(CONFIG) $(SOURCE) $(EBOOK_TMP)/ --glossary=$(GLOSSARY) --section-prefix="$(SECTIONPREFIX)"
# prepare and copy template
$(MKTPL) templates/epub--master.md $(EBOOK_TMP)/epub--master.md $(LOC) $(PRJ)
# transclude all to one file
cd $(EBOOK_TMP); multimarkdown --to=mmd --output=epub-compiled.md epub--master.md
# render to epub
cd $(EBOOK_TMP); pandoc epub-compiled.md -f markdown -t epub3 --toc --toc-depth=3 -s -o ../../$(TARGETFILE).epub
ebook:
# render an ebook as pdf (via LaTEX)
$(update-make-conf)
# render intro, chapters and appendix to separate md files (but without sectionprefix!)
mdslides build ebook $(CONFIG) $(SOURCE) $(EBOOK_TMP)/ --glossary=$(GLOSSARY) --no-section-prefix
# copy md and LaTEX templates
$(MKTPL) templates/ebook--master.md $(EBOOK_TMP)/ebook--master.md $(LOC) $(PRJ)
$(MKTPL) config/ebook.tex $(EBOOK_TMP)/ebook.tex $(LOC) $(PRJ)
$(MKTPL) config/ebook-style.sty $(EBOOK_TMP)/ebook-style.sty $(LOC) $(PRJ)
# make an index
mdslides index latex $(CONFIG) $(EBOOK_TMP)/tmp-index.md
# transclude all to one file
cd $(EBOOK_TMP); multimarkdown --to=mmd --output=tmp-ebook-compiled.md ebook--master.md
cd $(EBOOK_TMP); multimarkdown --to=latex --output=tmp-ebook-compiled.tex tmp-ebook-compiled.md
cd $(EBOOK_TMP); latexmk -pdf -xelatex -silent ebook.tex
cd $(EBOOK_TMP); mv ebook.pdf ../../$(TARGETFILE).pdf
# clean up
cd $(EBOOK_TMP); 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
# take no risk here!
-rm -r tmp
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 $(EBOOK_TMP)
-mkdir -p $(DOCS_TMP)
-mkdir -p $(TMPSUP)
-mkdir docs/_site
# images for ebook
ifneq ("$(wildcard $(EBOOK_TMP)/img)","")
rm -r $(EBOOK_TMP)/img
endif
cp -r img $(EBOOK_TMP)/img
cp templates/covers/* $(EBOOK_TMP)/img
# images for supporter epub
ifneq ("$(wildcard $(TMPSUP)/img)","")
# take no risk here!
rm -r $(TMPSUP)/img
endif
cp -r img $(TMPSUP)/img
# 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