Add statuses
This commit is contained in:
12
app/actions/statuses/index.rb
Normal file
12
app/actions/statuses/index.rb
Normal file
@@ -0,0 +1,12 @@
|
||||
module Adamantium
|
||||
module Actions
|
||||
module Statuses
|
||||
class Index < Action
|
||||
include Deps["views.statuses.index"]
|
||||
def handle(req, res)
|
||||
res.render index
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
@@ -3,6 +3,7 @@
|
||||
# auto_register: false
|
||||
|
||||
require "rexml/parsers/pullparser"
|
||||
require "sanitize"
|
||||
|
||||
module Adamantium
|
||||
module Decorators
|
||||
@@ -58,6 +59,10 @@ module Adamantium
|
||||
photos? ? "<div>#{photos.map { |p| "<img src='#{p["value"]}'/>" }.join("")} #{content}</div>" : content
|
||||
end
|
||||
|
||||
def raw_content
|
||||
Sanitize.fragment(content)
|
||||
end
|
||||
|
||||
def excerpt
|
||||
truncate_html(content, 140, true)
|
||||
end
|
||||
|
@@ -55,6 +55,7 @@ module Adamantium
|
||||
def post_listing(limit: nil)
|
||||
posts
|
||||
.where(post_type: "post", location: nil)
|
||||
.exclude(name: nil)
|
||||
.published
|
||||
.combine(:tags)
|
||||
.order(Sequel.desc(:published_at))
|
||||
@@ -93,6 +94,25 @@ module Adamantium
|
||||
query ? base.where(Sequel.ilike(:name, "%#{query}%")).to_a : base.to_a
|
||||
end
|
||||
|
||||
def statuses_listing(limit: nil)
|
||||
posts
|
||||
.where(post_type: "post", name: nil)
|
||||
.published
|
||||
.combine(:tags)
|
||||
.order(Sequel.desc(:published_at))
|
||||
.limit(limit)
|
||||
.to_a
|
||||
end
|
||||
|
||||
def latest_status
|
||||
posts
|
||||
.where(name: nil)
|
||||
.published
|
||||
.order(Sequel.desc(:published_at))
|
||||
.limit(1)
|
||||
.one
|
||||
end
|
||||
|
||||
def last_location
|
||||
posts
|
||||
.where(post_type: "checkin")
|
||||
|
@@ -4,9 +4,17 @@ div class="h-card prose dark:prose-invert mb-12 max-w-prose mx-auto text-gray-80
|
||||
|
||||
div class="mb-8 max-w-screen-md mx-auto border-t-4 border-solid border-gray-400 dark:border-gray-600"
|
||||
|
||||
div class="mb-12 p-2 grid grid-cols-7 gap-4 min-h-16 max-w-prose mx-auto bg-fuchsia-100 dark:bg-fuchsia-800 dark:text-gray-200 rounded"
|
||||
div class="col-span-6 text-left"
|
||||
a class="block my-auto hover:underline decoration-wavy" href=latest_status.permalink
|
||||
== "#{latest_status.raw_content}"
|
||||
a class="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="mb-4 flex max-w-prose mx-auto"
|
||||
h2 class="text-l text-gray-600 dark:text-gray-200" Recent posts
|
||||
a class="text-right flex-1 text-blue-400" href="/posts" See all →
|
||||
h2 class="text-l" Posts
|
||||
a class="text-right flex-1 text-blue-400 dark:text-blue-200" href="/posts" See all →
|
||||
|
||||
div class="mb-12 max-w-prose mx-auto"
|
||||
- posts.each do |post|
|
||||
|
8
app/templates/statuses/index.html.slim
Normal file
8
app/templates/statuses/index.html.slim
Normal file
@@ -0,0 +1,8 @@
|
||||
div class="mb-12 prose dark:prose-invert max-w-prose mx-auto text-gray-800 dark:text-gray-200"
|
||||
h1 Statuses
|
||||
|
||||
div class="h-feed mb-12 max-w-prose mx-auto"
|
||||
- posts.each do |post|
|
||||
== render :post, post: post
|
||||
|
||||
div class="max-w-screen-md mx-auto border-t-4 border-solid border-gray-400 dark:border-gray-600"
|
@@ -22,6 +22,10 @@ module Adamantium
|
||||
end
|
||||
end
|
||||
|
||||
expose :latest_status do
|
||||
Decorators::Posts::Decorator.new(post_repo.latest_status)
|
||||
end
|
||||
|
||||
expose :last_location do
|
||||
Decorators::Posts::Decorator.new(post_repo.last_location)
|
||||
end
|
||||
|
15
app/views/statuses/index.rb
Normal file
15
app/views/statuses/index.rb
Normal file
@@ -0,0 +1,15 @@
|
||||
module Adamantium
|
||||
module Views
|
||||
module Statuses
|
||||
class Index < Adamantium::View
|
||||
include Deps["repos.post_repo"]
|
||||
|
||||
expose :posts do
|
||||
post_repo.statuses_listing.map do |post|
|
||||
Decorators::Posts::Decorator.new(post)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
Reference in New Issue
Block a user