move base url specification to config.py
This commit is contained in:
@ -10,14 +10,12 @@ from article_utils import the_line_after_metadata, parse_metadata
|
||||
from page_builder import wrap_page
|
||||
from date_descriptions import MONTHS
|
||||
|
||||
import config
|
||||
|
||||
if len(argv) <= 1:
|
||||
print("No file was supplied")
|
||||
exit(-1)
|
||||
|
||||
if len(argv) <= 2:
|
||||
print("No address was supplied")
|
||||
exit(-1)
|
||||
|
||||
with open(argv[1], "r") as f:
|
||||
content = f.readlines()
|
||||
i = the_line_after_metadata(content)
|
||||
@ -53,7 +51,7 @@ article_head += "---\n\n"
|
||||
|
||||
header = f"""HTML header: <meta property="og:title" content="{title} on mjestečko"></meta>
|
||||
<meta property="og:type" content="article"></meta>
|
||||
<meta property="og:url" content="{argv[2]}/articles/{urllib.parse.quote(directory)}.html"></meta>
|
||||
<meta property="og:url" content="{config.address}/articles/{urllib.parse.quote(directory)}.html"></meta>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
"""
|
||||
if not brief is None:
|
||||
@ -61,6 +59,6 @@ if not brief is None:
|
||||
|
||||
front_image = re.compile(r"!\[.*\]\((.+?)\)", re.DOTALL).search(''.join(content[i:]))
|
||||
if not front_image is None:
|
||||
header += f"""<meta property="og:image" content="{argv[2]}/{urllib.parse.quote(front_image.group(1))}"></meta>\n"""
|
||||
header += f"""<meta property="og:image" content="{config.address}/{urllib.parse.quote(front_image.group(1))}"></meta>\n"""
|
||||
|
||||
print(header + ''.join(content[:i]) + wrap_page(article_head + ''.join(content[i:])))
|
||||
|
@ -15,19 +15,13 @@ if len(argv) <= 1:
|
||||
print("No directory was supplied")
|
||||
exit(-1)
|
||||
|
||||
if len(argv) <= 2:
|
||||
print("No address was supplied")
|
||||
exit(-1)
|
||||
|
||||
seed()
|
||||
|
||||
address = argv[2]
|
||||
|
||||
# todo: Find the latest pubDate
|
||||
feed = f"""<rss version="2.0">
|
||||
<channel>
|
||||
<title>{config.title}</title>
|
||||
<link>{address}</link>
|
||||
<link>{config.address}</link>
|
||||
<description>{config.description() if callable(config.description) else config.description}</description>
|
||||
<language>{config.language}</language>
|
||||
<lastBuildDate>{stringify_date(time.gmtime(int(time.time())))}</lastBuildDate>
|
||||
@ -55,7 +49,7 @@ for root, dirs, _ in walk(argv[1]):
|
||||
f""" <pubDate>{stringify_date(metadata["Date"])}</pubDate>\n"""
|
||||
feed += (
|
||||
f""" <guid>/articles/{d}</guid>\n"""
|
||||
f""" <link>{address}/articles/{urllib.parse.quote(d)}</link>\n"""
|
||||
f""" <link>{config.address}/articles/{urllib.parse.quote(d)}</link>\n"""
|
||||
" </item>\n"
|
||||
)
|
||||
break
|
||||
|
Reference in New Issue
Block a user