From d6783df90e8d1e1cb68217c442d7225324694705 Mon Sep 17 00:00:00 2001 From: sakrecoer Date: Fri, 25 Dec 2020 16:42:47 +0100 Subject: [PATCH] pleroma posts --- .gitignore | 3 ++ Gemfile | 2 ++ Gemfile.lock | 13 +++++++ _config.yml | 10 ++++-- _data/navigation.yml | 4 +-- _plugins/jekyll_xml_source.rb | 66 +++++++++++++++++++++++++++++++++++ index.html | 42 ++++++++++++++++++++++ 7 files changed, 136 insertions(+), 4 deletions(-) create mode 100644 _plugins/jekyll_xml_source.rb diff --git a/.gitignore b/.gitignore index 214cd01..1c12731 100644 --- a/.gitignore +++ b/.gitignore @@ -29,3 +29,6 @@ assets/albums/ # No Media Symbolic links media + +# See if cloudcannon renders plugin +_data/pleroma.json \ No newline at end of file diff --git a/Gemfile b/Gemfile index ae3cb88..052b126 100644 --- a/Gemfile +++ b/Gemfile @@ -6,4 +6,6 @@ group :jekyll_plugins do gem 'jekyll-sitemap' gem 'jekyll-last-modified-at' gem 'jekyll-image-size' + gem "json" + gem "activesupport" end diff --git a/Gemfile.lock b/Gemfile.lock index 2cd0d34..ee1a70b 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,6 +1,12 @@ GEM remote: https://rubygems.org/ specs: + activesupport (6.1.0) + concurrent-ruby (~> 1.0, >= 1.0.2) + i18n (>= 1.6, < 2) + minitest (>= 5.1) + tzinfo (~> 2.0) + zeitwerk (~> 2.3) addressable (2.7.0) public_suffix (>= 2.0.2, < 5.0) colorator (1.1.0) @@ -42,6 +48,7 @@ GEM jekyll (>= 3.7, < 5.0) jekyll-watch (2.2.1) listen (~> 3.0) + json (2.5.1) kramdown (2.3.0) rexml kramdown-parser-gfm (1.1.0) @@ -51,6 +58,7 @@ GEM rb-fsevent (~> 0.10, >= 0.10.3) rb-inotify (~> 0.9, >= 0.9.10) mercenary (0.4.0) + minitest (5.14.2) pathutil (0.16.2) forwardable-extended (~> 2.6) posix-spawn (0.3.15) @@ -65,16 +73,21 @@ GEM ffi (~> 1.9) terminal-table (1.8.0) unicode-display_width (~> 1.1, >= 1.1.1) + tzinfo (2.0.4) + concurrent-ruby (~> 1.0) unicode-display_width (1.7.0) + zeitwerk (2.4.2) PLATFORMS ruby DEPENDENCIES + activesupport jekyll (= 4.1.1) jekyll-image-size jekyll-last-modified-at jekyll-sitemap + json BUNDLED WITH 2.1.4 diff --git a/_config.yml b/_config.yml index bb0fc98..052bbd4 100644 --- a/_config.yml +++ b/_config.yml @@ -30,8 +30,8 @@ banner-vert: /images/setto_logo.svg icon: /images/setto-logoicon.svg logo: /images/setto-logo.svg logo-footer: /images/setto-logoicon-footer.svg -mediaurl: https://media.basspistol.com/setto.basspistol.com -#mediaurl: /media +#mediaurl: https://media.basspistol.com/setto.basspistol.com +mediaurl: /media publisher: name: Basspistol @@ -165,6 +165,12 @@ _explore: plugins: # - jekyll-pwa-plugin - jekyll-image-size +plugins_dir: ./_plugins + +jekyll_xml: + - data: pleroma + source: https://t.basspistol.org/users/setto/feed.atom + cache: true # pwa: # enabled: false # Optional diff --git a/_data/navigation.yml b/_data/navigation.yml index 0b90192..a9417d7 100644 --- a/_data/navigation.yml +++ b/_data/navigation.yml @@ -23,6 +23,6 @@ name: Links external_site: false - icon: 👋 - url: '/chat/#read' + url: 'https://matrix.to/#/!YQcdVviFQNGYFMYrxD:matrix.org' name: Chat - external_site: false \ No newline at end of file + external_site: true \ No newline at end of file diff --git a/_plugins/jekyll_xml_source.rb b/_plugins/jekyll_xml_source.rb new file mode 100644 index 0000000..e1631d0 --- /dev/null +++ b/_plugins/jekyll_xml_source.rb @@ -0,0 +1,66 @@ +## +# Download XML data from external sources +# Convert data to JSON and optionally save it to cache +# +# @author Derek Smart +# @copyright 2018 +# @license MIT + +require 'json' +require 'net/http' +require 'active_support/core_ext/hash' + +module Jekyll_Xml_Source + class Generator < Jekyll::Generator + safe true + priority :highest + + def saveToCache(data_source, name, content) + path = "#{data_source}/#{name}.json" + File.open(path,"w") do |file| + file.write(content) + end + end + + def loadFromCache(data_source, name) + path = "#{data_source}/#{name}.json" + if not File.exist?(path) + return + end + File.open(path,"r") do |file| + return JSON.load(file.read()) + end + end + + def generate(site) + config = site.config['jekyll_xml'] + data_source = (site.config['data_source'] || '_data') + + if !config + return + end + + config.each do |data| + if data['cache'] + site.data[data['data']] = loadFromCache(data_source, data['data']) + end + + if site.data[data['data']].nil? + begin + result = Net::HTTP.get_response(URI.parse(data['source'])).body + site.data[data['data']] = JSON.load(Hash.from_xml(result).to_json) + rescue + next + end + + if data['cache'] + saveToCache(data_source, data['data'], Hash.from_xml(result).to_json) + end + end + + end + + end + + end +end diff --git a/index.html b/index.html index 2a30ad5..ebe2f25 100644 --- a/index.html +++ b/index.html @@ -133,3 +133,45 @@ apps: {% endif %} {% endfor %} +
+ {% assign nasa = site.data.pleroma.feed.entry | sort: 'published' | reverse %} + {% for item in nasa %} +{% unless item.in_reply_to %} + {% if item.summary %} +

{{ item.summary }}

+ {% endif %} + {% assign d = item.published | date: "%-d" %} + {% case d %} + {% when '1' or '21' or '31' %}{{ d }}:st + {% when '2' or '22' %}{{ d }}:nd + {% when '3' or '23' %}{{ d }}:rd + {% else %}{{ d }}:th + {% endcase %} of + {% assign m = item.published | date: "%-m" %} + {% case m %} + {% when '1' %}January + {% when '2' %}February + {% when '3' %}March + {% when '4' %}April + {% when '5' %}May + {% when '6' %}June + {% when '7' %}July + {% when '8' %}August + {% when '9' %}September {% when '10' %}October {% when '11' %}November {% when '12' %}December + {% endcase %} + {{ item.published | date: "%Y" }} - {{ item.published | date: "%R" }} + + + + + {{ item.content }}
+ {% for enclosure in item.link %} + {% if enclosure.type == "image/jpeg" %} + + + {% endif %} + {% endfor %} +
+{% endunless %} + {% endfor %} +
\ No newline at end of file