Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SME with IIIF manifest #5051

Merged
merged 2 commits into from
Feb 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions app/controllers/media_objects_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,7 @@ def manifest
manifest = IIIFManifest::V3::ManifestFactory.new(presenter).to_h
# TODO: implement thumbnail in iiif_manifest
manifest["thumbnail"] = [{ "id" => presenter.thumbnail, "type" => 'Image' }] if presenter.thumbnail
manifest["rendering"] = presenter.rendering

respond_to do |wants|
wants.json { render json: manifest.to_json }
Expand Down
28 changes: 20 additions & 8 deletions app/javascript/components/ReactButtonContainer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,27 @@ class ReactButtonContainer extends Component {
constructor(props) {
super(props);

const { audioURL, baseURL, initStructure, masterFileID, streamDuration } = this.props;
const {
baseURL,
initStructure,
masterFileID,
mediaObjectID,
canvasIndex,
} = this.props;
this.state = {
show: false,
smeProps: {
structureURL: baseURL + '/master_files/' + masterFileID + '/structure.json',
waveformURL: baseURL + '/master_files/' + masterFileID + '/waveform.json',
manifestURL: baseURL + '/media_objects/' + mediaObjectID + '/manifest.json',
canvasIndex: canvasIndex,
initStructure: initStructure,
audioURL: audioURL,
streamDuration: Number(streamDuration)
},
structureSaved: true
};
}

handleClose = () => {
if(!this.state.structureSaved) {
if (!this.state.structureSaved) {
if (confirm("Unsaved changes will be lost. Are you sure?")) {
this.setState({
show: false
Expand All @@ -44,10 +49,10 @@ class ReactButtonContainer extends Component {

getStructureStatus = (value) => {
this.setState({ structureSaved: value });
}
};

render() {
const modalID = `edit_structure_${this.props.sectionIndex}`;
const modalID = `edit_structure_${this.props.canvasIndex}`;
return (
<div className="ReactButtonContainer">
<button
Expand All @@ -57,7 +62,14 @@ class ReactButtonContainer extends Component {
Edit Structure
</button>

<Modal id={modalID} show={this.state.show} animation={false} onHide={this.handleClose} backdrop="static" className="sme-modal-wrapper" dialogClassName="modal-wrapper-body">
<Modal
id={modalID}
show={this.state.show}
animation={false}
onHide={this.handleClose}
backdrop="static"
className="sme-modal-wrapper"
dialogClassName="modal-wrapper-body">
<Modal.Header closeButton>
<Modal.Title>Edit Structure</Modal.Title>
</Modal.Header>
Expand Down
6 changes: 3 additions & 3 deletions app/models/iiif_canvas_presenter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def stream_urls
def simple_iiif_range
# TODO: embed_title?
IiifManifestRange.new(
label: { '@none'.to_sym => [stream_info[:embed_title]] },
label: { "none" => [stream_info[:embed_title]] },
items: [
IiifCanvasPresenter.new(master_file: master_file, stream_info: stream_info, media_fragment: 't=0,')
]
Expand All @@ -102,15 +102,15 @@ def div_to_iiif_range(div_node)
raise Nokogiri::XML::SyntaxError, "Empty root or Div node: #{div_node[:label]}" if items.empty?

IiifManifestRange.new(
label: { '@none' => [div_node[:label]] },
label: { "none" => [div_node[:label]] },
items: items
)
end

def span_to_iiif_range(span_node)
fragment = "t=#{parse_hour_min_sec(span_node[:begin])},#{parse_hour_min_sec(span_node[:end])}"
IiifManifestRange.new(
label: { '@none' => [span_node[:label]] },
label: { "none" => [span_node[:label]] },
items: [
IiifCanvasPresenter.new(master_file: master_file, stream_info: stream_info, media_fragment: fragment)
]
Expand Down
9 changes: 9 additions & 0 deletions app/models/iiif_manifest_presenter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,15 @@ def thumbnail
@thumbnail ||= image_for(media_object.to_solr)
end

def rendering
media_object.master_files.collect do |mf|
{ "id" => "#{mf.waveform_master_file_url(mf.id)}.json", "type" => "SpecificResource",
"label" => { "en" => ["waveform.json"] },
"format" => "application/json"
}
end
end

def ranges
[
IiifManifestRange.new(
Expand Down
6 changes: 3 additions & 3 deletions app/views/media_objects/_structure.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Unless required by applicable law or agreed to in writing, software distributed
--- END LICENSE_HEADER BLOCK ---
%>

<p class="muted">Drag files to reorder them.</p>
<p class="text-muted">Drag files to reorder them.</p>

<% if @masterFiles.blank? %>
<div class="well">There are no media files</div>
Expand Down Expand Up @@ -70,9 +70,9 @@ Unless required by applicable law or agreed to in writing, software distributed
<div class="btn-toolbar">
<label class="btn btn-primary btn-struct mr-1 file-upload-label" for="structure_<%= index %>_filedata"><%= section.structuralMetadata.present? ? 'Replace' : 'Upload'%></label>
<% if section.structuralMetadata.valid? %>
<%= react_component("ReactButtonContainer", {sectionIndex: index, masterFileID: section.id, baseURL: request.protocol+request.host_with_port, streamDuration: section.duration, audioURL: stream_url, initStructure: section.structuralMetadata.as_json}) %>
<%= react_component("ReactButtonContainer", {canvasIndex: index, mediaObjectID: @media_object.id, masterFileID: section.id, baseURL: request.protocol+request.host_with_port, initStructure: section.structuralMetadata.as_json}) %>
<% else %>
<%= react_component("ReactButtonContainer", {sectionIndex: index, masterFileID: section.id, baseURL: request.protocol+request.host_with_port, streamDuration: section.duration, audioURL: stream_url, initStructure: { label: "#{item_label}", type: "div", items: [] }}, html_options={ class: 'react-button-container' }) %>
<%= react_component("ReactButtonContainer", {canvasIndex: index, mediaObjectID: @media_object.id, masterFileID: section.id, baseURL: request.protocol+request.host_with_port, initStructure: { label: "#{item_label}", type: "div", items: [] }}, html_options={ class: 'react-button-container' }) %>
<% end %>
<button type="button" class="btn btn-primary btn-struct mr-1" value="Advanced Edit" data-toggle="modal"
data-target="#advanced_edit_structure_<%= index %>">Advanced Edit</button>
Expand Down
25 changes: 15 additions & 10 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -894,9 +894,9 @@
"@babel/plugin-transform-react-pure-annotations" "^7.14.5"

"@babel/runtime@^7.1.2", "@babel/runtime@^7.15.4", "@babel/runtime@^7.2.0", "@babel/runtime@^7.3.1", "@babel/runtime@^7.4.4", "@babel/runtime@^7.8.3", "@babel/runtime@^7.9.2":
version "7.18.9"
resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.18.9.tgz#b4fcfce55db3d2e5e080d2490f608a3b9f407f4a"
integrity sha512-lkqXDcvlFT5rvEjiu6+QYO+1GXrEHRo2LOtS7E4GtX5ESIZOgepqsZBVIj6Pv+a6zqsya9VCgiK1KAK4BvJDAw==
version "7.19.0"
resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.19.0.tgz#22b11c037b094d27a8a2504ea4dcff00f50e2259"
integrity sha512-eR8Lo9hnDS7tqkO7NsV+mKvCmv5boaXFSZ70DnfhcgiEne8hv9oCEd36Klw74EtizEqLsy4YnW8UWwpBVolHZA==
dependencies:
regenerator-runtime "^0.13.4"

Expand Down Expand Up @@ -1892,11 +1892,6 @@ balanced-match@^1.0.0:
resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.2.tgz#e83e3a7e3f300b34cb9d87f615fa0cbf357690ee"
integrity sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==

base-64@^0.1.0:
version "0.1.0"
resolved "https://registry.yarnpkg.com/base-64/-/base-64-0.1.0.tgz#780a99c84e7d600260361511c4877613bf24f6bb"
integrity sha512-Y5gU45svrR5tI2Vt/X9GPd3L0HNIKzGu202EjxrXMpuc2V2CiKgemAbUUsqYmZJvPtCXoUKjNZwBJzsNScUbXA==

base64-js@^1.0.2:
version "1.5.1"
resolved "https://registry.yarnpkg.com/base64-js/-/base64-js-1.5.1.tgz#1b1b440160a5bf7ad40b650f095963481903930a"
Expand Down Expand Up @@ -4832,6 +4827,16 @@ manifesto.js@^4.1.0:
isomorphic-unfetch "^3.0.0"
lodash "^4.17.21"

manifesto.js@^4.2.14:
version "4.2.14"
resolved "https://registry.yarnpkg.com/manifesto.js/-/manifesto.js-4.2.14.tgz#376fc73f9884646ff79168a67c4d3356cbd28b48"
integrity sha512-6lsgr3j/DyxlIQfqE+0VlNeKlb3MzJVv42Is9+Y8AC6pBfVIqKV4xfGrP7B1q9jX59elFR4grYGDMVWi71KwSQ==
dependencies:
"@edsilv/http-status-codes" "^1.0.3"
"@iiif/vocabulary" "^1.0.20"
isomorphic-unfetch "^3.0.0"
lodash "^4.17.21"

map-cache@^0.2.2:
version "0.2.2"
resolved "https://registry.yarnpkg.com/map-cache/-/map-cache-0.2.2.tgz#c32abd0bd6525d9b051645bb4f26ac5dc98a0dbf"
Expand Down Expand Up @@ -6594,7 +6599,7 @@ react-redux@^7.2.6:

"react-structural-metadata-editor@https://github.com/avalonmediasystem/react-structural-metadata-editor":
version "1.1.0"
resolved "https://github.com/avalonmediasystem/react-structural-metadata-editor#649f6e415a414c04e231e9f400bf268915209956"
resolved "https://github.com/avalonmediasystem/react-structural-metadata-editor#ca1ed572f3104e6043e4b8fc60bf67f6a75259cd"
dependencies:
"@babel/runtime" "^7.4.4"
"@fortawesome/fontawesome-svg-core" "^1.2.4"
Expand All @@ -6603,9 +6608,9 @@ react-redux@^7.2.6:
"@material-ui/core" "^4.12.0"
"@material-ui/icons" "4.2.1"
axios "^0.21.2"
base-64 "^0.1.0"
hls.js "^1.1.2"
lodash "4.17.21"
manifesto.js "^4.2.14"
peaks.js "^0.26.0"
prop-types "^15.6.2"
react-bootstrap "1.6.4"
Expand Down