pleroma posts

This commit is contained in:
sakrecoer 2020-12-25 16:42:47 +01:00
parent be4d11f0c0
commit d6783df90e
7 changed files with 136 additions and 4 deletions

3
.gitignore vendored
View file

@ -29,3 +29,6 @@ assets/albums/
# No Media Symbolic links # No Media Symbolic links
media media
# See if cloudcannon renders plugin
_data/pleroma.json

View file

@ -6,4 +6,6 @@ group :jekyll_plugins do
gem 'jekyll-sitemap' gem 'jekyll-sitemap'
gem 'jekyll-last-modified-at' gem 'jekyll-last-modified-at'
gem 'jekyll-image-size' gem 'jekyll-image-size'
gem "json"
gem "activesupport"
end end

View file

@ -1,6 +1,12 @@
GEM GEM
remote: https://rubygems.org/ remote: https://rubygems.org/
specs: 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) addressable (2.7.0)
public_suffix (>= 2.0.2, < 5.0) public_suffix (>= 2.0.2, < 5.0)
colorator (1.1.0) colorator (1.1.0)
@ -42,6 +48,7 @@ GEM
jekyll (>= 3.7, < 5.0) jekyll (>= 3.7, < 5.0)
jekyll-watch (2.2.1) jekyll-watch (2.2.1)
listen (~> 3.0) listen (~> 3.0)
json (2.5.1)
kramdown (2.3.0) kramdown (2.3.0)
rexml rexml
kramdown-parser-gfm (1.1.0) kramdown-parser-gfm (1.1.0)
@ -51,6 +58,7 @@ GEM
rb-fsevent (~> 0.10, >= 0.10.3) rb-fsevent (~> 0.10, >= 0.10.3)
rb-inotify (~> 0.9, >= 0.9.10) rb-inotify (~> 0.9, >= 0.9.10)
mercenary (0.4.0) mercenary (0.4.0)
minitest (5.14.2)
pathutil (0.16.2) pathutil (0.16.2)
forwardable-extended (~> 2.6) forwardable-extended (~> 2.6)
posix-spawn (0.3.15) posix-spawn (0.3.15)
@ -65,16 +73,21 @@ GEM
ffi (~> 1.9) ffi (~> 1.9)
terminal-table (1.8.0) terminal-table (1.8.0)
unicode-display_width (~> 1.1, >= 1.1.1) unicode-display_width (~> 1.1, >= 1.1.1)
tzinfo (2.0.4)
concurrent-ruby (~> 1.0)
unicode-display_width (1.7.0) unicode-display_width (1.7.0)
zeitwerk (2.4.2)
PLATFORMS PLATFORMS
ruby ruby
DEPENDENCIES DEPENDENCIES
activesupport
jekyll (= 4.1.1) jekyll (= 4.1.1)
jekyll-image-size jekyll-image-size
jekyll-last-modified-at jekyll-last-modified-at
jekyll-sitemap jekyll-sitemap
json
BUNDLED WITH BUNDLED WITH
2.1.4 2.1.4

View file

@ -30,8 +30,8 @@ banner-vert: /images/setto_logo.svg
icon: /images/setto-logoicon.svg icon: /images/setto-logoicon.svg
logo: /images/setto-logo.svg logo: /images/setto-logo.svg
logo-footer: /images/setto-logoicon-footer.svg logo-footer: /images/setto-logoicon-footer.svg
mediaurl: https://media.basspistol.com/setto.basspistol.com #mediaurl: https://media.basspistol.com/setto.basspistol.com
#mediaurl: /media mediaurl: /media
publisher: publisher:
name: Basspistol name: Basspistol
@ -165,6 +165,12 @@ _explore:
plugins: plugins:
# - jekyll-pwa-plugin # - jekyll-pwa-plugin
- jekyll-image-size - jekyll-image-size
plugins_dir: ./_plugins
jekyll_xml:
- data: pleroma
source: https://t.basspistol.org/users/setto/feed.atom
cache: true
# pwa: # pwa:
# enabled: false # Optional # enabled: false # Optional

View file

@ -23,6 +23,6 @@
name: Links name: Links
external_site: false external_site: false
- icon: 👋 - icon: 👋
url: '/chat/#read' url: 'https://matrix.to/#/!YQcdVviFQNGYFMYrxD:matrix.org'
name: Chat name: Chat
external_site: false external_site: true

View file

@ -0,0 +1,66 @@
##
# Download XML data from external sources
# Convert data to JSON and optionally save it to cache
#
# @author Derek Smart<derek@grindaga.com>
# @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

View file

@ -133,3 +133,45 @@ apps:
{% endif %} {% endif %}
{% endfor %} {% endfor %}
<section>
{% assign nasa = site.data.pleroma.feed.entry | sort: 'published' | reverse %}
{% for item in nasa %}
{% unless item.in_reply_to %}
{% if item.summary %}
<h2 style="text-align: left;">{{ item.summary }}</h2>
{% 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 }} <br />
{% for enclosure in item.link %}
{% if enclosure.type == "image/jpeg" %}
<img src="{{ enclosure.href }}" height="300px" />
{% endif %}
{% endfor %}
<hr />
{% endunless %}
{% endfor %}
</section>