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
Hide 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.
module
.
exports
=
class
AnnotationUISync
###*
...
...
h/static/scripts/cross-frame.coffee
View file @
e5a03975
# Instantiates all objects used for cross frame discovery and communication.
module
.
exports
=
class
CrossFrame
providers
:
null
this
.
inject
=
[
'$rootScope'
,
'$document'
,
'$window'
,
'store'
,
'annotationUI'
'Discovery'
,
'bridge'
,
...
...
@@ -12,7 +10,7 @@ module.exports = class CrossFrame
Discovery
,
bridge
,
AnnotationSync
,
AnnotationUISync
)
->
@
provider
s
=
[]
@
frame
s
=
[]
createDiscovery
=
->
options
=
...
...
@@ -46,20 +44,17 @@ module.exports = class CrossFrame
createAnnotationUISync
=
(
annotationSync
)
->
new
AnnotationUISync
(
$rootScope
,
$window
,
bridge
,
annotationSync
,
annotationUI
)
addProvider
=
(
channel
)
=>
provider
=
{
channel
:
channel
,
entities
:
[]}
addFrame
=
(
channel
)
=>
channel
.
call
method
:
'getDocumentInfo'
success
:
(
info
)
=>
$rootScope
.
$apply
=>
provider
.
entities
=
(
link
.
href
for
link
in
info
.
metadata
.
link
)
@
providers
.
push
(
provider
)
@
frames
.
push
({
channel
:
channel
,
uri
:
info
.
uri
})
this
.
connect
=
->
discovery
=
createDiscovery
()
bridge
.
onConnect
(
add
Provider
)
bridge
.
onConnect
(
add
Frame
)
annotationSync
=
createAnnotationSync
()
annotationUISync
=
createAnnotationUISync
(
annotationSync
)
...
...
h/static/scripts/directive/share-dialog.coffee
View file @
e5a03975
...
...
@@ -15,13 +15,11 @@ module.exports = ['crossframe', (crossframe) ->
if
visible
scope
.
$evalAsync
(
->
elem
.
find
(
'#via'
).
focus
().
select
())
scope
.
$watchCollection
(
->
crossframe
.
providers
),
->
if
crossframe
.
providers
?
.
length
# XXX: Consider multiple providers in the future
p
=
crossframe
.
providers
[
0
]
if
p
.
entities
?
.
length
e
=
p
.
entities
[
0
]
scope
.
viaPageLink
=
'https://via.hypothes.is/'
+
e
scope
.
$watchCollection
(
->
crossframe
.
frames
),
(
frames
)
->
if
not
frames
.
length
return
# XXX: Consider sharing multiple frames in the future?
scope
.
viaPageLink
=
'https://via.hypothes.is/'
+
frames
[
0
].
uri
restrict
:
'A'
templateUrl
:
'share_dialog.html'
...
...
h/static/scripts/directive/test/share-dialog-test.coffee
View file @
e5a03975
...
...
@@ -15,7 +15,7 @@ describe 'share-dialog', ->
beforeEach
module
(
'h.templates'
)
beforeEach
module
(
$provide
)
->
fakeCrossFrame
=
{
provider
s
:
[]}
fakeCrossFrame
=
{
frame
s
:
[]}
$provide
.
value
'crossframe'
,
fakeCrossFrame
return
...
...
@@ -26,7 +26,7 @@ describe 'share-dialog', ->
it
'generates new via link'
,
->
$element
=
$compile
(
'<div share-dialog="">'
)(
$scope
)
fakeCrossFrame
.
providers
.
push
{
entities
:
[
'http://example.com'
]}
fakeCrossFrame
.
frames
.
push
({
uri
:
'http://example.com'
})
$scope
.
$digest
()
assert
.
equal
(
$scope
.
viaPageLink
,
'https://via.hypothes.is/http://example.com'
)
h/static/scripts/test/cross-frame-test.coffee
View file @
e5a03975
...
...
@@ -64,8 +64,8 @@ describe 'CrossFrame', ->
'source'
,
'origin'
,
'token'
)
it
'queries discovered frames for metadata'
,
->
info
=
{
metadata
:
link
:
[{
href
:
'http://example.com'
}]}
channel
=
{
call
:
sandbox
.
stub
().
yieldsTo
(
'success'
,
info
)}
uri
=
'http://example.com'
channel
=
{
call
:
sandbox
.
stub
().
yieldsTo
(
'success'
,
{
uri
:
uri
}
)}
fakeBridge
.
onConnect
.
yields
(
channel
)
crossframe
.
connect
()
assert
.
calledWith
(
channel
.
call
,
{
...
...
@@ -73,13 +73,13 @@ describe 'CrossFrame', ->
success
:
sinon
.
match
.
func
})
it
'updates the
provider
s array'
,
->
info
=
{
metadata
:
link
:
[{
href
:
'http://example.com'
}]}
channel
=
{
call
:
sandbox
.
stub
().
yieldsTo
(
'success'
,
info
)}
it
'updates the
frame
s array'
,
->
uri
=
'http://example.com'
channel
=
{
call
:
sandbox
.
stub
().
yieldsTo
(
'success'
,
{
uri
:
uri
}
)}
fakeBridge
.
onConnect
.
yields
(
channel
)
crossframe
.
connect
()
assert
.
deepEqual
(
crossframe
.
provider
s
,
[
{
channel
:
channel
,
entities
:
[
'http://example.com'
]
}
assert
.
deepEqual
(
crossframe
.
frame
s
,
[
{
channel
:
channel
,
uri
:
uri
}
])
...
...
h/static/scripts/test/widget-controller-test.coffee
View file @
e5a03975
...
...
@@ -31,7 +31,7 @@ describe 'WidgetController', ->
clearSelectedAnnotations
:
sandbox
.
spy
()
}
fakeAuth
=
{
user
:
null
}
fakeCrossFrame
=
{
provider
s
:
[]}
fakeCrossFrame
=
{
frame
s
:
[]}
fakeStore
=
{
SearchResource
:
...
...
@@ -73,9 +73,9 @@ describe 'WidgetController', ->
sandbox
.
restore
()
describe
'loadAnnotations'
,
->
it
'loads all annotation
for a provider
'
,
->
it
'loads all annotation
s for a frame
'
,
->
viewer
.
chunkSize
=
20
fakeCrossFrame
.
providers
.
push
{
entities
:
[
'http://example.com'
]}
fakeCrossFrame
.
frames
.
push
({
uri
:
'http://example.com'
})
$scope
.
$digest
()
loadSpy
=
fakeAnnotationMapper
.
loadAnnotations
assert
.
callCount
(
loadSpy
,
5
)
...
...
h/static/scripts/widget-controller.coffee
View file @
e5a03975
...
...
@@ -33,20 +33,17 @@ module.exports = class WidgetController
annotationMapper
.
loadAnnotations
(
results
.
rows
)
loadAnnotations
=
->
query
=
{}
for
p
in
crossframe
.
providers
for
e
in
p
.
entities
when
e
not
in
loaded
loaded
.
push
e
q
=
angular
.
extend
(
uri
:
e
,
query
)
_loadAnnotationsFrom
q
,
0
loadAnnotations
=
(
frames
)
->
for
f
in
frames
if
f
.
uri
in
loaded
continue
loaded
.
push
(
f
.
uri
)
_loadAnnotationsFrom
({
uri
:
f
.
uri
},
0
)
streamFilter
.
resetFilter
().
addClause
(
'/uri'
,
'one_of'
,
loaded
)
streamer
.
send
({
filter
:
streamFilter
.
getFilter
()})
$scope
.
$watchCollection
(
->
crossframe
.
provider
s
),
loadAnnotations
$scope
.
$watchCollection
(
->
crossframe
.
frame
s
),
loadAnnotations
$scope
.
focus
=
(
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