Send weekly posts to Day One
This commit is contained in:
1
Gemfile
1
Gemfile
@@ -36,6 +36,7 @@ gem "webmention"
|
|||||||
gem "sanitize"
|
gem "sanitize"
|
||||||
gem "time_math2", require: "time_math"
|
gem "time_math2", require: "time_math"
|
||||||
gem "lastfm", "~> 1.27"
|
gem "lastfm", "~> 1.27"
|
||||||
|
gem "mail"
|
||||||
|
|
||||||
group :cli, :development do
|
group :cli, :development do
|
||||||
gem "hanami-reloader"
|
gem "hanami-reloader"
|
||||||
|
17
Gemfile.lock
17
Gemfile.lock
@@ -61,6 +61,7 @@ GEM
|
|||||||
database_cleaner-sequel (2.0.2)
|
database_cleaner-sequel (2.0.2)
|
||||||
database_cleaner-core (~> 2.0.0)
|
database_cleaner-core (~> 2.0.0)
|
||||||
sequel
|
sequel
|
||||||
|
date (3.3.3)
|
||||||
diff-lcs (1.5.0)
|
diff-lcs (1.5.0)
|
||||||
domain_name (0.5.20190701)
|
domain_name (0.5.20190701)
|
||||||
unf (>= 0.0.5, < 1.0.0)
|
unf (>= 0.0.5, < 1.0.0)
|
||||||
@@ -225,6 +226,11 @@ GEM
|
|||||||
ffi-compiler (~> 1.0)
|
ffi-compiler (~> 1.0)
|
||||||
rake (~> 13.0)
|
rake (~> 13.0)
|
||||||
lumberjack (1.2.8)
|
lumberjack (1.2.8)
|
||||||
|
mail (2.8.1)
|
||||||
|
mini_mime (>= 0.1.1)
|
||||||
|
net-imap
|
||||||
|
net-pop
|
||||||
|
net-smtp
|
||||||
method_source (1.0.0)
|
method_source (1.0.0)
|
||||||
mime-types (3.4.1)
|
mime-types (3.4.1)
|
||||||
mime-types-data (~> 3.2015)
|
mime-types-data (~> 3.2015)
|
||||||
@@ -237,8 +243,17 @@ GEM
|
|||||||
hansi (~> 0.2.0)
|
hansi (~> 0.2.0)
|
||||||
mustermann (= 3.0.0)
|
mustermann (= 3.0.0)
|
||||||
nenv (0.3.0)
|
nenv (0.3.0)
|
||||||
|
net-imap (0.3.4)
|
||||||
|
date
|
||||||
|
net-protocol
|
||||||
|
net-pop (0.1.2)
|
||||||
|
net-protocol
|
||||||
|
net-protocol (0.2.1)
|
||||||
|
timeout
|
||||||
net-scp (4.0.0)
|
net-scp (4.0.0)
|
||||||
net-ssh (>= 2.6.5, < 8.0.0)
|
net-ssh (>= 2.6.5, < 8.0.0)
|
||||||
|
net-smtp (0.3.3)
|
||||||
|
net-protocol
|
||||||
net-ssh (7.0.1)
|
net-ssh (7.0.1)
|
||||||
netrc (0.11.0)
|
netrc (0.11.0)
|
||||||
nio4r (2.5.8)
|
nio4r (2.5.8)
|
||||||
@@ -365,6 +380,7 @@ GEM
|
|||||||
tilt (2.0.11)
|
tilt (2.0.11)
|
||||||
time_math2 (0.1.1)
|
time_math2 (0.1.1)
|
||||||
timecop (0.9.6)
|
timecop (0.9.6)
|
||||||
|
timeout (0.3.2)
|
||||||
transproc (1.1.1)
|
transproc (1.1.1)
|
||||||
unf (0.1.4)
|
unf (0.1.4)
|
||||||
unf_ext
|
unf_ext
|
||||||
@@ -404,6 +420,7 @@ DEPENDENCIES
|
|||||||
hanami-view!
|
hanami-view!
|
||||||
httparty
|
httparty
|
||||||
lastfm (~> 1.27)
|
lastfm (~> 1.27)
|
||||||
|
mail
|
||||||
ogpr
|
ogpr
|
||||||
pg
|
pg
|
||||||
pinboard!
|
pinboard!
|
||||||
|
@@ -8,6 +8,7 @@ module Adamantium
|
|||||||
"post_utilities.slugify",
|
"post_utilities.slugify",
|
||||||
renderer: "renderers.markdown",
|
renderer: "renderers.markdown",
|
||||||
syndicate: "commands.posts.syndicate",
|
syndicate: "commands.posts.syndicate",
|
||||||
|
send_to_dayone: "syndication.dayone",
|
||||||
add_post_syndication_source: "commands.posts.add_syndication_source",
|
add_post_syndication_source: "commands.posts.add_syndication_source",
|
||||||
send_webmentions: "commands.posts.send_webmentions",
|
send_webmentions: "commands.posts.send_webmentions",
|
||||||
]
|
]
|
||||||
@@ -18,6 +19,8 @@ module Adamantium
|
|||||||
post_params = prepare_params(params: post)
|
post_params = prepare_params(params: post)
|
||||||
created_post = post_repo.create(post_params)
|
created_post = post_repo.create(post_params)
|
||||||
|
|
||||||
|
send_to_dayone.call(name: post.name, content: post.content) if post[:category].include? "weekly"
|
||||||
|
|
||||||
syndicate.call(post).bind do |results|
|
syndicate.call(post).bind do |results|
|
||||||
results.each do |result|
|
results.each do |result|
|
||||||
source, url = result
|
source, url = result
|
||||||
|
@@ -2,5 +2,6 @@ Hanami.app.register_provider :syndication, namespace: true do
|
|||||||
start do
|
start do
|
||||||
register "mastodon", Adamantium::Syndication::Mastodon.new
|
register "mastodon", Adamantium::Syndication::Mastodon.new
|
||||||
register "pinboard", Adamantium::Syndication::Pinboard.new(api_key: target["settings"].pinboard_api_key)
|
register "pinboard", Adamantium::Syndication::Pinboard.new(api_key: target["settings"].pinboard_api_key)
|
||||||
|
register "dayone", Adamantium::Syndication::Dayone.new
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@@ -28,6 +28,9 @@ module Adamantium
|
|||||||
setting :lastfm_api_key, default: nil
|
setting :lastfm_api_key, default: nil
|
||||||
setting :lastfm_secret, default: nil
|
setting :lastfm_secret, default: nil
|
||||||
|
|
||||||
|
setting :from_email, default: nil
|
||||||
|
setting :dayone_email, default: nil
|
||||||
|
|
||||||
# Micropub endpoints
|
# Micropub endpoints
|
||||||
setting :micropub_media_endpoint, default: "", constructor: Types::Params::String
|
setting :micropub_media_endpoint, default: "", constructor: Types::Params::String
|
||||||
|
|
||||||
|
18
lib/adamantium/syndication/dayone.rb
Normal file
18
lib/adamantium/syndication/dayone.rb
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
require "mail"
|
||||||
|
|
||||||
|
module Adamantium
|
||||||
|
module Syndication
|
||||||
|
class Dayone
|
||||||
|
include Deps["settings"]
|
||||||
|
|
||||||
|
def call(name:, content:)
|
||||||
|
Mail.deliver do
|
||||||
|
to settings.dayone_email
|
||||||
|
from settings.from_email
|
||||||
|
subject name
|
||||||
|
body content
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
Reference in New Issue
Block a user