Save source name when adding syndication target

This commit is contained in:
2024-05-27 20:50:58 +10:00
parent b894fe93fa
commit f5ba90cc89
3 changed files with 80 additions and 51 deletions

View File

@@ -36,7 +36,7 @@ GIT
GEM GEM
remote: https://rubygems.org/ remote: https://rubygems.org/
specs: specs:
activesupport (7.1.3.2) activesupport (7.1.3.3)
base64 base64
bigdecimal bigdecimal
concurrent-ruby (~> 1.0, >= 1.0.2) concurrent-ruby (~> 1.0, >= 1.0.2)
@@ -53,8 +53,10 @@ GEM
ast (2.4.2) ast (2.4.2)
babosa (2.0.0) babosa (2.0.0)
base64 (0.2.0) base64 (0.2.0)
bcrypt_pbkdf (1.1.0) bcrypt_pbkdf (1.1.1)
bigdecimal (3.1.7) bcrypt_pbkdf (1.1.1-arm64-darwin)
bcrypt_pbkdf (1.1.1-x86_64-darwin)
bigdecimal (3.1.8)
bskyrb (0.5.3) bskyrb (0.5.3)
date (>= 3.3.3) date (>= 3.3.3)
httparty (>= 0.21.0) httparty (>= 0.21.0)
@@ -87,7 +89,7 @@ GEM
date (3.3.4) date (3.3.4)
diff-lcs (1.5.1) diff-lcs (1.5.1)
domain_name (0.6.20240107) domain_name (0.6.20240107)
dotenv (3.1.0) dotenv (3.1.2)
down (5.4.2) down (5.4.2)
addressable (~> 2.8) addressable (~> 2.8)
drb (2.2.1) drb (2.2.1)
@@ -107,7 +109,7 @@ GEM
dry-files (1.1.0) dry-files (1.1.0)
dry-inflector (1.0.0) dry-inflector (1.0.0)
dry-initializer (3.1.1) dry-initializer (3.1.1)
dry-logger (1.0.3) dry-logger (1.0.4)
dry-logic (1.5.0) dry-logic (1.5.0)
concurrent-ruby (~> 1.0) concurrent-ruby (~> 1.0)
dry-core (~> 1.0, < 2) dry-core (~> 1.0, < 2)
@@ -122,7 +124,7 @@ GEM
dry-configurable (~> 1.0, < 2) dry-configurable (~> 1.0, < 2)
dry-core (~> 1.0, < 2) dry-core (~> 1.0, < 2)
dry-events (~> 1.0, < 2) dry-events (~> 1.0, < 2)
dry-schema (1.13.3) dry-schema (1.13.4)
concurrent-ruby (~> 1.0) concurrent-ruby (~> 1.0)
dry-configurable (~> 1.0, >= 1.0.1) dry-configurable (~> 1.0, >= 1.0.1)
dry-core (~> 1.0, < 2) dry-core (~> 1.0, < 2)
@@ -260,18 +262,19 @@ GEM
http-accept (1.7.0) http-accept (1.7.0)
http-cookie (1.0.5) http-cookie (1.0.5)
domain_name (~> 0.5) domain_name (~> 0.5)
httparty (0.21.0) httparty (0.22.0)
csv
mini_mime (>= 1.0.0) mini_mime (>= 1.0.0)
multi_xml (>= 0.5.2) multi_xml (>= 0.5.2)
i18n (1.14.4) i18n (1.14.5)
concurrent-ruby (~> 1.0) concurrent-ruby (~> 1.0)
ice_nine (0.11.2) ice_nine (0.11.2)
image_processing (1.12.2) image_processing (1.12.2)
mini_magick (>= 4.9.5, < 5) mini_magick (>= 4.9.5, < 5)
ruby-vips (>= 2.0.17, < 3) ruby-vips (>= 2.0.17, < 3)
io-console (0.7.2) io-console (0.7.2)
irb (1.12.0) irb (1.13.1)
rdoc rdoc (>= 4.0.0)
reline (>= 0.4.2) reline (>= 0.4.2)
json (2.7.2) json (2.7.2)
jwt (2.8.1) jwt (2.8.1)
@@ -294,12 +297,13 @@ GEM
method_source (1.1.0) method_source (1.1.0)
mime-types (3.5.2) mime-types (3.5.2)
mime-types-data (~> 3.2015) mime-types-data (~> 3.2015)
mime-types-data (3.2024.0305) mime-types-data (3.2024.0507)
mini_magick (4.12.0) mini_magick (4.12.0)
mini_mime (1.1.5) mini_mime (1.1.5)
minitest (5.22.3) minitest (5.23.1)
multi_xml (0.6.0) multi_xml (0.7.1)
multipart-post (2.4.0) bigdecimal (~> 3.1)
multipart-post (2.4.1)
mustermann (3.0.0) mustermann (3.0.0)
ruby2_keywords (~> 0.0.1) ruby2_keywords (~> 0.0.1)
mustermann-contrib (3.0.0) mustermann-contrib (3.0.0)
@@ -307,7 +311,7 @@ GEM
mustermann (= 3.0.0) mustermann (= 3.0.0)
mutex_m (0.2.0) mutex_m (0.2.0)
nenv (0.3.0) nenv (0.3.0)
net-imap (0.4.10) net-imap (0.4.11)
date date
net-protocol net-protocol
net-pop (0.1.2) net-pop (0.1.2)
@@ -322,12 +326,12 @@ GEM
net-protocol net-protocol
net-ssh (7.2.3) net-ssh (7.2.3)
netrc (0.11.0) netrc (0.11.0)
nio4r (2.7.1) nio4r (2.7.3)
nokogiri (1.16.4-arm64-darwin) nokogiri (1.16.5-arm64-darwin)
racc (~> 1.4) racc (~> 1.4)
nokogiri (1.16.4-x86_64-darwin) nokogiri (1.16.5-x86_64-darwin)
racc (~> 1.4) racc (~> 1.4)
nokogiri (1.16.4-x86_64-linux) nokogiri (1.16.5-x86_64-linux)
racc (~> 1.4) racc (~> 1.4)
notiffany (0.1.3) notiffany (0.1.3)
nenv (~> 0.1) nenv (~> 0.1)
@@ -346,7 +350,7 @@ GEM
activesupport activesupport
httparty httparty
parallel (1.24.0) parallel (1.24.0)
parser (3.3.0.5) parser (3.3.1.0)
ast (~> 2.4.1) ast (~> 2.4.1)
racc racc
pg (1.5.6) pg (1.5.6)
@@ -359,9 +363,9 @@ GEM
puma (6.4.2) puma (6.4.2)
nio4r (~> 2.0) nio4r (~> 2.0)
que (2.3.0) que (2.3.0)
racc (1.7.3) racc (1.8.0)
rack (2.2.9) rack (2.2.9)
rack-contrib (2.4.0) rack-contrib (2.5.0)
rack (< 4) rack (< 4)
rack-rewrite (1.5.1) rack-rewrite (1.5.1)
rack-session (1.0.2) rack-session (1.0.2)
@@ -371,17 +375,17 @@ GEM
rainbow (3.1.1) rainbow (3.1.1)
rake (13.2.1) rake (13.2.1)
rb-fsevent (0.11.2) rb-fsevent (0.11.2)
rb-inotify (0.10.1) rb-inotify (0.11.1)
ffi (~> 1.0) ffi (~> 1.0)
rdoc (6.6.3.1) rdoc (6.7.0)
psych (>= 4.0.0) psych (>= 4.0.0)
redcarpet (3.6.0) redcarpet (3.6.0)
redis (5.2.0) redis (5.2.0)
redis-client (>= 0.22.0) redis-client (>= 0.22.0)
redis-client (0.22.1) redis-client (0.22.2)
connection_pool connection_pool
regexp_parser (2.9.0) regexp_parser (2.9.2)
reline (0.5.2) reline (0.5.7)
io-console (~> 0.5) io-console (~> 0.5)
rest-client (2.1.0) rest-client (2.1.0)
http-accept (>= 1.7.0, < 2.0) http-accept (>= 1.7.0, < 2.0)
@@ -390,16 +394,17 @@ GEM
netrc (~> 0.8) netrc (~> 0.8)
reverse_markdown (2.1.1) reverse_markdown (2.1.1)
nokogiri nokogiri
rexml (3.2.6) rexml (3.2.8)
rom (5.3.0) strscan (>= 3.0.9)
rom (5.3.2)
rom-changeset (~> 5.3, >= 5.3.0) rom-changeset (~> 5.3, >= 5.3.0)
rom-core (~> 5.3, >= 5.3.0) rom-core (~> 5.3, >= 5.3.2)
rom-repository (~> 5.3, >= 5.3.0) rom-repository (~> 5.3, >= 5.3.0)
rom-changeset (5.3.0) rom-changeset (5.3.0)
dry-core (~> 1.0) dry-core (~> 1.0)
rom-core (~> 5.3) rom-core (~> 5.3)
transproc (~> 1.0, >= 1.1.0) transproc (~> 1.0, >= 1.1.0)
rom-core (5.3.1) rom-core (5.3.2)
concurrent-ruby (~> 1.1) concurrent-ruby (~> 1.1)
dry-configurable (~> 1.0) dry-configurable (~> 1.0)
dry-core (~> 1.0) dry-core (~> 1.0)
@@ -418,7 +423,7 @@ GEM
dry-core (~> 1.0) dry-core (~> 1.0)
dry-initializer (~> 3.0, >= 3.0.1) dry-initializer (~> 3.0, >= 3.0.1)
rom-core (~> 5.3, >= 5.3.0) rom-core (~> 5.3, >= 5.3.0)
rom-sql (3.6.2) rom-sql (3.6.3)
dry-core (~> 1.0) dry-core (~> 1.0)
dry-types (~> 1.0) dry-types (~> 1.0)
rom (~> 5.2, >= 5.2.1) rom (~> 5.2, >= 5.2.1)
@@ -432,11 +437,11 @@ GEM
rspec-expectations (3.13.0) rspec-expectations (3.13.0)
diff-lcs (>= 1.2.0, < 2.0) diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.13.0) rspec-support (~> 3.13.0)
rspec-mocks (3.13.0) rspec-mocks (3.13.1)
diff-lcs (>= 1.2.0, < 2.0) diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.13.0) rspec-support (~> 3.13.0)
rspec-support (3.13.1) rspec-support (3.13.1)
rubocop (1.62.1) rubocop (1.63.5)
json (~> 2.3) json (~> 2.3)
language_server-protocol (>= 3.17.0) language_server-protocol (>= 3.17.0)
parallel (~> 1.10) parallel (~> 1.10)
@@ -447,11 +452,11 @@ GEM
rubocop-ast (>= 1.31.1, < 2.0) rubocop-ast (>= 1.31.1, < 2.0)
ruby-progressbar (~> 1.7) ruby-progressbar (~> 1.7)
unicode-display_width (>= 2.4.0, < 3.0) unicode-display_width (>= 2.4.0, < 3.0)
rubocop-ast (1.31.2) rubocop-ast (1.31.3)
parser (>= 3.3.0.4) parser (>= 3.3.1.0)
rubocop-performance (1.20.2) rubocop-performance (1.21.0)
rubocop (>= 1.48.1, < 2.0) rubocop (>= 1.48.1, < 2.0)
rubocop-ast (>= 1.30.0, < 2.0) rubocop-ast (>= 1.31.1, < 2.0)
ruby-progressbar (1.13.0) ruby-progressbar (1.13.0)
ruby-readability (0.7.0) ruby-readability (0.7.0)
guess_html_encoding (>= 0.0.4) guess_html_encoding (>= 0.0.4)
@@ -462,7 +467,7 @@ GEM
sanitize (6.1.0) sanitize (6.1.0)
crass (~> 1.0.2) crass (~> 1.0.2)
nokogiri (>= 1.12.0) nokogiri (>= 1.12.0)
sequel (5.79.0) sequel (5.80.0)
bigdecimal bigdecimal
shellany (0.0.1) shellany (0.0.1)
simple-rss (1.3.3) simple-rss (1.3.3)
@@ -472,29 +477,30 @@ GEM
snaky_hash (2.0.1) snaky_hash (2.0.1)
hashie hashie
version_gem (~> 1.1, >= 1.1.1) version_gem (~> 1.1, >= 1.1.1)
sshkit (1.22.1) sshkit (1.22.2)
base64 base64
mutex_m mutex_m
net-scp (>= 1.1.2) net-scp (>= 1.1.2)
net-sftp (>= 2.1.2) net-sftp (>= 2.1.2)
net-ssh (>= 2.8.0) net-ssh (>= 2.8.0)
standard (1.35.1) standard (1.36.0)
language_server-protocol (~> 3.17.0.2) language_server-protocol (~> 3.17.0.2)
lint_roller (~> 1.0) lint_roller (~> 1.0)
rubocop (~> 1.62.0) rubocop (~> 1.63.0)
standard-custom (~> 1.0.0) standard-custom (~> 1.0.0)
standard-performance (~> 1.3) standard-performance (~> 1.4)
standard-custom (1.0.2) standard-custom (1.0.2)
lint_roller (~> 1.0) lint_roller (~> 1.0)
rubocop (~> 1.50) rubocop (~> 1.50)
standard-performance (1.3.1) standard-performance (1.4.0)
lint_roller (~> 1.1) lint_roller (~> 1.1)
rubocop-performance (~> 1.20.2) rubocop-performance (~> 1.21.0)
standardrb (1.0.1) standardrb (1.0.1)
standard standard
steam-api (1.2.0) steam-api (1.2.0)
faraday (~> 1.0) faraday (~> 1.0)
stringio (3.1.0) stringio (3.1.0)
strscan (3.1.0)
temple (0.10.3) temple (0.10.3)
thor (1.3.1) thor (1.3.1)
tilt (2.3.0) tilt (2.3.0)
@@ -508,9 +514,9 @@ GEM
unicode-emoji (3.4.0) unicode-emoji (3.4.0)
unicode-version (~> 1.0) unicode-version (~> 1.0)
unicode-version (1.4.0) unicode-version (1.4.0)
vernier (0.7.0) vernier (1.0.1)
version_gem (1.1.4) version_gem (1.1.4)
warning (1.3.0) warning (1.4.0)
whenever (1.0.0) whenever (1.0.0)
chronic (>= 0.6.3) chronic (>= 0.6.3)
xml-simple (1.1.9) xml-simple (1.1.9)
@@ -519,7 +525,7 @@ GEM
date date
httparty httparty
json (>= 2.0) json (>= 2.0)
zeitwerk (2.6.13) zeitwerk (2.6.15)
PLATFORMS PLATFORMS
arm64-darwin-23 arm64-darwin-23

