{%- block main %} {%- endblock %} diff --git a/templates/index.html b/templates/index.html index 479993b..d94cc81 100644 --- a/templates/index.html +++ b/templates/index.html @@ -15,19 +15,19 @@ {%- endfor %} {% endblock %}
diff --git a/game.py b/game.py index a6ec85b..efde033 100755 --- a/game.py +++ b/game.py @@ -15,48 +15,48 @@ config = ConfigParser() config.read('config.ini') tz = pytz.timezone(config.get('main', 'timezone')) -@app.errorhandler(404) -def page_not_found(e): - lang = config.get('i18n', 'lang') - title = config.get('i18n', 'title') - url = config.get('main', 'base_url') - theme = config.get('main', 'theme') - desc = config.get('i18n', 'desc') - return render_template('404.html', title=title, lang=lang, desc=desc, theme=theme, url=url), 404 - -@app.errorhandler(500) -def internal_server_error(e): - lang = config.get('i18n', 'lang') - title = config.get('i18n', 'title') - url = config.get('main', 'base_url') - theme = config.get('main', 'theme') - desc = config.get('i18n', 'desc') - return render_template('500.html', title=title, lang=lang, desc=desc, theme=theme, url=url), 500 - -@app.route("/") -def hello(): - lang = config.get('i18n', 'lang') - title = config.get('i18n', 'title') - more = config.get('i18n', 'more') - desc = config.get('i18n', 'desc') - questions_prefix = config.get('i18n', 'questions_prefix') - questions_suffix = config.get('i18n', 'questions_suffix') - send_questions = config.get('i18n', 'send_questions') - separator = config.get('i18n', 'separator') - separator_char = config.get('main', 'separator_char') - mail = config.get('main', 'mail') - mailtext = config.get('i18n', 'mail_link') - helptext = config.get('i18n', 'help_link') - help = config.get('i18n', 'help') - url = config.get('main', 'base_url') - theme = config.get('main', 'theme') - animations = config.get('main', 'animations') - ablines = [] +i18n = { + 'lang': config.get('i18n', 'lang'), + 'title': config.get('i18n', 'title'), + 'more': config.get('i18n', 'more'), + 'desc': config.get('i18n', 'desc'), + 'questions_prefix': config.get('i18n', 'questions_prefix'), + 'questions_suffix': config.get('i18n', 'questions_suffix'), + 'separator': config.get('i18n', 'separator'), + 'mailtext': config.get('i18n', 'mail_link'), + 'helptext': config.get('i18n', 'help_link'), + 'help': config.get('i18n', 'help') +} +conf = { + 'separator_char': config.get('main', 'separator_char'), + 'mailto': config.get('main', 'mail'), + 'url': config.get('main', 'base_url'), + 'theme': config.get('main', 'theme'), + 'animations': config.get('main', 'animations') +} +def getEpoch(): now = datetime.now(tz=tz) epoch = now.timestamp() epoch = int(epoch) + return epoch + +@app.errorhandler(404) +def page_not_found(e): + epoch = getEpoch() + return render_template('404.html', config=conf, i18n=i18n, epoch=epoch), 404 + +@app.errorhandler(500) +def internal_server_error(e): + epoch = getEpoch() + return render_template('500.html', config=conf, i18n=i18n, epoch=epoch), 500 + +@app.route("/") +def hello(): + ablines = [] + epoch = getEpoch() + lines = getContent() while len(lines) < 2: print('Error reading content') @@ -64,7 +64,7 @@ def hello(): lines = getContent() for line in lines: - ab = line.split(separator_char) + ab = line.split(conf['separator_char']) ablines.append( {'A': str(ab[0]), 'B': str(ab[1])} ) @@ -72,7 +72,7 @@ def hello(): with open("ab.txt", "r") as f: num_lines = sum(1 for _ in f) - return render_template('index.html', title=title, separator=separator, content=ablines, num_lines=num_lines, epoch=epoch, mailto=mail, more=more, questions_prefix=questions_prefix, questions_suffix=questions_suffix, send_questions=send_questions, lang=lang, url=url, desc=desc, theme=theme, mailtext=mailtext, helptext=helptext, help=help, animations=animations) + return render_template('index.html', content=ablines, config=conf, i18n=i18n, num_lines=num_lines, epoch=epoch) def getContent(): lines = [a.strip() for a in open("ab.txt", "r").readlines()] diff --git a/static/js/autoReload.js b/static/js/autoReload.js index 8e45ddc..130625b 100644 --- a/static/js/autoReload.js +++ b/static/js/autoReload.js @@ -9,7 +9,7 @@ function countdown() { document.getElementById("next").innerHTML = timeleft; } timeleft -= 1; - }, 1000); + }, 750); } function autoReload() { diff --git a/templates/base.html b/templates/base.html index 094b56c..0317049 100644 --- a/templates/base.html +++ b/templates/base.html @@ -1,8 +1,8 @@ {%- if theme == "light" %} - + {%- else %} - + {%- endif %}
@@ -12,7 +12,7 @@ - {%- if animations == "1" or animations == "true" %} + {%- if config.animations == "1" or config.animations == "true" %} {%- endif %} @@ -24,17 +24,17 @@ - - - - + + + +