Commit eb9f9a7d authored by Ed Summers's avatar Ed Summers

got basic title metadata extraction working

parent b0b32c06
......@@ -64,6 +64,8 @@ class Annotator.Host extends Annotator
parsed[k] = v
parsed
this.addPlugin 'Document'
# Build a channel for the publish API
@api = Channel.build
origin: '*'
......@@ -158,6 +160,10 @@ class Annotator.Host extends Annotator
@drag.last = null
)
.bind('getDocumentMetadata', =>
return @plugins.Document.getDocumentMetadata()
)
scanDocument: (reason = "something happened") =>
try
console.log "Analyzing host frame, because " + reason + "..."
......@@ -263,4 +269,4 @@ class Annotator.Host extends Annotator
addToken: (token) =>
@api.notify
method: 'addToken'
params: token
\ No newline at end of file
params: token
......@@ -4,9 +4,15 @@ class Annotator.Plugin.Document extends Annotator.Plugin
'beforeAnnotationCreated': 'beforeAnnotationCreated'
pluginInit: ->
console.log "initializing Document plugin!"
@metadata = null
beforeAnnotationCreated: (annotation) =>
debugger
alert "creating annotation #{annotation}"
if not @metadata
@metadata = this.getDocumentMetadata()
annotation.document = @metadata
getDocumentMetadata: =>
$ = jQuery
@metadata =
title: $("head title").text()
return @metadata
......@@ -365,6 +365,11 @@ class Hypothesis extends Annotator
console.log "Also loading annotations for: " + href
this.plugins.Store.loadAnnotationsFromSearch uri: href
# get metadata for the annotated document
@provider.call
method: 'getDocumentMetadata'
success: (metadata) =>
this.plugins.Document.metadata = metadata
class DraftProvider
drafts: []
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment