Add more endpoints for now page

This commit is contained in:
2024-04-01 19:13:18 +11:00
parent 23bc0134d6
commit cbdc61c359
13 changed files with 128 additions and 28 deletions

27
Gemfile
View File

@@ -14,9 +14,10 @@ gem "hanami-view", "2.1.0"
gem "csv"
gem "rom-sql"
gem "pg"
gem "scraperd", github: "dNitza/scraperd", branch: "master"
gem "dotenv"
gem "whenever", require: false
gem "warning"
gem "dry-types"
gem "dry-matcher"
@@ -25,11 +26,13 @@ gem "puma"
gem "rake"
gem "slim"
gem "builder"
gem "georuby"
gem "gpx"
gem "redis"
gem "georuby"
gem "gnuplot"
gem "matrix"
gem "redis"
gem "rack-session"
gem "rack-rewrite"
@@ -42,27 +45,25 @@ gem "redcarpet"
gem "reverse_markdown"
gem "rexml"
gem "babosa"
gem "bskyrb"
gem "ogpr"
gem "ruby-filemagic", git: "https://github.com/dnitza/ruby-filemagic", branch: "master"
gem "mail_room", github: "dNitza/mail_room", branch: "master"
gem "charlock_holmes"
gem "sanitize"
gem "time_math2", require: "time_math"
gem "jwt"
gem "lastfm", "~> 1.27"
gem "mail"
gem "que"
gem "unicode-emoji"
gem "connection_pool"
gem "omdb-api", "1.4.3", require: false
gem "image_processing", "~> 1.0"
gem "onnxruntime"
gem "mini_magick"
gem "unicode-emoji"
gem "whenever", require: false
gem "warning"
gem "mail_room", github: "dNitza/mail_room", branch: "master"
gem "scraperd", github: "dNitza/scraperd", branch: "master"
gem "bskyrb"
gem "ogpr"
gem "omdb-api", "1.4.3", require: false
gem "lastfm", "~> 1.27"
gem "steam-api"
group :cli, :development do
gem "irb"

View File

@@ -158,10 +158,9 @@ GEM
ed25519 (1.3.0)
faker (3.3.0)
i18n (>= 1.8.11, < 2)
faraday (2.9.0)
faraday-net_http (>= 2.0, < 3.2)
faraday-net_http (3.1.0)
net-http
faraday (1.2.0)
multipart-post (>= 1.2, < 3)
ruby2_keywords
ffi (1.16.3)
formatador (1.1.0)
georuby (2.5.2)
@@ -280,6 +279,7 @@ GEM
mini_mime (1.1.5)
minitest (5.22.3)
multi_xml (0.6.0)
multipart-post (2.4.0)
mustermann (3.0.0)
ruby2_keywords (~> 0.0.1)
mustermann-contrib (3.0.0)
@@ -287,8 +287,6 @@ GEM
mustermann (= 3.0.0)
mutex_m (0.2.0)
nenv (0.3.0)
net-http (0.4.1)
uri
net-imap (0.4.10)
date
net-protocol
@@ -327,12 +325,6 @@ GEM
omdb-api (1.4.3)
activesupport
httparty
onnxruntime (0.9.0-arm64-darwin)
ffi
onnxruntime (0.9.0-x86_64-darwin)
ffi
onnxruntime (0.9.0-x86_64-linux)
ffi
parallel (1.24.0)
parser (3.3.0.5)
ast (~> 2.4.1)
@@ -479,6 +471,8 @@ GEM
rubocop-performance (~> 1.20.2)
standardrb (1.0.1)
standard
steam-api (1.2.0)
faraday (~> 1.0)
stringio (3.1.0)
temple (0.10.3)
thor (1.3.1)
@@ -493,7 +487,6 @@ GEM
unicode-emoji (3.4.0)
unicode-version (~> 1.0)
unicode-version (1.4.0)
uri (0.13.0)
vernier (0.6.0)
version_gem (1.1.4)
warning (1.3.0)
@@ -556,7 +549,6 @@ DEPENDENCIES
mini_magick
ogpr
omdb-api (= 1.4.3)
onnxruntime
pg
puma
que
@@ -578,6 +570,7 @@ DEPENDENCIES
scraperd!
slim
standardrb
steam-api
time_math2
timecop
unicode-emoji

View File

@@ -100,7 +100,7 @@ end
namespace :tailwind do
task :watch do
system("npx tailwindcss -i ./slices/main/assets/css/app.css -o ./slices/main/assets/builds/app.css --watch")
system("npx tailwindcss -i ./slices/main/assets/css/app.css -o ./public/assets/main/app.css --watch")
end
task :build do

View File

@@ -26,6 +26,7 @@ module Adamantium
"clients.omdb",
"clients.blue_sky",
"clients.mastodon",
"clients.steam",
"geo.gpx_parser",
"param_parser.micropub_post",
"param_parser.webmention",

View File

@@ -76,5 +76,9 @@ module Adamantium
setting :raise_exceptions, default: true
setting :gist_client_token, default: nil
setting :cache_pages, default: true
setting :steam_api_key, default: nil
setting :steam_user_id, default: nil
end
end

View File

@@ -0,0 +1,15 @@
require "time_math"
module Main
module Actions
module PastWeek
class Index < Action
include Deps["views.past_week.index"]
def handle(req, res)
res.body = cache(key: "past_week", content_proc: -> { index.call.to_str })
end
end
end
end
end

View File

@@ -0,0 +1,15 @@
require "time_math"
module Main
module Actions
module RecentlyPlayedGames
class Index < Action
include Deps["views.recently_played_games.index"]
def handle(req, res)
res.body = cache(key: "recently_played_games", content_proc: -> { index.call.to_str })
end
end
end
end
end

View File

@@ -38,6 +38,8 @@ module Main
get "/blogroll/opml", to: "blogroll.opml"
get "/recently_played", to: "recently_played.index"
get "/recently_played_games", to: "recently_played_games.index"
get "/past_week", to: "past_week.index"
get "/:slug", to: "pages.show"

View File

@@ -0,0 +1,16 @@
require "steam-api"
module Main
module Queries
module Posts
class RecentGames
include Deps["settings"]
def call
Steam.apikey = settings.steam_api_key
Steam::Player.recently_played_games(settings.steam_user_id).fetch("games", []).take(2)
end
end
end
end
end

View File

@@ -0,0 +1,3 @@
div class="bg-lime-100 rounded dark:bg-lime-900 dark:text-gray-100 content-justify hover:bg-lime-200 hover:dark:bg-lime-800 decoration-wavy rounded py-1.5 px-2"
= "Latest week post: "
a href="#{past_week.permalink}" #{past_week.name}

View File

@@ -0,0 +1,8 @@
table
- recently_played_games.each do |game|
tr
td
= game[:name]
td
= "(#{game[:playtime_forever]}hrs)"

View File

@@ -0,0 +1,17 @@
module Main
module Views
module PastWeek
class Index < Main::View
config.layout = false
include Deps["repos.post_repo"]
expose :past_week do
post_repo.week_posts(limit: 1).to_a.map do |post|
Decorators::Posts::Decorator.new(post)
end.first
end
end
end
end
end

View File

@@ -0,0 +1,25 @@
module Main
module Views
module RecentlyPlayedGames
class Index < Main::View
config.layout = false
include Deps["queries.posts.recent_games"]
expose :recently_played_games do |recently_played_result|
# raise recently_played_result["data"].inspect
recently_played_result.map do |game|
{
name: game["name"],
playtime_forever: game["playtime_forever"].to_i / 60,
}
end
end
private_expose :recently_played_result do
recent_games.call
end
end
end
end
end