move base url specification to config.py
This commit is contained in:
parent
c46ffec7fc
commit
9d1edbc90d
@ -5,7 +5,6 @@ set +e
|
|||||||
# Settings:
|
# Settings:
|
||||||
# =========
|
# =========
|
||||||
export CC=cc
|
export CC=cc
|
||||||
export URL=https://mjestecko.neocities.org
|
|
||||||
|
|
||||||
mkdir -p ./html/articles
|
mkdir -p ./html/articles
|
||||||
|
|
||||||
@ -24,7 +23,7 @@ for d in ./articles/*/; do
|
|||||||
mkdir -p "./html/articles/$(basename -- $d)"
|
mkdir -p "./html/articles/$(basename -- $d)"
|
||||||
cp -r "$d/.static/." "./html/articles/$(basename -- $d)/"
|
cp -r "$d/.static/." "./html/articles/$(basename -- $d)/"
|
||||||
fi
|
fi
|
||||||
./tools/article_wrapper.py "$d/page.mmd" $URL | ./tools/mmd/build/multimarkdown > "./html/articles/$(basename -- $d).html"
|
./tools/article_wrapper.py "$d/page.mmd" | ./tools/mmd/build/multimarkdown > "./html/articles/$(basename -- $d).html"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
@ -35,7 +34,7 @@ for f in ./html/tags/*.html; do
|
|||||||
echo $(cat "$f" | ./tools/mmd/build/multimarkdown) > "$f"
|
echo $(cat "$f" | ./tools/mmd/build/multimarkdown) > "$f"
|
||||||
done
|
done
|
||||||
|
|
||||||
./tools/feed_generator.py ./articles/ $URL > ./html/feed.xml
|
./tools/feed_generator.py ./articles/ > ./html/feed.xml
|
||||||
|
|
||||||
./tools/plaintext_article_listing_generator.py ./articles/ > ./html/articles.txt
|
./tools/plaintext_article_listing_generator.py ./articles/ > ./html/articles.txt
|
||||||
|
|
||||||
|
@ -5,6 +5,10 @@ from random import choice
|
|||||||
##
|
##
|
||||||
title = "mjestečko"
|
title = "mjestečko"
|
||||||
|
|
||||||
|
## Final hosting address, used in RSS feed absolute links as well as previews.
|
||||||
|
##
|
||||||
|
address = "https://mjestecko.neocities.org"
|
||||||
|
|
||||||
## Shows on top of every page providing navigation.
|
## Shows on top of every page providing navigation.
|
||||||
## Every entry forms a <li><a> child element of <nav>,
|
## Every entry forms a <li><a> child element of <nav>,
|
||||||
## where each dictionary pair forms an attached xml property.
|
## where each dictionary pair forms an attached xml property.
|
||||||
|
@ -10,14 +10,12 @@ from article_utils import the_line_after_metadata, parse_metadata
|
|||||||
from page_builder import wrap_page
|
from page_builder import wrap_page
|
||||||
from date_descriptions import MONTHS
|
from date_descriptions import MONTHS
|
||||||
|
|
||||||
|
import config
|
||||||
|
|
||||||
if len(argv) <= 1:
|
if len(argv) <= 1:
|
||||||
print("No file was supplied")
|
print("No file was supplied")
|
||||||
exit(-1)
|
exit(-1)
|
||||||
|
|
||||||
if len(argv) <= 2:
|
|
||||||
print("No address was supplied")
|
|
||||||
exit(-1)
|
|
||||||
|
|
||||||
with open(argv[1], "r") as f:
|
with open(argv[1], "r") as f:
|
||||||
content = f.readlines()
|
content = f.readlines()
|
||||||
i = the_line_after_metadata(content)
|
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>
|
header = f"""HTML header: <meta property="og:title" content="{title} on mjestečko"></meta>
|
||||||
<meta property="og:type" content="article"></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">
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
"""
|
"""
|
||||||
if not brief is None:
|
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:]))
|
front_image = re.compile(r"!\[.*\]\((.+?)\)", re.DOTALL).search(''.join(content[i:]))
|
||||||
if not front_image is None:
|
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:])))
|
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")
|
print("No directory was supplied")
|
||||||
exit(-1)
|
exit(-1)
|
||||||
|
|
||||||
if len(argv) <= 2:
|
|
||||||
print("No address was supplied")
|
|
||||||
exit(-1)
|
|
||||||
|
|
||||||
seed()
|
seed()
|
||||||
|
|
||||||
address = argv[2]
|
|
||||||
|
|
||||||
# todo: Find the latest pubDate
|
# todo: Find the latest pubDate
|
||||||
feed = f"""<rss version="2.0">
|
feed = f"""<rss version="2.0">
|
||||||
<channel>
|
<channel>
|
||||||
<title>{config.title}</title>
|
<title>{config.title}</title>
|
||||||
<link>{address}</link>
|
<link>{config.address}</link>
|
||||||
<description>{config.description() if callable(config.description) else config.description}</description>
|
<description>{config.description() if callable(config.description) else config.description}</description>
|
||||||
<language>{config.language}</language>
|
<language>{config.language}</language>
|
||||||
<lastBuildDate>{stringify_date(time.gmtime(int(time.time())))}</lastBuildDate>
|
<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"""
|
f""" <pubDate>{stringify_date(metadata["Date"])}</pubDate>\n"""
|
||||||
feed += (
|
feed += (
|
||||||
f""" <guid>/articles/{d}</guid>\n"""
|
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"
|
" </item>\n"
|
||||||
)
|
)
|
||||||
break
|
break
|
||||||
|
Loading…
Reference in New Issue
Block a user