Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Mirador annotations
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
IIIF
Mirador
Mirador annotations
Commits
7bfadd24
Commit
7bfadd24
authored
1 year ago
by
Anthony
Browse files
Options
Downloads
Patches
Plain Diff
Dumb annotation
parent
2c8661d1
Branches
Branches containing commit
No related tags found
1 merge request
!10
Draft: MigratingAnnotationCreation to MUI5.
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
demo/src/index.js
+1
-0
1 addition, 0 deletions
demo/src/index.js
src/AnnotationCreationUtils.js
+32
-14
32 additions, 14 deletions
src/AnnotationCreationUtils.js
src/WebAnnotation.js
+15
-16
15 additions, 16 deletions
src/WebAnnotation.js
src/WebAnnotationOld.js
+117
-0
117 additions, 0 deletions
src/WebAnnotationOld.js
with
165 additions
and
30 deletions
demo/src/index.js
+
1
−
0
View file @
7bfadd24
...
@@ -11,6 +11,7 @@ const config = {
...
@@ -11,6 +11,7 @@ const config = {
exportLocalStorageAnnotations
:
false
,
// display annotation JSON export button
exportLocalStorageAnnotations
:
false
,
// display annotation JSON export button
},
},
catalog
:
[
catalog
:
[
{
manifestIf
:
'
https://files.tetras-libre.fr/dev/Clock/manifest.json
'
},
{
manifestId
:
'
https://files.tetras-libre.fr/dev/Hakanai/manifest/manifest.json
'
},
{
manifestId
:
'
https://files.tetras-libre.fr/dev/Hakanai/manifest/manifest.json
'
},
{
manifestId
:
'
https://dzkimgs.l.u-tokyo.ac.jp/videos/iiif_in_japan_2017/manifest.json
'
},
{
manifestId
:
'
https://dzkimgs.l.u-tokyo.ac.jp/videos/iiif_in_japan_2017/manifest.json
'
},
{
manifestId
:
'
https://iiif.io/api/cookbook/recipe/0219-using-caption-file/manifest.json
'
},
{
manifestId
:
'
https://iiif.io/api/cookbook/recipe/0219-using-caption-file/manifest.json
'
},
...
...
This diff is collapsed.
Click to expand it.
src/AnnotationCreationUtils.js
+
32
−
14
View file @
7bfadd24
...
@@ -57,24 +57,42 @@ export async function getSvg(windowId) {
...
@@ -57,24 +57,42 @@ export async function getSvg(windowId) {
return
svg
;
return
svg
;
};
};
const
dumbAnnotation
=
{
"
id
"
:
"
https://preview.iiif.io/cookbook/master/recipe/0003-mvm-video/canvas/annotation/1
"
,
"
type
"
:
"
Annotation
"
,
"
motivation
"
:
"
commenting
"
,
"
body
"
:
{
"
id
"
:
"
https://files.tetras-libre.fr/dev/Hakanai/media/02_HKN-couv.jpg
"
,
"
type
"
:
"
Image
"
,
"
format
"
:
"
image/jpg
"
,
"
value
"
:
"
Test image annotation
"
},
"
target
"
:
"
https://preview.iiif.io/cookbook/master/recipe/0003-mvm-video/canvas#xywh=0,0,301,400&t=0,1000
"
}
;
export
function
saveAnnotation
(
canvases
,
config
,
receiveAnnotation
,
annotation
,
body
,
t
,
xywh
,
image
,
drawingStateSerialized
,
svg
,
tags
){
export
function
saveAnnotation
(
canvases
,
config
,
receiveAnnotation
,
annotation
,
body
,
t
,
xywh
,
image
,
drawingStateSerialized
,
svg
,
tags
){
// TODO promises not handled. Use promiseAll ?
// TODO promises not handled. Use promiseAll ?
canvases
.
forEach
(
async
(
canvas
)
=>
{
canvases
.
forEach
(
async
(
canvas
)
=>
{
const
storageAdapter
=
config
.
annotation
.
adapter
(
canvas
.
id
);
const
storageAdapter
=
config
.
annotation
.
adapter
(
canvas
.
id
);
const
anno
=
new
WebAnnotation
({
// const anno = new WebAnnotation({
body
,
// body,
canvasId
:
canvas
.
id
,
// canvasId: canvas.id,
fragsel
:
{
// fragsel: {
t
,
// t,
xywh
,
// xywh,
},
// },
id
:
(
annotation
&&
annotation
.
id
)
||
`
${
uuid
()}
`
,
// id: (annotation && annotation.id) || `${uuid()}`,
image
,
// image,
drawingStateSerialized
,
// drawingStateSerialized,
manifestId
:
canvas
.
options
.
resource
.
id
,
// manifestId: canvas.options.resource.id,
svg
,
// svg,
tags
,
// tags,
}).
toJson
();
// }).toJson();
const
anno
=
dumbAnnotation
;
anno
.
drawingState
=
drawingStateSerialized
;
if
(
annotation
)
{
if
(
annotation
)
{
storageAdapter
.
update
(
anno
)
storageAdapter
.
update
(
anno
)
...
...
This diff is collapsed.
Click to expand it.
src/WebAnnotation.js
+
15
−
16
View file @
7bfadd24
...
@@ -2,32 +2,31 @@
...
@@ -2,32 +2,31 @@
export
default
class
WebAnnotation
{
export
default
class
WebAnnotation
{
/** */
/** */
constructor
({
constructor
({
canvasId
,
id
,
fragsel
,
image
,
body
,
tags
,
svg
,
manifestId
,
drawingStateSerialized
id
,
body
,
drawingStateSerialized
,
motivation
,
target
,
})
{
})
{
this
.
id
=
id
;
this
.
id
=
id
;
this
.
canvasId
=
canvasId
;
this
.
type
=
'
Annotation
'
;
this
.
fragsel
=
fragsel
;
this
.
motivation
=
motivation
;
this
.
body
=
body
;
this
.
body
=
body
;
this
.
tags
=
tags
;
this
.
svg
=
svg
;
//this.image = image;
this
.
image
=
image
;
this
.
manifestId
=
manifestId
;
this
.
drawingState
=
drawingStateSerialized
;
this
.
drawingState
=
drawingStateSerialized
;
this
.
target
=
target
;
console
.
log
(
'
WebAnnotation constructor
'
,
this
);
console
.
log
(
'
WebAnnotation constructor
'
,
this
);
}
}
/** */
/** */
toJson
()
{
toJson
()
{
const
result
=
{
// const result = {
body
:
this
.
createBody
(),
// body: this.createBody(),
id
:
this
.
id
,
// drawingState: this.drawingState,
motivation
:
'
commenting
'
,
// id: this.id,
target
:
this
.
target
(),
// motivation: 'commenting',
type
:
'
Annotation
'
,
// target: this.target(),
drawingState
:
this
.
drawingState
,
// type: 'Annotation',
};
// };
const
result
=
this
;
console
.
log
(
'
WebAnnotation toJson
'
,
result
);
console
.
log
(
'
WebAnnotation toJson
'
,
result
);
return
result
;
return
result
;
}
}
...
...
This diff is collapsed.
Click to expand it.
src/WebAnnotationOld.js
0 → 100644
+
117
−
0
View file @
7bfadd24
/** */
export
default
class
WebAnnotation
{
/** */
constructor
({
canvasId
,
id
,
fragsel
,
image
,
body
,
tags
,
svg
,
manifestId
,
drawingStateSerialized
})
{
this
.
id
=
id
;
this
.
canvasId
=
canvasId
;
this
.
fragsel
=
fragsel
;
this
.
body
=
body
;
this
.
tags
=
tags
;
this
.
svg
=
svg
;
//this.image = image;
this
.
image
=
image
;
this
.
manifestId
=
manifestId
;
this
.
drawingState
=
drawingStateSerialized
;
console
.
log
(
'
WebAnnotation constructor
'
,
this
);
}
/** */
toJson
()
{
const
result
=
{
body
:
this
.
createBody
(),
id
:
this
.
id
,
motivation
:
'
commenting
'
,
target
:
this
.
target
(),
type
:
'
Annotation
'
,
drawingState
:
this
.
drawingState
,
};
console
.
log
(
'
WebAnnotation toJson
'
,
result
);
return
result
;
}
/** */
createBody
()
{
let
bodies
=
[];
if
(
this
.
body
&&
this
.
body
.
value
!==
''
)
{
const
textBody
=
{
type
:
'
TextualBody
'
,
value
:
this
.
body
.
value
,
};
bodies
.
push
(
textBody
);
}
if
(
this
.
image
)
{
// TODO dumb image { this.image.id}
const
imgBody
=
{
id
:
'
https://tetras-libre.fr/themes/tetras/img/logo.svg
'
,
type
:
'
Image
'
,
format
:
'
image/svg+xml
'
,
};
//bodies.push(imgBody);
const
testImageBody
=
{
"
id
"
:
"
https://files.tetras-libre.fr/dev/Hakanai/media/10_HKN-Garges_A2B4243.JPG
"
,
"
type
"
:
"
Image
"
,
"
format
"
:
"
image/jpg
"
};
bodies
.
push
(
testImageBody
);
}
// if (this.tags) {
// bodies = bodies.concat(this.tags.map((tag) => ({
// purpose: 'tagging',
// type: 'TextualBody',
// value: tag,
// })));
// }
if
(
bodies
.
length
===
1
)
{
return
bodies
[
0
];
}
return
bodies
;
}
/** Fill target object with selectors (if any), else returns target url */
target
()
{
if
(
!
this
.
svg
&&
(
!
this
.
fragsel
||
!
Object
.
values
(
this
.
fragsel
).
find
((
e
)
=>
e
!==
null
)))
{
return
this
.
canvasId
;
}
const
target
=
{
source
:
this
.
source
()
};
const
selectors
=
[];
if
(
this
.
svg
)
{
selectors
.
push
({
type
:
'
SvgSelector
'
,
value
:
this
.
svg
,
});
}
if
(
this
.
fragsel
)
{
selectors
.
push
({
type
:
'
FragmentSelector
'
,
value
:
Object
.
entries
(
this
.
fragsel
)
.
filter
((
kv
)
=>
kv
[
1
])
.
map
((
kv
)
=>
`
${
kv
[
0
]}
=
${
kv
[
1
]}
`
)
.
join
(
'
&
'
),
});
}
target
.
selector
=
selectors
.
length
===
1
?
selectors
[
0
]
:
selectors
;
return
target
;
}
/** */
source
()
{
let
source
=
this
.
canvasId
;
if
(
this
.
manifest
)
{
source
=
{
id
:
this
.
canvasId
,
partOf
:
{
id
:
this
.
manifest
.
id
,
type
:
'
Manifest
'
,
},
type
:
'
Canvas
'
,
};
}
return
source
;
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment