1
0
mirror of https://github.com/binary-kitchen/doorlockd synced 2024-12-22 10:24:26 +01:00

Parameterise more settings

Signed-off-by: Ralf Ramsauer <ralf@binary-kitchen.de>
This commit is contained in:
Ralf Ramsauer 2018-09-17 19:54:33 +02:00
parent 0bf9679eef
commit f6eabcd8cf
4 changed files with 16 additions and 7 deletions

View File

@ -64,8 +64,6 @@ default_ldap_uri = 'ldaps://ldap1.binary.kitchen/ ' \
'ldaps://ldapm.binary.kitchen/' 'ldaps://ldapm.binary.kitchen/'
default_binddn = 'cn=%s,ou=people,dc=binary-kitchen,dc=de' default_binddn = 'cn=%s,ou=people,dc=binary-kitchen,dc=de'
html_title = 'Binary Kitchen Doorlock (%s - v%s)' % (__status__, __version__)
webapp = Flask(__name__, webapp = Flask(__name__,
template_folder=template_folder, template_folder=template_folder,
static_folder=static_folder) static_folder=static_folder)
@ -75,6 +73,11 @@ serial_port = webapp.config.get('SERIAL_PORT')
simulate_ldap = webapp.config.get('SIMULATE_LDAP') simulate_ldap = webapp.config.get('SIMULATE_LDAP')
simulate_serial = webapp.config.get('SIMULATE_SERIAL') simulate_serial = webapp.config.get('SIMULATE_SERIAL')
run_hooks = webapp.config.get('RUN_HOOKS') run_hooks = webapp.config.get('RUN_HOOKS')
room = webapp.config.get('ROOM')
title = webapp.config.get('TITLE')
welcome = webapp.config.get('WELCOME')
html_title = '%s (%s - v%s)' % (title, __status__, __version__)
ldap.set_option(ldap.OPT_X_TLS_REQUIRE_CERT, ldap.OPT_X_TLS_DEMAND) ldap.set_option(ldap.OPT_X_TLS_REQUIRE_CERT, ldap.OPT_X_TLS_DEMAND)
ldap.set_option(ldap.OPT_REFERRALS, 0) ldap.set_option(ldap.OPT_REFERRALS, 0)
@ -406,7 +409,10 @@ def on_connect():
@webapp.route('/display') @webapp.route('/display')
def display(): def display():
return render_template('display.html') return render_template('display.html',
room=room,
title=title,
welcome=welcome)
@webapp.route('/api', methods=['POST']) @webapp.route('/api', methods=['POST'])
@ -478,7 +484,7 @@ def home():
response=response, response=response,
state_text=logic.state.to_html(), state_text=logic.state.to_html(),
led=logic.state.to_img(), led=logic.state.to_img(),
title=html_title) banner='%s - %s' % (title, room))
if __name__ == '__main__': if __name__ == '__main__':

View File

@ -11,4 +11,7 @@ LDAP_BINDDN = 'cn=%s,ou=people,dc=binary-kitchen,dc=de'
BOOTSTRAP_SERVE_LOCAL = True BOOTSTRAP_SERVE_LOCAL = True
TITLE = 'Binary Kitchen Doorlock'
ROOM = 'Hauptraum'
WELCOME = 'Willkommen in der Binary Kitchen'
SERIAL_PORT = '/dev/ttyAMA0' SERIAL_PORT = '/dev/ttyAMA0'

View File

@ -1,7 +1,6 @@
{% extends "layout.html" %} {% extends "layout.html" %}
{% block head %} {% block head %}
{{ title }}
{{ super() }} {{ super() }}
<meta http-equiv="refresh" content="600"> <meta http-equiv="refresh" content="600">
{% endblock %} {% endblock %}
@ -34,10 +33,11 @@
{% endblock %} {% endblock %}
{% block content %} {% block content %}
<h1 class="text-center display-4">Willkommen in der Binary Kitchen!</h1> <h1 class="text-center display-4">{{ welcome }}</h1>
<div class="row"> <div class="row">
<div class="col"> <div class="col">
<div class="text-center"> <div class="text-center">
<div class="h2">{{ room }}</div>
<img id="led" src=""> <img id="led" src="">
<div class="h2" id="message"></div> <div class="h2" id="message"></div>
</div> </div>

View File

@ -7,7 +7,7 @@
{%- endblock metas %} {%- endblock metas %}
{% block content %} {% block content %}
<h1 class="text-center">Binary Kitchen Doorlock</h1> <h1 class="text-center">{{ banner }}</h1>
<div class="row"> <div class="row">
<div class="col-md-3 text-center"> <div class="col-md-3 text-center">
<img src="{{ led }}"> <img src="{{ led }}">