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 0000000..a481b97 Binary files /dev/null and b/static/fonts/digital-7 (mono).ttf differ diff --git a/templates/card.j2 b/templates/card.j2 index 2733123..e68599c 100644 --- a/templates/card.j2 +++ b/templates/card.j2 @@ -1,4 +1,4 @@ -
+
{% 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 %}