list films cited
This commit is contained in:
parent
d1e1f311f0
commit
6764d53403
3 changed files with 66 additions and 11 deletions
|
@ -33,7 +33,7 @@
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: auto;
|
height: auto;
|
||||||
max-width: var(--container-width);
|
max-width: var(--container-width);
|
||||||
max-height: 80vh;
|
max-height: 88vh;
|
||||||
margin: auto;
|
margin: auto;
|
||||||
//transition: opacity 0.4s;
|
//transition: opacity 0.4s;
|
||||||
|
|
||||||
|
@ -49,7 +49,7 @@
|
||||||
img {
|
img {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: auto;
|
height: auto;
|
||||||
max-height: 80vh;
|
max-height: 88vh;
|
||||||
margin: auto;
|
margin: auto;
|
||||||
object-fit: contain;
|
object-fit: contain;
|
||||||
}
|
}
|
||||||
|
|
|
@ -225,7 +225,15 @@ function renderAnnotation(config, video, ascroll, annotation) {
|
||||||
div.style.background = `linear-gradient(to bottom, ${color1}, ${color2})`;
|
div.style.background = `linear-gradient(to bottom, ${color1}, ${color2})`;
|
||||||
var figcaption = ''
|
var figcaption = ''
|
||||||
if (annotation.title) {
|
if (annotation.title) {
|
||||||
figcaption = `<figcaption><a href="${baseURL}/${annotation.id}" target="_blank">${annotation.title}</a></figcaption>`
|
if (config.language == 'zh') {
|
||||||
|
var title = annotation.title.split('/')[1] || annotation.title
|
||||||
|
var director = annotation.director[1]
|
||||||
|
} else {
|
||||||
|
var title = annotation.title.split('/')[0]
|
||||||
|
var director = annotation.director[0]
|
||||||
|
}
|
||||||
|
var txt = `${title} (${director})`
|
||||||
|
figcaption = `<figcaption><a href="${baseURL}/${annotation.id}" target="_blank">${txt}</a></figcaption>`
|
||||||
}
|
}
|
||||||
annotation.value = annotation.value.replace(/src="\//g, `src="${baseURL}/`).replace(/href="\//g, `href="${baseURL}/`)
|
annotation.value = annotation.value.replace(/src="\//g, `src="${baseURL}/`).replace(/href="\//g, `href="${baseURL}/`)
|
||||||
div.innerHTML = `
|
div.innerHTML = `
|
||||||
|
@ -287,16 +295,43 @@ function renderAnnotations(config) {
|
||||||
updatePlayer(video, frame, config.first['in'], config.first['out'], src)
|
updatePlayer(video, frame, config.first['in'], config.first['out'], src)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (config.item_url) {
|
if (config.item_url || config.cited) {
|
||||||
var box= document.createElement('div')
|
var box = document.createElement('div')
|
||||||
var color = config.annotations[config.annotations.length - 1].color2
|
var color = config.annotations[config.annotations.length - 1].color2
|
||||||
box.style.background = `hsl(${color.hue}, 70%, 75%)`
|
box.style.background = `hsl(${color.hue}, 70%, 75%)`
|
||||||
var div = document.createElement('div')
|
var div = document.createElement('div')
|
||||||
div.classList.add('related-film')
|
div.classList.add('related-film')
|
||||||
|
if (config.item_url) {
|
||||||
|
if (config.language == 'zh') {
|
||||||
div.innerHTML = `
|
div.innerHTML = `
|
||||||
Film cited: <a href="${config.item_url}">${config.item_title} - ${config.item_director[0]}</a><br>
|
|
||||||
引用影片: <a href="${config.item_url}">${config.item_title_zh} - ${config.item_director[1]}</a>
|
引用影片: <a href="${config.item_url}">${config.item_title_zh} - ${config.item_director[1]}</a>
|
||||||
`
|
`
|
||||||
|
} else {
|
||||||
|
div.innerHTML = `
|
||||||
|
Film cited: <a href="${config.item_url}">${config.item_title} - ${config.item_director[0]}</a><br>
|
||||||
|
`
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
var html = []
|
||||||
|
config.cited.forEach(film => {
|
||||||
|
var title_en = film.title.split(' / ')[0]
|
||||||
|
var title_zh = film.title.split(' / ')[1] || title_en
|
||||||
|
if (config.language == 'en') {
|
||||||
|
var director = film.director ? ` (${film.director[0]})` : ''
|
||||||
|
html.push(`<a href="/polis+film/${film.id}/">${title_en}${director}</a>`)
|
||||||
|
} else {
|
||||||
|
var director = film.director ? ` (${film.director[1]})` : ''
|
||||||
|
html.push(`<a href="/polis+film/${film.id}/">${title_zh}${director}</a>`)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
var films = html.length == 1 ? 'Film' : 'Films'
|
||||||
|
html= html.join(', ')
|
||||||
|
if (config.language == 'zh') {
|
||||||
|
div.innerHTML = ` 引用影片: ${html}`
|
||||||
|
} else {
|
||||||
|
div.innerHTML = `${films} cited: ${html}`
|
||||||
|
}
|
||||||
|
}
|
||||||
box.appendChild(div)
|
box.appendChild(div)
|
||||||
ascroll.appendChild(box)
|
ascroll.appendChild(box)
|
||||||
}
|
}
|
||||||
|
@ -355,14 +390,22 @@ function loadAnnotations(config) {
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
|
var cited = {}
|
||||||
pandoraAPI('getEdit', {id: config.edit, keys: []}).then(response => {
|
pandoraAPI('getEdit', {id: config.edit, keys: []}).then(response => {
|
||||||
var annotations = []
|
var annotations = []
|
||||||
response.data.clips.forEach(clip => {
|
response.data.clips.forEach(clip => {
|
||||||
|
cited[clip.item] = {
|
||||||
|
title: clip.title,
|
||||||
|
director: clip.director,
|
||||||
|
id: clip.item
|
||||||
|
}
|
||||||
clip.layers[config.layer].forEach(annotation => {
|
clip.layers[config.layer].forEach(annotation => {
|
||||||
if (config.user && annotation.user != config.user) {
|
if (config.user && annotation.user != config.user) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
annotation.title = clip.title
|
;['title', 'director', 'date'].forEach(key => {
|
||||||
|
annotation[key] = clip[key]
|
||||||
|
})
|
||||||
if (config.only_e) {
|
if (config.only_e) {
|
||||||
if (annotation.value.slice(0, 2) == 'E:') {
|
if (annotation.value.slice(0, 2) == 'E:') {
|
||||||
annotation.value = annotation.value.slice(2).trim()
|
annotation.value = annotation.value.slice(2).trim()
|
||||||
|
@ -377,6 +420,7 @@ function loadAnnotations(config) {
|
||||||
})
|
})
|
||||||
loadClips(annotations).then(annotations => {
|
loadClips(annotations).then(annotations => {
|
||||||
config.annotations = annotations
|
config.annotations = annotations
|
||||||
|
config.cited = Object.values(cited)
|
||||||
renderAnnotations(config)
|
renderAnnotations(config)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
|
@ -97,18 +97,28 @@ class Text(models.Model):
|
||||||
return []
|
return []
|
||||||
clips = r['data']['clips']
|
clips = r['data']['clips']
|
||||||
annotations = []
|
annotations = []
|
||||||
|
cited = {}
|
||||||
layer = self.data.get('layer', None) or DEFAULT_LAYER
|
layer = self.data.get('layer', None) or DEFAULT_LAYER
|
||||||
for clip in clips:
|
for clip in clips:
|
||||||
|
item_id = clip['item']
|
||||||
|
cited[item_id] = {
|
||||||
|
'title': clip['title'],
|
||||||
|
'director': clip['director'],
|
||||||
|
'id': item_id,
|
||||||
|
}
|
||||||
for annotation in clip['layers'][layer]:
|
for annotation in clip['layers'][layer]:
|
||||||
if 'user' in self.data and annotation['user'] == self.data['user']:
|
if 'user' in self.data and annotation['user'] == self.data['user']:
|
||||||
continue
|
continue
|
||||||
annotation['title'] = clip['title']
|
for key in ('title', 'director', 'date'):
|
||||||
|
if key in clip:
|
||||||
|
annotation[key] = clip[key]
|
||||||
if self.data.get('only_e'):
|
if self.data.get('only_e'):
|
||||||
if annotation['value'].startswith('E:'):
|
if annotation['value'].startswith('E:'):
|
||||||
annotation['value'] = annotation['value'][2:].strip()
|
annotation['value'] = annotation['value'][2:].strip()
|
||||||
annotations.append(annotation)
|
annotations.append(annotation)
|
||||||
elif not annotation['value'].startswith('E:'):
|
elif not annotation['value'].startswith('E:'):
|
||||||
annotations.append(annotation)
|
annotations.append(annotation)
|
||||||
|
self.data['cited'] = list(cited.values())
|
||||||
return self.get_clips(api, annotations)
|
return self.get_clips(api, annotations)
|
||||||
|
|
||||||
def get_clips(self, api, annotations):
|
def get_clips(self, api, annotations):
|
||||||
|
@ -158,6 +168,7 @@ class Text(models.Model):
|
||||||
data['title'] = self.title
|
data['title'] = self.title
|
||||||
data['byline'] = self.byline
|
data['byline'] = self.byline
|
||||||
data['body'] = self.body
|
data['body'] = self.body
|
||||||
|
data['language'] = self.language
|
||||||
item_id = self.data.get('related')
|
item_id = self.data.get('related')
|
||||||
if not item_id:
|
if not item_id:
|
||||||
item_id = self.data.get('item')
|
item_id = self.data.get('item')
|
||||||
|
|
Loading…
Reference in a new issue