Refactor app in to its own slice
This commit is contained in:
0
slices/main/actions/.keep
Normal file
0
slices/main/actions/.keep
Normal file
15
slices/main/actions/blogroll/index.rb
Normal file
15
slices/main/actions/blogroll/index.rb
Normal file
@@ -0,0 +1,15 @@
|
||||
require "time_math"
|
||||
|
||||
module Main
|
||||
module Actions
|
||||
module Blogroll
|
||||
class Index < Action
|
||||
include Deps["views.blogroll.index"]
|
||||
|
||||
def handle(req, res)
|
||||
res.render index
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
15
slices/main/actions/blogroll/list.rb
Normal file
15
slices/main/actions/blogroll/list.rb
Normal file
@@ -0,0 +1,15 @@
|
||||
require "time_math"
|
||||
|
||||
module Main
|
||||
module Actions
|
||||
module Blogroll
|
||||
class List < Action
|
||||
include Deps["views.blogroll.list"]
|
||||
|
||||
def handle(req, res)
|
||||
res.body = cache(key: "blogroll", content_proc: -> { list.call.to_str }, expiry: TimeMath.min.advance(Time.now, +60))
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
16
slices/main/actions/blogroll/opml.rb
Normal file
16
slices/main/actions/blogroll/opml.rb
Normal file
@@ -0,0 +1,16 @@
|
||||
require "time_math"
|
||||
|
||||
module Main
|
||||
module Actions
|
||||
module Blogroll
|
||||
class Opml < Action
|
||||
include Deps["views.blogroll.opml"]
|
||||
|
||||
def handle(req, res)
|
||||
res.content_type = "text/xml; charset=utf-8"
|
||||
res.render opml, format: :xml
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
13
slices/main/actions/bookmarks/index.rb
Normal file
13
slices/main/actions/bookmarks/index.rb
Normal file
@@ -0,0 +1,13 @@
|
||||
module Main
|
||||
module Actions
|
||||
module Bookmarks
|
||||
class Index < Action
|
||||
include Deps["views.bookmarks.index"]
|
||||
|
||||
def handle(req, res)
|
||||
res.render index, query: req.params[:q]
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
13
slices/main/actions/bookmarks/metadata.rb
Normal file
13
slices/main/actions/bookmarks/metadata.rb
Normal file
@@ -0,0 +1,13 @@
|
||||
module Main
|
||||
module Actions
|
||||
module Bookmarks
|
||||
class Metadata < Action
|
||||
include Deps["views.bookmarks.metadata"]
|
||||
|
||||
def handle(req, res)
|
||||
res.render metadata, id: req.params[:id]
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
12
slices/main/actions/bookmarks/show.rb
Normal file
12
slices/main/actions/bookmarks/show.rb
Normal file
@@ -0,0 +1,12 @@
|
||||
module Main
|
||||
module Actions
|
||||
module Bookmarks
|
||||
class Show < Action
|
||||
include Deps["views.bookmarks.show"]
|
||||
def handle(req, res)
|
||||
res.render show, slug: req.params[:slug]
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
13
slices/main/actions/books/index.rb
Normal file
13
slices/main/actions/books/index.rb
Normal file
@@ -0,0 +1,13 @@
|
||||
module Main
|
||||
module Actions
|
||||
module Books
|
||||
class Index < Action
|
||||
include Deps["views.books.index"]
|
||||
|
||||
def handle(req, res)
|
||||
res.render index
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
14
slices/main/actions/feeds/rss.rb
Normal file
14
slices/main/actions/feeds/rss.rb
Normal file
@@ -0,0 +1,14 @@
|
||||
module Main
|
||||
module Actions
|
||||
module Feeds
|
||||
class Rss < Action
|
||||
include Deps["views.feeds.rss"]
|
||||
|
||||
def handle(req, res)
|
||||
res.content_type = "text/xml; charset=utf-8"
|
||||
res.render rss, format: :xml
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
14
slices/main/actions/feeds/statuses_rss.rb
Normal file
14
slices/main/actions/feeds/statuses_rss.rb
Normal file
@@ -0,0 +1,14 @@
|
||||
module Main
|
||||
module Actions
|
||||
module Feeds
|
||||
class StatusesRss < Action
|
||||
include Deps["views.feeds.statuses_rss"]
|
||||
|
||||
def handle(req, res)
|
||||
res.content_type = "text/xml; charset=utf-8"
|
||||
res.render statuses_rss, format: :xml
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
13
slices/main/actions/key/show.rb
Normal file
13
slices/main/actions/key/show.rb
Normal file
@@ -0,0 +1,13 @@
|
||||
module Main
|
||||
module Actions
|
||||
module Key
|
||||
class Show < Action
|
||||
include Deps["settings"]
|
||||
def handle(req, res)
|
||||
res.content_type = "text/plain"
|
||||
res.body = settings.micropub_pub_key
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
13
slices/main/actions/more/index.rb
Normal file
13
slices/main/actions/more/index.rb
Normal file
@@ -0,0 +1,13 @@
|
||||
module Main
|
||||
module Actions
|
||||
module More
|
||||
class Index < Action
|
||||
include Deps["views.more.index"]
|
||||
|
||||
def handle(req, res)
|
||||
res.render index
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
13
slices/main/actions/movies/index.rb
Normal file
13
slices/main/actions/movies/index.rb
Normal file
@@ -0,0 +1,13 @@
|
||||
module Main
|
||||
module Actions
|
||||
module Movies
|
||||
class Index < Action
|
||||
include Deps["views.movies.index"]
|
||||
|
||||
def handle(req, res)
|
||||
res.render index
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
16
slices/main/actions/pages/show.rb
Normal file
16
slices/main/actions/pages/show.rb
Normal file
@@ -0,0 +1,16 @@
|
||||
module Main
|
||||
module Actions
|
||||
module Pages
|
||||
class Show < Action
|
||||
include Deps["views.pages.show"]
|
||||
|
||||
def handle(req, res)
|
||||
slug = req.params[:slug]
|
||||
|
||||
res.status = File.exist?("slices/main/content/pages/#{slug}.md") ? 200 : 404
|
||||
res.render show, slug: slug
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
13
slices/main/actions/photos/index.rb
Normal file
13
slices/main/actions/photos/index.rb
Normal file
@@ -0,0 +1,13 @@
|
||||
module Main
|
||||
module Actions
|
||||
module Photos
|
||||
class Index < Action
|
||||
include Deps["views.photos.index"]
|
||||
|
||||
def handle(req, res)
|
||||
res.render index
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
13
slices/main/actions/places/index.rb
Normal file
13
slices/main/actions/places/index.rb
Normal file
@@ -0,0 +1,13 @@
|
||||
module Main
|
||||
module Actions
|
||||
module Places
|
||||
class Index < Action
|
||||
include Deps["views.places.index"]
|
||||
|
||||
def handle(req, res)
|
||||
res.render index
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
13
slices/main/actions/places/map_page.rb
Normal file
13
slices/main/actions/places/map_page.rb
Normal file
@@ -0,0 +1,13 @@
|
||||
module Main
|
||||
module Actions
|
||||
module Places
|
||||
class MapPage < Action
|
||||
include Deps["views.places.map_page"]
|
||||
|
||||
def handle(req, res)
|
||||
res.render map_page
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
13
slices/main/actions/podcasts/index.rb
Normal file
13
slices/main/actions/podcasts/index.rb
Normal file
@@ -0,0 +1,13 @@
|
||||
module Main
|
||||
module Actions
|
||||
module Podcasts
|
||||
class Index < Action
|
||||
include Deps["views.podcasts.index"]
|
||||
|
||||
def handle(req, res)
|
||||
res.render index
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
15
slices/main/actions/posts/archive.rb
Normal file
15
slices/main/actions/posts/archive.rb
Normal file
@@ -0,0 +1,15 @@
|
||||
module Main
|
||||
module Actions
|
||||
module Posts
|
||||
class Archive < Action
|
||||
include Deps["views.posts.archive"]
|
||||
|
||||
def handle(req, res)
|
||||
year = req.params[:year]
|
||||
|
||||
res.render archive, year: year
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
12
slices/main/actions/posts/index.rb
Normal file
12
slices/main/actions/posts/index.rb
Normal file
@@ -0,0 +1,12 @@
|
||||
module Main
|
||||
module Actions
|
||||
module Posts
|
||||
class Index < Action
|
||||
include Deps["views.posts.index"]
|
||||
def handle(req, res)
|
||||
res.render index, query: req.params[:q]
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
15
slices/main/actions/posts/show.rb
Normal file
15
slices/main/actions/posts/show.rb
Normal file
@@ -0,0 +1,15 @@
|
||||
module Main
|
||||
module Actions
|
||||
module Posts
|
||||
class Show < Action
|
||||
include Deps["views.posts.show"]
|
||||
|
||||
def handle(req, res)
|
||||
slug = req.params[:slug]
|
||||
|
||||
res.render show, slug: slug
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
25
slices/main/actions/posts/top_tracks.rb
Normal file
25
slices/main/actions/posts/top_tracks.rb
Normal file
@@ -0,0 +1,25 @@
|
||||
module Main
|
||||
module Actions
|
||||
module Posts
|
||||
class TopTracks < Action
|
||||
include Deps["views.posts.top_tracks", query: "queries.posts.top_tracks"]
|
||||
|
||||
def handle(req, res)
|
||||
res.content_type = "Application/JSON"
|
||||
res.status = 200
|
||||
tracks = query.call(slug: req.params[:slug])
|
||||
|
||||
track = if tracks.is_a? Array
|
||||
tracks.first
|
||||
else
|
||||
tracks
|
||||
end
|
||||
|
||||
if track
|
||||
res.render top_tracks, track: track
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
15
slices/main/actions/recently_played/index.rb
Normal file
15
slices/main/actions/recently_played/index.rb
Normal file
@@ -0,0 +1,15 @@
|
||||
require "time_math"
|
||||
|
||||
module Main
|
||||
module Actions
|
||||
module RecentlyPlayed
|
||||
class Index < Action
|
||||
include Deps["views.recently_played.index"]
|
||||
|
||||
def handle(req, res)
|
||||
res.body = cache(key: "recently_played", content_proc: -> { index.call.to_str })
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
12
slices/main/actions/site/home.rb
Normal file
12
slices/main/actions/site/home.rb
Normal file
@@ -0,0 +1,12 @@
|
||||
module Main
|
||||
module Actions
|
||||
module Site
|
||||
class Home < Action
|
||||
include Deps["views.site.home"]
|
||||
def handle(req, res)
|
||||
res.render home
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
12
slices/main/actions/statuses/index.rb
Normal file
12
slices/main/actions/statuses/index.rb
Normal file
@@ -0,0 +1,12 @@
|
||||
module Main
|
||||
module Actions
|
||||
module Statuses
|
||||
class Index < Action
|
||||
include Deps["views.statuses.index"]
|
||||
def handle(req, res)
|
||||
res.render index
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
13
slices/main/actions/tags/index.rb
Normal file
13
slices/main/actions/tags/index.rb
Normal file
@@ -0,0 +1,13 @@
|
||||
module Main
|
||||
module Actions
|
||||
module Tags
|
||||
class Index < Action
|
||||
include Deps["views.tags.index"]
|
||||
|
||||
def handle(req, res)
|
||||
res.render index
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
15
slices/main/actions/tags/show.rb
Normal file
15
slices/main/actions/tags/show.rb
Normal file
@@ -0,0 +1,15 @@
|
||||
module Main
|
||||
module Actions
|
||||
module Tags
|
||||
class Show < Action
|
||||
include Deps["views.tags.show"]
|
||||
|
||||
def handle(req, res)
|
||||
slug = req.params[:slug]
|
||||
|
||||
res.render show, slug: slug
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
19
slices/main/actions/timemachine/show.rb
Normal file
19
slices/main/actions/timemachine/show.rb
Normal file
@@ -0,0 +1,19 @@
|
||||
module Main
|
||||
module Actions
|
||||
module Timemachine
|
||||
class Show < Action
|
||||
include Deps["views.timemachine.show"]
|
||||
|
||||
def handle(req, res)
|
||||
year, month, day = [
|
||||
req.params[:year],
|
||||
req.params[:month],
|
||||
req.params[:day]
|
||||
]
|
||||
|
||||
res.render show, year: year, month: month, day: day
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
12
slices/main/actions/trips/index.rb
Normal file
12
slices/main/actions/trips/index.rb
Normal file
@@ -0,0 +1,12 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module Main
|
||||
module Actions
|
||||
module Trips
|
||||
class Index < Adamantium::Action
|
||||
def handle(req, res)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
15
slices/main/actions/trips/show.rb
Normal file
15
slices/main/actions/trips/show.rb
Normal file
@@ -0,0 +1,15 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module Main
|
||||
module Actions
|
||||
module Trips
|
||||
class Show < Adamantium::Action
|
||||
include Deps["views.trips.show"]
|
||||
|
||||
def handle(req, res)
|
||||
res.render show, id: req.params[:id]
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
33
slices/main/actions/workouts/create.rb
Normal file
33
slices/main/actions/workouts/create.rb
Normal file
@@ -0,0 +1,33 @@
|
||||
module Main
|
||||
module Actions
|
||||
module Workouts
|
||||
class Create < Action
|
||||
include Deps["geo.gpx_parser", "commands.workouts.create"]
|
||||
|
||||
def handle(req, res)
|
||||
tempfile = Tempfile.new(%w[path .gpx])
|
||||
|
||||
if !req.params.to_h.dig(:file, :tempfile).nil?
|
||||
tempfile.write req.params[:file][:tempfile].read
|
||||
else
|
||||
tempfile.write req.params[:file]
|
||||
end
|
||||
|
||||
tempfile.rewind
|
||||
|
||||
gpxfile = gpx_parser.call(path: tempfile.path)
|
||||
|
||||
if gpxfile.success?
|
||||
create.call(**gpxfile.value!)
|
||||
res.status = 201
|
||||
else
|
||||
res.status = 500
|
||||
end
|
||||
ensure
|
||||
tempfile.close
|
||||
tempfile.unlink
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
13
slices/main/actions/workouts/index.rb
Normal file
13
slices/main/actions/workouts/index.rb
Normal file
@@ -0,0 +1,13 @@
|
||||
module Main
|
||||
module Actions
|
||||
module Workouts
|
||||
class Index < Action
|
||||
include Deps["views.workouts.index"]
|
||||
|
||||
def handle(req, res)
|
||||
res.render index
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
Reference in New Issue
Block a user