diff --git a/.gitignore b/.gitignore index 9f06617..b796648 100644 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,4 @@ larigira.db larigira.db_* *.json .coverage +*.db diff --git a/larigira/config.py b/larigira/config.py index de64206..3ae9425 100644 --- a/larigira/config.py +++ b/larigira/config.py @@ -15,6 +15,7 @@ def get_conf(prefix='LARIGIRA_'): conf['MPD_PORT'] = int(os.getenv('MPD_PORT', '6600')) conf['CACHING_TIME'] = 10 conf['DB_URI'] = 'larigira.db' + conf['BOOTSTRAP_SERVE_LOCAL'] = True conf.update(from_envvars(prefix=prefix)) return conf diff --git a/larigira/dbadmin/__init__.py b/larigira/dbadmin/__init__.py index 250cc7b..d179942 100644 --- a/larigira/dbadmin/__init__.py +++ b/larigira/dbadmin/__init__.py @@ -1,3 +1,8 @@ +''' +This module contains a flask blueprint for db administration stuff + +Templates are self-contained in this directory +''' from __future__ import print_function from flask import current_app, Blueprint, render_template diff --git a/larigira/dbadmin/templates/dbadmin_base.html b/larigira/dbadmin/templates/dbadmin_base.html new file mode 100644 index 0000000..41a3c51 --- /dev/null +++ b/larigira/dbadmin/templates/dbadmin_base.html @@ -0,0 +1,54 @@ +{% extends "bootstrap/base.html" %} +{% block title %}Larigira{% endblock title %} +{% block navbar %} + +{% endblock %} + +{% macro dict_table(obj, exclude_list=[]) %} + + + + + + + + + {% for key in obj if key not in exclude_list%} + + + + + {% endfor %} + +
KeyValue
{{key}}{{obj[key]}}
+{% endmacro %} + +{# vim: set ts=2 sw=2 noet: #} diff --git a/larigira/dbadmin/templates/list.html b/larigira/dbadmin/templates/list.html index a2cee7e..fd4b24c 100644 --- a/larigira/dbadmin/templates/list.html +++ b/larigira/dbadmin/templates/list.html @@ -1,24 +1,28 @@ - - -Larigira - DB list - - -
- {% for e, actions in events %} -
-

Event {{e.eid}}

-
{{ e }}
-
-

Actions

-
    - {% for a in actions %} -
  1. {{ a }}
  2. - {% endfor %} -
-
{# actions #} -
{# event #} - {% endfor %} -
{# main #} - - +{% extends "dbadmin_base.html" %} +{% block title %}Larigira - DB list {%endblock%} + +{% block content %} +
+ {% for e, actions in events %} +
+
+

Event {{e.eid}} {{e.nick if 'nick'}}

+ {{dict_table(e, ['nick', 'actions'])}} + +
+
+

Actions

+
    + {% for a in actions %} +
  1. + {{a.nick}} + {{dict_table(a, ['nick'])}} +
  2. + {% endfor %} +
+
{# actions #} +
{# event #} + {% endfor %} +
+{% endblock content %} {# vim: set ts=2 sw=2 noet: #} diff --git a/larigira/rpc.py b/larigira/rpc.py index 386b20f..b844c38 100644 --- a/larigira/rpc.py +++ b/larigira/rpc.py @@ -4,8 +4,10 @@ import gc from greenlet import greenlet from flask import current_app, Blueprint, Flask, jsonify +from flask_bootstrap import Bootstrap from .dbadmin import db +from .config import get_conf rpc = Blueprint('rpc', __name__, url_prefix='/api') @@ -67,7 +69,9 @@ def rpc_wip(): def create_app(queue, larigira): - app = Flask(__name__) + app = Flask('larigira') + app.config.update(get_conf()) + Bootstrap(app) app.register_blueprint(rpc) app.register_blueprint(db) app.queue = queue diff --git a/setup.py b/setup.py index 9c217dc..b55c36f 100644 --- a/setup.py +++ b/setup.py @@ -39,6 +39,7 @@ setup(name='larigira', install_requires=[ 'gevent', 'flask', + 'flask-bootstrap', 'python-mpd2', 'tinydb' ],