diff options
author | Yuchen Pei <me@ypei.me> | 2018-05-11 17:10:58 +0200 |
---|---|---|
committer | Yuchen Pei <me@ypei.me> | 2018-05-11 17:10:58 +0200 |
commit | db786e35abb644d83f78c21e8c4f10e1d6568a5e (patch) | |
tree | ddbc2df9a7072c86830122a89b7ac683a494c7e5 /engine | |
parent | 08a326a3a2fc423ce498b0d80edecb7e596f1f28 (diff) |
changed layout of blog.html
- cut post length on blog.html to synopsis, defaulted to one paragraph
long
- edited engine accordingly
Diffstat (limited to 'engine')
-rw-r--r-- | engine/engine.py | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/engine/engine.py b/engine/engine.py index 1ef0f8e..91532fd 100644 --- a/engine/engine.py +++ b/engine/engine.py @@ -3,6 +3,7 @@ import re import yaml import pypandoc import logging +from lxml import etree from pyatom import AtomFeed def item_from_path(path): @@ -21,6 +22,9 @@ def item_from_path(path): res['body'] = pypandoc.convert_text(matchres.group(2), 'html', format='vimwiki') elif ext == '.html': res['body'] = matchres.group(2) + res.setdefault('synlen', 1) + paras = etree.HTML(res['body']).xpath('//p') + res['synopsis'] = ''.join([etree.tostring(p, encoding='unicode') for p in paras[:res['synlen']]]) return res def combine(item, template): |