WIP ajoute generation flux rss
This commit is contained in:
16
blog/blog.py
16
blog/blog.py
@@ -4,7 +4,7 @@ from pathlib import Path
|
||||
from blog.page import Page
|
||||
from blog.config import Config
|
||||
from jinja2 import Environment, FileSystemLoader, Template
|
||||
|
||||
from rss import RssFeed
|
||||
|
||||
class Blog:
|
||||
|
||||
@@ -34,6 +34,7 @@ class Blog:
|
||||
self._copy_css()
|
||||
self._build_all_pages(page_template)
|
||||
self._build_index(index_template)
|
||||
self._build_rss()
|
||||
|
||||
def _build_all_pages(self, template: Template):
|
||||
"""Convertit les pages markdown dans conf.inbox en html dans conf.outbox"""
|
||||
@@ -55,6 +56,19 @@ class Blog:
|
||||
with open(f"{self.conf.outbox}/index.html", "w+") as html_file:
|
||||
html_file.write(html_content)
|
||||
|
||||
def _build_rss(self):
|
||||
""" """
|
||||
feed = RssFeed(language="fr-fr", title=self.conf.title, link=self.conf.url, description=self.conf.presentation )
|
||||
for page in self.pages:
|
||||
feed.add_item(
|
||||
title = self.pages[page].meta["title"],
|
||||
link = Path(self.conf.url) / 'pages' / (page + '.html'),
|
||||
description = "Ma description a moi !",
|
||||
pubdate = self.pages[page].meta["date"]
|
||||
)
|
||||
with open(Path(self.conf.outbox) / "flux.rss", 'w+') as rss_file:
|
||||
feed.write(rss_file, 'utf-8')
|
||||
|
||||
def _copy_css(self):
|
||||
css_path = Path(self.conf.theme) / "css"
|
||||
dest_path = Path(self.conf.outbox) / "css"
|
||||
|
Reference in New Issue
Block a user