Skip to content

Commit 5cfc284

Browse files
committed
Dynamic menu bar
1 parent cfc6cf6 commit 5cfc284

3 files changed

Lines changed: 27 additions & 25 deletions

File tree

cloudbot/web/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ def get(self):
3333

3434

3535
class WebInterface():
36-
def __init__(self, bot, port=8080, address="0.0.0.0"):
36+
def __init__(self, bot, port=8090, address="0.0.0.0"):
3737
self.bot = bot
3838
self.port = port
3939
self.address = address

cloudbot/web/templates/basic.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{% extends "layout.html" %}
2+
{% set active_page = "index" %}
23
{% block title %}{{ heading }} - {{ super() }}{% endblock %}
34
{% block content %}
45
<div class="placeholder">

cloudbot/web/templates/layout.html

Lines changed: 25 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,30 @@
1+
{% set navigation_bar = [
2+
('/', 'index', 'Status'),
3+
('/commands/', 'commands', 'Commands'),
4+
('/factoids/', 'factoids', 'Factoids')
5+
] -%}
6+
{% set active_page = active_page|default('index') -%}
17
<!DOCTYPE html>
28
<html lang="en">
39
<head>
410
{% block head %}
5-
<meta charset="utf-8">
6-
<meta http-equiv="X-UA-Compatible" content="IE=edge">
7-
<meta name="viewport" content="width=device-width, initial-scale=1">
8-
<!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
9-
<meta name="description" content="">
10-
<meta name="author" content="">
11-
<link rel="icon" href="../../favicon.ico">
11+
<meta charset="utf-8">
12+
<meta http-equiv="X-UA-Compatible" content="IE=edge">
13+
<meta name="viewport" content="width=device-width, initial-scale=1">
14+
<meta name="description" content="">
15+
<meta name="author" content="">
16+
<link rel="icon" href="../../favicon.ico">
1217

13-
<title>{% block title %}{{ main_title }}{% endblock %}</title>
18+
<title>{% block title %}{{ main_title }}{% endblock %}</title>
1419

15-
<!-- Bootstrap core CSS -->
16-
<link href="./s/css/bootstrap.min.css" rel="stylesheet">
17-
<link href="./s/css/style.css" rel="stylesheet">
20+
<link href="./s/css/bootstrap.min.css" rel="stylesheet">
21+
<link href="./s/css/style.css" rel="stylesheet">
1822

19-
<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
20-
<!--[if lt IE 9]>
21-
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
22-
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
23-
<![endif]-->
23+
<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
24+
<!--[if lt IE 9]>
25+
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
26+
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
27+
<![endif]-->
2428
{% endblock %}
2529
</head>
2630

@@ -40,9 +44,10 @@
4044
</div>
4145
<div id="navbar" class="collapse navbar-collapse">
4246
<ul class="nav navbar-nav">
43-
<li class="active"><a href="#">Home</a></li>
44-
<li><a href="#about">About</a></li>
45-
<li><a href="#contact">Contact</a></li>
47+
{% for href, id, caption in navigation_bar %}
48+
<li{% if id == active_page %} class="active"{% endif %}><a href="{{ href|e }}">{{ caption|e }}</a>
49+
</li>
50+
{% endfor %}
4651
</ul>
4752
</div>
4853
<!--/.nav-collapse -->
@@ -52,12 +57,8 @@
5257
<div class="container">
5358
{% block content %}{% endblock %}
5459
</div>
55-
<!-- /.container -->
5660

57-
58-
<!-- Bootstrap core JavaScript
59-
================================================== -->
60-
<!-- Placed at the end of the document so the pages load faster -->
61+
<!-- javascript -->
6162
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
6263
<script src="./s/js/bootstrap.min.js"></script>
6364
<!-- IE10 viewport hack for Surface/desktop Windows 8 bug -->

0 commit comments

Comments
 (0)