fix paths

This commit is contained in:
cellarspoon 2021-12-15 12:05:44 +01:00
parent 55050aa3f6
commit 30dbc6212f
No known key found for this signature in database
GPG Key ID: 03789458B3D0C410
4 changed files with 15 additions and 18 deletions

View File

@ -17,20 +17,20 @@ from natural import date
from slugify import slugify from slugify import slugify
# a publicly accessible ICS calendar # a publicly accessible ICS calendar
calendar_url = os.environ.get("CALENDAR_URL", "") calendar_url = os.environ.get("CALENDAR_URL")
# your Hugo content directory # your Hugo content directory
output_dir = os.environ.get("OUTPUT_DIR", "") output_dir = os.environ.get("OUTPUT_DIR")
cal = Calendar(requests.get(calendar_url).text) cal = Calendar(requests.get(calendar_url).text)
env = jinja2.Environment(loader=jinja2.FileSystemLoader(os.path.curdir)) template_dir = os.path.join(Path(__file__).parent.resolve(), "templates")
env = jinja2.Environment(loader=jinja2.FileSystemLoader(template_dir))
if not os.path.exists(output_dir): if not os.path.exists(output_dir):
os.mkdir(output_dir) os.mkdir(output_dir)
cwd = Path.resolve() template = env.get_template("calendar.md")
template = env.get_template(os.path.join(cwd, "templates" "calendar.md"))
existing_posts = os.listdir(output_dir) existing_posts = os.listdir(output_dir)

View File

@ -192,18 +192,15 @@ if not os.path.exists("etags"):
os.mkdir("etags") os.mkdir("etags")
env = jinja2.Environment(loader=jinja2.FileSystemLoader(os.path.curdir)) template_dir = os.path.join(Path(__file__).parent.resolve(), "templates")
env = jinja2.Environment(loader=jinja2.FileSystemLoader(template_dir))
output_dir = os.environ.get( output_dir = os.environ.get("OUTPUT_DIR")
"OUTPUT_DIR", "/home/r/Programming/lumbung.space/lumbung.space-web/content/posts/"
)
# output_dir = os.environ.get('OUTPUT_DIR', 'network/')
if not os.path.exists(output_dir): if not os.path.exists(output_dir):
os.makedirs(output_dir) os.makedirs(output_dir)
cwd = Path.resolve() template = env.get_template("feed.md")
template = env.get_template(os.path.join(cwd, "templates" "feed.md"))
# add iframe to the allowlist of feedparser's sanitizer, # add iframe to the allowlist of feedparser's sanitizer,
# this is now handled in parse_post() # this is now handled in parse_post()

View File

@ -111,13 +111,13 @@ mastodon = login_mastodon_bot()
output_dir = output_dir output_dir = output_dir
env = jinja2.Environment(loader=jinja2.FileSystemLoader(os.path.curdir)) template_dir = os.path.join(Path(__file__).parent.resolve(), "templates")
env = jinja2.Environment(loader=jinja2.FileSystemLoader(template_dir))
env.filters["localize_media_url"] = localize_media_url env.filters["localize_media_url"] = localize_media_url
env.filters["filter_mastodon_urls"] = filter_mastodon_urls env.filters["filter_mastodon_urls"] = filter_mastodon_urls
cwd = Path.resolve() template = env.get_template("hashtag.md")
template = env.get_template(os.path.join(cwd, "templates" "hashtag.md"))
if not os.path.exists(output_dir): if not os.path.exists(output_dir):

View File

@ -35,7 +35,8 @@ def linebreaks(text):
return br.sub(r"<br />\n", text) return br.sub(r"<br />\n", text)
env = jinja2.Environment(loader=jinja2.FileSystemLoader(os.path.curdir)) template_dir = os.path.join(Path(__file__).parent.resolve(), "templates")
env = jinja2.Environment(loader=jinja2.FileSystemLoader(template_dir))
env.filters["duration"] = duration env.filters["duration"] = duration
env.filters["linebreaks"] = linebreaks env.filters["linebreaks"] = linebreaks
@ -119,8 +120,7 @@ output_dir = os.environ.get(
if not os.path.exists(output_dir): if not os.path.exists(output_dir):
os.mkdir(output_dir) os.mkdir(output_dir)
cwd = Path.resolve() template = env.get_template("video.md")
template = env.get_template(os.path.join(cwd, "templates" "video.md"))
existing_posts = os.listdir(output_dir) existing_posts = os.listdir(output_dir)