|
@@ -12,7 +12,7 @@
|
|
# along with Blogit.py; if not, write to the Free Software
|
|
# along with Blogit.py; if not, write to the Free Software
|
|
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
# ============================================================================
|
|
# ============================================================================
|
|
-# Copyright (C) 2013 Oz Nahum Tiram <nahumoz@gmail.com>
|
|
|
|
|
|
+# Copyright (C) 2013-2016 Oz Nahum Tiram <nahumoz@gmail.com>
|
|
# ============================================================================
|
|
# ============================================================================
|
|
|
|
|
|
# Note about Summary
|
|
# Note about Summary
|
|
@@ -47,7 +47,6 @@ import SimpleHTTPServer
|
|
import BaseHTTPServer
|
|
import BaseHTTPServer
|
|
import socket
|
|
import socket
|
|
import SocketServer
|
|
import SocketServer
|
|
-import yaml
|
|
|
|
from jinja2 import Environment, FileSystemLoader
|
|
from jinja2 import Environment, FileSystemLoader
|
|
import markdown2
|
|
import markdown2
|
|
import tinydb
|
|
import tinydb
|
|
@@ -261,12 +260,6 @@ class Entry(object):
|
|
GLOBAL_TEMPLATE_CONTEXT["site_url"]
|
|
GLOBAL_TEMPLATE_CONTEXT["site_url"]
|
|
)
|
|
)
|
|
|
|
|
|
- @property
|
|
|
|
- def body_html(self):
|
|
|
|
- return markdown2.markdown(self.body, extras=['fenced-code-blocks',
|
|
|
|
- 'hilite',
|
|
|
|
- 'tables'])
|
|
|
|
-
|
|
|
|
@property
|
|
@property
|
|
def permalink(self):
|
|
def permalink(self):
|
|
if self.kind == 'page':
|
|
if self.kind == 'page':
|
|
@@ -284,22 +277,14 @@ class Entry(object):
|
|
except KeyError:
|
|
except KeyError:
|
|
return []
|
|
return []
|
|
|
|
|
|
- def _read_header(self, file):
|
|
|
|
- header = ['---']
|
|
|
|
- while True:
|
|
|
|
- line = file.readline()
|
|
|
|
- line = line.rstrip()
|
|
|
|
- if not line:
|
|
|
|
- break
|
|
|
|
- header.append(line)
|
|
|
|
- header = yaml.load(StringIO('\n'.join(header)))
|
|
|
|
- # todo: dispatch header to attribute
|
|
|
|
- # todo: parse date from string to a datetime object
|
|
|
|
- return header
|
|
|
|
-
|
|
|
|
def prepare(self):
|
|
def prepare(self):
|
|
- file = codecs.open(self.abspath, 'r')
|
|
|
|
- self.header = self._read_header(file)
|
|
|
|
|
|
+
|
|
|
|
+ self.body_html = markdown2.markdown(codecs.open(self.abspath, 'r').read(),
|
|
|
|
+ extras=['fenced-code-blocks',
|
|
|
|
+ 'hilite',
|
|
|
|
+ 'tables', 'metadata'])
|
|
|
|
+ self.header = self.body_html.metadata
|
|
|
|
+ self.header['tags'] = self.header['tags'].split(',')
|
|
self.date = self.header.get('published', datetime.date.today())
|
|
self.date = self.header.get('published', datetime.date.today())
|
|
for k, v in self.header.items():
|
|
for k, v in self.header.items():
|
|
try:
|
|
try:
|
|
@@ -307,11 +292,6 @@ class Entry(object):
|
|
except:
|
|
except:
|
|
pass
|
|
pass
|
|
|
|
|
|
- body = file.readlines()
|
|
|
|
-
|
|
|
|
- self.body = ''.join(body)
|
|
|
|
- file.close()
|
|
|
|
-
|
|
|
|
@property
|
|
@property
|
|
def entry_template(self):
|
|
def entry_template(self):
|
|
template_name = self.header.get('template', 'entry.html')
|
|
template_name = self.header.get('template', 'entry.html')
|
|
@@ -617,5 +597,6 @@ def main(): # pragma: no coverage
|
|
if args.publish:
|
|
if args.publish:
|
|
publish()
|
|
publish()
|
|
|
|
|
|
|
|
+
|
|
if __name__ == '__main__': # pragma: no coverage
|
|
if __name__ == '__main__': # pragma: no coverage
|
|
main()
|
|
main()
|