Don't prepend images with the blog base URL if they are already full URLs
This commit is contained in:
parent
bf714a30bc
commit
43897cc961
1 changed files with 18 additions and 9 deletions
|
@ -1,5 +1,7 @@
|
||||||
import os
|
import os
|
||||||
|
import re
|
||||||
from typing import Optional
|
from typing import Optional
|
||||||
|
from urllib.parse import urljoin
|
||||||
|
|
||||||
from flask import (
|
from flask import (
|
||||||
jsonify,
|
jsonify,
|
||||||
|
@ -167,15 +169,22 @@ def rss_route():
|
||||||
base_link=config.link,
|
base_link=config.link,
|
||||||
title=page.get("title", "[No Title]"),
|
title=page.get("title", "[No Title]"),
|
||||||
link=page.get("uri", ""),
|
link=page.get("uri", ""),
|
||||||
published=page["published"].strftime(
|
published=(
|
||||||
"%a, %d %b %Y %H:%M:%S GMT"
|
page["published"].strftime("%a, %d %b %Y %H:%M:%S GMT")
|
||||||
)
|
if "published" in page
|
||||||
if "published" in page
|
else ""
|
||||||
else "",
|
),
|
||||||
content=page.get("description", "")
|
content=(
|
||||||
if short_description
|
page.get("description", "")
|
||||||
else page.get("content", ""),
|
if short_description
|
||||||
image=page.get("image", ""),
|
else page.get("content", "")
|
||||||
|
),
|
||||||
|
image=(
|
||||||
|
urljoin(config.link, page["image"])
|
||||||
|
if page.get("image")
|
||||||
|
and not re.search(r"^https?://", page["image"])
|
||||||
|
else page.get("image", "")
|
||||||
|
),
|
||||||
)
|
)
|
||||||
for _, page in pages
|
for _, page in pages
|
||||||
]
|
]
|
||||||
|
|
Loading…
Reference in a new issue