Add posts from archive to weekly posts
This commit is contained in:
@@ -124,6 +124,25 @@ module Adamantium
|
|||||||
.one
|
.one
|
||||||
end
|
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';
|
||||||
|
|
||||||
|
posts
|
||||||
|
.where(post_type: "post")
|
||||||
|
.published
|
||||||
|
.where { Sequel.extract(:year, :published_at) < start_date.year }
|
||||||
|
.where { Sequel.extract(:month, :published_at) >= start_date.month }
|
||||||
|
.where { Sequel.extract(:month, :published_at) <= end_date.month }
|
||||||
|
.where { Sequel.extract(:day, :published_at) >= start_date.day }
|
||||||
|
.where { Sequel.extract(:day, :published_at) <= end_date.day }
|
||||||
|
.to_a
|
||||||
|
end
|
||||||
|
|
||||||
def for_rss
|
def for_rss
|
||||||
posts
|
posts
|
||||||
.where(post_type: "post", location: nil)
|
.where(post_type: "post", location: nil)
|
||||||
|
@@ -26,8 +26,16 @@ article class="h-entry"
|
|||||||
|
|
||||||
- if post.tags.map(&:label).include? "weekly"
|
- if post.tags.map(&:label).include? "weekly"
|
||||||
div class="max-w-prose mx-auto text-gray-600 dark:text-gray-200 flex"
|
div class="max-w-prose mx-auto text-gray-600 dark:text-gray-200 flex"
|
||||||
div class="mx-auto" hx-get="/post/top_tracks/#{post.slug}" hx-trigger="load"
|
div hx-get="/post/top_tracks/#{post.slug}" hx-trigger="load"
|
||||||
|
|
||||||
|
- if past_posts.count > 0
|
||||||
|
div class="block grow bg-blue-100 dark:bg-blue-600 rounded px-4 py-2 mb-12"
|
||||||
|
p class="text-sm mb-0" This week, years ago
|
||||||
|
ul class="mt-0"
|
||||||
|
- past_posts.each do |past_post|
|
||||||
|
li class="m-0"
|
||||||
|
a class="hover:underline" href=past_post.permalink
|
||||||
|
= "#{past_post.display_title} (#{past_post.published_at.year})"
|
||||||
div class="mb-4 max-w-screen-md mx-auto border-t-4 border-solid border-gray-400 dark:border-gray-600"
|
div class="mb-4 max-w-screen-md mx-auto border-t-4 border-solid border-gray-400 dark:border-gray-600"
|
||||||
|
|
||||||
div class="max-w-prose mx-auto text-gray-600 dark:text-gray-200 flex"
|
div class="max-w-prose mx-auto text-gray-600 dark:text-gray-200 flex"
|
||||||
|
@@ -1,11 +1,12 @@
|
|||||||
a href=url class="block flex bg-pink-100 dark:bg-pink-600 rounded px-4 py-2 mb-12"
|
div class="mx-auto mr-4"
|
||||||
div class="mr-4 my-auto"
|
a href=url class="block flex bg-pink-100 dark:bg-pink-600 rounded px-4 py-2 mb-12"
|
||||||
div class="w-34 h-34 my-auto text-[2.041rem] block dark:hidden" 👩🏼🎤
|
div class="mr-4 my-auto"
|
||||||
div class="w-34 h-34 my-auto text-[2.041rem] hidden dark:block" 👨🏽🎤
|
div class="w-34 h-34 my-auto text-[2.041rem] block dark:hidden" 👩🏼🎤
|
||||||
div
|
div class="w-34 h-34 my-auto text-[2.041rem] hidden dark:block" 👨🏽🎤
|
||||||
p class="text-sm" Top track this week
|
div
|
||||||
p class=""
|
p class="text-sm" Top track this week
|
||||||
span class="font-semibold"= name
|
p class="hover:underline"
|
||||||
span by
|
span class="font-semibold"= name
|
||||||
span class="font-semibold"= artist
|
span by
|
||||||
|
span class="font-semibold"= artist
|
||||||
|
|
||||||
|
@@ -1,3 +1,5 @@
|
|||||||
|
require "time_math"
|
||||||
|
|
||||||
module Adamantium
|
module Adamantium
|
||||||
module Views
|
module Views
|
||||||
module Posts
|
module Posts
|
||||||
@@ -7,6 +9,13 @@ module Adamantium
|
|||||||
expose :post do |slug:|
|
expose :post do |slug:|
|
||||||
Decorators::Posts::Decorator.new(post_repo.fetch!(slug))
|
Decorators::Posts::Decorator.new(post_repo.fetch!(slug))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
expose :past_posts do |post|
|
||||||
|
start_date = TimeMath.week.floor(post.published_at)
|
||||||
|
end_date = TimeMath.week.ceil(post.published_at)
|
||||||
|
posts = post_repo.from_the_archives(start_date: start_date, end_date: end_date)
|
||||||
|
posts.map { |p| Decorators::Posts::Decorator.new(p) }
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Reference in New Issue
Block a user