Commit bf0a27c9 authored by Sean Hammond's avatar Sean Hammond

Use domain as citation title if no document

An annotation's document.title is used as the citation when displaying
an annotation. If this is an older annotation that has no document, fall
back to using the domain as the citation title instead.

Fixes #1542
parent 48a182a4
......@@ -211,15 +211,15 @@ AnnotationController = [
@annotationURI = new URL("/a/#{@annotation.id}", this.baseURI).href
# Extract the document metadata.
uri = model.uri
domain = new URL(uri).hostname
if model.document
uri = model.uri
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
if @document.title.length > 30
@document.title = @document.title[0..29] + '…'
else
@document = null
@document =
uri: uri
domain: domain
title: domain
if @document.title.length > 30
@document.title = @document.title[0..29] + '…'
# Form the tags for ngTagsInput.
@annotation.tags = ({text} for text in (model.tags or []))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment