-
Notifications
You must be signed in to change notification settings - Fork 16
/
build-implementations.sh
executable file
·256 lines (199 loc) · 7.56 KB
/
build-implementations.sh
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
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
#!/bin/bash
tsv=implementations.tsv
oldest_imp=`ls -t implementations/*.md | tail -1`
if [ ! -f $tsv ]; then
echo $tsv not found\!
echo Can\'t build implementations\; exiting
exit -1
fi
num_tsv=`wc -l implementations.tsv | awk '{print $1-1}'`
num_md=`ls -1 implementations/*.md | wc -l`
echo we have $num_tsv lines of TSV and $num_md implementations pages.
if [[ $num_tsv -eq $num_md ]] && [[ $oldest_imp -nt $tsv ]] ; then
echo All files in implementations/\*.md are newer than $tsv
echo So we don\'t need to build implementations.
exit 0;
fi
echo Building MD for implementations...
expectedFieldsFile=implementations-fields.tsv
if [ ! -f $expectedFieldsFile ]; then
echo $expectedFieldsFile not found\!
echo Can\'t build implementations\; exiting
exit -2
fi
# First confirm assumptions about fields
echo Confirming assumptions about fields in $tsv
# head -1 $tsv | diff -w $expectedFieldsFile -
head -1 $tsv | diff $expectedFieldsFile -
if [ ! $? -eq 0 ] ; then
echo Oh no\! Field names were not as expected by $0 - diff above
echo exiting
exit -3
else
echo ...confirmed
fi
impl_dir=implementations
# At this point we believe we can recreate everything inside $impl_dir
rm -f ${impl_dir}/*.{md,html}
# Now loop through the remaining rows (all but the first) making a file for each...
# tail +2 $tsv
# awk 1 is to add an extra newline at the end if necessary
tail +2 $tsv | \
# head -10 | \
awk 1 | \
while read line; do
# First parse all the TSV fields into bash variables
TIMESTAMP=`echo "$line" | cut -f1`
SUBMITTER_NAME=$(echo "$line" | cut -f2)
SUBMITTER_WEBSITE=$(echo "$line" | cut -f3)
NAME=$(echo "$line" | cut -f4)
UPDATE=$(echo "$line" | cut -f5)
URL=$(echo "$line" | cut -f6)
URL_OSC_PART=$(echo "$line" | cut -f7)
TYPE=$(echo "$line" | cut -f8)
DESCRIPTION=$(echo "$line" | cut -f9)
PLATFORM=$(echo "$line" | cut -f10)
FEATURES=$(echo "$line" | cut -f11)
TYPES=$(echo "$line" | cut -f12)
BUNDLE=$(echo "$line" | cut -f13)
TIMETAG=$(echo "$line" | cut -f14)
TRANSPORT=$(echo "$line" | cut -f15)
PUBLICATIONS=$(echo "$line" | cut -f16)
IMAGES=$(echo "$line" | cut -f17)
STATUS=$(echo "$line" | cut -f18)
STATUSDATE=$(echo "$line" | cut -f19)
SUPERSEDED=$(echo "$line" | cut -f20)
VIDEOS=$(echo "$line" | cut -f21)
STATUSDETAILS=$(echo "$line" | cut -f22)
# Determine this filename based on the name, using these rules:
# Omit anything in parentheses
# Omit anything after a comma or colon that is followed by a space
# Omit all punctuation characters
# Remove trailing whitespace
# Convert spaces to '-'
# Convert repeated '--' to just one
FILENAME=`echo $NAME | sed 's/(.*)//g' | sed 's/[,:][ ].*//g' | tr '-' ' ' | tr -d '[:punct:]' | sed 's/[ ]*$//g' | tr ' ' '-' | tr -s '-'`
FILENAME=${impl_dir}/${FILENAME}.md
echo $NAME '==>' $FILENAME
if [ -f $FILENAME ]; then
# Not good; we deleted all markdown files at the beginning of this script,
# so this must mean:
echo At least two implementations want to have the same filename $FILENAME
echo Abort.
exit -4;
fi
# Now we actually write the markdown file for this implementation...
echo "# ${NAME}" > $FILENAME
echo "" >> $FILENAME
if [ ! -z "$SUPERSEDED" ] ; then
echo "**This implementation has been superseded by another!**" >> $FILENAME
echo $SUPERSEDED >> $FILENAME
echo "" >> $FILENAME
fi
if [ ! -z "$STATUSDATE" ] ; then
ASOF=" (as of $STATUSDATE)";
else
ASOF="";
fi
if [ ! -z "$STATUS" ] ; then
echo "**[status](../implementation-status.html)**: ${STATUS}${ASOF}" >> $FILENAME
echo "" >> $FILENAME
if [ ! -z "$STATUSDETAILS" ] ; then
echo "**Status details**: " >> $FILENAME
echo "$STATUSDETAILS" >> $FILENAME
echo "" >> $FILENAME
fi
fi
if [ ! -z "$TYPE" ] ; then
echo "**Project Type**: $TYPE" >> $FILENAME
echo "" >> $FILENAME
fi
if [ ! -z "$URL" ] ; then
echo "**Project URL**: <$URL>" >> $FILENAME
echo "" >> $FILENAME
fi
if [ ! -z "$URL_OSC_PART" ] ; then
echo "**OSC Documentation URL**: <$URL_OSC_PART>" >> $FILENAME
echo "" >> $FILENAME
fi
if [ ! -z "$DESCRIPTION" ] ; then
echo "## Description" >> $FILENAME
echo "" >> $FILENAME
echo "$DESCRIPTION" >> $FILENAME
echo "" >> $FILENAME
fi
if [ ! -z "$PLATFORM" ] || [ ! -z "$FEATURES" ] || [ ! -z "$TYPES" ] || [ ! -z "$BUNDLE" ] || [ ! -z "$TIMETAG" ] || [ ! -z "$TRANSPORT" ] ; then
echo "## Implementation Details" >> $FILENAME
echo "" >> $FILENAME
fi
if [ ! -z "$PLATFORM" ] ; then
echo "**Platform(s)**: ${PLATFORM}" >> $FILENAME
echo "" >> $FILENAME
fi
if [ ! -z "$FEATURES" ] ; then
echo "**Features**: ${FEATURES}" >> $FILENAME
echo "" >> $FILENAME
fi
if [ ! -z "$TYPES" ] ; then
echo "**Supported OSC types**: ${TYPES}" >> $FILENAME
echo "" >> $FILENAME
fi
if [ ! -z "$BUNDLE" ] ; then
echo "**Bundle support**: ${BUNDLE}" >> $FILENAME
echo "" >> $FILENAME
fi
if [ ! -z "$TIMETAG" ] ; then
echo "**Timetag support**: ${TIMETAG}" >> $FILENAME
echo "" >> $FILENAME
fi
if [ ! -z "$TRANSPORT" ] ; then
echo "**Transport support**: ${TRANSPORT}" >> $FILENAME
echo "" >> $FILENAME
fi
if [ ! -z "$PUBLICATIONS" ] ; then
echo "## Publications " >> $FILENAME
echo "" >> $FILENAME
echo "$PUBLICATIONS" >> $FILENAME
echo "" >> $FILENAME
fi
if [ ! -z "$IMAGES" ] ; then
# XXX This needs to be much much smarter, like to handle
# multiple images
if [[ $IMAGES == *[\(\)\<\>]* ]]
then
# assume it's proper markdown
sayimages="$IMAGES"
else
# assume it's a single URL
sayimages="<$IMAGES>"
fi
echo "## Images " >> $FILENAME
echo "" >> $FILENAME
echo "$sayimages" >> $FILENAME
echo "" >> $FILENAME
fi
if [ ! -z "$VIDEOS" ] ; then
echo "## Videos " >> $FILENAME
echo "" >> $FILENAME
echo "$VIDEOS" >> $FILENAME
echo "" >> $FILENAME
fi
if [ -z "$SUBMITTER_NAME" ] ; then
FULLSUBMITTER="Anonymous"
else
if [ -z "$SUBMITTER_WEBSITE" ] ; then
FULLSUBMITTER="$SUBMITTER_NAME"
else
FULLSUBMITTER="[$SUBMITTER_NAME]($SUBMITTER_WEBSITE)"
fi
fi
if [ -z "$UPDATE" ] ; then
MAYBEUPDATE="as an update "
else
MAYBEUPDATE=""
fi
echo "---" >> $FILENAME
echo "Submitted "$MAYBEUPDATE"to [opensoundcontrol.org](https://opensoundcontrol.org) by $FULLSUBMITTER at $TIMESTAMP" >> $FILENAME
done
echo have a nice day
exit 0