link cited film
This commit is contained in:
parent
419090f490
commit
38e6bc6313
3 changed files with 33 additions and 1 deletions
|
@ -93,4 +93,12 @@
|
|||
color: rgba(#fff, 1);
|
||||
font-size: 38px;
|
||||
}
|
||||
|
||||
.related-film {
|
||||
padding: 4px;
|
||||
padding-top: 32px;
|
||||
padding-bottom: 32px;
|
||||
max-width: var(--container-width);
|
||||
margin: auto;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -279,6 +279,18 @@ function renderAnnotations(config) {
|
|||
updatePlayer(video, frame, config.first['in'], config.first['out'], src)
|
||||
}
|
||||
}
|
||||
if (config.item_url) {
|
||||
var box= document.createElement('div')
|
||||
var color = config.annotations[config.annotations.length - 1].color2
|
||||
box.style.background = `hsl(${color.hue}, 70%, 75%)`
|
||||
var div = document.createElement('div')
|
||||
div.classList.add('related-film')
|
||||
div.innerHTML = `
|
||||
Film cited: <a href="${config.item_url}">${config.item_title} ${config.item_title_zh}</a><br>
|
||||
`
|
||||
box.appendChild(div)
|
||||
ascroll.appendChild(box)
|
||||
}
|
||||
}
|
||||
|
||||
async function loadClips(annotations) {
|
||||
|
@ -311,7 +323,9 @@ async function loadClips(annotations) {
|
|||
|
||||
function loadAnnotations(config) {
|
||||
if (config.item) {
|
||||
pandoraAPI('get', {id: config.item, keys: ['layers']}).then(response => {
|
||||
pandoraAPI('get', {id: config.item, keys: [
|
||||
'layers'
|
||||
]}).then(response => {
|
||||
var annotations = response.data.layers[config.layer].filter(annotation => {
|
||||
return !(config.user && annotation.user != config.user)
|
||||
})
|
||||
|
|
|
@ -134,10 +134,20 @@ class Text(models.Model):
|
|||
super().save(*args, **kwargs)
|
||||
|
||||
def json(self):
|
||||
from ..video.models import Film
|
||||
data = {}
|
||||
data['title'] = self.title
|
||||
data['byline'] = self.byline
|
||||
data['body'] = self.body
|
||||
item_id = self.data.get('related')
|
||||
if not item_id:
|
||||
item_id = self.data.get('item')
|
||||
if item_id:
|
||||
item = Film.objects.filter(padma_id=item_id).first()
|
||||
if item:
|
||||
for key in ('title', 'title_zh'):
|
||||
data['item_' + key] = item.data[key]
|
||||
data['item_url'] = item.get_absolute_url()
|
||||
if isinstance(self.annotations, list) and len(self.annotations) > 0:
|
||||
data['annotations'] = self.annotations
|
||||
data.update(self.data)
|
||||
|
|
Loading…
Reference in a new issue