Pages rendered in the RSS feed route shouldn't include the HTML head boilerplate
This commit is contained in:
parent
88a21c7112
commit
1cfa8c27db
3 changed files with 23 additions and 9 deletions
|
@ -97,7 +97,13 @@ class BlogApp(Flask):
|
||||||
|
|
||||||
return metadata
|
return metadata
|
||||||
|
|
||||||
def get_page(self, page: str, title: Optional[str] = None, skip_header: bool = False):
|
def get_page(
|
||||||
|
self,
|
||||||
|
page: str,
|
||||||
|
title: Optional[str] = None,
|
||||||
|
skip_header: bool = False,
|
||||||
|
skip_html_head: bool = False
|
||||||
|
):
|
||||||
if not page.endswith('.md'):
|
if not page.endswith('.md'):
|
||||||
page = page + '.md'
|
page = page + '.md'
|
||||||
|
|
||||||
|
@ -127,13 +133,15 @@ class BlogApp(Flask):
|
||||||
else None
|
else None
|
||||||
),
|
),
|
||||||
content=markdown(f.read(), extensions=['fenced_code', 'codehilite', MarkdownLatex()]),
|
content=markdown(f.read(), extensions=['fenced_code', 'codehilite', MarkdownLatex()]),
|
||||||
skip_header=skip_header
|
skip_header=skip_header,
|
||||||
|
skip_html_head=skip_html_head,
|
||||||
)
|
)
|
||||||
|
|
||||||
def get_pages(
|
def get_pages(
|
||||||
self,
|
self,
|
||||||
with_content: bool = False,
|
with_content: bool = False,
|
||||||
skip_header: bool = False,
|
skip_header: bool = False,
|
||||||
|
skip_html_head: bool = False,
|
||||||
sorter: Type[PagesSorter] = PagesSortByTime,
|
sorter: Type[PagesSorter] = PagesSortByTime,
|
||||||
reverse: bool = True,
|
reverse: bool = True,
|
||||||
) -> List[Tuple[int, dict]]:
|
) -> List[Tuple[int, dict]]:
|
||||||
|
@ -145,7 +153,8 @@ class BlogApp(Flask):
|
||||||
'content': (
|
'content': (
|
||||||
self.get_page(
|
self.get_page(
|
||||||
os.path.join(root, f),
|
os.path.join(root, f),
|
||||||
skip_header=skip_header
|
skip_header=skip_header,
|
||||||
|
skip_html_head=skip_html_head,
|
||||||
)
|
)
|
||||||
if with_content else ''
|
if with_content else ''
|
||||||
),
|
),
|
||||||
|
|
|
@ -75,7 +75,7 @@ def article_route(article: str):
|
||||||
|
|
||||||
@app.route('/rss', methods=['GET'])
|
@app.route('/rss', methods=['GET'])
|
||||||
def rss_route():
|
def rss_route():
|
||||||
pages = app.get_pages(with_content=True, skip_header=True)
|
pages = app.get_pages(with_content=True, skip_header=True, skip_html_head=True)
|
||||||
short_description = 'short' in request.args
|
short_description = 'short' in request.args
|
||||||
|
|
||||||
return Response('''<?xml version="1.0" encoding="UTF-8" ?>
|
return Response('''<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
|
|
|
@ -1,8 +1,11 @@
|
||||||
|
{% if not skip_html_head %}
|
||||||
{% with title=title, skip_header=skip_header or not config.header, styles=['/css/blog.css', '/css/code.css'] %}
|
{% with title=title, skip_header=skip_header or not config.header, styles=['/css/blog.css', '/css/code.css'] %}
|
||||||
{% include 'common-head.html' %}
|
{% include 'common-head.html' %}
|
||||||
{% endwith %}
|
{% endwith %}
|
||||||
|
|
||||||
<main>
|
<main>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
<div class="container">
|
<div class="container">
|
||||||
{% if not skip_header %}
|
{% if not skip_header %}
|
||||||
{% if title %}
|
{% if title %}
|
||||||
|
@ -48,6 +51,8 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{% include 'footer.html' %}
|
{% include 'footer.html' %}
|
||||||
</main>
|
|
||||||
|
|
||||||
|
{% if not skip_html_head %}
|
||||||
|
</main>
|
||||||
{% include 'common-tail.html' %}
|
{% include 'common-tail.html' %}
|
||||||
|
{% endif %}
|
||||||
|
|
Loading…
Reference in a new issue