initial upload
This commit is contained in:
parent
fd91316758
commit
745967b373
6 changed files with 269 additions and 0 deletions
42
pycker/templates/admin_show_entries.html
Normal file
42
pycker/templates/admin_show_entries.html
Normal file
|
@ -0,0 +1,42 @@
|
|||
<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>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<?python
|
||||
import datetime
|
||||
now = datetime.datetime.now()
|
||||
?>
|
||||
|
||||
<p><form action="generate" method="GET">
|
||||
<input type="submit" value="Generate" />
|
||||
<i><a href="../../${static_url}" title="static website">static website</a></i>
|
||||
</form></p>
|
||||
|
||||
<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="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="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>
|
||||
</form>
|
||||
<td><form action="delete" method="GET">
|
||||
<input type="hidden" name="entry_id" value="${entry.id}" />
|
||||
<input type="submit" value="Delete" />
|
||||
</form></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
</body>
|
||||
</html>
|
23
pycker/templates/display.html
Normal file
23
pycker/templates/display.html
Normal file
|
@ -0,0 +1,23 @@
|
|||
<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>Ticker</title>
|
||||
</head>
|
||||
|
||||
|
||||
<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()}
|
||||
|
||||
</body>
|
||||
</html>
|
54
pycker/templates/layout.html
Normal file
54
pycker/templates/layout.html
Normal file
|
@ -0,0 +1,54 @@
|
|||
<!DOCTYPE html>
|
||||
<html xmlns="http://www.w3.org/1999/xhtml"
|
||||
xmlns:py="http://genshi.edgewall.org/" py:strip="">
|
||||
|
||||
<py:match path="head" once="true">
|
||||
<head py:attrs="select('@*')">
|
||||
<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äge">aktuellere</a>' % prev_link)
|
||||
if next_link:
|
||||
result.append('<a href="%s" title="zeige ältere Einträge">ältere</a>' % next_link)
|
||||
return genshi.Markup(" | ".join(result))
|
||||
?>
|
||||
|
||||
<py:match path="body" once="true">
|
||||
<body py:attrs="select('@*')">
|
||||
|
||||
${select('*|text()')}
|
||||
|
||||
</body>
|
||||
</py:match>
|
||||
</html>
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue