refactor name
This commit is contained in:
parent
7568cdb2c3
commit
28f5aacab3
18
generate.py
18
generate.py
@ -20,6 +20,11 @@ template_environment = Environment(
|
||||
with open("metadata.json", "r") as f:
|
||||
metadata = load(f)
|
||||
|
||||
story_names = [
|
||||
path.basename(post).split('/')[-1][:-3] for post in glob(md_dir + "*")
|
||||
]
|
||||
story_names.sort()
|
||||
|
||||
for placename in metadata.keys():
|
||||
read_path = f"{out_dir}{placename}/"
|
||||
photos = [
|
||||
@ -126,24 +131,17 @@ def render_places():
|
||||
|
||||
def sub_http_local_urls(match):
|
||||
name = match.group(1)
|
||||
post_names = [
|
||||
path.basename(post).split('/')[-1][:-3] for post in glob(md_dir + "*")
|
||||
]
|
||||
if name in post_names:
|
||||
if name in story_names:
|
||||
return name + ".gmi"
|
||||
else:
|
||||
return match.group(0)
|
||||
|
||||
def render_gemini_index():
|
||||
template = template_environment.get_template("gemini_main")
|
||||
post_names = [
|
||||
path.basename(post).split('/')[-1][:-3] for post in glob(md_dir + "*")
|
||||
]
|
||||
post_names.sort()
|
||||
with open(gemini_out_dir + "index.gmi", "w") as f:
|
||||
f.write(template.render({
|
||||
"post_info": {post_name: metadata[post_name]["title"] for post_name in post_names},
|
||||
"post_states": {post_name: metadata[post_name]["state"] for post_name in post_names}
|
||||
"post_info": {post_name: metadata[post_name]["title"] for post_name in story_names},
|
||||
"post_states": {post_name: metadata[post_name]["state"] for post_name in story_names}
|
||||
}))
|
||||
|
||||
def render_gemini_places():
|
||||
|
Loading…
x
Reference in New Issue
Block a user