[37157] | 1 | #!/bin/bash
|
---|
[37106] | 2 |
|
---|
[37124] | 3 | source ../_local_collect_config.sh
|
---|
[37106] | 4 |
|
---|
| 5 |
|
---|
[37157] | 6 | # Build up URL through static 'site' URL to collect/<openannotation>.json
|
---|
| 7 | #iuri_prefix=http://localhost:4343/greenstone3/library/sites/intermuse/collect/$col
|
---|
[37106] | 8 |
|
---|
[37157] | 9 | ## ifilename=${1:-archives/HASH012c.dir/openannotation-list.json}
|
---|
| 10 | #ifilename=${1:-amadeus-iiif-manifest--with-otherContent.json}
|
---|
[37106] | 11 |
|
---|
| 12 |
|
---|
[37157] | 13 | ##iuri_tail=${ifilename#archives/}
|
---|
[37106] | 14 |
|
---|
[37157] | 15 | ##iuri="${iuri_prefix}${iuri_tail}"
|
---|
| 16 | #iuri="${iuri_prefix}/${ifilename}"
|
---|
[37106] | 17 |
|
---|
[37157] | 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 | echo ""
|
---|
| 40 | echo "Downloading openannotation JSON for $docid as workaround to strip out leading blank space"
|
---|
| 41 | echo ""
|
---|
| 42 | curl "$download_url" | egrep -v "^\\s*$" > tmp/doc-openannotation--with-otherContent.json
|
---|
| 43 |
|
---|
| 44 |
|
---|
| 45 | iuri="$gs_library_url/sites/intermuse/collect/$col/tmp/doc-openannotation--with-otherContent.json"
|
---|
| 46 |
|
---|
[37106] | 47 | internal_url_base="http://localhost:4343/simpleAnnotationStore"
|
---|
| 48 |
|
---|
| 49 | post_url="${internal_url_base}/manifests"
|
---|
| 50 |
|
---|
| 51 | echo ""
|
---|
| 52 |
|
---|
[37157] | 53 | echo curl -X POST -d \"uri=${iuri}\" \"$post_url\"
|
---|
[37106] | 54 | curl -X POST -d "uri=${iuri}" "$post_url"
|
---|
| 55 |
|
---|
[37157] | 56 | #if [ $? = 0 ] ; then
|
---|
| 57 | # /bin/rm tmp/doc-openannotation--with-otherContent.json
|
---|
| 58 | #fi
|
---|
| 59 |
|
---|
[37106] | 60 | echo ""
|
---|
| 61 |
|
---|
| 62 |
|
---|
[37124] | 63 | # Returns JSON output of the form:
|
---|
| 64 | # {"loaded":{"short_id":"f3bac06f17c9240b76b082dbdcbb365a","uri":"http-greenstone://intermuse/programmes/HASH012cd965c3e83d504f4a78cd/manifest"}}
|
---|
| 65 |
|
---|
| 66 | # The short_id is needed to ...
|
---|
[37157] | 67 |
|
---|
| 68 |
|
---|
| 69 | # {"loaded":{"short_id":"e2465cd7e5174f2720cee110d9b4a06a","uri":"http-greenstone://intermuse/programmes-and-performers/HASH012cd965c3e83d504f4a78cd/manifest"}}+ echo ''
|
---|