From 59dbc98a7607522341886c90a2070cb24d95b10e Mon Sep 17 00:00:00 2001 From: j Date: Wed, 24 Nov 2021 09:20:50 +0100 Subject: [PATCH] fixes fixes fixes --- app/static/css/partials/_film.scss | 22 +++++++---- app/static/css/partials/_menu.scss | 1 + app/static/js/about.js | 59 +----------------------------- app/static/js/api.js | 21 +++++++++++ app/static/js/ascroll.js | 19 ---------- app/static/js/play.js | 19 ---------- app/templates/about.html | 4 ++ app/templates/film.html | 2 +- app/templates/film_play.html | 3 +- app/templates/text.html | 1 + app/text/views.py | 1 + 11 files changed, 48 insertions(+), 104 deletions(-) create mode 100644 app/static/js/api.js diff --git a/app/static/css/partials/_film.scss b/app/static/css/partials/_film.scss index 23c6a59..ab5acee 100755 --- a/app/static/css/partials/_film.scss +++ b/app/static/css/partials/_film.scss @@ -71,6 +71,7 @@ main > .film { max-width: var(--container-width); margin: auto; .info { + position: relative; margin-bottom: 32px; text-overflow: ellipsis; overflow: hidden; @@ -165,14 +166,19 @@ main > .film { .info-meta { display: inline-block; - margin: 0 auto; - position: absolute; + margin: 40px auto; + position: relative; max-width: 600px; - top: 50%; - left: 50%; - transform: translate(-50%, -50%); animation: fade_in 1s linear 0.4s forwards; opacity: 0; + line-height: 1.4; +} +@media screen and (max-width: 799px) { + .info-meta { + margin-top: 20px; + width: 70%; + transform: unset; + } } main > .film { @@ -259,10 +265,12 @@ main > .film { font-size: 18px; } -.film-play-padma { +.film-play-pandora{ font-family: "wrong font"; a { - color: #ddd; + color: var(--color-link); + font-size: 24px; + font-weight: bold; text-decoration: none; } } diff --git a/app/static/css/partials/_menu.scss b/app/static/css/partials/_menu.scss index d941f4f..4ca8cdf 100755 --- a/app/static/css/partials/_menu.scss +++ b/app/static/css/partials/_menu.scss @@ -9,6 +9,7 @@ @media screen and (max-width: 799px) { padding-top: calc(var(--spacing) * 1.6); + height: 98px; } @media screen and (min-width: 800px) { diff --git a/app/static/js/about.js b/app/static/js/about.js index d785bfb..5c31224 100755 --- a/app/static/js/about.js +++ b/app/static/js/about.js @@ -1,58 +1,3 @@ -document.querySelectorAll('.accordion-checkbox').forEach(cbox => { - cbox.addEventListener('change', function() { - const label = this.previousElementSibling - const caret = label.querySelector('.text-about') - if (cbox.checked) { - caret.innerHTML = '' - } else { - caret.innerHTML = '' - } - }) +pandoraAPI('getPage', {'name': 'about'}).then(response => { + document.querySelector('main .about').innerHTML = response.data.text }) - -// FIXME: maybe move to utils -function getCookie(name) { - var cookieValue = null; - if (document.cookie && document.cookie !== '') { - var cookies = document.cookie.split(';'); - for (var i = 0; i < cookies.length; i++) { - var cookie = cookies[i].trim() - // Does this cookie string begin with the name we want? - if (cookie.substring(0, name.length + 1) === (name + '=')) { - cookieValue = decodeURIComponent(cookie.substring(name.length + 1)); - break; - } - } - } - if (!cookieValue && name === 'csrftoken') { - var input = document.querySelector('input[name="csrfmiddlewaretoken"]') - if (input) { - cookieValue = input.value - } - } - return cookieValue; -} - -document.getElementById('contact-form').addEventListener('submit', async function(event) { - // console.log('foobar') - event.preventDefault() - let data = new FormData() - data.append('email', document.getElementById('input-email').value) - data.append('message', document.getElementById('input-msg').value) - data.append('csrfmiddlewaretoken', getCookie('csrftoken')) - document.getElementById('contact-container').innerHTML = '...' - let success; - try { - const response = await fetch('/polis+contact/', { - method: 'POST', - body: data - }) - let resData = await response.json() - success = resData.success - } catch (e) { - console.log('error', e) - success = false - } - const thanksMsg = success ? 'Thanks for your message 謝謝您的訊息' : 'Failed to send message. Try again later.' - document.getElementById('contact-container').innerHTML = `
${thanksMsg}
` -}) \ No newline at end of file diff --git a/app/static/js/api.js b/app/static/js/api.js new file mode 100644 index 0000000..5672d3e --- /dev/null +++ b/app/static/js/api.js @@ -0,0 +1,21 @@ +var cache = cache || {} + +async function pandoraAPI(action, data) { + var url = pandoraURL + '/api/' + //var url = '/pandoraAPI/' + var key = JSON.stringify([action, data]) + if (!cache[key]) { + var response = await fetch(url, { + method: 'POST', + headers: {'Content-Type': 'application/json'}, + body: JSON.stringify({ + action: action, + data: data + }) + }) + cache[key] = await response.json() + } + return cache[key] +} + + diff --git a/app/static/js/ascroll.js b/app/static/js/ascroll.js index aecc78d..859b9fe 100755 --- a/app/static/js/ascroll.js +++ b/app/static/js/ascroll.js @@ -1,26 +1,7 @@ -var cache = cache || {} var layer = 'keywords' var imageResolution = 480 var videoExtension -async function pandoraAPI(action, data) { - var url = pandoraURL + '/api/' - //var url = '/pandoraAPI/' - var key = JSON.stringify([action, data]) - if (!cache[key]) { - var response = await fetch(url, { - method: 'POST', - headers: {'Content-Type': 'application/json'}, - body: JSON.stringify({ - action: action, - data: data - }) - }) - cache[key] = await response.json() - } - return cache[key] -} - function setVideoSrc(video, src) { var ext if (!videoExtension) { diff --git a/app/static/js/play.js b/app/static/js/play.js index 0721748..20791d0 100644 --- a/app/static/js/play.js +++ b/app/static/js/play.js @@ -1,26 +1,7 @@ -var cache = cache || {} var layer = 'keywords' var imageResolution = 480 var videoExtension -async function pandoraAPI(action, data) { - var url = pandoraURL + '/api/' - //var url = '/pandoraAPI/' - var key = JSON.stringify([action, data]) - if (!cache[key]) { - var response = await fetch(url, { - method: 'POST', - headers: {'Content-Type': 'application/json'}, - body: JSON.stringify({ - action: action, - data: data - }) - }) - cache[key] = await response.json() - } - return cache[key] -} - function setVideoSrc(video, src) { var ext if (!videoExtension) { diff --git a/app/templates/about.html b/app/templates/about.html index 4ad1deb..41c6c03 100644 --- a/app/templates/about.html +++ b/app/templates/about.html @@ -7,5 +7,9 @@ {% endblock %} {% block end %} + + {% endblock %} diff --git a/app/templates/film.html b/app/templates/film.html index c5b21e7..23a3232 100644 --- a/app/templates/film.html +++ b/app/templates/film.html @@ -93,7 +93,7 @@ body { {% endfor %}
- +
{% if film.related_texts.exists %}
diff --git a/app/templates/film_play.html b/app/templates/film_play.html index 767ada4..28c8e1a 100644 --- a/app/templates/film_play.html +++ b/app/templates/film_play.html @@ -7,5 +7,6 @@ var config = {{ config | safe }}; var pandoraURL = "{{ pandora_url }}"; - + + {% endblock %} diff --git a/app/templates/text.html b/app/templates/text.html index 859f7bc..0e6fa6a 100644 --- a/app/templates/text.html +++ b/app/templates/text.html @@ -39,6 +39,7 @@ var config = {{ text.json | safe }}; var pandoraURL = "{{ pandora_url }}"; + {% if text.data.view == 'player' %} {% else %} diff --git a/app/text/views.py b/app/text/views.py index 268a82a..6f2f3ec 100644 --- a/app/text/views.py +++ b/app/text/views.py @@ -43,6 +43,7 @@ def page(request, slug=''): def about(request): context = {} + context['pandora_url'] = settings.DEFAULT_PANDORA_API.replace('/api/', '') return render(request, 'about.html', context) def texts(request):