StandardRB
This commit is contained in:
@@ -186,12 +186,12 @@ module Adamantium
|
|||||||
.order(:year)
|
.order(:year)
|
||||||
.to_a
|
.to_a
|
||||||
end
|
end
|
||||||
|
|
||||||
def search(term:)
|
def search(term:)
|
||||||
posts
|
posts
|
||||||
.where(post_type: "post", location: nil)
|
.where(post_type: "post", location: nil)
|
||||||
.published
|
.published
|
||||||
.search(term: term)
|
.search(term: term)
|
||||||
.combine(:tags)
|
.combine(:tags)
|
||||||
.order(Sequel.desc(:published_at))
|
.order(Sequel.desc(:published_at))
|
||||||
.to_a
|
.to_a
|
||||||
|
@@ -17,9 +17,9 @@ module Adamantium
|
|||||||
post_repo.post_listing
|
post_repo.post_listing
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
expose :query do |query:|
|
expose :query do |query:|
|
||||||
query == "" ? nil : query
|
(query == "") ? nil : query
|
||||||
end
|
end
|
||||||
|
|
||||||
expose :post_years do
|
expose :post_years do
|
||||||
|
@@ -7,10 +7,10 @@ use Rack::Static, urls: ["/assets", "/media"], root: "public"
|
|||||||
raise StandardError.new("No secret key") unless ENV["SESSION_SECRET"]
|
raise StandardError.new("No secret key") unless ENV["SESSION_SECRET"]
|
||||||
|
|
||||||
use Rack::Session::Cookie,
|
use Rack::Session::Cookie,
|
||||||
:domain => URI.parse(ENV["MICROPUB_SITE_URL"]).host,
|
domain: URI.parse(ENV["MICROPUB_SITE_URL"]).host,
|
||||||
:path => '/',
|
path: "/",
|
||||||
:expire_after => 3600*24,
|
expire_after: 3600 * 24,
|
||||||
:secret => ENV["SESSION_SECRET"]
|
secret: ENV["SESSION_SECRET"]
|
||||||
|
|
||||||
require "rack/rewrite"
|
require "rack/rewrite"
|
||||||
use Rack::Rewrite do
|
use Rack::Rewrite do
|
||||||
|
@@ -53,10 +53,10 @@ module Adamantium
|
|||||||
setting :micropub_authorization_endpoint
|
setting :micropub_authorization_endpoint
|
||||||
setting :micropub_token_endpoint
|
setting :micropub_token_endpoint
|
||||||
|
|
||||||
setting :microblog_auth_endpoint, default: nil
|
setting :microblog_auth_endpoint, default: nil
|
||||||
|
|
||||||
setting :overcast_username, default: nil
|
setting :overcast_username, default: nil
|
||||||
setting :overcast_password, default: nil
|
setting :overcast_password, default: nil
|
||||||
|
|
||||||
setting :mastodon_token, default: nil
|
setting :mastodon_token, default: nil
|
||||||
setting :mastodon_server, default: nil
|
setting :mastodon_server, default: nil
|
||||||
|
@@ -8,7 +8,7 @@ module Adamantium
|
|||||||
|
|
||||||
def call(env)
|
def call(env)
|
||||||
session = env["rack.session"]
|
session = env["rack.session"]
|
||||||
return [403, {'Content-Type' => 'text/html'}, ["Unauthorized | <a href=\"/admin/login\">Login</>"]] unless @auth_proc.call(session[:user_id])
|
return [403, {"Content-Type" => "text/html"}, ["Unauthorized | <a href=\"/admin/login\">Login</>"]] unless @auth_proc.call(session[:user_id])
|
||||||
|
|
||||||
@app.call(env)
|
@app.call(env)
|
||||||
end
|
end
|
||||||
|
@@ -20,7 +20,7 @@ module Adamantium
|
|||||||
podcast_list = []
|
podcast_list = []
|
||||||
|
|
||||||
doc.xpath("//outline[@type='rss']").each_with_object(podcast_list) do |rss, memo|
|
doc.xpath("//outline[@type='rss']").each_with_object(podcast_list) do |rss, memo|
|
||||||
podcasts = rss.xpath("outline[@type='podcast-episode']").select{|ep| ep.get_attribute("played") == "1" }
|
podcasts = rss.xpath("outline[@type='podcast-episode']").select { |ep| ep.get_attribute("played") == "1" }
|
||||||
|
|
||||||
name = rss.get_attribute("title")
|
name = rss.get_attribute("title")
|
||||||
|
|
||||||
@@ -43,4 +43,4 @@ module Adamantium
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@@ -5,7 +5,7 @@ module Admin
|
|||||||
include Deps["commands.sessions.create"]
|
include Deps["commands.sessions.create"]
|
||||||
|
|
||||||
def handle(req, res)
|
def handle(req, res)
|
||||||
create.(email: req.params[:email])
|
create.call(email: req.params[:email])
|
||||||
|
|
||||||
res.redirect_to "/admin"
|
res.redirect_to "/admin"
|
||||||
end
|
end
|
||||||
|
@@ -5,7 +5,7 @@ module Admin
|
|||||||
include Deps["commands.sessions.validate"]
|
include Deps["commands.sessions.validate"]
|
||||||
|
|
||||||
def handle(req, res)
|
def handle(req, res)
|
||||||
user_id = validate.(token: req.params[:token])
|
user_id = validate.call(token: req.params[:token])
|
||||||
session = req.env["rack.session"]
|
session = req.env["rack.session"]
|
||||||
|
|
||||||
session[:user_id] = user_id
|
session[:user_id] = user_id
|
||||||
|
@@ -9,7 +9,7 @@ module Admin
|
|||||||
bookmark = bookmark_repo.fetch(id: bookmark_id)
|
bookmark = bookmark_repo.fetch(id: bookmark_id)
|
||||||
|
|
||||||
page_cacher.call(url: bookmark.url) do |content|
|
page_cacher.call(url: bookmark.url) do |content|
|
||||||
bookmark_repo.update(id: bookmark_id, params: { cached_content: content })
|
bookmark_repo.update(id: bookmark_id, params: {cached_content: content})
|
||||||
end
|
end
|
||||||
|
|
||||||
Success()
|
Success()
|
||||||
|
@@ -5,8 +5,8 @@ module Admin
|
|||||||
module Sessions
|
module Sessions
|
||||||
class Create
|
class Create
|
||||||
include Deps[
|
include Deps[
|
||||||
"repos.login_tokens_repo",
|
"repos.login_tokens_repo",
|
||||||
"repos.user_repo"
|
"repos.user_repo"
|
||||||
]
|
]
|
||||||
|
|
||||||
def call(email:)
|
def call(email:)
|
||||||
@@ -37,7 +37,7 @@ module Admin
|
|||||||
body "#{app_settings.micropub_site_url}/admin/login/#{token.token}"
|
body "#{app_settings.micropub_site_url}/admin/login/#{token.token}"
|
||||||
end
|
end
|
||||||
|
|
||||||
mail[:to] = email
|
mail[:to] = user.email
|
||||||
mail[:from] = app_settings.from_email
|
mail[:from] = app_settings.from_email
|
||||||
|
|
||||||
mail.deliver
|
mail.deliver
|
||||||
|
@@ -12,13 +12,9 @@ module Admin
|
|||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
|
|
||||||
user_id = token.user_id
|
token.user_id
|
||||||
|
|
||||||
if user_id
|
|
||||||
user_id
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@@ -3,7 +3,7 @@ require "adamantium/middleware/authenticate"
|
|||||||
module Adamantium
|
module Adamantium
|
||||||
class AuthenticatedAdminAction
|
class AuthenticatedAdminAction
|
||||||
def self.call(action:)
|
def self.call(action:)
|
||||||
auth_proc = -> (id) { Admin::Container["repos.user_repo"].exists(id) }
|
auth_proc = ->(id) { Admin::Container["repos.user_repo"].exists(id) }
|
||||||
action_proc = ->(env) { Admin::Container["actions.#{action}"].call(env) }
|
action_proc = ->(env) { Admin::Container["actions.#{action}"].call(env) }
|
||||||
|
|
||||||
Adamantium::Middleware::Authenticate.new(action_proc, auth_proc)
|
Adamantium::Middleware::Authenticate.new(action_proc, auth_proc)
|
||||||
|
@@ -8,10 +8,10 @@ html
|
|||||||
|
|
||||||
title Admin // Daniel Nitsikopoulos
|
title Admin // Daniel Nitsikopoulos
|
||||||
|
|
||||||
= stylesheet_tag "app"
|
= stylesheet_tag "admin/app"
|
||||||
link rel="icon" type="image/x-icon" href="/assets/favicon.ico"
|
link rel="icon" type="image/x-icon" href="/assets/favicon.ico"
|
||||||
|
|
||||||
= javascript_tag "app"
|
= javascript_tag "admin/app"
|
||||||
|
|
||||||
script src="https://unpkg.com/htmx.org@1.9.2/dist/htmx.min.js" integrity="sha384-L6OqL9pRWyyFU3+/bjdSri+iIphTN/bvYyM37tICVyOJkWZLpP2vGn6VUEXgzg6h" crossorigin="anonymous"
|
script src="https://unpkg.com/htmx.org@1.9.2/dist/htmx.min.js" integrity="sha384-L6OqL9pRWyyFU3+/bjdSri+iIphTN/bvYyM37tICVyOJkWZLpP2vGn6VUEXgzg6h" crossorigin="anonymous"
|
||||||
script src="https://cdn.jsdelivr.net/npm/alpinejs@3.12.0/dist/cdn.min.js" defer="true"
|
script src="https://cdn.jsdelivr.net/npm/alpinejs@3.12.0/dist/cdn.min.js" defer="true"
|
||||||
|
@@ -4,10 +4,10 @@
|
|||||||
module Micropub
|
module Micropub
|
||||||
class Action < Adamantium::Action
|
class Action < Adamantium::Action
|
||||||
include Deps["logger",
|
include Deps["logger",
|
||||||
"settings",
|
"settings",
|
||||||
not_found_view: "views.not_found",
|
not_found_view: "views.not_found",
|
||||||
error_view: "views.error",
|
error_view: "views.error",
|
||||||
sentry: "sentry.client"]
|
sentry: "sentry.client"]
|
||||||
|
|
||||||
include Dry::Matcher.for(:handle, with: Dry::Matcher::ResultMatcher)
|
include Dry::Matcher.for(:handle, with: Dry::Matcher::ResultMatcher)
|
||||||
include Dry::Monads[:result]
|
include Dry::Monads[:result]
|
||||||
|
@@ -4,7 +4,6 @@
|
|||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
<title>Adamantium - Micropub</title>
|
<title>Adamantium - Micropub</title>
|
||||||
<%= favicon_tag %>
|
|
||||||
<%= stylesheet_tag "micropub/app" %>
|
<%= stylesheet_tag "micropub/app" %>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
Reference in New Issue
Block a user