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
a0db71b3
Commit
a0db71b3
authored
Aug 10, 2015
by
Randall Leeds
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use serviceUrl in store
parent
e2e999c1
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
5 additions
and
24 deletions
+5
-24
store.coffee
h/static/scripts/store.coffee
+4
-11
store-test.coffee
h/static/scripts/test/store-test.coffee
+1
-13
No files found.
h/static/scripts/store.coffee
View file @
a0db71b3
...
...
@@ -10,15 +10,8 @@
# store.SearchResource().
###
module
.
exports
=
[
'$document'
,
'$http'
,
'$resource'
,
(
$document
,
$http
,
$resource
)
->
# Find any service link tag
svc
=
$document
.
find
(
'link'
)
.
filter
->
@
rel
is
'service'
and
@
type
is
'application/annotatorsvc+json'
.
filter
->
@
href
.
prop
(
'href'
)
or
''
'$http'
,
'$resource'
,
'serviceUrl'
(
$http
,
$resource
,
serviceUrl
)
->
camelize
=
(
string
)
->
string
.
replace
/(?:^|_)([a-z])/g
,
(
_
,
char
)
->
char
.
toUpperCase
()
...
...
@@ -26,7 +19,7 @@ module.exports = [
$resolved
:
false
# We call the service_url and the backend api gives back
# the actions and urls it provides.
$promise
:
$http
.
get
(
s
vc
)
$promise
:
$http
.
get
(
s
erviceUrl
)
.
finally
->
store
.
$resolved
=
true
.
then
(
response
)
->
for
name
,
actions
of
response
.
data
.
links
...
...
@@ -34,6 +27,6 @@ module.exports = [
# For the search resource, one URL is given for all actions.
# For the annotations, each action has its own URL.
prop
=
"
#{
camelize
(
name
)
}
Resource"
store
[
prop
]
=
$resource
(
actions
.
url
or
s
vc
,
{},
actions
)
store
[
prop
]
=
$resource
(
actions
.
url
or
s
erviceUrl
,
{},
actions
)
store
]
h/static/scripts/test/store-test.coffee
View file @
a0db71b3
...
...
@@ -4,7 +4,6 @@ describe 'store', ->
$httpBackend
=
null
sandbox
=
null
store
=
null
fakeDocument
=
null
before
->
angular
.
module
(
'h'
,
[
'ngResource'
])
...
...
@@ -14,18 +13,7 @@ describe 'store', ->
beforeEach
module
(
$provide
)
->
sandbox
=
sinon
.
sandbox
.
create
()
link
=
document
.
createElement
(
"link"
)
link
.
rel
=
'service'
link
.
type
=
'application/annotatorsvc+json'
link
.
href
=
'http://example.com/api'
fakeDocument
=
{
find
:
sandbox
.
stub
().
returns
(
$
(
link
))
}
$provide
.
value
'$document'
,
fakeDocument
$provide
.
value
'serviceUrl'
,
'http://example.com/api'
return
afterEach
->
...
...
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