Add “more” page

This commit is contained in:
2023-04-25 20:45:16 +10:00
parent 7155d19d84
commit ad3f557dc2
14 changed files with 140 additions and 7 deletions

View File

@@ -53,6 +53,16 @@ module Adamantium
posts.post_tags.where(post_id: post_id, tag_id: tag[:id]).changeset(:delete).commit if tag
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)
posts
.where(post_type: "post", location: nil)
@@ -198,6 +208,17 @@ module Adamantium
delete_post = posts.where(slug: slug).command(:update)
delete_post.call(published_at: Time.now)
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

View File

@@ -4,6 +4,12 @@ module Adamantium
def fetch!(slug)
tags.where(slug: slug).one!
end
def list
tags
.order(Sequel.function(:lower, :label))
.to_a
end
end
end
end