From d2fe5d01d54d5f6795cd746a23ba529a58da63a3 Mon Sep 17 00:00:00 2001 From: LongHairedHacker Date: Mon, 25 Jan 2016 16:13:00 +0100 Subject: [PATCH] Added page title as primary heading Added read more links to newsfeed Better templates for news in test folder Smaller cleanups --- test_input/templates/base.html | 1 + test_input/templates/newsfeed.html | 8 ++++++-- test_input/templates/newsfeed.rss | 14 +++++++++++++- verdandi/constants.py | 1 + verdandi/modules/newsfeed.py | 2 -- verdandi/modules/page.py | 2 ++ verdandi/verdandi.py | 5 +++-- 7 files changed, 26 insertions(+), 7 deletions(-) diff --git a/test_input/templates/base.html b/test_input/templates/base.html index 5a74e36..dcd2549 100644 --- a/test_input/templates/base.html +++ b/test_input/templates/base.html @@ -6,6 +6,7 @@ {{menu}}
{% block content %} +

{{page_title}}

{{content}}
Created: {{content_creation_time.strftime('%d.%m.%Y %H:%M:%S')}}
diff --git a/test_input/templates/newsfeed.html b/test_input/templates/newsfeed.html index 442bf2b..b981425 100644 --- a/test_input/templates/newsfeed.html +++ b/test_input/templates/newsfeed.html @@ -2,7 +2,11 @@ {% block content %} -{{items | pprint}} - +{% for item in items %} +
+

{{item.title}}

+ {{item.content}} +
+{% endfor %} {% endblock %} diff --git a/test_input/templates/newsfeed.rss b/test_input/templates/newsfeed.rss index 93e0d35..03e9809 100644 --- a/test_input/templates/newsfeed.rss +++ b/test_input/templates/newsfeed.rss @@ -1 +1,13 @@ -{{items | pprint}} + + + + {% for item in items %} + + {{item.title}} + {{item.url}} + {{item.content}} + {{item.creation_time.strftime('%d.%m.%Y %H:%M:%S')}} + + {% endfor %} + + diff --git a/verdandi/constants.py b/verdandi/constants.py index d95d0ee..e9558c6 100644 --- a/verdandi/constants.py +++ b/verdandi/constants.py @@ -8,3 +8,4 @@ MARKDOWN_EXTENSIONS = ['markdown.extensions.sane_lists', SERVE_PORT = 8000 +SERVE_BIND_ADDRESS = "0.0.0.0" diff --git a/verdandi/modules/newsfeed.py b/verdandi/modules/newsfeed.py index c0418be..fe9ac59 100644 --- a/verdandi/modules/newsfeed.py +++ b/verdandi/modules/newsfeed.py @@ -66,8 +66,6 @@ class NewsFeed(MenuItemMixin, TemplateMixin, AssetsMixin): rendered_items = sorted(rendered_items, key=lambda item: item['creation_time'], reverse=True) context['items'] = rendered_items - print rendered_items - return context diff --git a/verdandi/modules/page.py b/verdandi/modules/page.py index c7c55cd..d67e824 100644 --- a/verdandi/modules/page.py +++ b/verdandi/modules/page.py @@ -35,6 +35,8 @@ class Page(MenuItemMixin, NewsItemMixin, TemplateMixin, AssetsMixin): lines = self.content['content'].split('\n') elipsized_content = '\n'.join(lines[0:self.news_item_len]) + elipsized_content += '\n\n Read [more](%s) ...' % self.url + item = { 'title': self.title, 'content': elipsized_content, diff --git a/verdandi/verdandi.py b/verdandi/verdandi.py index 25e1e95..91b9b53 100644 --- a/verdandi/verdandi.py +++ b/verdandi/verdandi.py @@ -9,7 +9,7 @@ from SimpleHTTPServer import SimpleHTTPRequestHandler -from constants import OUTPUT_DIRECTORY, TEMPLATE_DIRECTORY, SERVE_PORT +from constants import OUTPUT_DIRECTORY, TEMPLATE_DIRECTORY, SERVE_PORT, SERVE_BIND_ADDRESS class Verdandi(object): @@ -58,5 +58,6 @@ class Verdandi(object): if len(sys.argv) > 1 and sys.argv[1] == 'serve': os.chdir(self.output_directory) - httpd = SocketServer.TCPServer(("0.0.0.0", SERVE_PORT), SimpleHTTPRequestHandler) + httpd = SocketServer.TCPServer((SERVE_BIND_ADDRESS, SERVE_PORT), SimpleHTTPRequestHandler) + print "Serving under %s:%d" % (SERVE_BIND_ADDRESS, SERVE_PORT) httpd.serve_forever()