+ + +
+ ${nav_links(prev_link, next_link)} + +
+

${entry['title']}

+
+ ${formatter(entry['content'])} +
${show_timestamp(entry['timestamp'])}
+
+
+ + ${nav_links(prev_link, next_link)} +
+ + diff --git a/templates/layout.html b/templates/layout.html index 13dc1a1..6717905 100644 --- a/templates/layout.html +++ b/templates/layout.html @@ -4,45 +4,11 @@ - - ${select('*|text()')} + + ${select('*|text()')} - ") and html.endswith("

"): - 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('aktuellere' % prev_link) - if next_link: - result.append('ältere' % next_link) - return genshi.Markup(" | ".join(result)) - ?> - diff --git a/tycker.py b/tycker.py index 66893ae..e1af11d 100644 --- a/tycker.py +++ b/tycker.py @@ -34,19 +34,14 @@ for path in list(sys.path): if os.path.isdir(option): sys.path.append(option) -DATE_FORMAT = "%H:%M %d.%m.%Y" -PAGE_SIZE = 10 -FILENAME_TEMPLATE = "ticker%d.html" -FULL_PATH_FILENAME_TEMPLATE = os.path.join(BASE_DIR, os.path.pardir, FILENAME_TEMPLATE) -BASE_URL = "./" - import datetime import bobo import sqlobject import genshi.template +from settings import * -db_uri = "sqlite:///%s/tycker.sqlite" % BASE_DIR +db_uri = "sqlite://%s" % DB_FILE sqlobject.sqlhub.processConnection = sqlobject.connectionForURI(db_uri) loader = genshi.template.TemplateLoader(os.path.join(BASE_DIR, 'templates'), auto_reload=True) @@ -63,7 +58,7 @@ def render(filename, **values): return stream.render("html", doctype="html") def get_filename(index): - return FULL_PATH_FILENAME_TEMPLATE % index + return os.path.join(OUTPUT_DIR, FILENAME_TEMPLATE % index) def get_link(index): return FILENAME_TEMPLATE % index @@ -98,7 +93,7 @@ def submit_entry(entry_id=None, title=None, content=None, date=None): if not all((title, content, date)): return bobo.redirect(BASE_URL) try: - date = datetime.datetime.strptime(date, DATE_FORMAT) + date = datetime.datetime.strptime(date, DATE_FORMAT_FULL) except ValueError: bobo.redirect(BASE_URL) if entry_id is None: @@ -132,7 +127,7 @@ def generate_static(): def show_entries(): values = {} values["entries"] = Entry.select().orderBy("-timestamp") - values["date_format"] = DATE_FORMAT + values["date_format"] = DATE_FORMAT_FULL values["static_url"] = get_link(1) return render("admin_show_entries.html", **values)