From b611e04abd4576e65d2a9d9dd070d09a02d97aab Mon Sep 17 00:00:00 2001 From: EuAndreh Date: Sat, 14 Nov 2020 13:40:08 -0300 Subject: Generate feed files for all collections and languages --- _config.yml | 34 ++++++++++++++++--------------- _includes/link-listing.html | 2 +- _layouts/default.html | 8 ++++---- _layouts/slides.html | 2 +- _plugins/generate-feeds-for-categories.rb | 30 ++++++++++++++++++++++++--- feed.articles.en.atom | 3 --- feed.articles.eo.atom | 3 --- feed.articles.fr.atom | 3 --- feed.articles.pt.atom | 3 --- feed.pastebins.en.atom | 3 --- feed.pastebins.eo.atom | 3 --- feed.pastebins.fr.atom | 3 --- feed.pastebins.pt.atom | 3 --- feed.slides.en.atom | 3 --- feed.slides.eo.atom | 3 --- feed.slides.fr.atom | 3 --- feed.slides.pt.atom | 3 --- feed.tils.en.atom | 3 --- feed.tils.eo.atom | 3 --- feed.tils.fr.atom | 3 --- feed.tils.pt.atom | 3 --- 21 files changed, 51 insertions(+), 73 deletions(-) delete mode 100644 feed.articles.en.atom delete mode 100644 feed.articles.eo.atom delete mode 100644 feed.articles.fr.atom delete mode 100644 feed.articles.pt.atom delete mode 100644 feed.pastebins.en.atom delete mode 100644 feed.pastebins.eo.atom delete mode 100644 feed.pastebins.fr.atom delete mode 100644 feed.pastebins.pt.atom delete mode 100644 feed.slides.en.atom delete mode 100644 feed.slides.eo.atom delete mode 100644 feed.slides.fr.atom delete mode 100644 feed.slides.pt.atom delete mode 100644 feed.tils.en.atom delete mode 100644 feed.tils.eo.atom delete mode 100644 feed.tils.fr.atom delete mode 100644 feed.tils.pt.atom diff --git a/_config.yml b/_config.yml index 7bec895..49a94de 100644 --- a/_config.yml +++ b/_config.yml @@ -6,6 +6,8 @@ author: name: EuAndreh email: eu@euandre.org +langs: ['en', 'pt', 'fr', 'eo'] + permalink: /:year/:month/:day/:title:output_ext markdown: kramdown # default markdown renderer for Jekyll @@ -83,10 +85,10 @@ t: fr: "Blogue d'EuAndreh" eo: "Blogo de EuAndreh" url: - en: "feed.articles.en.atom" - pt: "feed.articles.pt.atom" - fr: "feed.articles.fr.atom" - eo: "feed.articles.eo.atom" + en: "/feed.articles.en.atom" + pt: "/feed.articles.pt.atom" + fr: "/feed.articles.fr.atom" + eo: "/feed.articles.eo.atom" pastebins: listing: en: "Pastebins listing" @@ -100,10 +102,10 @@ t: fr: "Pastebins d'EuAndreh" eo: "Pastebins de EuAndreh" url: - en: "feed.pastebins.en.atom" - pt: "feed.pastebins.pt.atom" - fr: "feed.pastebins.fr.atom" - eo: "feed.pastebins.eo.atom" + en: "/feed.pastebins.en.atom" + pt: "/feed.pastebins.pt.atom" + fr: "/feed.pastebins.fr.atom" + eo: "/feed.pastebins.eo.atom" tils: name: en: "TIL" @@ -127,10 +129,10 @@ t: fr: "AJA d'EuAndreh" eo: "HML de EuAndreh" url: - en: "feed.tils.en.atom" - pt: "feed.tils.pt.atom" - fr: "feed.tils.fr.atom" - eo: "feed.tils.eo.atom" + en: "/feed.tils.en.atom" + pt: "/feed.tils.pt.atom" + fr: "/feed.tils.fr.atom" + eo: "/feed.tils.eo.atom" slides: name: en: "Slides" @@ -154,10 +156,10 @@ t: fr: "Diapositives d'EuAndreh" eo: "Lumbildoj de EuAndreh" url: - en: "feed.slides.en.atom" - pt: "feed.slides.pt.atom" - fr: "feed.slides.fr.atom" - eo: "feed.slides.eo.atom" + en: "/feed.slides.en.atom" + pt: "/feed.slides.pt.atom" + fr: "/feed.slides.fr.atom" + eo: "/feed.slides.eo.atom" posted_on: en: "Posted on" pt: "Postado em" diff --git a/_includes/link-listing.html b/_includes/link-listing.html index 2ceaf6a..9252b7b 100644 --- a/_includes/link-listing.html +++ b/_includes/link-listing.html @@ -1,6 +1,6 @@

{{ site.t[include.kind].listing[page.lang] }} - + {{ site.t.alt.atom[page.lang] }}

diff --git a/_layouts/default.html b/_layouts/default.html index 71c4069..704525b 100644 --- a/_layouts/default.html +++ b/_layouts/default.html @@ -4,10 +4,10 @@ - - - - + + + + {{ page.title }} - EuAndreh diff --git a/_layouts/slides.html b/_layouts/slides.html index 839fe2a..4f99f52 100644 --- a/_layouts/slides.html +++ b/_layouts/slides.html @@ -3,7 +3,7 @@ - + {{ page.title }} - EuAndreh diff --git a/_plugins/generate-feeds-for-categories.rb b/_plugins/generate-feeds-for-categories.rb index f5cc8db..9958fba 100644 --- a/_plugins/generate-feeds-for-categories.rb +++ b/_plugins/generate-feeds-for-categories.rb @@ -1,5 +1,5 @@ module Jekyll - class FeedsForCategoriesGenerator < Generator + class FeedsGenerator < Generator safe true def gen_categories_index(site) @@ -23,7 +23,8 @@ module Jekyll categories_index end - def generate(site) + def feeds_by_category(site) + feed_pages = [] gen_categories_index(site).each do |collection_name, langs| langs.each do |lang, categories| categories.each do |category_name, articles| @@ -33,10 +34,33 @@ module Jekyll page.content = <<-EOF {% include feed.atom entries=site.#{collection_name} kind="#{collection_name}" lang="#{lang}" categories_filter="#{category_name}" %} EOF - site.pages << page + feed_pages << page end end end + feed_pages + end + + def global_feeds(site) + feed_pages = [] + langs = site.config['langs'] + collections = site.config['collections'].keys + langs.each do |lang| + collections.each do |collection| + feed_name = "feed.#{collection}.#{lang}.atom" + page = PageWithoutAFile.new(site, site.source, "", feed_name) + page.content = <<-EOF +{% include feed.atom entries=site.#{collection} kind="#{collection}" lang="#{lang}" %} + EOF + feed_pages << page + end + end + feed_pages + end + + def generate(site) + site.pages.concat(feeds_by_category(site)) + site.pages.concat(global_feeds(site)) end end diff --git a/feed.articles.en.atom b/feed.articles.en.atom deleted file mode 100644 index 929e9c8..0000000 --- a/feed.articles.en.atom +++ /dev/null @@ -1,3 +0,0 @@ ---- ---- -{% include feed.atom entries=site.articles kind="articles" lang="en" %} diff --git a/feed.articles.eo.atom b/feed.articles.eo.atom deleted file mode 100644 index 8e80177..0000000 --- a/feed.articles.eo.atom +++ /dev/null @@ -1,3 +0,0 @@ ---- ---- -{% include feed.atom entries=site.articles kind="articles" lang="eo" %} diff --git a/feed.articles.fr.atom b/feed.articles.fr.atom deleted file mode 100644 index 8c52673..0000000 --- a/feed.articles.fr.atom +++ /dev/null @@ -1,3 +0,0 @@ ---- ---- -{% include feed.atom entries=site.articles kind="articles" lang="fr" %} diff --git a/feed.articles.pt.atom b/feed.articles.pt.atom deleted file mode 100644 index f4f58ca..0000000 --- a/feed.articles.pt.atom +++ /dev/null @@ -1,3 +0,0 @@ ---- ---- -{% include feed.atom entries=site.articles kind="articles" lang="pt" %} diff --git a/feed.pastebins.en.atom b/feed.pastebins.en.atom deleted file mode 100644 index ea7e4bd..0000000 --- a/feed.pastebins.en.atom +++ /dev/null @@ -1,3 +0,0 @@ ---- ---- -{% include feed.atom entries=site.pastebins kind="pastebins" lang="en" %} diff --git a/feed.pastebins.eo.atom b/feed.pastebins.eo.atom deleted file mode 100644 index a95f6d4..0000000 --- a/feed.pastebins.eo.atom +++ /dev/null @@ -1,3 +0,0 @@ ---- ---- -{% include feed.atom entries=site.pastebins kind="pastebins" lang="eo" %} diff --git a/feed.pastebins.fr.atom b/feed.pastebins.fr.atom deleted file mode 100644 index 1e77095..0000000 --- a/feed.pastebins.fr.atom +++ /dev/null @@ -1,3 +0,0 @@ ---- ---- -{% include feed.atom entries=site.pastebins kind="pastebins" lang="fr" %} diff --git a/feed.pastebins.pt.atom b/feed.pastebins.pt.atom deleted file mode 100644 index 1e77095..0000000 --- a/feed.pastebins.pt.atom +++ /dev/null @@ -1,3 +0,0 @@ ---- ---- -{% include feed.atom entries=site.pastebins kind="pastebins" lang="fr" %} diff --git a/feed.slides.en.atom b/feed.slides.en.atom deleted file mode 100644 index 6874fc1..0000000 --- a/feed.slides.en.atom +++ /dev/null @@ -1,3 +0,0 @@ ---- ---- -{% include feed.atom entries=site.slides kind="slides" lang="en" %} diff --git a/feed.slides.eo.atom b/feed.slides.eo.atom deleted file mode 100644 index ddf55c1..0000000 --- a/feed.slides.eo.atom +++ /dev/null @@ -1,3 +0,0 @@ ---- ---- -{% include feed.atom entries=site.slides kind="slides" lang="eo" %} diff --git a/feed.slides.fr.atom b/feed.slides.fr.atom deleted file mode 100644 index 2476160..0000000 --- a/feed.slides.fr.atom +++ /dev/null @@ -1,3 +0,0 @@ ---- ---- -{% include feed.atom entries=site.slides kind="slides" lang="fr" %} diff --git a/feed.slides.pt.atom b/feed.slides.pt.atom deleted file mode 100644 index 4d44562..0000000 --- a/feed.slides.pt.atom +++ /dev/null @@ -1,3 +0,0 @@ ---- ---- -{% include feed.atom entries=site.slides kind="slides" lang="pt" %} diff --git a/feed.tils.en.atom b/feed.tils.en.atom deleted file mode 100644 index 97be510..0000000 --- a/feed.tils.en.atom +++ /dev/null @@ -1,3 +0,0 @@ ---- ---- -{% include feed.atom entries=site.tils kind="tils" lang="en" %} diff --git a/feed.tils.eo.atom b/feed.tils.eo.atom deleted file mode 100644 index 82ea975..0000000 --- a/feed.tils.eo.atom +++ /dev/null @@ -1,3 +0,0 @@ ---- ---- -{% include feed.atom entries=site.tils kind="tils" lang="eo" %} diff --git a/feed.tils.fr.atom b/feed.tils.fr.atom deleted file mode 100644 index 938c32d..0000000 --- a/feed.tils.fr.atom +++ /dev/null @@ -1,3 +0,0 @@ ---- ---- -{% include feed.atom entries=site.tils kind="tils" lang="fr" %} diff --git a/feed.tils.pt.atom b/feed.tils.pt.atom deleted file mode 100644 index d646e94..0000000 --- a/feed.tils.pt.atom +++ /dev/null @@ -1,3 +0,0 @@ ---- ---- -{% include feed.atom entries=site.tils kind="tils" lang="pt" %} -- cgit v1.2.3