From 6f6c856229e9b8cea89c82cf6705e7a69f01c9af Mon Sep 17 00:00:00 2001 From: Guy Godfroy Date: Wed, 9 Dec 2020 17:11:47 +0100 Subject: [PATCH] create an example folder --- .gitignore | 1 - config.py.example => example/config.py | 10 ++++----- example/md/firt_post.md | 9 +++++++++ example/templates/atom.tpl | 28 ++++++++++++++++++++++++++ example/templates/author.tpl | 5 +++++ example/templates/authors_index.tpl | 5 +++++ example/templates/index.tpl | 18 +++++++++++++++++ example/templates/post.tpl | 14 +++++++++++++ example/templates/posts_list.tpl | 5 +++++ example/templates/tag.tpl | 5 +++++ example/templates/tags_index.tpl | 5 +++++ 11 files changed, 99 insertions(+), 6 deletions(-) rename config.py.example => example/config.py (95%) create mode 100644 example/md/firt_post.md create mode 100644 example/templates/atom.tpl create mode 100644 example/templates/author.tpl create mode 100644 example/templates/authors_index.tpl create mode 100644 example/templates/index.tpl create mode 100644 example/templates/post.tpl create mode 100644 example/templates/posts_list.tpl create mode 100644 example/templates/tag.tpl create mode 100644 example/templates/tags_index.tpl diff --git a/.gitignore b/.gitignore index 3570422..bee8a64 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1 @@ -config.py __pycache__ diff --git a/config.py.example b/example/config.py similarity index 95% rename from config.py.example rename to example/config.py index 0471ec0..b7ff908 100644 --- a/config.py.example +++ b/example/config.py @@ -2,19 +2,19 @@ # It is not intended to be executed. # locale (for templates, for example dates rendering) -locale = "fr_FR.utf8" +locale = "en_US.utf8" # path to directory containing markdonw files to convert -md_path = "/srv/my-site-content/posts" +md_path = "/srv/gemini/example/md" # path to gemini blog root directory -gmi_path = "/srv/gemini/my-site" +gmi_path = "/srv/gemini/example/gmi" # directory within gmi_path which will contains converted posts posts_dir = "posts" # path to directory containing templates -tpl_path = "/srv/gemini/templates" +tpl_path = "/srv/gemini/example/templates" # list of markdown files extensions # Any file with a different extension will be ignored. @@ -40,7 +40,7 @@ gmi_extension = ".gmi" # Some CMS make you use some placeholders (for instance for assets URL). # You have to inform geminer of them here. replace = [ - ("%assets_url%", "https://hashtagueule.fr/assets") + ("%assets_url%", "https://example.com/assets") ] # md2gemini settings diff --git a/example/md/firt_post.md b/example/md/firt_post.md new file mode 100644 index 0000000..3bd5c65 --- /dev/null +++ b/example/md/firt_post.md @@ -0,0 +1,9 @@ +--- +title: "First post" +author: raspbeguy +date: 2020-12-09 +tags: foo,bar +--- +# I am a post + +Look at me! diff --git a/example/templates/atom.tpl b/example/templates/atom.tpl new file mode 100644 index 0000000..2946f1c --- /dev/null +++ b/example/templates/atom.tpl @@ -0,0 +1,28 @@ + + + My blog + Les gentils du net + + + {{ now().strftime('%FT%TZ') }} + + raspbeguy + + + gemini://example.com +{%- for post in posts|sort(attribute="date",reverse=True) %} + + {{ post.title }} + gemini://example.com/{{ post.path }} + + {{ post.date.strftime('%FT%TZ') }} + {{ post.date.strftime('%FT%TZ') }} + + {{ post.author.name }} + +{%- for tag in post.tags %} + +{%- endfor %} + +{%- endfor %} + diff --git a/example/templates/author.tpl b/example/templates/author.tpl new file mode 100644 index 0000000..c391fd1 --- /dev/null +++ b/example/templates/author.tpl @@ -0,0 +1,5 @@ +# Posts by {{ prop_item.name }} + +{% for post in prop_item.posts|sort(attribute="date",reverse=True) -%} +=> /{{ post.path }} [{{ post.date.strftime('%d/%m/%Y') }}] {{ post.title }} +{% endfor %} diff --git a/example/templates/authors_index.tpl b/example/templates/authors_index.tpl new file mode 100644 index 0000000..94e0401 --- /dev/null +++ b/example/templates/authors_index.tpl @@ -0,0 +1,5 @@ +# Authors list + +{% for author, value in prop.items()|sort(attribute='1.name') -%} +=> /authors/{{ author }}.gmi {{ value.name }} ({{ value.posts | length }} articles) +{% endfor %} diff --git a/example/templates/index.tpl b/example/templates/index.tpl new file mode 100644 index 0000000..fe91cdc --- /dev/null +++ b/example/templates/index.tpl @@ -0,0 +1,18 @@ +# My blog + +## I deserve all your attention. + +This is my blog. Please read it and like it. + +Last posts : +{% for post in (posts|sort(attribute="date",reverse=True))[:30] -%} +=> /{{ post.path }} {{ post.date.strftime('%Y-%m-%d') }} - {{ post.title }} +{% endfor %} +=> /posts.gmi All posts +=> /tags.gmi Tag list +=> /authors.gmi Authors list + +=> /atom.xml Atom feed + +This capsule has been generated by Geminer. +=> https://git.gugod.fr/raspbeguy/geminer Dépôt de Geminer diff --git a/example/templates/post.tpl b/example/templates/post.tpl new file mode 100644 index 0000000..d310232 --- /dev/null +++ b/example/templates/post.tpl @@ -0,0 +1,14 @@ +# {{ post.title }} + +by {{ post.author.name }}, on {{ post.date.strftime('%d %B %Y') }} +{% set tags = [] %}{% for tag in post.tags %}{{ tags.append(tag.name) or "" }}{% endfor %}{{ tags|join(", ") }} + +{{ post.content }} + +=> / Back to home +=> /authors/{{ post.author.slug }}.gmi More posts by {{ post.author.name }} + +Posts having those tags: +{% for tag in post.tags|sort(attribute="name") -%} +=> /tags/{{ tag.slug }}.gmi {{ tag.name }} +{% endfor %} diff --git a/example/templates/posts_list.tpl b/example/templates/posts_list.tpl new file mode 100644 index 0000000..93b335a --- /dev/null +++ b/example/templates/posts_list.tpl @@ -0,0 +1,5 @@ +# Posts list + +{% for post in posts|sort(attribute="date",reverse=True) -%} +=> /{{ post.path }} [{{ post.date.strftime('%d/%m/%Y') }}] {{ post.title }} +{% endfor %} diff --git a/example/templates/tag.tpl b/example/templates/tag.tpl new file mode 100644 index 0000000..cad38b0 --- /dev/null +++ b/example/templates/tag.tpl @@ -0,0 +1,5 @@ +# Posts with tag "{{ prop_item.name }}" + +{% for post in prop_item.posts|sort(attribute="date",reverse=True) -%} +=> /{{ post.path }} [{{ post.date.strftime('%d/%m/%Y') }}] {{ post.title }} +{% endfor %} diff --git a/example/templates/tags_index.tpl b/example/templates/tags_index.tpl new file mode 100644 index 0000000..6874a04 --- /dev/null +++ b/example/templates/tags_index.tpl @@ -0,0 +1,5 @@ +# Tags list + +{% for tag, value in prop.items()|sort(attribute='1.name') -%} +=> /tags/{{ tag }}.gmi {{ value.name }} ({{ value.posts | length }} articles) +{% endfor %}