Skip to content

Commit

Permalink
Merge pull request #549 from giacomomarchioro/0540-link-for-opening-m…
Browse files Browse the repository at this point in the history
…ultiple-canvases

0540 link for opening multiple canvases
  • Loading branch information
giacomomarchioro authored Oct 25, 2024
2 parents e76f549 + 962abae commit 0fd8792
Show file tree
Hide file tree
Showing 28 changed files with 498 additions and 25 deletions.
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ gem 'jekyll', '~> 4.1.1'

# for local development, clone theme + use path loader
# gem 'iiifc-theme', path: 'iiifc-theme'
gem 'iiifc-theme', github: 'iiif/iiifc-theme', branch: 'main'
gem 'iiifc-theme', github: 'iiif/iiifc-theme', branch: 'ignore-font-awsome'

# For open graph and Twitter Card elements
gem 'jekyll-seo-tag'
Expand Down
12 changes: 6 additions & 6 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
GIT
remote: https://github.com/iiif/iiifc-theme.git
revision: afff3ef39910d7454c58abf2b9c9e6a50cc7cb4c
branch: main
revision: a1a48285ca5bbf81d6967cf31fdcdb571da3068b
branch: ignore-font-awsome
specs:
iiifc-theme (0.1.0)
html-proofer
Expand All @@ -18,7 +18,7 @@ GEM
addressable (2.8.7)
public_suffix (>= 2.0.2, < 7.0)
colorator (1.1.0)
concurrent-ruby (1.3.3)
concurrent-ruby (1.3.4)
diff-lcs (1.5.1)
em-websocket (0.5.3)
eventmachine (>= 0.12.9)
Expand Down Expand Up @@ -84,7 +84,7 @@ GEM
racc (~> 1.4)
nokogumbo (2.0.5)
nokogiri (~> 1.8, >= 1.8.4)
parallel (1.25.1)
parallel (1.26.3)
pathutil (0.16.2)
forwardable-extended (~> 2.6)
public_suffix (6.0.1)
Expand All @@ -95,7 +95,7 @@ GEM
rb-inotify (0.11.1)
ffi (~> 1.0)
redcarpet (3.6.0)
rexml (3.3.4)
rexml (3.3.6)
strscan
rouge (3.30.0)
rspec (3.13.0)
Expand All @@ -104,7 +104,7 @@ GEM
rspec-mocks (~> 3.13.0)
rspec-core (3.13.0)
rspec-support (~> 3.13.0)
rspec-expectations (3.13.1)
rspec-expectations (3.13.2)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.13.0)
rspec-mocks (3.13.1)
Expand Down
39 changes: 39 additions & 0 deletions _includes/content-state-viewers.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{% if include.viewers %}
{% assign viewers = include.viewers | split: "," %}
{% else %}
{% assign viewers = page.viewers %}
{% endif %}
[JSON-LD]({{ include.iiif-content }}) {% for viewerTxt in viewers %}{% assign viewer = viewerTxt | strip %}| {% include viewer_link.html type=viewer manifest=include.iiif-content class="content-state" %}{% endfor %}

{% if page.code %}
{% include code_links.html %}
{% endif %}

