Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
coopwire-hypothesis
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
孙灵跃 Leon Sun
coopwire-hypothesis
Commits
e5a03975
Commit
e5a03975
authored
Jul 19, 2015
by
Randall Leeds
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2348 from hypothesis/search-for-one-uri
Search for one URI
parents
9afb4237
28ac128e
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
29 additions
and
39 deletions
+29
-39
annotation-ui-sync.coffee
h/static/scripts/annotation-ui-sync.coffee
+1
-1
cross-frame.coffee
h/static/scripts/cross-frame.coffee
+4
-9
share-dialog.coffee
h/static/scripts/directive/share-dialog.coffee
+5
-7
share-dialog-test.coffee
h/static/scripts/directive/test/share-dialog-test.coffee
+2
-2
cross-frame-test.coffee
h/static/scripts/test/cross-frame-test.coffee
+7
-7
widget-controller-test.coffee
h/static/scripts/test/widget-controller-test.coffee
+3
-3
widget-controller.coffee
h/static/scripts/widget-controller.coffee
+7
-10
No files found.
h/static/scripts/annotation-ui-sync.coffee
View file @
e5a03975
# Uses a channel between the sidebar and the attached
provider
s to ensure
# Uses a channel between the sidebar and the attached
frame
s to ensure
# the interface remains in sync.
# the interface remains in sync.
module
.
exports
=
class
AnnotationUISync
module
.
exports
=
class
AnnotationUISync
###*
###*
...
...
h/static/scripts/cross-frame.coffee
View file @
e5a03975
# Instantiates all objects used for cross frame discovery and communication.
# Instantiates all objects used for cross frame discovery and communication.
module
.
exports
=
class
CrossFrame
module
.
exports
=
class
CrossFrame
providers
:
null
this
.
inject
=
[
this
.
inject
=
[
'$rootScope'
,
'$document'
,
'$window'
,
'store'
,
'annotationUI'
'$rootScope'
,
'$document'
,
'$window'
,
'store'
,
'annotationUI'
'Discovery'
,
'bridge'
,
'Discovery'
,
'bridge'
,
...
@@ -12,7 +10,7 @@ module.exports = class CrossFrame
...
@@ -12,7 +10,7 @@ module.exports = class CrossFrame
Discovery
,
bridge
,
Discovery
,
bridge
,
AnnotationSync
,
AnnotationUISync
AnnotationSync
,
AnnotationUISync
)
->
)
->
@
provider
s
=
[]
@
frame
s
=
[]
createDiscovery
=
->
createDiscovery
=
->
options
=
options
=
...
@@ -46,20 +44,17 @@ module.exports = class CrossFrame
...
@@ -46,20 +44,17 @@ module.exports = class CrossFrame
createAnnotationUISync
=
(
annotationSync
)
->
createAnnotationUISync
=
(
annotationSync
)
->
new
AnnotationUISync
(
$rootScope
,
$window
,
bridge
,
annotationSync
,
annotationUI
)
new
AnnotationUISync
(
$rootScope
,
$window
,
bridge
,
annotationSync
,
annotationUI
)
addProvider
=
(
channel
)
=>
addFrame
=
(
channel
)
=>
provider
=
{
channel
:
channel
,
entities
:
[]}
channel
.
call
channel
.
call
method
:
'getDocumentInfo'
method
:
'getDocumentInfo'
success
:
(
info
)
=>
success
:
(
info
)
=>
$rootScope
.
$apply
=>
$rootScope
.
$apply
=>
provider
.
entities
=
(
link
.
href
for
link
in
info
.
metadata
.
link
)
@
frames
.
push
({
channel
:
channel
,
uri
:
info
.
uri
})
@
providers
.
push
(
provider
)
this
.
connect
=
->
this
.
connect
=
->
discovery
=
createDiscovery
()
discovery
=
createDiscovery
()
bridge
.
onConnect
(
add
Provider
)
bridge
.
onConnect
(
add
Frame
)
annotationSync
=
createAnnotationSync
()
annotationSync
=
createAnnotationSync
()
annotationUISync
=
createAnnotationUISync
(
annotationSync
)
annotationUISync
=
createAnnotationUISync
(
annotationSync
)
...
...
h/static/scripts/directive/share-dialog.coffee
View file @
e5a03975
...
@@ -15,13 +15,11 @@ module.exports = ['crossframe', (crossframe) ->
...
@@ -15,13 +15,11 @@ module.exports = ['crossframe', (crossframe) ->
if
visible
if
visible
scope
.
$evalAsync
(
->
elem
.
find
(
'#via'
).
focus
().
select
())
scope
.
$evalAsync
(
->
elem
.
find
(
'#via'
).
focus
().
select
())
scope
.
$watchCollection
(
->
crossframe
.
providers
),
->
scope
.
$watchCollection
(
->
crossframe
.
frames
),
(
frames
)
->
if
crossframe
.
providers
?
.
length
if
not
frames
.
length
# XXX: Consider multiple providers in the future
return
p
=
crossframe
.
providers
[
0
]
# XXX: Consider sharing multiple frames in the future?
if
p
.
entities
?
.
length
scope
.
viaPageLink
=
'https://via.hypothes.is/'
+
frames
[
0
].
uri
e
=
p
.
entities
[
0
]
scope
.
viaPageLink
=
'https://via.hypothes.is/'
+
e
restrict
:
'A'
restrict
:
'A'
templateUrl
:
'share_dialog.html'
templateUrl
:
'share_dialog.html'
...
...
h/static/scripts/directive/test/share-dialog-test.coffee
View file @
e5a03975
...
@@ -15,7 +15,7 @@ describe 'share-dialog', ->
...
@@ -15,7 +15,7 @@ describe 'share-dialog', ->
beforeEach
module
(
'h.templates'
)
beforeEach
module
(
'h.templates'
)
beforeEach
module
(
$provide
)
->
beforeEach
module
(
$provide
)
->
fakeCrossFrame
=
{
provider
s
:
[]}
fakeCrossFrame
=
{
frame
s
:
[]}
$provide
.
value
'crossframe'
,
fakeCrossFrame
$provide
.
value
'crossframe'
,
fakeCrossFrame
return
return
...
@@ -26,7 +26,7 @@ describe 'share-dialog', ->
...
@@ -26,7 +26,7 @@ describe 'share-dialog', ->
it
'generates new via link'
,
->
it
'generates new via link'
,
->
$element
=
$compile
(
'<div share-dialog="">'
)(
$scope
)
$element
=
$compile
(
'<div share-dialog="">'
)(
$scope
)
fakeCrossFrame
.
providers
.
push
{
entities
:
[
'http://example.com'
]}
fakeCrossFrame
.
frames
.
push
({
uri
:
'http://example.com'
})
$scope
.
$digest
()
$scope
.
$digest
()
assert
.
equal
(
$scope
.
viaPageLink
,
assert
.
equal
(
$scope
.
viaPageLink
,
'https://via.hypothes.is/http://example.com'
)
'https://via.hypothes.is/http://example.com'
)
h/static/scripts/test/cross-frame-test.coffee
View file @
e5a03975
...
@@ -64,8 +64,8 @@ describe 'CrossFrame', ->
...
@@ -64,8 +64,8 @@ describe 'CrossFrame', ->
'source'
,
'origin'
,
'token'
)
'source'
,
'origin'
,
'token'
)
it
'queries discovered frames for metadata'
,
->
it
'queries discovered frames for metadata'
,
->
info
=
{
metadata
:
link
:
[{
href
:
'http://example.com'
}]}
uri
=
'http://example.com'
channel
=
{
call
:
sandbox
.
stub
().
yieldsTo
(
'success'
,
info
)}
channel
=
{
call
:
sandbox
.
stub
().
yieldsTo
(
'success'
,
{
uri
:
uri
}
)}
fakeBridge
.
onConnect
.
yields
(
channel
)
fakeBridge
.
onConnect
.
yields
(
channel
)
crossframe
.
connect
()
crossframe
.
connect
()
assert
.
calledWith
(
channel
.
call
,
{
assert
.
calledWith
(
channel
.
call
,
{
...
@@ -73,13 +73,13 @@ describe 'CrossFrame', ->
...
@@ -73,13 +73,13 @@ describe 'CrossFrame', ->
success
:
sinon
.
match
.
func
success
:
sinon
.
match
.
func
})
})
it
'updates the
provider
s array'
,
->
it
'updates the
frame
s array'
,
->
info
=
{
metadata
:
link
:
[{
href
:
'http://example.com'
}]}
uri
=
'http://example.com'
channel
=
{
call
:
sandbox
.
stub
().
yieldsTo
(
'success'
,
info
)}
channel
=
{
call
:
sandbox
.
stub
().
yieldsTo
(
'success'
,
{
uri
:
uri
}
)}
fakeBridge
.
onConnect
.
yields
(
channel
)
fakeBridge
.
onConnect
.
yields
(
channel
)
crossframe
.
connect
()
crossframe
.
connect
()
assert
.
deepEqual
(
crossframe
.
provider
s
,
[
assert
.
deepEqual
(
crossframe
.
frame
s
,
[
{
channel
:
channel
,
entities
:
[
'http://example.com'
]
}
{
channel
:
channel
,
uri
:
uri
}
])
])
...
...
h/static/scripts/test/widget-controller-test.coffee
View file @
e5a03975
...
@@ -31,7 +31,7 @@ describe 'WidgetController', ->
...
@@ -31,7 +31,7 @@ describe 'WidgetController', ->
clearSelectedAnnotations
:
sandbox
.
spy
()
clearSelectedAnnotations
:
sandbox
.
spy
()
}
}
fakeAuth
=
{
user
:
null
}
fakeAuth
=
{
user
:
null
}
fakeCrossFrame
=
{
provider
s
:
[]}
fakeCrossFrame
=
{
frame
s
:
[]}
fakeStore
=
{
fakeStore
=
{
SearchResource
:
SearchResource
:
...
@@ -73,9 +73,9 @@ describe 'WidgetController', ->
...
@@ -73,9 +73,9 @@ describe 'WidgetController', ->
sandbox
.
restore
()
sandbox
.
restore
()
describe
'loadAnnotations'
,
->
describe
'loadAnnotations'
,
->
it
'loads all annotation
for a provider
'
,
->
it
'loads all annotation
s for a frame
'
,
->
viewer
.
chunkSize
=
20
viewer
.
chunkSize
=
20
fakeCrossFrame
.
providers
.
push
{
entities
:
[
'http://example.com'
]}
fakeCrossFrame
.
frames
.
push
({
uri
:
'http://example.com'
})
$scope
.
$digest
()
$scope
.
$digest
()
loadSpy
=
fakeAnnotationMapper
.
loadAnnotations
loadSpy
=
fakeAnnotationMapper
.
loadAnnotations
assert
.
callCount
(
loadSpy
,
5
)
assert
.
callCount
(
loadSpy
,
5
)
...
...
h/static/scripts/widget-controller.coffee
View file @
e5a03975
...
@@ -33,20 +33,17 @@ module.exports = class WidgetController
...
@@ -33,20 +33,17 @@ module.exports = class WidgetController
annotationMapper
.
loadAnnotations
(
results
.
rows
)
annotationMapper
.
loadAnnotations
(
results
.
rows
)
loadAnnotations
=
->
loadAnnotations
=
(
frames
)
->
query
=
{}
for
f
in
frames
if
f
.
uri
in
loaded
for
p
in
crossframe
.
providers
continue
for
e
in
p
.
entities
when
e
not
in
loaded
loaded
.
push
(
f
.
uri
)
loaded
.
push
e
_loadAnnotationsFrom
({
uri
:
f
.
uri
},
0
)
q
=
angular
.
extend
(
uri
:
e
,
query
)
_loadAnnotationsFrom
q
,
0
streamFilter
.
resetFilter
().
addClause
(
'/uri'
,
'one_of'
,
loaded
)
streamFilter
.
resetFilter
().
addClause
(
'/uri'
,
'one_of'
,
loaded
)
streamer
.
send
({
filter
:
streamFilter
.
getFilter
()})
streamer
.
send
({
filter
:
streamFilter
.
getFilter
()})
$scope
.
$watchCollection
(
->
crossframe
.
provider
s
),
loadAnnotations
$scope
.
$watchCollection
(
->
crossframe
.
frame
s
),
loadAnnotations
$scope
.
focus
=
(
annotation
)
->
$scope
.
focus
=
(
annotation
)
->
if
angular
.
isObject
annotation
if
angular
.
isObject
annotation
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment