-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathpublish
executable file
·548 lines (493 loc) · 17.6 KB
/
publish
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
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
#!/bin/sh
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# Copyright (C) 2013 - 2016 Open Microscopy Environment
# Massachusetts Institute of Technology,
# National Institutes of Health,
# University of Dundee,
# University of Wisconsin at Madison
#
# This work is licensed under the
# Creative Commons Attribution 3.0 Unported License.
# To view a copy of this license, visit
# http://creativecommons.org/licenses/by/3.0/
# or send a letter to
# Creative Commons, 444 Castro Street, Suite 900,
# Mountain View, California, 94041, USA.
# For attribution instructions, visit
# http://www.openmicroscopy.org/info/attribution
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
set -e
XARGSOPTS=
xargs -r </dev/null 2>/dev/null >/dev/null && XARGSOPTS="-r"
# Parse date from a YYYY-MM string
parsedate() {
if date -j 2>/dev/null >/dev/null; then
echo $(date -jnu -f "%Y-%m" "$1" '+%B %Y')
else
echo $(date -d "${1}-01" '+%B %Y')
fi
}
curdate() {
date '+%B %Y'
}
# Get the most recent version of a schema
# $1=schema name
mostrecentversion() {
echo "$(basename $(dirname $(find target/specification/released-schema -name "$1" | grep -v $devmarker | sort | tail -n1)))"
}
# Check if the a schema is the most recent version (return true) or legacy (return false)
# $1=schema name
# $2=release to check if current
ismostrecent() {
if [ "$2" != "$(mostrecentversion "$1")" ]; then
return 1
fi
return 0
}
# Check if a schema is current (not necessarily the latest version).
# $1=schema name
iscurrent() {
if [ "${1%.xsd}" = "ome" ] || [ "${1%.xsd}" = "OME" ]
then
return 0
fi
return 1
}
# Check if the a schema is the most recent version (return true) or legacy (return false)
# $1=schema name
# $2=release to check if current
schemastatus() {
if iscurrent "$1"; then
if ismostrecent "$1" "$2"; then
echo "currently in use (and is the most recent release)"
else
echo "currently in use (but superseded by a more recent release)"
fi
else
if ismostrecent "$1" "$2"; then
echo "no longer in use (final release)"
else
echo "no longer in use (and superseded by a more recent release)"
fi
fi
}
# Get the version of a schema
# $1=schema name
# $2=release to check if current
schemaversion() {
version=$(grep "version=" "target/specification/released-schema/$2/$1" | grep -v 'xml' | head -n1 | sed -e 's;^.*version="\([0-9][0-9]*\)".*$;\1;')
if [ -z "$version" ]; then
version="1"
fi
echo "$version"
}
# Describe a schema (single sentence)
schemadesc() {
case "${1%.xsd}" in
BinaryFile)
echo "Binary File schema used to describe a file location, or the location of a fragment within a file. It is combined with the main OME schema as of 2016-06." ;;
OME|ome)
echo "main schema which defines the OME ontology for microscopy." ;;
OMERO)
echo "schema extensions used by OMERO. It is not used by the OME schema but provides a structure for data in StructuredAnnotation blocks used by OMERO." ;;
ROI)
echo "Region Of Interest schema. It is combined with the main OME schema as of 2016-06." ;;
SA)
echo "Structured Annotation schema. It is combined with the main OME schema as of 2016-06." ;;
SPW)
echo "Screen/Plate/Well schema. It is combined with the main OME schema as of 2016-06." ;;
AnalysisChain)
echo "Analysis Chain schema. Analysis chains are how module outputs are connected to inputs of other modules." ;;
AnalysisModule)
echo "Analysis Module Library schema. Analysis modules are image analysis algorithms or, more generally, how information is generated in OME. Makes use of CLI and MLI schemas." ;;
CA)
echo "standard Custom Attribute schema." ;;
CLI)
echo "Command Line Interface sub-schema." ;;
DataHistory)
echo "Data History schema. Data history describes the data dependency in OME." ;;
MLI)
echo "Matlab Interface sub-schema." ;;
STD)
echo "Semantic Type definition schema. Once a Semantic Type is defined, data for the defined type can be imported into the OME server." ;;
*)
echo "${1%.xsd} schema." ;;
esac
}
# from http://stackoverflow.com/questions/2829613/how-do-you-tell-if-a-string-contains-another-string-in-unix-shell-scripting
# contains(string, substring)
#
# Returns 0 if the specified string contains the specified substring,
# otherwise returns 1.
contains() {
string="$1"
substring="$2"
if test "${string#*$substring}" != "$string"
then
return 0 # $substring is in $string
else
return 1 # $substring is not in $string
fi
}
devmarker="DEV"
root=target/published
# Clean up
rm -rf "$root"
mkdir -p "$root"
for dir in target/specification/released-schema/20*
do
if contains $dir $devmarker; then
echo "Skipping $dir folder"
continue
fi
for schema in "$dir"/*.xsd
do
rel=$(basename "$dir")
base=${schema%.xsd}
base=$(basename "$base")
name=$(basename "$schema")
type="$(schemastatus "$name" "$rel")"
version="$(schemaversion "$name" "$rel")"
year=$(echo "$rel" | sed -e 's;^\([0-9][0-9]*\)-.*$;\1;')
month=$(echo "$rel" | sed -e 's;^.*-\([0-9][0-9]*\)$;\1;')
# Skip files only used internally for legacy schema
if [ "$rel" = "2003-FC" ] && [ "$base" != "ome" ]; then
continue;
fi
# For some reason, the OME schema has always been lowercased
if [ "$base" = "ome" ]; then
base="OME"
fi
if [ -z "$version" ]; then
version=1
fi
# Special case copying of legacy schemas
if [ "$year" = "2003" ]; then
path="${root}/${base}/${month}"
path=$(echo "$path" | sed -e 's;/2003-\(.*\);/\1;')
reldate="2003 ($month)"
else
path="${root}/${base}/${rel}"
reldate=$(parsedate "$rel")
fi
# Copy schema
mkdir -p "$path"
cp -v "$schema" "${path}/${name}"
# Generate companion HTML index.html
echo "HTML [1] -> ${path}/index.html"
cat <<EOF > "${path}/index.html"
<?xml version='1.0'?>
<!DOCTYPE html PUBLIC "-//XML-DEV//DTD XHTML RDDL 1.0//EN"
"http://www.w3.org/2001/rddl/rddl-xhtml.dtd" >
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:rddl="http://www.rddl.org/" xml:lang="en">
<head>
<title>Open Microscopy Environment ${base} Schema</title>
</head>
<body>
<h1>Open Microscopy Environment OME Schema</h1>
<div class="head">
<p>${reldate}</p>
</div>
<div id="toc">
<h2>Table of contents</h2>
<ol>
<li><a href="#intro">Introduction</a></li>
<li><a href="#status">Status</a></li>
<li><a href="#schema">Schema</a></li>
</ol>
</div>
<div id="intro">
<h2>Introduction</h2>
<p>This document outlines the ${base} Schema created by the
<a href="http://www.openmicroscopy.org/">Open Microscopy Environment</a>.
Detailed information on the schema is available
<a href="http://www.openmicroscopy.org/site/support/ome-model/index.html">here</a>.
</p>
</div>
<div id="status">
<h2>Status</h2>
<p>This schema is <strong>${type}</strong> and at version
<strong>${version}</strong>.</p>
<p>A list of the current versions of all the Open Microscopy Environment
schemas is available <a href="../../index.html">here</a>.</p>
</div>
<div id="schema">
<h2>Schema</h2>
<p>The schema XSD file is <a href="${name}">${name}</a>.</p>
<p>Note: Some browsers will try to render XSD files when you view them. This
can result in either a blank screen or unformatted text. Choose to either
download the file or view the source.</p>
</div>
<hr/>
</body>
</html>
EOF
done
done
# Special cases
# Transforms folder
path="${root}/Transforms/"
dir="target/specification/transforms"
mkdir -p "$path"
for transform in "$dir"/*.xsl
do
if contains $transform $devmarker; then
echo "Skipping $transform"
continue
fi
cp -v "$transform" "$path"
done
# Root index
# Create an HTML link for a schema.
# $1=schema
# $2=year (may be blank)
# $3=filter (current or legacy)
# $4=verbose (true or false)
# $5=schema set (current or legacy)
createlink() {
name=$(basename "$1")
release="$2"
shortname="${name%.xsd}"
if [ "$shortname" = "ome" ]; then
shortname="OME"
fi
if [ "$5" = "legacy" ]; then
reldate="2003 ($2)"
else
if [ -z "$2" ]; then
release=$(mostrecentversion "$name")
reldate=$(parsedate "$release")
else
reldate=$(parsedate "$2")
fi
fi
if [ "$5" = "current" ]; then
relversion=$(schemaversion "$name" "$release")
else
relversion=$(schemaversion "$name" "2003-$release")
fi
reldesc=" The $(schemadesc "$name")"
if [ "$4" = "false" ]; then
reldesc=""
fi
link=$(find $root -name "$name" | grep "$release" | head -n1)
link=$(echo "$link" | sed -e "s;$root/;;")
if [ -n "$2" ]; then
link=$(echo "$link" | sed -e "s;^${shortname}/;;")
fi
if [ -z "$2" ]; then
line="<li><a href=\"${shortname}/index.html\">${shortname}</a> - $reldate, version ${relversion} [<a href=\"${link}\">${name}</a>]${reldesc}</li>"
else
line="<li><a href=\"$2/index.html\">$2</a> - $reldate, version ${relversion} [<a href=\"${link}\">${name}</a>] ${reldesc}</li>"
fi
if [ -z "$2" ]; then
if iscurrent "$name" && [ "$3" = "current" ]; then
echo "$line"
elif ! iscurrent "$name" && [ "$3" != "current" ]; then
echo "$line"
fi
else
if ismostrecent "$name" "$2" && [ "$3" = "current" ]; then
echo "$line"
elif ! ismostrecent "$name" "$2" && [ "$3" != "current" ]; then
echo "$line"
fi
fi
}
# Create main HTML index page
createmainindex() {
cat <<EOF
<?xml version='1.0'?>
<!DOCTYPE html PUBLIC "-//XML-DEV//DTD XHTML RDDL 1.0//EN"
"http://www.w3.org/2001/rddl/rddl-xhtml.dtd" >
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:rddl="http://www.rddl.org/" xml:lang="en">
<head>
<title>Open Microscopy Environment Schemas</title>
</head>
<body>
<h1>Open Microscopy Environment Schemas</h1>
<div class="head">
<p>$(curdate)</p>
</div>
<div id="toc">
<h2>Table of contents</h2>
<ol>
<li><a href="#intro">Introduction</a></li>
<li><a href="#schema.list">Schemas</a></li>
<li><a href="#history">History</a></li>
</ol>
</div>
<div id="intro">
<h2>Introduction</h2>
<p>This document outlines the XML Schemas created by the
<a href="http://www.openmicroscopy.org/">Open Microscopy Environment</a>.
Detailed information on the schemas is available
<a href="http://www.openmicroscopy.org/site/support/ome-model/index.html">here</a>.
</p>
</div>
EOF
cat <<EOF
<div id="schema.list">
<h2>Schemas</h2>
<p>This has the schema name, the current version, a link to the XSD file, and
a short description. Generated documentation for the schemas is available at:
<a href="http://www.openmicroscopy.org/Schemas/Documentation/Generated/OME-2016-06/ome.html">http://www.openmicroscopy.org/Schemas/Documentation/Generated/OME-2016-06/ome.html</a></a>
</p>
<p><em>Note: Some browsers will try to render XSD files when you view them.
This can result in either a blank screen or unformatted text. Choose to either
download the file or view the source.</em></p>
<h4>Active Schemas</h4>
<ul>
EOF
for schema in $(find $root -name '*xsd' | xargs $XARGSOPTS -n1 basename | sort | uniq ); do
createlink "$schema" "" "current" "true" "current" "$1"
done
cat <<EOF
</ul>
<h4>Legacy Schemas</h4>
<ul>
EOF
for schema in $(find $root -name '*xsd' | xargs $XARGSOPTS -n1 basename | sort | uniq); do
createlink "$schema" "" "legacy" "true" "current" "$1"
done
cat <<EOF
</ul>
</div>
<div id="history">
<h2>History</h2>
<p>This lists the most recent version of past schemas. The schemas are in a
process of constant development to extend and refine the OME Data Model. See
the
<a href="http://www.openmicroscopy.org/site/support/ome-model/schemas/index.html">Schema version history</a> for more information.
</p>
<ul>
EOF
for release in $(ls -1d target/specification/released-schema/20* | grep -v 2003 | grep -v $devmarker | xargs $XARGSOPTS -n1 basename | sort -r); do
reldate=$(parsedate "$release")
echo "<li>$reldate - namespace /$release/</li>"
done
for release in $(ls -1d target/specification/released-schema/20* | grep 2003 | xargs $XARGSOPTS -n1 basename | sort -r | grep FC | sed -e 's;2003-\(.*\);\1;') $(ls -1d target/specification/released-schema/20* | grep 2003 | xargs $XARGSOPTS -n1 basename | sort -r | grep -v FC | sed -e 's;2003-\(.*\);\1;'); do
reldate="2003 ($release)"
echo "<li>$reldate - namespace /$release/*.xsd</li>"
done
cat <<EOF
</ul>
</div>
<hr/>
</body>
</html>
EOF
}
createintermediateindex() {
current="This schema is currently used."
if ! iscurrent "$1"; then
current="This schema is no longer in use."
fi
schema="$1.xsd"
if [ "$1" = "OME" ]; then
schema="ome.xsd"
fi
cat <<EOF
<?xml version='1.0'?>
<!DOCTYPE html PUBLIC "-//XML-DEV//DTD XHTML RDDL 1.0//EN"
"http://www.w3.org/2001/rddl/rddl-xhtml.dtd" >
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:rddl="http://www.rddl.org/" xml:lang="en">
<head>
<title>Open Microscopy Environment $1 Schemas</title>
</head>
<body>
<h1>Open Microscopy Environment $1 Schemas</h1>
<div class="head">
<p>$(curdate)</p>
</div>
<div id="toc">
<h2>Table of contents</h2>
<ol>
<li><a href="#intro">Introduction</a></li>
<li><a href="#schema.list">Schemas</a></li>
<li><a href="#history">History</a></li>
</ol>
</div>
<div id="intro">
<h2>Introduction</h2>
<p>This document outlines the XML $1 Schemas created by the
<a href="http://www.openmicroscopy.org/">Open Microscopy Environment</a>. This
is the $(schemadesc "$1") Detailed information on the schemas is available
<a href="http://www.openmicroscopy.org/site/support/ome-model/index.html">here</a>.
</p>
</div>
EOF
cat <<EOF
<div id="schema.list">
<h2>Schemas</h2>
<p>This has the schema name, the current version, a link to the XSD file, and
a short description</p>
<p><em>Note: Some browsers will try to render XSD files when you view them.
This can result in either a blank screen or unformatted text. Choose to either
download the file or view the source.</em></p>
<p><b>$current</b></p>
<h4>Most recent schema</h4>
<ul>
EOF
for year in $(find $root -name "$schema" | xargs $XARGSOPTS -n1 dirname | xargs $XARGSOPTS -n1 basename | grep -v $devmarker | grep -v html | grep 20 | sort -r); do
createlink "$schema" "$year" "current" "false" "current"
done
for year in $(find $root -name "$schema" | grep 2003 | xargs $XARGSOPTS -n1 dirname | xargs $XARGSOPTS -n1 basename | grep -v $devmarker | grep -v html | sort -r | grep FC) $(find $root -name "$schema" | xargs $XARGSOPTS -n1 dirname | xargs $XARGSOPTS -n1 basename | grep -v $devmarker | grep -v html | sort -r | grep -v 20 | grep -v FC); do
createlink "$schema" "$year" "current" "false" "legacy"
done
cat <<EOF
</ul>
<h4>Older schemas</h4>
<ul>
EOF
for year in $(find $root -name "$schema" | xargs $XARGSOPTS -n1 dirname | xargs $XARGSOPTS -n1 basename | grep -v $devmarker | grep -v html | grep 20 | sort -r); do
createlink "$schema" "$year" "legacy" "false" "current"
done
for year in $(find $root -name "$schema" | xargs $XARGSOPTS -n1 dirname | xargs $XARGSOPTS -n1 basename | grep -v $devmarker | grep -v html | sort -r | grep FC) $(find $root -name "$schema" | xargs $XARGSOPTS -n1 dirname | xargs $XARGSOPTS -n1 basename | grep -v $devmarker | grep -v html | sort -r | grep -v 20 | grep -v FC); do
createlink "$schema" "$year" "legacy" "false" "legacy"
done
cat <<EOF
</ul>
</div>
<div id="history">
<h2>History</h2>
<p>This lists the current and prior versions of the $1 schema. The schemas are
in a process of constant development to extend and refine the OME Data Model.
See the
<a href="https://www.openmicroscopy.org/site/support/ome-model/schemas/index.html">Schema version history</a>
for more information.
</p>
<ul>
EOF
for release in $(ls -1d "$root"/$1/20* | xargs $XARGSOPTS -n1 basename | grep -v $devmarker | grep -v html | sort -r ); do
reldate=$(parsedate "$release")
echo "<li>$reldate - namespace /$release/</li>"
done
for release in $(ls -1d "$root"/$1/* | xargs $XARGSOPTS -n1 basename | grep -v $devmarker | grep -v html | sort -r | grep FC) $(ls -1d "$root"/$1/* | xargs $XARGSOPTS -n1 basename | grep -v $devmarker | grep -v html | sort -r | grep -v 20 | grep -v FC); do
reldate="2003 ($release)"
echo "<li>$reldate - namespace /$release/$schema</li>"
done
cat <<EOF
</ul>
</div>
<hr/>
</body>
</html>
EOF
}
for type in $(find "${root}" -mindepth 1 -maxdepth 1 -type d | sed -e 's;^published/;;'); do
if [ "$(basename $type)" != "Transforms" ]; then
echo "HTML [2] -> ${type}/index.html"
createintermediateindex "$(basename $type)" > "${type}/index.html"
fi
done
echo "HTML [4] -> ${root}/index.html"
createmainindex "current" > "${root}/index.html"
cp -r ${root}/* .