From e1d4f1d7125fe2d7b4dffb1a8074154d0560e529 Mon Sep 17 00:00:00 2001 From: Daniel Muckerman Date: Mon, 15 Jun 2020 10:10:46 -0400 Subject: [PATCH] Add trip counter to page and config file --- app.py | 7 +++++ config/config.yaml | 5 ++++ static/clock.css | 34 +++++++++++++++++++++ static/clock.js | 48 ++++++++++++++++++++++++++++++ static/fonts/digital-7 (mono).ttf | Bin 0 -> 34404 bytes templates/card.j2 | 2 +- templates/countdown.j2 | 23 ++++++++++++++ templates/index.j2 | 13 ++++++++ 8 files changed, 131 insertions(+), 1 deletion(-) create mode 100644 static/clock.css create mode 100644 static/clock.js create mode 100644 static/fonts/digital-7 (mono).ttf create mode 100644 templates/countdown.j2 diff --git a/app.py b/app.py index 4a60f2c..ea6eb21 100644 --- a/app.py +++ b/app.py @@ -15,6 +15,11 @@ account_url = yaml_data['accounts']['account_url'] description = yaml_data['description'] +countdown_data = None +if yaml_data['countdown']['active'] == True: + countdown_data = yaml_data['countdown'] + print(countdown_data) + apps = [] for itm in yaml_data['apps'].items(): apps.append(itm[1]) @@ -22,6 +27,8 @@ for itm in yaml_data['apps'].items(): @app.route('/') def index(): + if countdown_data != None: + return render_template('index.j2', apps = apps, search = search, account_url = account_url, description = description, countdown = countdown_data) return render_template('index.j2', apps = apps, search = search, account_url = account_url, description = description) diff --git a/config/config.yaml b/config/config.yaml index 5c88d08..8033714 100644 --- a/config/config.yaml +++ b/config/config.yaml @@ -7,6 +7,11 @@ accounts: description: "It turns out Technical Incompetence's amazingness is just too great for this lame internet - we need a new one to maximize our full potential. Welcome to the Technical Incompetence internet. Population - US." +countdown: + active: True + name: "The End of Drunktrips: You Can (Not) Continue" + timestamp: "June 26 2020 11:00:00 GMT-0400" + apps: chat: name: "Rocket Chat" diff --git a/static/clock.css b/static/clock.css new file mode 100644 index 0000000..4bc6313 --- /dev/null +++ b/static/clock.css @@ -0,0 +1,34 @@ +@font-face{ + font-family:'digital-clock-font'; + src: url('/static/fonts/digital-7 (mono).ttf'); +} + +#clockdiv > div{ + padding: 6px; + border-radius: 3px; + /* background: #00BF96; */ + display: inline-block; +} + +#clockdiv div > span{ + padding: 8px; + border-radius: 3px; + /* background: #00816A; */ + display: inline-block; + width: 100%; + text-align: center; + font-family: digital-clock-font; + font-size: 32px; + vertical-align: middle; +} + +@media (min-width: 350px) { + #clockdiv div > span{ + font-size: 40px; + } +} + +#trip-name { + font-size: 16px; + text-align: center; +} diff --git a/static/clock.js b/static/clock.js new file mode 100644 index 0000000..00deb50 --- /dev/null +++ b/static/clock.js @@ -0,0 +1,48 @@ +function getTimeRemaining(endtime){ + const total = Date.parse(endtime) - Date.parse(new Date()); + const seconds = Math.floor( (total/1000) % 60 ); + const minutes = Math.floor( (total/1000/60) % 60 ); + const hours = Math.floor( (total/(1000*60*60)) % 24 ); + const days = Math.floor( total/(1000*60*60*24) ); + + return { + total, + days, + hours, + minutes, + seconds + }; +} + +function initializeClock(id, endtime) { + const clock = document.getElementById(id); + + const daysSpan = clock.querySelector('.days'); + const hoursSpan = clock.querySelector('.hours'); + const minutesSpan = clock.querySelector('.minutes'); + const secondsSpan = clock.querySelector('.seconds'); + + function updateClock() { + const t = getTimeRemaining(endtime); + + if (t.days < 0) { + clearInterval(timeinterval); + $('#clock-card').hide(); + } + + daysSpan.innerHTML = t.days; + hoursSpan.innerHTML = ('0' + t.hours).slice(-2); + minutesSpan.innerHTML = ('0' + t.minutes).slice(-2); + secondsSpan.innerHTML = ('0' + t.seconds).slice(-2); + + if (t.total <= 0) { + clearInterval(timeinterval); + } + } + + updateClock(); // run function once at first to avoid delay + var timeinterval = setInterval(updateClock, 1000); +} + +initializeClock('clockdiv', deadline); +$('#trip-name').text(tripName); \ No newline at end of file diff --git a/static/fonts/digital-7 (mono).ttf b/static/fonts/digital-7 (mono).ttf new file mode 100644 index 0000000000000000000000000000000000000000..a481b97b4f84fd4199360c511517a5cf22d2a664 GIT binary patch literal 34404 zcmeHw4R}=5ng4rdCYfaNF`3LHlkdzVgbWapFd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L(A~MIvwL%AM}1&*PtV3#4GmkiY^mSG zikmt&cXrjU*sy-?npJCh+Sg5O2`t>uwSh-!N$T0O`o?fz&c^OQV@qIKc-FM$S&fZo ze%iD|H9lcve1~-5gt)bJcXn=R@9qq&+|V7^*x9{lLs$E{z_pt?>vLRfC<6NHJG)n` z(S?DH>pI&vb)vMZ=h_uLs8`=OE!;G{c}C03)Bc}ez<^@TPsa{J88MJx+Y__zK%J59 z*X&FNo&y%`R_xrO*f|V_orV`zCbRQ2lni~Eg~R`4f`76Y`1I4LO$mTbOt^NH3&=`L zFZOYx5(=Bt)TbZ_$hAsP)MKURE2(uYJsH=lx+@?!l56rA6hQ6jzJQvzU6|6>nnHok zqo5cvktyeG1h8H1KvTng) +
{% if app['image'] is defined %} diff --git a/templates/countdown.j2 b/templates/countdown.j2 new file mode 100644 index 0000000..f341fd5 --- /dev/null +++ b/templates/countdown.j2 @@ -0,0 +1,23 @@ +
+
+
+
+
+ +
+
+ +
+
+ +
+
+ +
+
+
+
+
+
+
+
\ No newline at end of file diff --git a/templates/index.j2 b/templates/index.j2 index db9282d..209c6cc 100644 --- a/templates/index.j2 +++ b/templates/index.j2 @@ -4,6 +4,9 @@ {% block styles %} {{super()}} +{% if countdown is defined %} + +{% endif %} {% endblock %} {% block navbar %} @@ -25,6 +28,9 @@


{% endif %} + {% if countdown is defined %} + {% include "countdown.j2" %} + {% endif %}

{{ description }}

{% for app in apps %} @@ -36,6 +42,13 @@ {% block scripts %} {{ super () }} +{% if countdown is defined %} + + +{% endif %}