1 | #!/bin/bash
|
---|
2 |
|
---|
3 | source ../_local_collect_config.sh
|
---|
4 |
|
---|
5 |
|
---|
6 | # Build up URL through static 'site' URL to collect/<openannotation>.json
|
---|
7 | #iuri_prefix=http://localhost:4343/greenstone3/library/sites/intermuse/collect/$col
|
---|
8 |
|
---|
9 | ## ifilename=${1:-archives/HASH012c.dir/openannotation-list.json}
|
---|
10 | #ifilename=${1:-amadeus-iiif-manifest--with-otherContent.json}
|
---|
11 |
|
---|
12 |
|
---|
13 | ##iuri_tail=${ifilename#archives/}
|
---|
14 |
|
---|
15 | ##iuri="${iuri_prefix}${iuri_tail}"
|
---|
16 | #iuri="${iuri_prefix}/${ifilename}"
|
---|
17 |
|
---|
18 |
|
---|
19 | docid="${1:-HASH012cd965c3e83d504f4a78cd}"
|
---|
20 |
|
---|
21 | download_url="$gs_library_url/collection/$col/document/$docid"
|
---|
22 | download_url="$download_url?sa=iiif-manifest&ed=1&includeFileAssocOpenAnnotations=true&excerptid-text=iiif-manifest"
|
---|
23 |
|
---|
24 | if [ ! -d tmp ] ; then
|
---|
25 | echo ""
|
---|
26 | echo "Making directory 'tmp'"
|
---|
27 | mkdir tmp
|
---|
28 | fi
|
---|
29 |
|
---|
30 | # Workaround for JSON parsing error. When using the Greenstone document URL directly
|
---|
31 | # then POSTing to /simpleAnnotationStore/manifests resulted in a JSON error
|
---|
32 | # Issue caused by leading blank space
|
---|
33 | #
|
---|
34 | # Workaround is to download it as collect/tmp/doc-openannotation--with-otherContent.json
|
---|
35 | # and as part of that process, strip out whitespace.
|
---|
36 | # Then a new URL is built to the collect/tmp/doc-openannotation--with-otherContent.json
|
---|
37 | # and that version of the file is POSTed to /simpleAnnotationStore/manifests
|
---|
38 |
|
---|
39 | pid=$$
|
---|
40 |
|
---|
41 | echo ""
|
---|
42 | echo "Downloading openannotation JSON for $docid as workaround to strip out leading blank space"
|
---|
43 | echo " $download_url"
|
---|
44 | echo ""
|
---|
45 | curl --silent "$download_url" | egrep -v "^\\s*$" > tmp/doc-openannotation--with-otherContent--pid$pid.json
|
---|
46 |
|
---|
47 |
|
---|
48 | iuri="$gs_library_url/sites/$site/collect/$col/tmp/doc-openannotation--with-otherContent--pid$pid.json"
|
---|
49 |
|
---|
50 | internal_url_base="http://localhost:$gs_http_port/simpleAnnotationStore"
|
---|
51 |
|
---|
52 | post_url="${internal_url_base}/manifests"
|
---|
53 |
|
---|
54 | echo ""
|
---|
55 |
|
---|
56 | echo curl -X POST -d \"uri=${iuri}\" \"$post_url\"
|
---|
57 | #echo "[Dry run, suppressing curl]"
|
---|
58 | curl --silent -X POST -d "uri=${iuri}" "$post_url"
|
---|
59 |
|
---|
60 | if [ $? = 0 ] ; then
|
---|
61 | echo "For debugging purposes, supressing removal of tmp/doc-openannotation--with-otherContent--pid$pid.json"
|
---|
62 | /bin/rm tmp/doc-openannotation--with-otherContent--pid$pid.json
|
---|
63 | fi
|
---|
64 |
|
---|
65 | echo ""
|
---|
66 |
|
---|
67 | # When the IIIFManifest file is ingested, the returned JSON includes the 'short_id' for the
|
---|
68 | # submitted file. This is a value that a built Greenstone collection needs to know to
|
---|
69 | # use Mirador's search within-the-document, but produced at this stage is too late
|
---|
70 | # to be incorporated. The solution to this has been to look into how SAS calculates
|
---|
71 | # this short_id value, and encode the same calculation into the GoogleVisionAPI plugin
|
---|
72 | # so the same value can be computed there (when it is generating OpenAnnotations, and
|
---|
73 | # storing them as associated files), with the computed value set as the metadata field
|
---|
74 | # SASShortID
|
---|
75 |
|
---|
76 |
|
---|
77 | # In more detail ...
|
---|
78 | #
|
---|
79 | # To search within specific IIIFManafest, the SAS Search endpoint makes use of a field
|
---|
80 | # called 'short_id'. This turns out to be an MD5 hash of the URL, and is done so the
|
---|
81 | # Restful URL to query the document specifies the
|
---|
82 |
|
---|
83 | # For example the Doc ID:
|
---|
84 | # http://ld.greenstone.org/intermuse/demo-localhost/HMS_1/canvas/1
|
---|
85 | #
|
---|
86 | # gets hashed to 212807d9741cd2497368dee6c16f2882
|
---|
87 | #
|
---|
88 | # and so is then searched through SAS as:
|
---|
89 | #
|
---|
90 | # http://localhost:8383/simpleAnnotationStore/search-api/212807d9741cd2497368dee6c16f2882/search?q=SOUL
|
---|
91 |
|
---|
92 |
|
---|
93 | # So Greenstone3's XSL presentation layer can correctly construct the URL to search within
|
---|
94 | # the Mirador viewer using the SAS search endpoint, it need to set this short_id as a piece
|
---|
95 | # of metadata (SASShortID).
|
---|
96 | #
|
---|
97 | # This is done in the GoogleVisionAPI Plugin, 'replicating' (computing up-stream, really)
|
---|
98 | # the MD5 hash calculation that SAS also does at this point, when the IIIFManifest is ingested
|
---|
99 |
|
---|