View File

@@ -5,7 +5,8 @@ module Micropub
include Deps[ include Deps[
"repos.post_repo", "repos.post_repo",
"renderers.markdown", "renderers.markdown",
"commands.posts.add_syndication_source" "commands.posts.add_syndication_source",
"queries.posts.syndication_url_to_source"
] ]
def call(params:) def call(params:)
@@ -31,7 +32,8 @@ module Micropub
if params.key? :add if params.key? :add
attrs_to_add = {} attrs_to_add = {}
syndication = params[:add].delete(:syndication)&.first syndication_url = params[:add].delete(:syndication)&.first
syndication_source = syndication_url_to_source.call(url: syndication_url) if syndication_url && !syndication_url.empty?
tags = params[:add].delete(:category) tags = params[:add].delete(:category)
content = params[:add].delete(:content)&.first content = params[:add].delete(:content)&.first
name = params[:add].delete(:name) name = params[:add].delete(:name)
@@ -46,7 +48,7 @@ module Micropub
post_repo.update(post.id, attrs_to_add) unless attrs_to_add.empty? post_repo.update(post.id, attrs_to_add) unless attrs_to_add.empty?
post_repo.tag_post(post_id: post.id, tags: tags) if tags && !tags.empty? post_repo.tag_post(post_id: post.id, tags: tags) if tags && !tags.empty?
add_syndication_source.call(post.id, "", syndication) if syndication && !syndication.empty? add_syndication_source.call(post.id, syndication_source, syndication_url) if syndication_url && !syndication_url.empty?
Success() Success()
end end

View File

@@ -0,0 +1,21 @@
module Micropub
module Queries
module Posts
class SyndicationUrlToSource
def call(url:)
if url.match("https://social.dnitza.com")
return :mastodon
end
if url.match("https://bsky.social")
return :bluesky
end
if url.match("https://gist.github.com")
return :gist
end
end
end
end
end
end