Add “more” page
This commit is contained in:
13
app/actions/more/index.rb
Normal file
13
app/actions/more/index.rb
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
module Adamantium
|
||||||
|
module Actions
|
||||||
|
module More
|
||||||
|
class Index < Action
|
||||||
|
include Deps["views.more.index"]
|
||||||
|
|
||||||
|
def handle(req, res)
|
||||||
|
res.render index
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
15
app/actions/posts/archive.rb
Normal file
15
app/actions/posts/archive.rb
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
module Adamantium
|
||||||
|
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
|
@@ -1,4 +1,4 @@
|
|||||||
Hi! 👋 I'm Daniel, a software engineer living in Canberra, Australia.
|
Hi! 👋 I'm Daniel, a software engineer living in Canberra, Australia.
|
||||||
|
|
||||||
Welcome to my personal site! This is where I post the things I have [written](/posts), the [photos](/photos) I have taken, the [bookmarks](/bookmarks) I have saved, and the [places](/places) I have been.
|
Welcome to my personal site! This is where I post the things I have [written](/posts), the [photos](/photos) I have taken, the [bookmarks](/bookmarks) I have saved, the [places](/places) I have been, and a whole bunch [more](/more).
|
||||||
|
|
||||||
|
0
app/content/pages/more.md
Normal file
0
app/content/pages/more.md
Normal file
@@ -53,6 +53,16 @@ module Adamantium
|
|||||||
posts.post_tags.where(post_id: post_id, tag_id: tag[:id]).changeset(:delete).commit if tag
|
posts.post_tags.where(post_id: post_id, tag_id: tag[:id]).changeset(:delete).commit if tag
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def by_year(year:)
|
||||||
|
posts
|
||||||
|
.where(post_type: "post", location: nil)
|
||||||
|
.exclude(name: nil)
|
||||||
|
.published
|
||||||
|
.where { Sequel.&(Sequel.extract(:year, :published_at) =~ year) }
|
||||||
|
.combine(:tags)
|
||||||
|
.to_a
|
||||||
|
end
|
||||||
|
|
||||||
def post_listing(limit: nil)
|
def post_listing(limit: nil)
|
||||||
posts
|
posts
|
||||||
.where(post_type: "post", location: nil)
|
.where(post_type: "post", location: nil)
|
||||||
@@ -198,6 +208,17 @@ module Adamantium
|
|||||||
delete_post = posts.where(slug: slug).command(:update)
|
delete_post = posts.where(slug: slug).command(:update)
|
||||||
delete_post.call(published_at: Time.now)
|
delete_post.call(published_at: Time.now)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def post_years
|
||||||
|
posts
|
||||||
|
.where(post_type: "post", location: nil)
|
||||||
|
.exclude(name: nil)
|
||||||
|
.published
|
||||||
|
.dataset
|
||||||
|
.group_and_count(Sequel.extract(:year, :published_at).as(:year))
|
||||||
|
.order(:year)
|
||||||
|
.to_a
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@@ -4,6 +4,12 @@ module Adamantium
|
|||||||
def fetch!(slug)
|
def fetch!(slug)
|
||||||
tags.where(slug: slug).one!
|
tags.where(slug: slug).one!
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def list
|
||||||
|
tags
|
||||||
|
.order(Sequel.function(:lower, :label))
|
||||||
|
.to_a
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
16
app/templates/more/index.html.slim
Normal file
16
app/templates/more/index.html.slim
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
div class="mb-12 max-w-prose mx-auto text-gray-800 dark:text-gray-200"
|
||||||
|
h1 class="text-4xl font-extrabold" More
|
||||||
|
|
||||||
|
h2 class="text-xl" Explore posts
|
||||||
|
|
||||||
|
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="/tags" 🔖 By tag
|
||||||
|
/ a class="block p-1 border border-lime-200 bg-lime-300 text-lime-900 hover:bg-lime-200 text-center rounded-lg" href="/years" 🗓️ By year
|
||||||
|
a class="block p-1 border border-lime-200 bg-lime-300 text-lime-900 hover:bg-lime-200 text-center rounded-lg" href="/posts" 🪧 All posts
|
||||||
|
|
||||||
|
h2 class="text-xl" Explore everything else
|
||||||
|
|
||||||
|
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
|
||||||
|
|
16
app/templates/posts/archive.html.slim
Normal file
16
app/templates/posts/archive.html.slim
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
div class="mb-4 prose dark:prose-invert max-w-prose mx-auto text-gray-800 dark:text-gray-200"
|
||||||
|
h1 Archive: #{year}
|
||||||
|
|
||||||
|
div class="mb-12 max-w-prose mx-auto text-gray-800 dark:text-gray-200"
|
||||||
|
nav class="space-x-1 text-sm md:text-sm uppercase md:block"
|
||||||
|
span Archive:
|
||||||
|
- post_years.each do |y|
|
||||||
|
a href="/posts/archive/#{y}" class="text-sm hover:text-gray-400 #{year.to_s == y.to_s ? 'underline decoration-wavy' : ''}"= y
|
||||||
|
- if y != post_years.last
|
||||||
|
span ·
|
||||||
|
div class="h-feed mb-12 max-w-prose mx-auto"
|
||||||
|
- posts.each do |post|
|
||||||
|
== render "shared/post", post: post
|
||||||
|
|
||||||
|
div class="max-w-screen-md mx-auto border-t-4 border-solid border-gray-400 dark:border-gray-600"
|
||||||
|
|
@@ -1,6 +1,13 @@
|
|||||||
div class="mb-12 prose dark:prose-invert max-w-prose mx-auto text-gray-800 dark:text-gray-200"
|
div class="mb-4 prose dark:prose-invert max-w-prose mx-auto text-gray-800 dark:text-gray-200"
|
||||||
h1 Writing
|
h1 Writing
|
||||||
|
|
||||||
|
div class="mb-12 max-w-prose mx-auto text-gray-800 dark:text-gray-200"
|
||||||
|
nav class="space-x-1 text-sm md:text-sm uppercase md:block"
|
||||||
|
span Archive:
|
||||||
|
- post_years.each do |year|
|
||||||
|
a href="/posts/archive/#{year}" class="text-sm hover:text-gray-400"= year
|
||||||
|
- if year != post_years.last
|
||||||
|
span ·
|
||||||
div class="h-feed mb-12 max-w-prose mx-auto"
|
div class="h-feed mb-12 max-w-prose mx-auto"
|
||||||
- posts.each do |post|
|
- posts.each do |post|
|
||||||
== render "shared/post", post: post
|
== render "shared/post", post: post
|
||||||
|
@@ -1,9 +1,15 @@
|
|||||||
article class="h-entry"
|
article class="h-entry"
|
||||||
div class="mb-12 prose dark:prose-invert max-w-prose mx-auto text-gray-800 dark:text-gray-200"
|
div class="mb-12 prose dark:prose-invert max-w-prose mx-auto text-gray-800 dark:text-gray-200"
|
||||||
h1 class="p-name"
|
h1 class="p-name mb-2"
|
||||||
a class="u-url" href=post.permalink
|
a class="u-url" href=post.permalink
|
||||||
= post.display_title
|
= post.display_title
|
||||||
|
nav class="space-x-1 text-sm md:text-sm md:block"
|
||||||
|
- if post.location || post.photos? || post.videos?
|
||||||
|
span See more:
|
||||||
|
- if post.location
|
||||||
|
a href="/places" places
|
||||||
|
- if post.photos? || post.videos?
|
||||||
|
a href="/photos" photos
|
||||||
article class="mb-12 prose dark:prose-invert max-w-prose mx-auto text-gray-800 dark:text-gray-200 prose-a:text-blue-600 prose-a:no-underline hover:prose-a:underline prose-img:rounded"
|
article class="mb-12 prose dark:prose-invert max-w-prose mx-auto text-gray-800 dark:text-gray-200 prose-a:text-blue-600 prose-a:no-underline hover:prose-a:underline prose-img:rounded"
|
||||||
div class="e-content"
|
div class="e-content"
|
||||||
== post.content
|
== post.content
|
||||||
|
8
app/views/more/index.rb
Normal file
8
app/views/more/index.rb
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
module Adamantium
|
||||||
|
module Views
|
||||||
|
module More
|
||||||
|
class Index < View
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
21
app/views/posts/archive.rb
Normal file
21
app/views/posts/archive.rb
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
module Adamantium
|
||||||
|
module Views
|
||||||
|
module Posts
|
||||||
|
class Archive < View
|
||||||
|
include Deps["repos.post_repo"]
|
||||||
|
|
||||||
|
expose :year do |year:|
|
||||||
|
year
|
||||||
|
end
|
||||||
|
|
||||||
|
expose :posts do |year:|
|
||||||
|
post_repo.by_year(year: year).map { |post| Decorators::Posts::Decorator.new(post) }
|
||||||
|
end
|
||||||
|
|
||||||
|
expose :post_years do
|
||||||
|
post_repo.post_years.map { |py| py[:year].to_i }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
@@ -9,6 +9,10 @@ module Adamantium
|
|||||||
Decorators::Posts::Decorator.new(post)
|
Decorators::Posts::Decorator.new(post)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
expose :post_years do
|
||||||
|
post_repo.post_years.map { |py| py[:year].to_i }
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@@ -19,7 +19,7 @@ module Adamantium
|
|||||||
get "/post/top_tracks/:slug", to: "posts.top_tracks"
|
get "/post/top_tracks/:slug", to: "posts.top_tracks"
|
||||||
get "/post/:slug", to: "posts.show"
|
get "/post/:slug", to: "posts.show"
|
||||||
get "/posts", to: "posts.index"
|
get "/posts", to: "posts.index"
|
||||||
# get "/posts/archive/:year", to: "posts.archive"
|
get "/posts/archive/:year", to: "posts.archive"
|
||||||
|
|
||||||
get "/bookmarks", to: "bookmarks.index"
|
get "/bookmarks", to: "bookmarks.index"
|
||||||
get "/bookmarks/metadata/:id", to: "bookmarks.metadata"
|
get "/bookmarks/metadata/:id", to: "bookmarks.metadata"
|
||||||
@@ -29,7 +29,7 @@ module Adamantium
|
|||||||
get "/places", to: "places.index"
|
get "/places", to: "places.index"
|
||||||
get "/statuses", to: "statuses.index"
|
get "/statuses", to: "statuses.index"
|
||||||
|
|
||||||
# get "/tags", to: "tags.index"
|
get "/tags", to: "tags.index"
|
||||||
get "/tagged/:slug", to: "tags.show"
|
get "/tagged/:slug", to: "tags.show"
|
||||||
|
|
||||||
get "/key", to: "key.show" if Hanami.app.settings.micropub_pub_key
|
get "/key", to: "key.show" if Hanami.app.settings.micropub_pub_key
|
||||||
@@ -37,7 +37,7 @@ module Adamantium
|
|||||||
get "/feeds/rss", to: "feeds.rss"
|
get "/feeds/rss", to: "feeds.rss"
|
||||||
get "/feeds/statuses_rss", to: "feeds.statuses_rss"
|
get "/feeds/statuses_rss", to: "feeds.statuses_rss"
|
||||||
|
|
||||||
# get "/more", to: "more.index"
|
get "/more", to: "more.index"
|
||||||
|
|
||||||
get "/hikes", to: "workouts.index"
|
get "/hikes", to: "workouts.index"
|
||||||
post "/workouts", to: "workouts.create"
|
post "/workouts", to: "workouts.create"
|
||||||
|
Reference in New Issue
Block a user