From 9d52c03cc8773371e81eff8a80dd448d47291ac5 Mon Sep 17 00:00:00 2001 From: mco-system Date: Sun, 16 Apr 2023 18:38:01 +1100 Subject: [PATCH] refactor: planning --- config.yml | 2 +- src/thsf/__init__.py | 15 +- src/thsf/static/css/planning.css | 225 ------------------------------ src/thsf/static/css/slot.css | 66 +++++++++ src/thsf/static/scripts/thsf23.js | 14 ++ src/thsf/templates/base.html | 3 +- src/thsf/templates/planning.html | 1 - src/thsf/templates/slot.html | 104 +++++++------- 8 files changed, 152 insertions(+), 278 deletions(-) delete mode 100644 src/thsf/static/css/planning.css create mode 100644 src/thsf/static/css/slot.css create mode 100644 src/thsf/static/scripts/thsf23.js diff --git a/config.yml b/config.yml index 7b2544c..a049ae7 100644 --- a/config.yml +++ b/config.yml @@ -14,7 +14,7 @@ log: handlers: [wsgi] propagate: no root: - level: INFO + level: DEBUG handlers: [wsgi] app: secret_key: xxx diff --git a/src/thsf/__init__.py b/src/thsf/__init__.py index 537afbf..210e022 100644 --- a/src/thsf/__init__.py +++ b/src/thsf/__init__.py @@ -24,7 +24,6 @@ class AppConfig: # ------------------------------------------------------------------------------ logger = logging.getLogger('wsgi') app = Flask(__name__) -minify(app=app, html=True, js=True, cssless=True) # ------------------------------------------------------------------------------ # -- Local configuration @@ -45,6 +44,8 @@ except Exception as err: logger.critical("[{}] {}".format(err.__class__, str(err))) sys.exit(1) +if app.local_config["log"]["root"]["level"] != "DEBUG": + minify(app=app, html=True, js=True, cssless=True) # ------------------------------------------------------------------------------ # -- Tools @@ -56,6 +57,15 @@ def page_not_found(err): def get_slots(): return backend.get(endpoint=f"events/{app.local_config['pretalx']['event']}/schedules/{app.local_config['pretalx']['schedule']}").json() +def get_speaker_biography(name): + try: + speaker_info = backend.get(endpoint=f"events/{app.local_config['pretalx']['event']}/speakers/", params={"q": name}).json() + logging.info(speaker_info) + return speaker_info["results"][0]["biography"].strip() + except Exception as err: + logging.error(f"UnknownSpeakerError: {name}") + return None + # ------------------------------------------------------------------------------ # -- Custom filters # ------------------------------------------------------------------------------ @@ -107,6 +117,9 @@ def index(): @app.route('/planning', methods=['GET']) def planning(): slots = get_slots() + for slot in slots["slots"]: + for speaker in slot["speakers"]: + speaker["biography"] = get_speaker_biography(speaker["name"]) return render_template("planning.html", slots=sorted(slots["slots"], key=lambda slot: slot["slot"]["start"]), diff --git a/src/thsf/static/css/planning.css b/src/thsf/static/css/planning.css deleted file mode 100644 index fb16acc..0000000 --- a/src/thsf/static/css/planning.css +++ /dev/null @@ -1,225 +0,0 @@ -@media screen and (min-width: 45em) { - .slot { - display: flex; - flex: 1; - justify-content: center; - text-align: center; - flex-direction: row; - margin: 0.3em 0; - width: 20em; - } - .slot_info .details { - visibility: hidden; - font-weight: bold; - background-color: var(--main-color); - color: var(--alt-main-color); - text-align: left; - padding: 1em; - border-radius: 6px; - position: absolute; - z-index: 1; - bottom: 0; - left: 0; - opacity: 0; - transition: opacity 1s; - transform: translateX(-2em) translateY(102%); - width: 27.5em; - overflow-y: auto; - border-style: solid; - border-color: var(--alt-main-color); - border-width: 1px; - } -} - -@media screen and (max-width: 44em) { - .slot { - display: flex; - flex: 1; - justify-content: center; - text-align: center; - flex-direction: row; - margin: 0.3em 0; - width: 21em; - } - .slot_info .details { - visibility: hidden; - font-weight: bold; - background-color: var(--main-color); - color: var(--alt-main-color); - text-align: left; - padding: 1em; - border-radius: 6px; - position: absolute; - z-index: 1; - bottom: 0; - left: 0; - opacity: 0; - transition: opacity 1s; - transform: translateX(-2em) translateY(102%); - width: 28em; - overflow-y: auto; - border-style: solid; - border-color: var(--alt-main-color); - border-width: 1px; - } -} - -.slot_info, -.slot_info_buttons { - display: flex; - flex-direction: row; - align-content: flex-start; -} - -.metadata, .data { - display: flex; - flex-direction: column; - justify-content: start; - align-content: flex-start; - padding: 0.5em; - border-style: solid; -} - -.metadata { - width: 7em; - border-radius: 10px 0 0 10px; - color: var(--main-color); - font-family: pfdintextcompprothin; - border-width: 1px 0 0px 1px; - text-align: left; -} - -.data { - width: 14em; - background-color: var(--main-color); - color: var(--alt-main-color); - border-color: var(--main-color); - border-width: 1px 1px 1px 0; - font-family: pfdintextcompprothin; - text-align: left; -} - -.metadata > .slot_info_buttons > .button, -.metadata > .slot_info_buttons > .slot_info > .button { - font-size: 1em; - margin-right: 0.3em; -} - -.title { - font-family: pfdintextcompprothin; - font-weight: bold; - margin-bottom: 0.5em; -} - -.speakers { - font-family: pfdintextcompprothin; - font-weight: bold; - margin-bottom: 0.2em; -} - -.speaker { - position: relative; - display: inline-block; -} - -.speaker_details:hover { - cursor: pointer; -} - -.speaker .details { - visibility: hidden; - background-color: var(--main-color); - color: var(--alt-main-color); - text-align: left; - padding: 1em; - border-radius: 6px; - position: absolute; - z-index: 1; - bottom: 0; - left: 0; - opacity: 0; - transition: opacity 1s; - transform: translateY(102%); - overflow-y: auto; - border-style: solid; - border-color: var(--alt-main-color); - border-width: 1px; -} - -.speaker .details::after { - content: ""; - position: relative; - margin-left: -5px; - border-width: 5px; -} - -.speaker:hover .details { - visibility: visible; - opacity: 1; - font-size: 0.7em; - padding: 0.2em; -} - -.speaker > .details > img, -.abstract > img { - max-width: 200px; - max-height: 200px; - float: left; - margin: 0 0.5em 0.5em 0; -} - -.speaker > .details > p { - text-align: justify; - font-size: 0.5em; -} - -.slot_info { - position: relative; -} - -.slot_info .details > .description { - margin-top: 1em; -} - -.slot_info .details::after { - content: ""; - position: relative; - margin-left: -5px; - border-width: 5px; -} - -.slot_info:hover .details { - visibility: visible; - opacity: 1; - font-size: 0.7em; - padding: 0.2em; -} - -.slot_info > .details > img, -.abstract > img { - max-width: 200px; - max-height: 200px; - float: left; - margin: 0 0.5em 0.5em 0; -} - -.slot_info > .details > p { - text-align: justify; - font-size: 0.5em; -} - -.abstract > p { - text-align: justify; - font-size: 1em; -} - -.data > .details { - font-family: pfdintextcompprothin; - font-weight: bold; - margin-bottom: 0.2em; - font-size: 0.8em; -} - -.data > .resources > .resource > a { - color: var(--main-bg-color); -} diff --git a/src/thsf/static/css/slot.css b/src/thsf/static/css/slot.css new file mode 100644 index 0000000..f824b10 --- /dev/null +++ b/src/thsf/static/css/slot.css @@ -0,0 +1,66 @@ +.slot { + display: flex; + flex-direction: column; + justify-content: center; + align-items: center; + align-content: center; + margin-bottom: 1em; + width: 20em; +} + +.slot_header { + margin: 0; + width: 20em; + font-family: pfdintextcompprothin; + font-weight: bold; +} + +.slot_title { + border-radius: 1em 0 0 0; + color: var(--main-color); + padding: 0.5em; + text-align: center; + display: flex; + flex-direction: row; + justify-content: flex-start; + align-content: flex-start; + align-items: flex-start; + width: 20em; + cursor: pointer; +} + +.slot_title .title{ + margin-left: 0.5em; +} + +.slot_info { + background-color: var(--main-color); + color: var(--alt-main-color); + margin: 0; + padding: 0.5em; + display: flex; + flex-direction: column; + justify-content: flex-start; + align-content: flex-start; + align-items: flex-start; + border-radius: 0 0 0 1em; +} + +.speaker { + cursor: pointer; +} + +.speakers > .speaker > .name > span { + text-decoration: underline; +} + +.speaker_details, +.slot_details { + visibility: hidden; + display: none; +} + +.speaker_img, +.slot_img { + width: 18em; +} diff --git a/src/thsf/static/scripts/thsf23.js b/src/thsf/static/scripts/thsf23.js new file mode 100644 index 0000000..50fad40 --- /dev/null +++ b/src/thsf/static/scripts/thsf23.js @@ -0,0 +1,14 @@ +function switch_visibility(item){ + console.log(item.style.visibility); + console.log(item.style.display); + if (item.style.visibility == "hidden" || item.style.display == "none") { + item.style.visibility = "visible"; + item.style.display = "block"; + } else if (item.style.visibility == "" && item.style.display == "") { + item.style.visibility = "visible"; + item.style.display = "block"; + } else { + item.style.visibility = "hidden"; + item.style.display = "none"; + } +} diff --git a/src/thsf/templates/base.html b/src/thsf/templates/base.html index 532e5ba..0ad7d0a 100644 --- a/src/thsf/templates/base.html +++ b/src/thsf/templates/base.html @@ -4,6 +4,7 @@ THSF 2023: S/Extraire + + href="{{ url_for('static', filename='css/slot.css') }}"> diff --git a/src/thsf/templates/planning.html b/src/thsf/templates/planning.html index 226ecee..9fa9c5b 100644 --- a/src/thsf/templates/planning.html +++ b/src/thsf/templates/planning.html @@ -2,7 +2,6 @@ {% block content %}
{% for slot in slots %} - {% set index = loop.index %} {% if filter %} {% if slot.submission_type.en | lower in filter %} {% include "slot.html" %} diff --git a/src/thsf/templates/slot.html b/src/thsf/templates/slot.html index 3259781..af32619 100644 --- a/src/thsf/templates/slot.html +++ b/src/thsf/templates/slot.html @@ -1,58 +1,64 @@
-