Add movies page
This commit is contained in:
13
app/actions/movies/index.rb
Normal file
13
app/actions/movies/index.rb
Normal file
@@ -0,0 +1,13 @@
|
||||
module Adamantium
|
||||
module Actions
|
||||
module Movies
|
||||
class Index < Action
|
||||
include Deps["views.movies.index"]
|
||||
|
||||
def handle(req, res)
|
||||
res.render index
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
15
app/repos/movie_repo.rb
Normal file
15
app/repos/movie_repo.rb
Normal file
@@ -0,0 +1,15 @@
|
||||
module Adamantium
|
||||
module Repos
|
||||
class MovieRepo < Adamantium::Repo[:movies]
|
||||
commands :create
|
||||
|
||||
def listing
|
||||
movies.order(Sequel.lit("year desc")).to_a
|
||||
end
|
||||
|
||||
def by_title_and_year(title:, year:)
|
||||
movies.where(title: title, year: year).one
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
@@ -13,4 +13,6 @@ div class="mb-12 max-w-prose mx-auto text-gray-800 dark:text-gray-200"
|
||||
div class="grid grid-cols-4 grid-flow-col gap-2 mb-6"
|
||||
a class="block p-1 border border-lime-200 bg-lime-300 text-lime-900 hover:bg-lime-200 text-center rounded-lg" href="/colophon" 🧱 Colophon
|
||||
a class="block p-1 border border-lime-200 bg-lime-300 text-lime-900 hover:bg-lime-200 text-center rounded-lg" href="/hikes" 🥾 Hikes
|
||||
a class="block p-1 border border-lime-200 bg-lime-300 text-lime-900 hover:bg-lime-200 text-center rounded-lg" href="/movies" 🍿 Movies
|
||||
/ a class="block p-1 border border-lime-200 bg-lime-300 text-lime-900 hover:bg-lime-200 text-center rounded-lg" href="/art" 🎨 Art things
|
||||
|
||||
|
18
app/templates/movies/index.html.slim
Normal file
18
app/templates/movies/index.html.slim
Normal file
@@ -0,0 +1,18 @@
|
||||
div class="mb-12 prose dark:prose-invert max-w-prose mx-auto text-gray-800 dark:text-gray-200"
|
||||
h1 Movies
|
||||
|
||||
div class="mb-12 max-w-prose mx-auto"
|
||||
table class="prose dark:prose-invert table-auto"
|
||||
thead
|
||||
tr
|
||||
td Title
|
||||
td Year
|
||||
- movies.each do |movie|
|
||||
tr
|
||||
td
|
||||
a href="#{movie.url}"
|
||||
= movie.title
|
||||
td
|
||||
= movie.year
|
||||
|
||||
div class="max-w-screen-md mx-auto border-t-4 border-solid border-gray-400 dark:border-gray-600"
|
14
app/views/movies/index.rb
Normal file
14
app/views/movies/index.rb
Normal file
@@ -0,0 +1,14 @@
|
||||
module Adamantium
|
||||
module Views
|
||||
module Movies
|
||||
class Index < View
|
||||
|
||||
include Deps["repos.movie_repo"]
|
||||
|
||||
expose :movies do
|
||||
movie_repo.listing
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
Reference in New Issue
Block a user