<script>
function encodeContentState(plainContentState) {
let uriEncoded = encodeURIComponent(plainContentState); // using built in function
let base64 = btoa(uriEncoded); // using built in function
let base64url = base64.replace(/\+/g, "-").replace(/\//g, "_");
let base64urlNoPadding = base64url.replace(/=/g, "");
return base64urlNoPadding;
}

const links = document.getElementsByClassName("content-state");

Array.from(links).forEach(link => {
link.title = "Generating iiif-content link...."
fetch(link.dataset.iiifContent).then(response=> {
response.json().then (anno => {
const encoded = encodeContentState(JSON.stringify(anno));

if (/iiif-content=.*&/.test(link.href)){
link.href = link.href.replace(/iiif-content=.*&/, "iiif-content=" + encoded + '&');
} else {
link.href = link.href.replace(/iiif-content=.*$/, "iiif-content=" + encoded);
}
link.title = "";
})

});
});
</script>
4 changes: 4 additions & 0 deletions _includes/links.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,11 @@

[0466]: {{ site.cookbook_url | absolute_url }}/recipe/0466-link-for-loading-manifest/ "Loading a manifest with a viewer using a link"

[0485]: {{ site.cookbook_url | absolute_url }}/recipe/0485-contentstate-canvas-region/ "Open a specific region of a canvas in a viewer"

[0434]: {{ site.cookbook_url | absolute_url }}/recipe/0434-choice-av/ "Multiple Choice of Audio Formats in a Single View (Canvas)"
[0489]: {{ site.cookbook_url | absolute_url }}/recipe/0489-multimedia-canvas/ "Rendering Multiple Media Types on a Time-Based Canvas"
[0540]: {{ site.cookbook_url | absolute_url }}/recipe/0540-link-for-opening-multiple-canvases/ "Sharing a link for opening two or more Canvases"

[cookbook-process]: {{site.cookbook_url | absolute_url }}/recipe

Expand Down
2 changes: 1 addition & 1 deletion _includes/viewer_link.html
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,4 @@
{% else %}
{% capture default_text %}Unknown Viewer type '{{ include.type}}'{% endcapture %}
{% capture viewer_url %}{{manifest_url |strip}}{% endcapture %}
{% endif %}<a href="{{ viewer_url | strip }}" target="_blank">{{ include.text | default: default_text }}</a>
{% endif %}<a href="{{ viewer_url | strip }}" class="{{ include.class }}" data-iiif-content="{{manifest_url |strip}}" target="_blank">{{ include.text | default: default_text }}</a>
6 changes: 5 additions & 1 deletion index.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ _(leading on to segmentation examples later)_
* [Multiple choice of images in a single view][0033] (29)
* [Foldouts, Flaps, and Maps][0035]
* [Composition from Multiple Images][0036] (30,31)
* [Rendering Multiple Media Types on a Time-Based Canvas][0489]
* Multiple images and multiple choices (32,33,34)
* [Annotating part of an image to a Canvas][recipe-segment-image-part] (e.g., crop out scanner) (35,36,37,38)
* [Image Rotation Two Ways][0040]
Expand All @@ -136,10 +137,13 @@ _(leading on to segmentation examples later)_
* [Linking to Structured Metadata][0053] (8)


## Sharing IIIF content
## Sharing IIIF content
Recipes using [Content State API](https://iiif.io/api/content-state/1.0/)

* [Loading a manifest with a viewer using a link][0466]
* [Open a specific region of a canvas in a viewer][0485]
* [Sharing a link for opening two or more Canvases][0540]



## Technical
Expand Down
1 change: 1 addition & 0 deletions recipe/0001-mvm-image/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ viewers:
- Clover
- Glycerine Viewer
- Theseus
- Curation
topic:
- basic
- image
Expand Down
3 changes: 2 additions & 1 deletion recipe/0004-canvas-size/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ viewers:
- Mirador
- Annona
- Theseus
- Curation
topic: image
code:
- iiif-prezi3
Expand Down Expand Up @@ -39,7 +40,7 @@ The aspect ratio should be consistent between your source image and Canvas. Othe

This example shows a Manifest with a single Canvas that has height and width dimensions three times the pixel dimensions of the image in order to construct a Canvas with both dimensions greater than 1000px.

{% include manifest_links.html viewers="UV, Mirador, Annona, Theseus" manifest="manifest.json" %}
{% include manifest_links.html viewers="UV, Mirador, Annona, Theseus, Curation" manifest="manifest.json" %}
{% include jsonviewer.html src="manifest.json" config="data-line='14-15,29-30'"%}

# Related recipes
Expand Down
3 changes: 2 additions & 1 deletion recipe/0005-image-service/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ viewers:
- Clover
- Glycerine Viewer
- Theseus
- Curation
topic:
- basic
- image
Expand Down Expand Up @@ -37,7 +38,7 @@ Though a version 3 Manifest may specify a service using the version 2 `@id` and

## Example

{% include manifest_links.html viewers="Mirador, Annona, Clover, Glycerine Viewer, Theseus" manifest="manifest.json" %}
{% include manifest_links.html viewers="Mirador, Annona, Clover, Glycerine Viewer, Theseus, Curation" manifest="manifest.json" %}

{% include jsonviewer.html src="manifest.json" config='data-line="36-42"' %}

Expand Down
9 changes: 7 additions & 2 deletions recipe/0006-text-language/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ viewers:
- Annona
- Glycerine Viewer
- Theseus
- Curation
topic: basic
property: label, summary, metadata, requiredStatement
code:
Expand Down Expand Up @@ -38,11 +39,15 @@ In the `metadata` and `requiredStatement` properties, the `label` strings for "C

Finally, the `summary` property (lines 49-54) has values in both English and French.

To see the language choice in the linked viewers, open the settings menu (gear icon) and choose either English or French.
With the Universal Viewer, Mirador, and Glycerine you can open the settings menu (gear icon) and choose either English or French.

For the Curation viewer you need to add a `lang=fr` parameter to access the French properties. You can see the French values on the [IIIF Curation Viewer](http://codh.rois.ac.jp/software/iiif-curation-viewer/demo/?manifest=https://iiif.io/api/cookbook/recipe/0006-text-language/manifest.json&lang=fr) demo site.

Note not all viewers support all languages and users should check the viewers with their manifests to see if they need to configure the viewer to make the extra languages available.

The image in this example was sourced via Wikimedia Commons and is public domain.

{% include manifest_links.html viewers="UV, Mirador, Annona, Glycerine Viewer, Theseus" manifest="manifest.json" %}
{% include manifest_links.html viewers="UV, Mirador, Annona, Glycerine Viewer, Theseus, Curation" manifest="manifest.json" %}

{% include jsonviewer.html src="manifest.json" config='data-line="6-11, 16-21, 24-26, 31-36, 39-44, 49-54, 58-63, 66-68"' %}

Expand Down
3 changes: 2 additions & 1 deletion recipe/0007-string-formats/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ viewers:
- Clover
- Glycerine Viewer
- Theseus
- Curation
topic: property
property: label, summary, metadata, requiredStatement
code:
Expand All @@ -33,7 +34,7 @@ For security reasons, clients are expected to allow only `a`, `b`, `br`, `i`, `i

## Example

{% include manifest_links.html viewers="UV, Mirador, Annona, Clover, Glycerine Viewer, Theseus" manifest="manifest.json" %}
{% include manifest_links.html viewers="UV, Mirador, Annona, Clover, Glycerine Viewer, Theseus, Curation" manifest="manifest.json" %}

{% include jsonviewer.html src="manifest.json" config='data-line="7,12,24,38"' %}

Expand Down
3 changes: 2 additions & 1 deletion recipe/0008-rights/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ viewers:
- Clover
- Glycerine Viewer
- Theseus
- Curation
topic: property
property: rights, requiredStatement
code:
Expand Down Expand Up @@ -41,7 +42,7 @@ None known.

## Example

{% include manifest_links.html viewers="UV, Mirador, Annona, Clover, Glycerine Viewer, Theseus" manifest="manifest.json" %}
{% include manifest_links.html viewers="UV, Mirador, Annona, Clover, Glycerine Viewer, Theseus, Curation" manifest="manifest.json" %}

{% include jsonviewer.html src="manifest.json" config='data-line="15-27"' %}

Expand Down
3 changes: 2 additions & 1 deletion recipe/0009-book-1/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ viewers:
- Clover
- Glycerine Viewer
- Theseus
- Curation
topic:
- image
- basic
Expand Down Expand Up @@ -38,7 +39,7 @@ You should also consider providing a [thumbnail][prezi3-thumbnail] for each Canv

## Example

{% include manifest_links.html viewers="UV, Mirador, Annona, Clover, Glycerine Viewer, Theseus" manifest="manifest.json" %}
{% include manifest_links.html viewers="UV, Mirador, Annona, Clover, Glycerine Viewer, Theseus, Curation" manifest="manifest.json" %}

{% include jsonviewer.html src="manifest.json" %}

Expand Down
7 changes: 5 additions & 2 deletions recipe/0010-book-2-viewing-direction/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ viewers:
- UV
- Mirador
- Annona
- Theseus
- id: Theseus
support: partial
- id: Curation
support: partial
topic:
- image
- property
Expand Down Expand Up @@ -41,7 +44,7 @@ None known

This Manifest shows the playbill for "Akiba gongen kaisen-banashi," "Futatsu chōchō kuruwa nikki", and "Godairiki koi no fūjime", kabuki performances at the Chikugo Theater in Osaka, from the fifth month of Kaei 2 (May, 1849).

{% include manifest_links.html viewers="UV, Mirador, Annona, Theseus" manifest="manifest-rtl.json" %}
{% include manifest_links.html viewers="UV, Mirador, Annona, Theseus, Curation" manifest="manifest-rtl.json" %}

{% include jsonviewer.html src="manifest-rtl.json" config='data-line="15"' %}

Expand Down
3 changes: 2 additions & 1 deletion recipe/0029-metadata-anywhere/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ viewers:
support: partial
- Glycerine Viewer
- Theseus
- Curation
topic: property
property: metadata
---
Expand All @@ -38,7 +39,7 @@ Note: Clover supports Metadata at the Manifest level but not down at the Canvas.

Credit: *John Dee performing an experiment before Queen Elizabeth I*. Oil painting by Henry Gillard Glindoni. Credit: Wellcome Collection. Attribution-NonCommercial 4.0 International (CC BY-NC 4.0)

{% include manifest_links.html viewers="UV, Mirador, Annona, Clover, Glycerine Viewer, Theseus" manifest="manifest.json" %}
{% include manifest_links.html viewers="UV, Mirador, Annona, Clover, Glycerine Viewer, Theseus, Curation" manifest="manifest.json" %}

{% include jsonviewer.html src="manifest.json" config='data-line="10-59, 83-96, 136-149"' %}

Expand Down
3 changes: 2 additions & 1 deletion recipe/0118-multivalue/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ viewers:
- Annona
- Glycerine Viewer
- Theseus
- Curation
topic: property
property: label, summary, metadata, requiredStatement
---
Expand All @@ -32,7 +33,7 @@ None

In this example, the work has multiple titles in both English and French. The Manifest `label` provides a single title in French within a single-value array (lines 6–8). The alternative titles are provided in the `metadata` property in both English and French, each with variants contained within two separate arrays -- one array for English (lines 18–21) and one for French (lines 22–25). In the `summary` property (lines 30–32) the value is included as a single-string array.

{% include manifest_links.html viewers="UV, Mirador, Annona, Glycerine Viewer, Theseus" manifest="manifest.json" %}
{% include manifest_links.html viewers="UV, Mirador, Annona, Glycerine Viewer, Theseus, Curation" manifest="manifest.json" %}

{% include jsonviewer.html src="manifest.json" config='data-line="6-8, 18-21, 22-25, 30-32"'%}

Expand Down
1 change: 1 addition & 0 deletions recipe/0283-missing-image/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ viewers:
- Mirador
- Glycerine Viewer
- Theseus
- Curation
topic:
- image
- basic
Expand Down
2 changes: 1 addition & 1 deletion recipe/0318-navPlace-navDate/manifest-5.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"type": "Manifest",
"label": {
"en": [
" A View of Trajan's Forum, Rome, 1821"
"A View of Trajan's Forum, Rome, 1821"
]
},
"navDate": "1821-01-01T00:00:00+00:00",
Expand Down
6 changes: 2 additions & 4 deletions recipe/0346-multilingual-annotation-body/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,7 @@
"id": "{{ id.path }}/annotation/p0001-comment",
"type": "Annotation",
"motivation": "commenting",
"body": [
{
"body": {
"type": "Choice",
"items": [
{
Expand All @@ -70,8 +69,7 @@
"format": "text/plain"
}
]
}
],
},
"target": "{{ id.path }}/canvas/p1#xywh=1650,1200,925,1250"
}
]
Expand Down
14 changes: 14 additions & 0 deletions recipe/0485-contentstate-canvas-region/annotation.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"@context": "http://iiif.io/api/presentation/3/context.json",
"id": "https://example.org/import/1",
"type": "Annotation",
"motivation": ["contentState"],
"target": {
"id": "https://iiif.io/api/cookbook/recipe/0009-book-1/canvas/p2#xywh=1528,3024,344,408",
"type": "Canvas",
"partOf": [{
"id": "https://iiif.io/api/cookbook/recipe/0009-book-1/manifest.json",
"type": "Manifest"
}]
}
}
Loading

0 comments on commit 0fd8792

Please sign in to comment.