Skip to content

Commit cfc6cf6

Browse files
committed
Start adding templates and layout
1 parent 61525da commit cfc6cf6

3 files changed

Lines changed: 21 additions & 15 deletions

File tree

cloudbot/web/main.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
import asyncio
2-
31
from tornado import gen
4-
from tornado.web import RequestHandler, Application, StaticFileHandler, url
2+
from tornado.web import Application, RequestHandler, StaticFileHandler
53
from tornado.platform.asyncio import AsyncIOMainLoop
64

75
from jinja2 import Environment, PackageLoader
@@ -25,8 +23,13 @@ def get_application():
2523
class TestHandler(RequestHandler):
2624
@gen.coroutine
2725
def get(self):
28-
template = wi.env.get_template('layout.html')
29-
self.write(template.render())
26+
template = wi.env.get_template('basic.html')
27+
args = {
28+
'main_title': 'CloudBot',
29+
'heading': 'Placeholder Page',
30+
'text': 'Lorem ipsum!'
31+
}
32+
self.write(template.render(**args))
3033

3134

3235
class WebInterface():

cloudbot/web/templates/basic.html

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{% extends "layout.html" %}
2+
{% block title %}{{ heading }} - {{ super() }}{% endblock %}
3+
{% block content %}
4+
<div class="placeholder">
5+
<h1>{{ heading }}</h1>
6+
<p class="lead">{{ text }}</p>
7+
</div>
8+
{% endblock %}

cloudbot/web/templates/layout.html

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<!DOCTYPE html>
22
<html lang="en">
33
<head>
4+
{% block head %}
45
<meta charset="utf-8">
56
<meta http-equiv="X-UA-Compatible" content="IE=edge">
67
<meta name="viewport" content="width=device-width, initial-scale=1">
@@ -9,7 +10,7 @@
910
<meta name="author" content="">
1011
<link rel="icon" href="../../favicon.ico">
1112

12-
<title>Starter Template for Bootstrap</title>
13+
<title>{% block title %}{{ main_title }}{% endblock %}</title>
1314

1415
<!-- Bootstrap core CSS -->
1516
<link href="./s/css/bootstrap.min.css" rel="stylesheet">
@@ -20,6 +21,7 @@
2021
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
2122
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
2223
<![endif]-->
24+
{% endblock %}
2325
</head>
2426

2527
<body>
@@ -34,7 +36,7 @@
3436
<span class="icon-bar"></span>
3537
<span class="icon-bar"></span>
3638
</button>
37-
<a class="navbar-brand" href="#">Project name</a>
39+
<a class="navbar-brand" href="#">{{ main_title }}</a>
3840
</div>
3941
<div id="navbar" class="collapse navbar-collapse">
4042
<ul class="nav navbar-nav">
@@ -48,14 +50,7 @@
4850
</nav>
4951

5052
<div class="container">
51-
52-
<div class="placeholder">
53-
<h1>Placeholder Text</h1>
54-
55-
<p class="lead">Use this document as a way to quickly start any new project.<br> All you get is this text and a
56-
mostly barebones HTML document.</p>
57-
</div>
58-
53+
{% block content %}{% endblock %}
5954
</div>
6055
<!-- /.container -->
6156

0 commit comments

Comments
 (0)