-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
IIIF #5 - Updating resource to extract EXIF data after save
- Loading branch information
1 parent
25296ab
commit 6bf18e1
Showing
11 changed files
with
214 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
app/services/images/manifest.rb → app/services/iiif/manifest.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
module Images | ||
module Iiif | ||
class Manifest | ||
def self.create(resource) | ||
manifest = to_json('manifest.json') | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
module Images | ||
class Exif | ||
def self.extract(file) | ||
begin | ||
data = ::Exif::Data.new(File.open(file.path)).to_h | ||
encode data | ||
rescue | ||
# Do nothing. The image may not contain EXIF data | ||
end | ||
end | ||
|
||
private | ||
|
||
def self.encode(hash) | ||
hash.keys.each do |key| | ||
value = hash[key] | ||
|
||
if value.is_a?(String) | ||
hash[key] = hash[key].force_encoding('ISO-8859-1').encode('UTF-8') | ||
elsif value.is_a?(Hash) | ||
hash[key] = encode(hash[key]) | ||
end | ||
end | ||
|
||
hash | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
// @flow | ||
|
||
import React, { useCallback, type ComponentType } from 'react'; | ||
import { | ||
Button, | ||
Grid, | ||
Header, | ||
Modal, | ||
Table | ||
} from 'semantic-ui-react'; | ||
import _ from 'underscore'; | ||
import { useTranslation } from 'react-i18next'; | ||
|
||
type Props = { | ||
exif: any, | ||
onClose: () => void | ||
}; | ||
|
||
const ResourceExifModal: ComponentType<any> = (props: Props) => { | ||
const { t } = useTranslation(); | ||
|
||
/** | ||
* Renders the header component and table structure. | ||
* | ||
* @type {function([*,*])} | ||
*/ | ||
const renderHeader = useCallback(([key, value]) => ( | ||
<> | ||
<Header | ||
content={key} | ||
/> | ||
<Table | ||
columns={2} | ||
padded | ||
striped | ||
> | ||
<Table.Body> | ||
{ _.map(Object.entries(value), renderItem) } | ||
{ _.isEmpty(value) && ( | ||
<Table.Row> | ||
<Table.Cell> | ||
No records | ||
</Table.Cell> | ||
</Table.Row> | ||
)} | ||
</Table.Body> | ||
</Table> | ||
</> | ||
), []); | ||
|
||
/** | ||
* Renders the table row for the passed key/value. | ||
* | ||
* @type {function([*,*])} | ||
*/ | ||
const renderItem = useCallback(([key, value]) => ( | ||
<Table.Row> | ||
<Table.Cell>{ key }</Table.Cell> | ||
<Table.Cell>{ value }</Table.Cell> | ||
</Table.Row> | ||
), []); | ||
|
||
return ( | ||
<Modal | ||
centered={false} | ||
open | ||
> | ||
<Modal.Header> | ||
<Grid | ||
columns={2} | ||
> | ||
<Grid.Column> | ||
<Header | ||
content={t('ResourceExifModal.title')} | ||
/> | ||
</Grid.Column> | ||
<Grid.Column | ||
textAlign='right' | ||
> | ||
<Button | ||
basic | ||
content={t('Common.buttons.close')} | ||
onClick={props.onClose} | ||
/> | ||
</Grid.Column> | ||
</Grid> | ||
</Modal.Header> | ||
<Modal.Content> | ||
{ _.map(Object.entries(props.exif), renderHeader) } | ||
</Modal.Content> | ||
<Modal.Actions> | ||
<Button | ||
basic | ||
content={t('Common.buttons.close')} | ||
onClick={props.onClose} | ||
/> | ||
</Modal.Actions> | ||
</Modal> | ||
); | ||
}; | ||
|
||
export default ResourceExifModal; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// @flow | ||
|
||
import CloverIIIF from '@samvera/clover-iiif'; | ||
import React, { type ComponentType } from 'react'; | ||
import { Modal } from 'semantic-ui-react'; | ||
|
||
type Props = { | ||
manifestId: string, | ||
onClose: () => void | ||
}; | ||
|
||
const ResourceViewerModal: ComponentType<any> = (props: Props) => ( | ||
<Modal | ||
centered={false} | ||
closeIcon | ||
onClose={props.onClose} | ||
open | ||
> | ||
<Modal.Content> | ||
<CloverIIIF | ||
manifestId={props.manifestId} | ||
options={{ | ||
showIIIFBadge: false | ||
}} | ||
/> | ||
</Modal.Content> | ||
</Modal> | ||
); | ||
|
||
export default ResourceViewerModal; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters