admin interface with tab layout

This commit is contained in:
phil 2015-04-27 20:07:18 +00:00
parent 5d2a411f6a
commit a2c83f1b05
6 changed files with 153 additions and 97 deletions

View file

@ -0,0 +1,60 @@
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:py="http://genshi.edgewall.org/"
xmlns:xi="http://www.w3.org/2001/XInclude">
<xi:include href="layout.html" />
<head>
<title>Admin Ticker</title>
<link href="../admin.css" type="text/css" rel="stylesheet" />
<link href="../bootstrap/css/bootstrap.min.css" type="text/css" rel="stylesheet" media="all" />
<link href="../bootstrap/css/bootstrap-theme.min.css" type="text/css" rel="stylesheet" media="all" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
</head>
<body>
<div class="container theme-showcase" role="main">
<h1 id="title">Tycker Administration</h1>
<?python
import datetime
now = datetime.datetime.now()
?>
<div class="page-header"></div>
<ul class="nav nav-tabs">
<li role="presentation" class="active"><a href="#">New entry</a></li>
<li role="presentation"><a href="edit">All entries</a></li>
<li role="presentation"><a href="../../${static_url}" title="static website" target="_blank">Ticker</a></li>
</ul>
<div class="row">
<div class="col-xs-12 col-md-8">
<p>&nbsp;</p>
<div id="timestamp">
<form action="generate" method="GET">
<button type="submit" class="btn btn-default">Generate current timestamp</button>
</form>
</div>
<form action="submit" method="GET">
<div class="form-group">
<label for="Timestamp">Timestamp</label>
<input type="text" class="form-control" id="Timestamp" name="date" value="${now.strftime(date_format)}" />
</div>
<div class="form-group">
<label for="Title">Title</label>
<input type="text" class="form-control" id="Titel" name="title" value="" autofocus="autofocus" />
</div>
<div class="form-group">
<label for="Content">Content</label>
<textarea class="form-control" name="content" rows="8" cols="80" />
</div>
<button type="submit" class="btn btn-default">Create</button>
</form>
<p>&nbsp;</p>
</div>
<div class="col-xs-6 col-md-4">
<xi:include href="help.html" />
</div>
</div>
</div>
</body>
</html>

View file

@ -0,0 +1,57 @@
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:py="http://genshi.edgewall.org/"
xmlns:xi="http://www.w3.org/2001/XInclude">
<xi:include href="layout.html" />
<head>
<title>Admin Ticker</title>
<link href="../admin.css" type="text/css" rel="stylesheet" />
<link href="../bootstrap/css/bootstrap.min.css" type="text/css" rel="stylesheet" media="all" />
<link href="../bootstrap/css/bootstrap-theme.min.css" type="text/css" rel="stylesheet" media="all" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
</head>
<body>
<div class="container theme-showcase" role="main">
<h1 id="title">Tycker Administration</h1>
<?python
import datetime
now = datetime.datetime.now()
?>
<div class="page-header"></div>
<ul class="nav nav-tabs">
<li role="presentation"><a href="../admin">New entry</a></li>
<li role="presentation" class="active"><a href="#">All entries</a></li>
<li role="presentation"><a href="../../${static_url}" title="static website" target="_blank">Ticker</a></li>
</ul>
<div class="row">
<div class="col-xs-12 col-md-8">
<p>&nbsp;</p>
<div class="well" py:for="entry in entries">
<form action="submit" method="GET" >
<div class="form-group">
<input type="text" class="form-control" name="date" value="${entry['timestamp'].strftime(date_format)}" />
</div>
<div class="form-group">
<input type="text" class="form-control" name="title" value="${entry['title']}" />
</div>
<div class="form-group">
<textarea name="content" class="form-control" rows="8" cols="80">${entry['content']}</textarea>
</div>
<input type="hidden" name="entry_id" value="${entry.id}" /><button type="submit" class="btn btn-default">Update</button>
</form>
<br/>
<form action="delete" method="GET">
<input type="hidden" name="entry_id" value="${entry.id}" />
<button type="submit" class="btn btn-default">Delete</button>
</form>
</div>
</div>
<div class="col-xs-6 col-md-4">
<xi:include href="help.html" />
</div>
</div>
</div>
</body>
</html>

View file

@ -1,94 +0,0 @@
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:py="http://genshi.edgewall.org/"
xmlns:xi="http://www.w3.org/2001/XInclude">
<xi:include href="layout.html" />
<head>
<title>Admin Ticker</title>
<link href="../admin.css" type="text/css" rel="stylesheet" />
<link href="../bootstrap/css/bootstrap.min.css" type="text/css" rel="stylesheet" media="all" />
<link href="../bootstrap/css/bootstrap-theme.min.css" type="text/css" rel="stylesheet" media="all" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
</head>
<body>
<div class="container theme-showcase" role="main">
<h1 id="title">Tycker Administration</h1>
<?python
import datetime
now = datetime.datetime.now()
?>
<div class="page-header"></div>
<p><a href="../../${static_url}" title="static website">Show frontpage of this tycker</a></p>
<div id="help">
<p>The content may be written in <a href="http://www.wikicreole.org/imageServlet?page=CheatSheet%2Fcreole_cheat_sheet.png" target="_blank">wikicreole syntax</a>. Here are some examples:</p>
<dl>
<dt><strong>Emphasis</strong></dt>
<dd><em>//italics//</em>; <strong>**bold**</strong></dd>
<dt><strong>Links</strong></dt>
<dd>[[URL]]; [[URL|linkname]]</dd>
<dt><strong>Headings</strong></dt>
<dd>== Large heading; === Medium heading; ==== Small heading</dd>
<dt><strong>Lists</strong></dt>
<dd>* Bullet list; ** Sub item of bullet list; # Numbered list; ## Sub item of numbered list</dd>
<dt><strong>Line break</strong></dt>
<dd>Force\\Linebreak</dd>
<dt><strong>Howto</strong></dt>
<dd>1. Press "Generate current timestamp" button to insert the current timestamp<br/>2. Choose a title<br/>3. Create some content<br/>4. Press "Create" button to publish to frontpage</dd>
</dl>
</div>
<div id="timestamp">
<form action="generate" method="GET">
<button type="submit" class="btn btn-default">Generate current timestamp</button>
</form>
</div>
<form action="submit" method="GET">
<div class="form-group">
<label for="Timestamp">Timestamp</label>
<input type="text" class="form-control" id="Timestamp" name="date" value="${now.strftime(date_format)}" />
</div>
<div class="form-group">
<label for="Title">Title</label>
<input type="text" class="form-control" id="Titel" name="title" value="" autofocus="autofocus" />
</div>
<div class="form-group">
<label for="Content">Content</label>
<textarea class="form-control" name="content" rows="8" cols="80" />
</div>
<button type="submit" class="btn btn-default">Create</button>
</form>
<hr/>
<h3>Old entries</h3>
<div class="well" py:for="entry in entries">
<form action="submit" method="GET" >
<div class="form-group">
<input type="text" class="form-control" name="date" value="${entry['timestamp'].strftime(date_format)}" />
</div>
<div class="form-group">
<input type="text" class="form-control" name="title" value="${entry['title']}" />
</div>
<div class="form-group">
<textarea name="content" class="form-control" rows="8" cols="80">${entry['content']}</textarea>
</div>
<input type="hidden" name="entry_id" value="${entry.id}" /><button type="submit" class="btn btn-default">Update</button>
</form>
<br/>
<form action="delete" method="GET">
<input type="hidden" name="entry_id" value="${entry.id}" />
<button type="submit" class="btn btn-default">Delete</button>
</form>
</div>
</div>
</body>
</html>

View file

@ -40,7 +40,15 @@
${nav_links(prev_link, next_link)} ${nav_links(prev_link, next_link)}
</div> </div>
<div class="col-xs-6 col-md-4"><div id="clockbox"></div></div> <div class="col-xs-6 col-md-4">
<div class="panel panel-default">
<div class="panel-body">
<div id="clockbox"></div>
</div>
</div>
</div>
</div> </div>
</div> </div>
<div id="footer" class="page-footer" /> <div id="footer" class="page-footer" />

View file

@ -0,0 +1,17 @@
<div id="help">
<p>The content may be written in <a href="http://www.wikicreole.org/imageServlet?page=CheatSheet%2Fcreole_cheat_sheet.png" target="_blank">wikicreole syntax</a>. Here are some examples:</p>
<dl>
<dt><strong>Emphasis</strong></dt>
<dd><em>//italics//</em> <br/><strong>**bold**</strong></dd>
<dt><strong>Links</strong></dt>
<dd>[[URL]] <br/>[[URL|linkname]]</dd>
<dt><strong>Headings</strong></dt>
<dd>== Large heading <br/>=== Medium heading <br/>==== Small heading</dd>
<dt><strong>Lists</strong></dt>
<dd>* Bullet list <br/>** Sub item of bullet list <br/># Numbered list <br/>## Sub item of numbered list</dd>
<dt><strong>Line break</strong></dt>
<dd>Force\\Linebreak</dd>
<dt><strong>Howto</strong></dt>
<dd>1. Press "Generate current timestamp" button to insert the current timestamp<br/>2. Choose a title<br/>3. Create some content<br/>4. Press "Create" button to publish to frontpage</dd>
</dl>
</div>

View file

@ -124,12 +124,20 @@ def generate_static():
return bobo.redirect(BASE_URL) return bobo.redirect(BASE_URL)
@bobo.query('/') @bobo.query('/')
def show_entries(): def create_entry():
values = {} values = {}
values["entries"] = Entry.select().orderBy("-timestamp") values["entries"] = Entry.select().orderBy("-timestamp")
values["date_format"] = DATE_FORMAT_FULL values["date_format"] = DATE_FORMAT_FULL
values["static_url"] = get_link(1) values["static_url"] = get_link(1)
return render("admin_show_entries.html", **values) return render("admin_create.html", **values)
@bobo.query('/edit')
def edit_entries():
values = {}
values["entries"] = Entry.select().orderBy("-timestamp")
values["date_format"] = DATE_FORMAT_FULL
values["static_url"] = get_link(1)
return render("admin_edit.html", **values)
@bobo.query('') @bobo.query('')
def redirect_base(): def redirect_base():