diff --git a/app/static/css/partials/_ascroll.scss b/app/static/css/partials/_ascroll.scss index f0b1268..33181ac 100755 --- a/app/static/css/partials/_ascroll.scss +++ b/app/static/css/partials/_ascroll.scss @@ -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; + } } diff --git a/app/static/js/ascroll.js b/app/static/js/ascroll.js index 6553d1f..f61dc79 100755 --- a/app/static/js/ascroll.js +++ b/app/static/js/ascroll.js @@ -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: ${config.item_title} ${config.item_title_zh}
+ ` + 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) }) diff --git a/app/text/models.py b/app/text/models.py index 5ea4e8d..f0f46b2 100644 --- a/app/text/models.py +++ b/app/text/models.py @@ -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)