Show bookmarks on post page
This commit is contained in:
@@ -5,9 +5,10 @@ module Main
|
||||
include Deps["views.posts.show"]
|
||||
|
||||
def handle(req, res)
|
||||
slug = req.params[:slug]
|
||||
|
||||
res.render show, slug: slug
|
||||
res.status = 200
|
||||
res.body = cache(key: "posts_show",
|
||||
params: [req.params[:slug]],
|
||||
content_proc: ->(slug) { show.call(context: Main::Views::Context.new(request: req), slug: slug) })
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@@ -10,13 +10,6 @@ module Main
|
||||
end
|
||||
|
||||
def from_the_archives(start_date:, end_date:)
|
||||
# SELECT * FROM posts
|
||||
# WHERE EXTRACT(month FROM "published_at") >= 2
|
||||
# WHERE EXTRACT(month FROM "published_at") <= 2+
|
||||
# AND EXTRACT(day FROM "published_at") > 20
|
||||
# AND EXTRACT(day FROM "published_at") < 27
|
||||
# AND post_type = 'post';
|
||||
|
||||
movies
|
||||
.where { Sequel.extract(:year, :watched_at) >= start_date.year }
|
||||
.where { Sequel.extract(:year, :watched_at) <= start_date.year }
|
||||
|
@@ -154,6 +154,13 @@ module Main
|
||||
.to_a
|
||||
end
|
||||
|
||||
def bookmarks_for_week(date:)
|
||||
posts
|
||||
.where(post_type: "bookmark")
|
||||
.where(published_at: TimeMath.day.advance(date, -7)...TimeMath.day.floor(date))
|
||||
.to_a
|
||||
end
|
||||
|
||||
def all_posts
|
||||
posts
|
||||
.where(post_type: ["post", "code", "bookmark"])
|
||||
|
@@ -109,6 +109,14 @@ article class="h-entry"
|
||||
img loading="lazy" class="rounded hover:opacity-80" src=movie.poster
|
||||
/ figcaption= movie.title
|
||||
hr
|
||||
- if bookmarks_this_week.count > 0
|
||||
div class="max-w-prose mx-auto text-gray-600 dark:text-gray-200 mb-8"
|
||||
h3 class="text-xl mb-4" Bookmarked this week
|
||||
ul
|
||||
- bookmarks_this_week.each do |bookmark|
|
||||
li
|
||||
a class="block bg-emerald-100 dark:bg-emerald-600 hover:dark:bg-emerald-900 hover:bg-emerald-200 dark:text-white rounded mb-2 p-2" href=bookmark.url
|
||||
span class="grow-0 inline-block" = bookmark.name
|
||||
- if text_posts.count > 0 || photo_posts.count > 0
|
||||
div class="max-w-prose mx-auto text-gray-600 dark:text-gray-200 mb-4"
|
||||
h3 class="text-xl mb-0" This week, years ago
|
||||
@@ -123,7 +131,6 @@ article class="h-entry"
|
||||
span class="grow-0 inline-block pr-2" = past_post.display_title
|
||||
span class="border-b border-blue-400 dark:border-blue-900 -top-3 relative border-dashed grow inline-block"
|
||||
span class="grow-0 inline-block pl-2" = past_post.published_at.year
|
||||
|
||||
div class="max-w-prose mx-auto text-gray-600 dark:text-gray-200 flex"
|
||||
div class="grid grid-cols-3 gap-4 mb-4 max-w-prose mx-auto"
|
||||
- photo_posts.group_by{ |p| p.published_at.year }.each do |year, posts|
|
||||
|
@@ -24,6 +24,10 @@ module Main
|
||||
movies.map { |p| Decorators::Movies::Decorator.new(p) }
|
||||
end
|
||||
|
||||
expose :bookmarks_this_week do |post|
|
||||
post_repo.bookmarks_for_week(date: post.published_at).map { |p| Decorators::Posts::Decorator.new(p) }
|
||||
end
|
||||
|
||||
expose :text_posts do |past_posts|
|
||||
past_posts.reject(&:photos?)
|
||||
end
|
||||
@@ -44,11 +48,11 @@ module Main
|
||||
end
|
||||
|
||||
expose :replies do |post|
|
||||
post.webmentions.select {|w| w[:type] == "reply" }
|
||||
post.webmentions.select { |w| w[:type] == "reply" }
|
||||
end
|
||||
|
||||
expose :likes do |post|
|
||||
post.webmentions.select {|w| w[:type] == "like" }
|
||||
post.webmentions.select { |w| w[:type] == "like" }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Reference in New Issue
Block a user