Modify font awesome navbar menu logo's and remove default config file

This commit is contained in:
wez3 2017-01-07 00:06:48 +01:00
parent 0b322dc131
commit c585648d80
3 changed files with 20 additions and 32 deletions

View File

@ -11,34 +11,19 @@
time = False # True/False: show time in top bar time = False # True/False: show time in top bar
google_maps_api_key = X # Google Maps Embed API key google_maps_api_key = X # Google Maps Embed API key
# Add Navbar items here # Add Navbar items here. The key is the navbar link name. The first value is the URI name, second value can be any font awesome logo to be displayed.
[navbar] [navbar]
[[menu]] [[menu]]
Dashboard = dashboard Dashboard = dashboard, dashboard
Woonkamer = woonkamer Woonkamer = woonkamer, home
Slaapkamer = slaapkamer Slaapkamer = slaapkamer, bed
Badkamer = badkamer Werkkamer = werkkamer, home
Auto = auto Auto = auto, automobile
Tuin = tuin Tuin = tuin, bug
Security = security Verkeer = verkeer, road
Verkeer = verkeer Flitsers = flitsers, camera
Flitsers = flitsers Server = server, desktop
Statistics = statistics Instellingen = instellingen, wrench
Server = server
Instellingen = instellingen
[[icons]]
dashboard = dashboard
woonkamer = home
slaapkamer = bed
badkamer = bath
auto = automobile
tuin = bug
security = shield
verkeer = road
flitsers = camera
statistics = line-chart
server = desktop
instellingen = wrench
# Each navbar item needs a section. Components specify which components are displayed on the page. Other subsections contain names, Domoticz IDX's and options of the components displayed. # Each navbar item needs a section. Components specify which components are displayed on the page. Other subsections contain names, Domoticz IDX's and options of the components displayed.
[dashboard] [dashboard]

View File

@ -8,9 +8,6 @@ import hashlib, configobj, json, sys, os
import modules.api as api import modules.api as api
import modules.security as security import modules.security as security
# Modify config file name:
configfile = "example.conf"
app = Flask(__name__) app = Flask(__name__)
@app.before_request @app.before_request
@ -32,7 +29,6 @@ def generatePage():
blockArray = [] blockArray = []
configValues = {} configValues = {}
configValues["navbar"] = config["navbar"]["menu"] configValues["navbar"] = config["navbar"]["menu"]
configValues["navbar_icons"] = config["navbar"]["icons"]
configValues["server_location"] = config["general_settings"]["server"].get("url") configValues["server_location"] = config["general_settings"]["server"].get("url")
configValues["flask_server_location"] = config["general_settings"]["server"].get("flask_url") configValues["flask_server_location"] = config["general_settings"]["server"].get("flask_url")
configValues["domoboard"] = config["general_settings"]["domoboard"] configValues["domoboard"] = config["general_settings"]["domoboard"]
@ -141,6 +137,8 @@ if __name__ == '__main__':
args = parser.parse_args() args = parser.parse_args()
if args.configfile: if args.configfile:
configfile = args.configfile configfile = args.configfile
else:
sys.exit("Please specify a config file with the -c parameter.")
if os.path.isfile(configfile): if os.path.isfile(configfile):
unsanitizedConfig = configobj.ConfigObj(configfile) unsanitizedConfig = configobj.ConfigObj(configfile)
else: else:
@ -161,7 +159,8 @@ if __name__ == '__main__':
app.secret_key = config["general_settings"]["server"]["secret_key"] app.secret_key = config["general_settings"]["server"]["secret_key"]
app.add_url_rule('/', 'index', index) app.add_url_rule('/', 'index', index)
for k, v in config["navbar"]["menu"].iteritems(): for k, v in config["navbar"]["menu"].iteritems():
app.add_url_rule('/' + v.lower(), v.lower(), generatePage, methods=['GET']) v = strToList(v)
app.add_url_rule('/' + v[0].lower(), v[0].lower(), generatePage, methods=['GET'])
app.add_url_rule('/settings', 'settings', generatePage, methods=['GET']) app.add_url_rule('/settings', 'settings', generatePage, methods=['GET'])
app.add_url_rule('/log', 'log', generatePage, methods=['GET']) app.add_url_rule('/log', 'log', generatePage, methods=['GET'])
app.add_url_rule('/logout/', 'logout', logout_view, methods=['GET']) app.add_url_rule('/logout/', 'logout', logout_view, methods=['GET'])

View File

@ -20,7 +20,11 @@
<div class="menu_section"> <div class="menu_section">
<ul class="nav side-menu"> <ul class="nav side-menu">
{% for k, v in configValues["navbar"].iteritems() %} {% for k, v in configValues["navbar"].iteritems() %}
<li><a href="{{v}}"><i class="fa fa-{{configValues["navbar_icons"][v]}} fa-fw" aria-hidden="true"></i>{{k}}</a></li> {% if v is not string %}
<li><a href="{{v[0]}}"> <i class="fa fa-{{v[1]}} fa-fw" aria-hidden="true"></i> {{k}}</a></li>
{% else %}
<li><a href="{{v}}">{{k}}</a></li>
{% endif %}
{% endfor %} {% endfor %}
</ul> </ul>