Filter week posts on homepage
This commit is contained in:
@@ -94,6 +94,18 @@ module Adamantium
|
||||
.to_a
|
||||
end
|
||||
|
||||
def week_posts(limit: nil)
|
||||
posts
|
||||
.where(post_type: "post", location: nil)
|
||||
.exclude(name: nil)
|
||||
.weekly
|
||||
.published
|
||||
.combine(:tags)
|
||||
.order(Sequel.desc(:published_at))
|
||||
.limit(limit)
|
||||
.to_a
|
||||
end
|
||||
|
||||
def post_listing(limit: nil)
|
||||
posts
|
||||
.where(post_type: "post", location: nil)
|
||||
@@ -105,6 +117,18 @@ module Adamantium
|
||||
.to_a
|
||||
end
|
||||
|
||||
def home_post_listing(limit: nil)
|
||||
posts
|
||||
.where(post_type: "post", location: nil)
|
||||
.exclude(name: nil)
|
||||
.non_weekly
|
||||
.published
|
||||
.combine(:tags)
|
||||
.order(Sequel.desc(:published_at))
|
||||
.limit(limit)
|
||||
.to_a
|
||||
end
|
||||
|
||||
def photo_listing(limit: nil)
|
||||
posts
|
||||
.where(post_type: ["post", "checkin"])
|
||||
|
@@ -19,6 +19,16 @@ div class="mb-8 max-w-screen-md mx-auto border-t-4 border-solid border-gray-400
|
||||
a class="col-span-7 sm:col-span-1 px-2 text-center transition-colors rounded bg-fuchsia-50 hover:bg-fuchsia-200 dark:bg-fuchsia-900 dark:hover:bg-fuchsia-700 inline-block grid content-center max-h-12 my-auto" href="/statuses"
|
||||
p See all
|
||||
|
||||
div class="flex justify-between max-w-prose mx-auto mb-2"
|
||||
h2 class="text-l text-gray-600 dark:text-gray-200" Weekly posts
|
||||
a class="rounded px-2 text-blue-600 bg-blue-100 dark:bg-blue-900/60 hover:dark:bg-blue-800 hover:dark:text-blue-100 dark:text-blue-200 hover:text-blue-600 hover:bg-blue-200" href="/tagged/weekly" See all →
|
||||
|
||||
div class="mb-12 max-w-prose mx-auto bg-gray-100 rounded p-2 dark:bg-gray-900 dark:text-gray-100"
|
||||
ul class="columns-2"
|
||||
- week_posts.each do |post|
|
||||
li
|
||||
a class="hover:underline decoration-wavy" href="/post/#{post.slug}" = post.name
|
||||
|
||||
div class="flex justify-between max-w-prose mx-auto mb-2"
|
||||
h2 class="text-l text-gray-600 dark:text-gray-200" 📯 Posts
|
||||
a class="rounded px-2 text-blue-600 bg-blue-100 dark:bg-blue-900/60 hover:dark:bg-blue-800 hover:dark:text-blue-100 dark:text-blue-200 hover:text-blue-600 hover:bg-blue-200" href="/posts" See all →
|
||||
|
@@ -10,8 +10,14 @@ module Adamantium
|
||||
renderer.call(content: markdown_content)
|
||||
end
|
||||
|
||||
expose :week_posts do
|
||||
post_repo.week_posts(limit: 10).map do |post|
|
||||
Decorators::Posts::Decorator.new(post)
|
||||
end
|
||||
end
|
||||
|
||||
expose :posts do
|
||||
post_repo.post_listing(limit: 5).map do |post|
|
||||
post_repo.home_post_listing(limit: 5).map do |post|
|
||||
Decorators::Posts::Decorator.new(post)
|
||||
end
|
||||
end
|
||||
|
@@ -22,6 +22,16 @@ module Adamantium
|
||||
where(self[:published_at] <= Time.now)
|
||||
end
|
||||
|
||||
def weekly
|
||||
ref = post_tags.where(:tag_id => "70").select(:post_id).dataset
|
||||
where(:id => ref)
|
||||
end
|
||||
|
||||
def non_weekly
|
||||
ref = post_tags.where(:tag_id => "70").select(:post_id).dataset
|
||||
exclude(:id => ref)
|
||||
end
|
||||
|
||||
def published_between(start_date, end_date)
|
||||
where(self[:published_at] >= start_date)
|
||||
.where(self[:published_at] <= end_date)
|
||||
|
Reference in New Issue
Block a user