From 30dbc6212f9bf946df7bd1fd623b76f98c9d7374 Mon Sep 17 00:00:00 2001 From: cellarspoon Date: Wed, 15 Dec 2021 12:05:44 +0100 Subject: [PATCH] fix paths --- lumbunglib/{calendar.py => cloudcal.py} | 10 +++++----- lumbunglib/feed.py | 11 ++++------- lumbunglib/hashtag.py | 6 +++--- lumbunglib/video.py | 6 +++--- 4 files changed, 15 insertions(+), 18 deletions(-) rename lumbunglib/{calendar.py => cloudcal.py} (95%) diff --git a/lumbunglib/calendar.py b/lumbunglib/cloudcal.py similarity index 95% rename from lumbunglib/calendar.py rename to lumbunglib/cloudcal.py index 5720420..98c546e 100644 --- a/lumbunglib/calendar.py +++ b/lumbunglib/cloudcal.py @@ -17,20 +17,20 @@ from natural import date from slugify import slugify # a publicly accessible ICS calendar -calendar_url = os.environ.get("CALENDAR_URL", "") +calendar_url = os.environ.get("CALENDAR_URL") # 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) -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): os.mkdir(output_dir) -cwd = Path.resolve() -template = env.get_template(os.path.join(cwd, "templates" "calendar.md")) +template = env.get_template("calendar.md") existing_posts = os.listdir(output_dir) diff --git a/lumbunglib/feed.py b/lumbunglib/feed.py index 8541085..886e4a5 100644 --- a/lumbunglib/feed.py +++ b/lumbunglib/feed.py @@ -192,18 +192,15 @@ if not os.path.exists("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", "/home/r/Programming/lumbung.space/lumbung.space-web/content/posts/" -) -# output_dir = os.environ.get('OUTPUT_DIR', 'network/') +output_dir = os.environ.get("OUTPUT_DIR") if not os.path.exists(output_dir): os.makedirs(output_dir) -cwd = Path.resolve() -template = env.get_template(os.path.join(cwd, "templates" "feed.md")) +template = env.get_template("feed.md") # add iframe to the allowlist of feedparser's sanitizer, # this is now handled in parse_post() diff --git a/lumbunglib/hashtag.py b/lumbunglib/hashtag.py index cb58c45..5111755 100644 --- a/lumbunglib/hashtag.py +++ b/lumbunglib/hashtag.py @@ -111,13 +111,13 @@ mastodon = login_mastodon_bot() 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["filter_mastodon_urls"] = filter_mastodon_urls -cwd = Path.resolve() -template = env.get_template(os.path.join(cwd, "templates" "hashtag.md")) +template = env.get_template("hashtag.md") if not os.path.exists(output_dir): diff --git a/lumbunglib/video.py b/lumbunglib/video.py index 92bdadd..ecf1d9b 100644 --- a/lumbunglib/video.py +++ b/lumbunglib/video.py @@ -35,7 +35,8 @@ def linebreaks(text): return br.sub(r"
\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["linebreaks"] = linebreaks @@ -119,8 +120,7 @@ output_dir = os.environ.get( if not os.path.exists(output_dir): os.mkdir(output_dir) -cwd = Path.resolve() -template = env.get_template(os.path.join(cwd, "templates" "video.md")) +template = env.get_template("video.md") existing_posts = os.listdir(output_dir)