simple extra pages
This commit is contained in:
parent
6f52b678b7
commit
95d11ef112
|
@ -90,6 +90,7 @@ post_props = [
|
||||||
# * index_tpl (facultative): template of the property values index
|
# * index_tpl (facultative): template of the property values index
|
||||||
#
|
#
|
||||||
# Filenames are relative to meta_dir and extensions are automatically added.
|
# Filenames are relative to meta_dir and extensions are automatically added.
|
||||||
|
# If filename contains an extension, it will override gmi_extension value.
|
||||||
# When a string value is facultative, it defaults to property name, except for
|
# When a string value is facultative, it defaults to property name, except for
|
||||||
# index_name, which disables property values global index if not specified.
|
# index_name, which disables property values global index if not specified.
|
||||||
index_props = [
|
index_props = [
|
||||||
|
@ -110,3 +111,22 @@ index_props = [
|
||||||
"index_tpl": "authors_index"
|
"index_tpl": "authors_index"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
# custom extra pages to generate
|
||||||
|
# Each entry will generate a single page.
|
||||||
|
# This is the place to define homepage and feed page for instance.
|
||||||
|
# Templates will have to handle the full unsorted list of posts.
|
||||||
|
# "name" key is mandatory. It is the filename of the page.
|
||||||
|
# If filename contains an extension, it will override gmi_extension value.
|
||||||
|
# "tpl" key is facultative, defaults to name (without extension if any)
|
||||||
|
custom_pages = [
|
||||||
|
{
|
||||||
|
"name": "index",
|
||||||
|
"tpl": "index"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "atom.xml",
|
||||||
|
"tpl": "atom"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
26
geminer.py
26
geminer.py
|
@ -146,11 +146,18 @@ for dirname, subdirlist, mdlist in os.walk(md_path):
|
||||||
with open(gmi_subpath + "/" + gmifile, "w") as gmi:
|
with open(gmi_subpath + "/" + gmifile, "w") as gmi:
|
||||||
gmi.write(gmitext)
|
gmi.write(gmitext)
|
||||||
|
|
||||||
# Generate home page
|
# Generate custom extra pages
|
||||||
with open(tpl_path + "/index.tpl", "r") as tpl:
|
for page_dict in custom_page:
|
||||||
|
rel_path, filename = os.path.split(page_dict["name"])
|
||||||
|
os.makedirs(rel_path, exist_ok=True)
|
||||||
|
basename, extension = os.path.spolitext(page_dict["name"])
|
||||||
|
if not extension:
|
||||||
|
extention = gmi_extension
|
||||||
|
filename = basename + extension
|
||||||
|
with open(tpm_path + "/" + page_dict.get("tpl", basename) + ".tpl", "r") as tpl:
|
||||||
template = Template(tpl.read())
|
template = Template(tpl.read())
|
||||||
text = template.render(posts=posts)
|
text = template.render(posts=posts)
|
||||||
with open(gmi_path + "/index.gmi", "w") as gmi:
|
with open(gmi_path + rel_path + "/" + filename, "w") as gmi:
|
||||||
gmi.write(text)
|
gmi.write(text)
|
||||||
|
|
||||||
# Generate custom meta pages
|
# Generate custom meta pages
|
||||||
|
@ -162,7 +169,7 @@ for prop_dict in config.index_props:
|
||||||
) as tpl:
|
) as tpl:
|
||||||
template = Template(tpl.read())
|
template = Template(tpl.read())
|
||||||
text = template.render(prop=posts_prop_index[prop])
|
text = template.render(prop=posts_prop_index[prop])
|
||||||
with open(gmi_path + "/" + prop_dict["index_name"] + ".gmi", "w") as gmi:
|
with open(gmi_path + "/" + prop_dict["index_name"] + gmi_extension, "w") as gmi:
|
||||||
gmi.write(text)
|
gmi.write(text)
|
||||||
os.makedirs(gmi_path + "/" + prop_dict.get("item_dir", prop), exist_ok=True)
|
os.makedirs(gmi_path + "/" + prop_dict.get("item_dir", prop), exist_ok=True)
|
||||||
with open(tpl_path + "/" + prop_dict.get("item_tpl", prop) + ".tpl", "r") as tpl:
|
with open(tpl_path + "/" + prop_dict.get("item_tpl", prop) + ".tpl", "r") as tpl:
|
||||||
|
@ -170,13 +177,6 @@ for prop_dict in config.index_props:
|
||||||
for item in posts_prop_index[prop]:
|
for item in posts_prop_index[prop]:
|
||||||
text = template.render(prop_item=posts_prop_index[prop][item])
|
text = template.render(prop_item=posts_prop_index[prop][item])
|
||||||
with open(
|
with open(
|
||||||
gmi_path + "/" + prop_dict.get("item_dir", prop) + "/" + item + ".gmi", "w"
|
gmi_path + "/" + prop_dict.get("item_dir", prop) + "/" + item + gmi_extension, "w"
|
||||||
) as gmi:
|
) as gmi:
|
||||||
gmi.write(text)
|
gmi.write(text)
|
||||||
|
|
||||||
# Generate posts list page
|
|
||||||
with open(tpl_path + "/posts_list.tpl", "r") as tpl:
|
|
||||||
template = Template(tpl.read())
|
|
||||||
text = template.render(posts=posts)
|
|
||||||
with open(gmi_path + "/posts.gmi", "w") as gmi:
|
|
||||||
gmi.write(text)
|
|
||||||
|
|
Loading…
Reference in New Issue