parent
87c00ae761
commit
843463b548
|
@ -1,3 +1,5 @@
|
||||||
Jinja2==2.7.3
|
Jinja2==2.7.3
|
||||||
Markdown==2.6
|
Markdown==2.6
|
||||||
MarkupSafe==0.23
|
MarkupSafe==0.23
|
||||||
|
python-dateutil==2.4.2
|
||||||
|
six==1.10.0
|
||||||
|
|
|
@ -1,3 +1,6 @@
|
||||||
|
12.2.2014 13:37
|
||||||
|
12.2.2014 23:42
|
||||||
|
|
||||||
Test
|
Test
|
||||||
----
|
----
|
||||||
Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum.
|
Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum.
|
||||||
|
|
|
@ -1,3 +1,6 @@
|
||||||
|
1.1.2016 12:00
|
||||||
|
22.1.2016 17:00
|
||||||
|
|
||||||
First test
|
First test
|
||||||
==========
|
==========
|
||||||
This is a first test newsitem
|
This is a first test newsitem
|
||||||
|
|
|
@ -1,3 +1,6 @@
|
||||||
|
15.1.2016 12:00
|
||||||
|
22.1.2016 17:00
|
||||||
|
|
||||||
Second test
|
Second test
|
||||||
==========
|
==========
|
||||||
This is an other test newsitem
|
This is an other test newsitem
|
||||||
|
|
|
@ -2,6 +2,8 @@
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
|
||||||
|
from dateutil import parser
|
||||||
|
|
||||||
class TemplateMixin(object):
|
class TemplateMixin(object):
|
||||||
template = "base.html"
|
template = "base.html"
|
||||||
url = "index.html"
|
url = "index.html"
|
||||||
|
@ -30,3 +32,19 @@ class TemplateMixin(object):
|
||||||
out_file = open(out_path, "wb")
|
out_file = open(out_path, "wb")
|
||||||
out_file.write(result)
|
out_file.write(result)
|
||||||
out_file.close()
|
out_file.close()
|
||||||
|
|
||||||
|
|
||||||
|
def read_content_file(self, path):
|
||||||
|
content_file = open(path, 'r')
|
||||||
|
|
||||||
|
result = {}
|
||||||
|
|
||||||
|
first_line = content_file.readline()
|
||||||
|
second_line = content_file.readline()
|
||||||
|
|
||||||
|
result['content'] = content_file.read()
|
||||||
|
|
||||||
|
result['creation_time'] = parser.parse(first_line)
|
||||||
|
result['edit_time'] = parser.parse(second_line)
|
||||||
|
|
||||||
|
return result
|
||||||
|
|
|
@ -55,14 +55,9 @@ class NewsFeed(MenuItemMixin, TemplateMixin, AssetsMixin):
|
||||||
|
|
||||||
full_path = os.path.join(item_directory, news_file)
|
full_path = os.path.join(item_directory, news_file)
|
||||||
|
|
||||||
ctime = os.path.getctime(full_path)
|
item = self.read_content_file(full_path)
|
||||||
item['creation_time'] = datetime.fromtimestamp(ctime)
|
|
||||||
|
|
||||||
mtime = os.path.getmtime(full_path)
|
item['content'] = markdown_converter.convert(item['content'])
|
||||||
item['edit_time'] = datetime.fromtimestamp(mtime)
|
|
||||||
|
|
||||||
markdown_source = open(full_path, 'r').read()
|
|
||||||
item['content'] = markdown_converter.convert(markdown_source)
|
|
||||||
|
|
||||||
print item
|
print item
|
||||||
|
|
||||||
|
|
|
@ -25,13 +25,12 @@ class Page(MenuItemMixin, TemplateMixin, AssetsMixin):
|
||||||
full_path = os.path.join(self.content_directory, self.content_file)
|
full_path = os.path.join(self.content_directory, self.content_file)
|
||||||
markdown_converter = markdown.Markdown(extensions = self.markdown_extensions)
|
markdown_converter = markdown.Markdown(extensions = self.markdown_extensions)
|
||||||
|
|
||||||
ctime = os.path.getctime(full_path)
|
content = self.read_content_file(full_path)
|
||||||
context['content_creation_time'] = datetime.fromtimestamp(ctime)
|
|
||||||
|
|
||||||
mtime = os.path.getmtime(full_path)
|
context['content_creation_time'] = content['creation_time']
|
||||||
context['content_edit_time'] = datetime.fromtimestamp(mtime)
|
context['content_edit_time'] = content['edit_time']
|
||||||
|
|
||||||
markdown_source = open(full_path, 'r').read()
|
markdown_source = content['content']
|
||||||
context['content'] = markdown_converter.convert(markdown_source)
|
context['content'] = markdown_converter.convert(markdown_source)
|
||||||
|
|
||||||
return context
|
return context
|
||||||
|
|
|
@ -58,5 +58,5 @@ class Verdandi(object):
|
||||||
|
|
||||||
if len(sys.argv) > 1 and sys.argv[1] == 'serve':
|
if len(sys.argv) > 1 and sys.argv[1] == 'serve':
|
||||||
os.chdir(self.output_directory)
|
os.chdir(self.output_directory)
|
||||||
httpd = SocketServer.TCPServer(("", SERVE_PORT), SimpleHTTPRequestHandler)
|
httpd = SocketServer.TCPServer(("0.0.0.0", SERVE_PORT), SimpleHTTPRequestHandler)
|
||||||
httpd.serve_forever()
|
httpd.serve_forever()
|
||||||
|
|
Loading…
Reference in New Issue