-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
192 lines (154 loc) · 7.67 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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
# specify thh main file and all the files that you are including
SOURCE= main.tex $(wildcard local*.tex) $(wildcard chapters/*.tex)
# specify your main target here:
pdf: main.bbl main.pdf #by the time main.pdf, bib assures there is a newer aux file
complete: index main.pdf
index: main.snd
main.pdf: main.aux
xelatex main
main.aux: $(SOURCE)
xelatex -no-pdf main
#create only the book
main.bbl: $(SOURCE) localbibliography.bib
xelatex -no-pdf main
biber main
main.snd: main.bbl
touch main.adx main.sdx main.ldx
sed -i s/.*\\emph.*// main.adx #remove titles which biblatex puts into the name index
sed -i 's/hyperindexformat{\\\(infn {[0-9]*\)}/\1/' main.sdx # ordering of references to footnotes
sed -i 's/hyperindexformat{\\\(infn {[0-9]*\)}/\1/' main.adx
sed -i 's/hyperindexformat{\\\(infn {[0-9]*\)}/\1/' main.ldx
sed -i 's/.*Office.*//' main.adx
sed -i 's/.*Team.*//' main.adx
sed -i 's/.*Bureau.*//' main.adx
sed -i 's/.*Organisation.*//' main.adx
sed -i 's/.*Organization.*//' main.adx
sed -i 's/.*Embassy.*//' main.adx
sed -i 's/.*Association.*//' main.adx
sed -i 's/.*Commission.*//' main.adx
sed -i 's/.*committee.*//' main.adx
sed -i 's/.*government.*//' main.adx
sed -i 's/.*Instituto.*//' main.adx
sed -i 's/\\MakeCapital//' main.adx
sed -i 's/@incollection{chapters\/17-Discussionfooter,author={Sandra Auderset and Caroline de Becker and Gladys Camacho Rios and Eric W. Campbell and Javier Carol and Minella Duzerol and Patience Epps and Ambrocio Gutiérrez and Cristian R. Juárez and Magdalena Lemus Serrano and Stephen Francis Mann and Taylor L. Miller and Shun Nakamoto and Zoe Poirier Maruenda and Andrés Salanova and Hiroto Uchihara and Natalie Weber and Anthony C. Woodbury and Dennis Wylie and Adam J. R. Tallman/@incollection{chapters\/17-Discussionfooter,author={Sandra Auderset et al./' collection_tmp.bib
fixindex
makeindex -o main.and main.adx
grep -o ", [^0-9, \\]*," main.and
makeindex -o main.lnd main.ldx
makeindex -o main.snd main.sdx
makeglossaries main
# echo "check for doublets in name index"
# grep -o ", [^0-9, \\}]*," main.and|sed "s/, //" | sed "s/,\$//"
xelatex main
#create a png of the cover
cover: FORCE
convert main.pdf\[0\] -quality 100 -background white -alpha remove -bordercolor "#999999" -border 2 cover.png
cp cover.png googlebooks_frontcover.png
convert -geometry 50x50% cover.png covertwitter.png
convert main.pdf\[0\] -quality 100 -background white -alpha remove -bordercolor "#999999" -border 2 -resize x495 coveromp.png
display cover.png
openreview: openreview.pdf
openreview.pdf:
pdftk main.pdf multistamp orstamp.pdf output openreview.pdf
proofreading: proofreading.pdf
versions.json:
grep "^.title{" localmetadata.tex|grep -o "{.*"|egrep -o "[^{}]+">title
grep "^.author{" localmetadata.tex|grep -o "{.*"|egrep -o "[^{}]+" |sed 's/ and/"},{"name":"/g'>author
echo '{"versions": [{"versiontype": "proofreading",' >versions.json
echo -n ' "title": "' >>versions.json
echo -n `cat title` >> versions.json
echo '",' >> versions.json
echo -n ' "authors": [{"name": "'>> versions.json
echo -n `cat author` >> versions.json
echo '"}],' >> versions.json
echo ' "license": "CC-BY-4.0",'>> versions.json
echo -n ' "publishedAt": "' >> versions.json
echo -n `date --rfc-3339=s|sed s/" "/T/|sed s/+.*/.000Z/` >> versions.json
echo -n '"'>> versions.json
echo '}'>> versions.json
echo ' ]'>> versions.json
echo '}'>> versions.json
rm author title
paperhive: proofreading.pdf versions.json README.md
(git commit -m 'new README' README.md && git push) || echo "README up to date" #this is needed for empty repositories, otherwise they cannot be branched
git checkout gh-pages || git branch gh-pages; git checkout gh-pages
git add proofreading.pdf versions.json
git commit -m 'prepare for proofreading' proofreading.pdf versions.json
git push origin gh-pages
sleep 3
curl -X POST 'https://paperhive.org/api/document-items/remote?type=langsci&id='`basename $(pwd)`
git checkout main
git commit -m 'new README' README.md
git push
papercurl:
$(eval dir=$(shell pwd))
$(eval ID=$(shell basename $(dir)))
$(eval urlstring="https://paperhive.org/api/document-items/remote?type=langsci&id="$(ID))
curl -X POST $(urlstring)
firstedition:
git checkout gh-pages
git pull origin gh-pages
basename `pwd` > ID
python getfirstedition.py `cat ID`
git add first_edition.pdf
git commit -am 'provide first edition'
git push origin gh-pages
git checkout main
curl -X POST 'https://paperhive.org/api/document-items/remote?type=langsci&id='`cat ID`
proofreading.pdf:
pdftk main.pdf multistamp prstamp.pdf output proofreading.pdf
chop:
egrep -o "\{[0-9]+\}\{chapter\.[0-9]+\}" main.toc| egrep -o "[0-9]+\}\{chapter"|egrep -o [0-9]+ > cuts.txt
egrep -o "\{chapter\}\{Index\}\{[0-9]+\}\{section\*\.[0-9]+\}" main.toc| grep -o "\..*"|egrep -o [0-9]+ >> cuts.txt
bash chopchapters.sh `grep "mainmatter starts" main.log|grep -o "[0-9]*" $1 $2`
#housekeeping
clean:
rm -f *.bak *~ *.backup *.tmp \
*.adx *.and *.idx *.ind *.ldx *.lnd *.sdx *.snd *.rdx *.rnd *.wdx *.wnd \
*.log *.blg *.ilg \
*.aux *.toc *.cut *.out *.tpm *.bbl *-blx.bib *_tmp.bib *bcf \
*.glg *.glo *.gls *.wrd *.wdv *.xdv *.mw *.clr *.pgs \
main.run.xml \
chapters/*aux chapters/*~ chapters/*.bak chapters/*.backup \
langsci/*/*aux langsci/*/*~ langsci/*/*.bak langsci/*/*.backup
realclean: clean
rm -f *.dvi *.ps *.pdf
chapterlist:
grep chapter main.toc|sed "s/.*numberline {[0-9]\+}\(.*\).newline.*/\\1/"
chapternames:
egrep -o "\{chapter\}\{\\\numberline \{[0-9]+}[A-Z][^\}]+\}" main.toc | egrep -o "[[:upper:]][^\}]+" > chapternames
barechapters:
cat chapters/*tex | detex > barechapters.txt
languagecandidates:
grep -ohP "(?<=[a-z]|[0-9])(\))?(,)? (\()?[A-Z]['a-zA-Z-]+" chapters/*tex| grep -o [A-Z].* |sort -u >languagelist.txt
FORCE:
README.md:
echo `grep title localmetadata.tex|sed "s/\\\\\title{\(.*\)}/\# \1/"` > README.md
echo '## Publication Info' >> README.md
echo -n '- Authors: ' >> README.md
echo `grep author localmetadata.tex|sed "s/\\\\\author{\(.*\)}/\1/"` >> README.md
echo "- Publication Date: not yet published" >> README.md
echo -n "- Series: " >> README.md
echo `grep "lsSeries}" localmetadata.tex|sed "s/.*lsSeries}{\(.*\)}/\1/"` >> README.md
echo "## Description" >> README.md
echo -n "[Book page on langsci-press.org](http://langsci-press.org/catalog/book/" >> README.md
echo `grep lsID localmetadata.tex|sed "s/.*lsID\}{\(.*\)}/\1)/"` >> README.md
echo "## License" >> README.md
echo "Copyright: (c) "`date +"%Y"`", the authors." >> README.md
echo "All data, code and documentation in this repository is published under the [Creative Commons Attribution 4.0 Licence](http://creativecommons.org/licenses/by/4.0/) (CC BY 4.0)." >> README.md
supersede: convert cover.png -fill white -colorize 60% -pointsize 64 -draw "gravity center fill red rotate -45 text 0,12 'superseded' " superseded.png; display superseded.png
wikicite:
echo '<ref name="abc">{{Cite book' > wiki
echo -n "| vauthors = " >>wiki; echo `grep author localmetadata.tex|sed "s/\\\\\author{\(.*\)}/\1/"` >>wiki
echo -n "| title =" >>wiki; echo `grep title localmetadata.tex|sed "s/\\\\\title{\(.*\)}/\1/"` >>wiki
echo "| place = Berlin" >>wiki
echo "| publisher = Language Science Press" >>wiki
echo "| date = 2018" >>wiki
echo "| format = pdf" >>wiki
echo -n "| url = http://langsci-press.org/catalog/book/" >>wiki; echo `grep lsID localmetadata.tex|sed "s/.*lsID\}{\(.*\)}/\1/"` >>wiki
echo -n "| doi =" >>wiki; echo `cat doi` >>wiki
echo "| doi-access=free" >>wiki
echo -n "| isbn = " >>wiki; echo `grep lsISBNdigital localmetadata.tex|sed "s/.*lsISBNdigital\}{\(.*\)}/\1)/"` >>wiki
echo "}}" >>wiki
echo " </ref>" >>wiki
more wiki