M cogito2/database/article.py +7 -3
@@ 1,11 1,15 @@
+import xml.etree.ElementTree as ET
+
class Article:
- def __init__(self, id, content, created_at):
+ def __init__(self, id, title, teasing, content, created_at):
self.id = id
+ self.title = title
+ self.teasing = teasing
self.content = content
self.created_at = created_at
def get_title(self):
- return "title"
+ return self.title
def get_teasing(self):
- return "teasing"
+ return self.teasing
def get_body(self):
return self.content
M cogito2/database/article_factory.py +6 -1
@@ 1,13 1,18 @@
from .article import Article
+from .markdown import get_html
from pathlib import PosixPath
from datetime import datetime
+from .htmlparser import get_teasing
def build_from_posix_file(posix_file: PosixPath, file_root_path=''):
file_path = str(posix_file)
id = file_path.replace(file_root_path, '').replace(posix_file.suffix, '')
+ content = get_html(posix_file.read_text())
return Article(
id=id,
- content=posix_file.read_text(),
+ title=posix_file.stem.replace('_', ' ').capitalize(),
+ teasing=get_teasing(content),
+ content=content,
created_at=datetime.fromtimestamp(posix_file.stat().st_ctime)
)
M cogito2/templates/show.html +0 -1
@@ 6,7 6,6 @@
Published {{ article.created_at.strftime('%Y-%m-%d') }} on <a href="{{ url_for('article_archive') }}">Eddie Barraco's blog</a>
</p>
<div>
- {{ article.get_teasing()|safe }}
{{ article.get_body()|safe }}
</div>
{% endblock %}