Skip to content

Retrieve templates as RDF

michelleif edited this page Nov 25, 2020 · 1 revision

Sinopia treats templates just like any other resource, so templates are edited like any other resource: using the Sinopia Editor. For users who would like to work with templates in their raw form, outside of Sinopia, here's 2 ways to get the raw templates.

Retrieve one template at a time using preview and copy/paste

  1. From the Resource Templates tab, click the pencil icon next to the template you want to retrieve. This opens the template as if you were going to edit it (so don't change it!)
  2. Use the eye icon to open the template in Preview mode
  3. Change the Format dropdown to N-Triples
  4. Select all the text in the box and copy/paste it to wherever you want to work with it

Retrieve a batch of templates

You will need:

  • wget: this should work on any OS with wget installed
  • jq: this should work on any Unixy OS (Linux, OS X)
  1. Create a file urls.txt containing the URIs of the templates you want to retrieve. For example:
https://api.sinopia.io/resource/ld4p:RT:bf2:Cartographic:Instance
https://api.sinopia.io/resource/ld4p:RT:bf2:Cartographic:Work
https://api.sinopia.io/resource/ld4p:RT:bf2:Monograph:Instance:Un-nested
  1. Retrieve the templates:
wget -i urls.txt --show-progress --directory-prefix=templates --header "Accept: application/ld+json" -N
  1. Pretty and rename the files:
find templates/ -type f -exec bash -c "jq '' {} > {}.jsonld" \; -delete
Clone this wiki locally