leichte Layout-Aufhuebschungen

This commit is contained in:
lars 2015-04-25 21:58:21 +00:00
parent e84e413dd7
commit 297b268395
6 changed files with 85 additions and 61 deletions

View file

@ -20,13 +20,13 @@
<table border="1">
<tr><th>Timestamp</th><th>Title</th><th>Content</th></tr>
<tr><form action="submit" method="GET">
<td><input type="text" size="15" name="date" value="${now.strftime(date_format)}" /></td>
<td><input type="text" size="20" name="date" value="${now.strftime(date_format)}" /></td>
<td><input type="text" size="25" name="title" value="" autofocus="autofocus" /></td>
<td><textarea name="content" rows="8" cols="80" /></td>
<td><input type="submit" value="Create" /></td>
</form></tr>
<tr py:for="entry in entries"><form action="submit" method="GET">
<td><input type="text" size="15" name="date" value="${entry['timestamp'].strftime(date_format)}" /></td>
<td><input type="text" size="20" name="date" value="${entry['timestamp'].strftime(date_format)}" /></td>
<td><input type="text" size="25" name="title" value="${entry['title']}" /></td>
<td><textarea name="content" rows="8" cols="80">${entry['content']}</textarea></td>
<td><input type="hidden" name="entry_id" value="${entry.id}" /><input type="submit" value="Update" /></td>

View file

@ -1,23 +1,43 @@
<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" />
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" lang="en"
xmlns:w="http://www.example.org/widgets"
xmlns:xi="http://www.w3.org/2001/XInclude"
xmlns:py="http://genshi.edgewall.org/">
<head>
<title>Ticker</title>
<meta charset="utf-8" />
<link type="text/css" rel="stylesheet" media="all" href="bootstrap/css/bootstrap.min.css" />
<link type="text/css" rel="stylesheet" media="all" href="bootstrap/css/bootstrap-theme.min.css" />
<link type="text/css" rel="stylesheet" media="all" href="style.css" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
</head>
<?python from helpers import formatter, show_timestamp, nav_links ?>
<body>
${nav_links()}
<ul>
<li py:for="entry in entries">
<span class="timestamp">${show_timestamp(entry['timestamp'])}</span><br/>
<span class="title">${entry['title']}:</span>
<span class="content">${formatter(entry['content'])}</span>
</li>
</ul>
${nav_links()}
<div class="container theme-showcase" role="main">
<div class="page-header">
<h1 id="title" />
</div>
<div class="container">
${nav_links(prev_link, next_link)}
<div class="well" py:for="entry in entries">
<h2>${entry['title']}</h2>
<blockquote class="blockquote">
${formatter(entry['content'])}
<footer>${show_timestamp(entry['timestamp'])}</footer>
</blockquote>
</div>
${nav_links(prev_link, next_link)}
</div>
<div id="footer" class="page-footer" />
</div>
</body>
</html>

View file

@ -4,45 +4,11 @@
<py:match path="head" once="true">
<head py:attrs="select('@*')">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
${select('*|text()')}
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
${select('*|text()')}
</head>
</py:match>
<?python
import creoleparser
import genshi
import datetime
def formatter(text):
if not text:
return u""
text = text.replace("\\", "\\\\")
html = creoleparser.text2html(text, encoding=None).strip()
if html.startswith("<p>") and html.endswith("</p>"):
html = html[3:-4]
return genshi.Markup(html)
TODAY_FORMAT = "%H:%M"
FULL_FORMAT = "%d.%m.%y %H:%M"
last_day = datetime.datetime.today() - datetime.timedelta(days=1)
def show_timestamp(date):
if date <= last_day:
template = TODAY_FORMAT
else:
template = FULL_FORMAT
return date.strftime(template)
def nav_links():
result = []
if prev_link:
result.append('<a href="%s" title="zeige neuere Eintr&auml;ge">aktuellere</a>' % prev_link)
if next_link:
result.append('<a href="%s" title="zeige &auml;ltere Eintr&auml;ge">&auml;ltere</a>' % next_link)
return genshi.Markup(" | ".join(result))
?>
<py:match path="body" once="true">
<body py:attrs="select('@*')">