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
39e85a0d
Commit
39e85a0d
authored
Apr 02, 2015
by
Nick Stenning
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2118 from hypothesis/1542-source-url-not-visible-on-older-annotations
Use domain as citation title if no document
parents
7e06bdfb
05e0cd83
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
8 deletions
+21
-8
annotation.coffee
h/static/scripts/directive/annotation.coffee
+9
-6
annotation-test.coffee
h/static/scripts/directive/test/annotation-test.coffee
+12
-2
No files found.
h/static/scripts/directive/annotation.coffee
View file @
39e85a0d
...
...
@@ -211,15 +211,15 @@ AnnotationController = [
@annotationURI = new URL("/a/#{@annotation.id}", this.baseURI).href
# Extract the document metadata.
if model.document
uri = model.uri
domain = new URL(uri).hostname
if model.document
if uri.indexOf("urn") is 0
# This URI is not clickable, see if we have something better
for link in model.document.link when link.href.indexOf("urn")
uri = link.href
break
domain = new URL(uri).hostname
documentTitle = if Array.isArray(model.document.title)
model.document.title[0]
else
...
...
@@ -229,11 +229,14 @@ AnnotationController = [
uri: uri
domain: domain
title: documentTitle or domain
else
@document =
uri: uri
domain: domain
title: domain
if @document.title.length > 30
@document.title = @document.title[0..29] + '…'
else
@document = null
# Form the tags for ngTagsInput.
@annotation.tags = ({text} for text in (model.tags or []))
...
...
h/static/scripts/directive/test/annotation-test.coffee
View file @
39e85a0d
...
...
@@ -209,10 +209,20 @@ describe 'annotation', ->
controller
.
render
()
assert
.
equal
(
controller
.
document
.
title
,
'example.com'
)
it
's
kips the document object if no document is present on the annotation
'
,
->
it
's
till sets the uri correctly if the annotation has no document
'
,
->
delete
annotation
.
document
controller
.
render
()
assert
.
isNull
(
controller
.
document
)
assert
(
controller
.
document
.
uri
==
$scope
.
annotation
.
uri
)
it
'still sets the domain correctly if the annotation has no document'
,
->
delete
annotation
.
document
controller
.
render
()
assert
(
controller
.
document
.
domain
==
'example.com'
)
it
'uses the domain for the title when the annotation has no document'
,
->
delete
annotation
.
document
controller
.
render
()
assert
(
controller
.
document
.
title
==
'example.com'
)
describe
'when there are no targets'
,
->
beforeEach
->
...
...
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