Fix RSS format
This commit is contained in:
parent
21b6e3e0f1
commit
3911e59d93
2 changed files with 12 additions and 9 deletions
|
@ -5,7 +5,7 @@
|
|||
<description>
|
||||
<![CDATA[
|
||||
<p>
|
||||
{{ content }}
|
||||
{{ content_rss }}
|
||||
</p>
|
||||
]]>
|
||||
</description>
|
||||
|
|
19
makesite.py
19
makesite.py
|
@ -101,9 +101,7 @@ def read_headers(text):
|
|||
def rfc_2822_format(date_str):
|
||||
"""Convert yyyy-mm-dd date string to RFC 2822 format date string."""
|
||||
d = datetime.datetime.strptime(date_str, "%Y-%m-%d")
|
||||
weekday = FRENCH_WEEKDAYS[d.weekday()]
|
||||
month = FRENCH_MONTHS[d.month - 1]
|
||||
return f"{weekday}, {d.day:02d} {month} {d.year} {d.strftime('%H:%M:%S')} +0000"
|
||||
return d.replace(tzinfo=datetime.timezone.utc).strftime('%a, %d %b %Y %H:%M:%S %z')
|
||||
|
||||
|
||||
def slugify(value):
|
||||
|
@ -119,7 +117,7 @@ def slugify(value):
|
|||
return re.sub("[-\s]+", "-", value)
|
||||
|
||||
|
||||
def read_content(filename):
|
||||
def read_content(filename, params):
|
||||
"""Read content and metadata from file into a dictionary."""
|
||||
# Read file content.
|
||||
text = fread(filename)
|
||||
|
@ -156,6 +154,7 @@ def read_content(filename):
|
|||
content.update(
|
||||
{
|
||||
"content": text,
|
||||
"content_rss": fix_relative_links(params["site_url"], text),
|
||||
"rfc_2822_date": rfc_2822_format(content["date"]),
|
||||
"summary": summary,
|
||||
}
|
||||
|
@ -164,6 +163,10 @@ def read_content(filename):
|
|||
return content
|
||||
|
||||
|
||||
def fix_relative_links(site_url, text):
|
||||
return text.replace("src=\"/images/20", "src=\"" + site_url + "/images/20")
|
||||
|
||||
|
||||
def clean_html_tag(text):
|
||||
"""Remove HTML tags."""
|
||||
while True:
|
||||
|
@ -207,7 +210,7 @@ def make_posts(
|
|||
|
||||
for posix_path in Path(src).glob(src_pattern):
|
||||
src_path = str(posix_path)
|
||||
content = read_content(src_path)
|
||||
content = read_content(src_path, params)
|
||||
|
||||
# render text / summary for basic fields
|
||||
content["content"] = render(content["content"], **params)
|
||||
|
@ -301,7 +304,7 @@ def make_notes(
|
|||
|
||||
for posix_path in Path(src).glob(src_pattern):
|
||||
src_path = str(posix_path)
|
||||
content = read_content(src_path)
|
||||
content = read_content(src_path, params)
|
||||
|
||||
# render text / summary for basic fields
|
||||
content["content"] = render(content["content"], **params)
|
||||
|
@ -539,7 +542,6 @@ def main(param_file):
|
|||
**params
|
||||
)
|
||||
|
||||
|
||||
# Create notes.
|
||||
notes = make_notes(
|
||||
"notes",
|
||||
|
@ -557,7 +559,8 @@ def main(param_file):
|
|||
archive_title_layout,
|
||||
None,
|
||||
**params
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
# Test parameter to be set temporarily by unit tests.
|
||||
_test = None
|
||||
|
|
Loading…
Add table
Reference in a new issue