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
254a069a
Commit
254a069a
authored
Feb 16, 2015
by
Nick Stenning
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1937 from hypothesis/load_all_annotations
Load all annotations
parents
82fbab54
8375bdb6
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
88 additions
and
22 deletions
+88
-22
controllers.coffee
h/static/scripts/controllers.coffee
+19
-3
controllers-test.coffee
tests/js/controllers-test.coffee
+69
-19
No files found.
h/static/scripts/controllers.coffee
View file @
254a069a
...
...
@@ -187,8 +187,24 @@ class ViewerController
loaded
=
[]
_loadAnnotationsFrom
=
(
query
,
offset
)
->
queryCore
=
limit
:
20
offset
:
offset
sort
:
'created'
order
:
'asc'
q
=
angular
.
extend
(
queryCore
,
query
)
store
.
SearchResource
.
get
q
,
(
results
)
->
total
=
results
.
total
offset
+=
results
.
rows
.
length
if
offset
<
total
_loadAnnotationsFrom
query
,
offset
annotationMapper
.
loadAnnotations
(
results
.
rows
)
loadAnnotations
=
->
query
=
limit
:
200
query
=
{}
if
annotationUI
.
tool
is
'highlight'
return
unless
auth
.
user
query
.
user
=
auth
.
user
...
...
@@ -196,8 +212,8 @@ class ViewerController
for
p
in
crossframe
.
providers
for
e
in
p
.
entities
when
e
not
in
loaded
loaded
.
push
e
r
=
store
.
SearchResource
.
get
angular
.
extend
(
uri
:
e
,
query
),
(
results
)
->
annotationMapper
.
loadAnnotations
(
results
.
rows
)
q
=
angular
.
extend
(
uri
:
e
,
query
)
_loadAnnotationsFrom
q
,
0
streamfilter
.
resetFilter
().
addClause
(
'/uri'
,
'one_of'
,
loaded
)
...
...
tests/js/controllers-test.coffee
View file @
254a069a
assert
=
chai
.
assert
sinon
.
assert
.
expose
assert
,
prefix
:
null
fakeStore
=
SearchResource
:
get
:
sinon
.
spy
()
describe
'h'
,
->
$scope
=
null
fakeAuth
=
null
fakeIdentity
=
null
fakeLocation
=
null
fakeParams
=
null
fakeStreamer
=
null
fakeStore
=
SearchResource
:
get
:
sinon
.
spy
()
sandbox
=
null
beforeEach
module
(
'h'
)
...
...
@@ -20,19 +18,6 @@ describe 'h', ->
beforeEach
module
(
$provide
)
->
sandbox
=
sinon
.
sandbox
.
create
()
fakeAnnotator
=
{
plugins
:
{
Auth
:
{
withToken
:
sandbox
.
spy
()}
}
options
:
{}
socialView
:
{
name
:
'none'
}
addPlugin
:
sandbox
.
spy
()
}
fakeAuth
=
{
user
:
null
}
fakeIdentity
=
{
watch
:
sandbox
.
spy
()
request
:
sandbox
.
spy
()
...
...
@@ -41,7 +26,9 @@ describe 'h', ->
fakeLocation
=
{
search
:
sandbox
.
stub
().
returns
({})
}
fakeParams
=
{
id
:
'test'
}
fakeStreamer
=
{
open
:
sandbox
.
spy
()
close
:
sandbox
.
spy
()
...
...
@@ -83,6 +70,69 @@ describe 'h', ->
it
'sets the isEmbedded property to false'
,
->
assert
.
isFalse
(
$scope
.
isEmbedded
)
describe
'ViewerController'
,
->
$scope
=
null
fakeAnnotationMapper
=
null
fakeAuth
=
null
fakeCrossFrame
=
null
fakeStore
=
null
fakeStreamer
=
null
sandbox
=
null
viewer
=
null
beforeEach
module
(
'h'
)
beforeEach
module
(
$provide
)
->
sandbox
=
sinon
.
sandbox
.
create
()
fakeAnnotationMapper
=
{
loadAnnotations
:
sandbox
.
spy
()}
fakeAuth
=
{
user
:
null
}
fakeCrossFrame
=
{
providers
:
[]}
fakeStore
=
{
SearchResource
:
get
:
(
query
,
callback
)
->
offset
=
query
.
offset
or
0
limit
=
query
.
limit
or
20
result
=
total
:
100
rows
:
[
offset
..
offset
+
limit
-
1
]
callback
result
}
fakeStreamer
=
{
open
:
sandbox
.
spy
()
close
:
sandbox
.
spy
()
send
:
sandbox
.
spy
()
}
$provide
.
value
'annotationMapper'
,
fakeAnnotationMapper
$provide
.
value
'auth'
,
fakeAuth
$provide
.
value
'crossframe'
,
fakeCrossFrame
$provide
.
value
'store'
,
fakeStore
$provide
.
value
'streamer'
,
fakeStreamer
return
beforeEach
inject
(
$controller
,
$rootScope
)
->
$scope
=
$rootScope
.
$new
()
viewer
=
$controller
'ViewerController'
,
{
$scope
}
afterEach
->
sandbox
.
restore
()
describe
'loadAnnotations'
,
->
it
'loads all annotation for a provider'
,
->
fakeCrossFrame
.
providers
.
push
{
entities
:
[
'http://example.com'
]}
$scope
.
$digest
()
loadSpy
=
fakeAnnotationMapper
.
loadAnnotations
assert
.
callCount
(
loadSpy
,
5
)
assert
.
calledWith
(
loadSpy
,
[
0
..
19
])
assert
.
calledWith
(
loadSpy
,
[
20
..
39
])
assert
.
calledWith
(
loadSpy
,
[
40
..
59
])
assert
.
calledWith
(
loadSpy
,
[
60
..
79
])
assert
.
calledWith
(
loadSpy
,
[
80
..
99
])
describe
'AnnotationUIController'
,
->
$scope
=
null
$rootScope
=
null
...
...
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