Add statuses
This commit is contained in:
1
Gemfile
1
Gemfile
@@ -33,6 +33,7 @@ gem "pinboard", git: "https://github.com/dnitza/pinboard", branch: "master"
|
|||||||
gem "ogpr"
|
gem "ogpr"
|
||||||
gem "ruby-filemagic", git: "https://github.com/dnitza/ruby-filemagic", branch: "master"
|
gem "ruby-filemagic", git: "https://github.com/dnitza/ruby-filemagic", branch: "master"
|
||||||
gem "webmention"
|
gem "webmention"
|
||||||
|
gem "sanitize"
|
||||||
|
|
||||||
group :cli, :development do
|
group :cli, :development do
|
||||||
gem "hanami-reloader"
|
gem "hanami-reloader"
|
||||||
|
@@ -56,6 +56,7 @@ GEM
|
|||||||
sshkit (~> 1.3)
|
sshkit (~> 1.3)
|
||||||
coderay (1.1.3)
|
coderay (1.1.3)
|
||||||
concurrent-ruby (1.2.0)
|
concurrent-ruby (1.2.0)
|
||||||
|
crass (1.0.6)
|
||||||
database_cleaner-core (2.0.1)
|
database_cleaner-core (2.0.1)
|
||||||
database_cleaner-sequel (2.0.2)
|
database_cleaner-sequel (2.0.2)
|
||||||
database_cleaner-core (~> 2.0.0)
|
database_cleaner-core (~> 2.0.0)
|
||||||
@@ -339,6 +340,9 @@ GEM
|
|||||||
rubocop-ast (>= 0.4.0)
|
rubocop-ast (>= 0.4.0)
|
||||||
ruby-progressbar (1.11.0)
|
ruby-progressbar (1.11.0)
|
||||||
ruby2_keywords (0.0.5)
|
ruby2_keywords (0.0.5)
|
||||||
|
sanitize (6.0.1)
|
||||||
|
crass (~> 1.0.2)
|
||||||
|
nokogiri (>= 1.12.0)
|
||||||
sequel (5.65.0)
|
sequel (5.65.0)
|
||||||
shellany (0.0.1)
|
shellany (0.0.1)
|
||||||
slim (5.0.0)
|
slim (5.0.0)
|
||||||
@@ -405,6 +409,7 @@ DEPENDENCIES
|
|||||||
rom-factory
|
rom-factory
|
||||||
rom-sql
|
rom-sql
|
||||||
ruby-filemagic!
|
ruby-filemagic!
|
||||||
|
sanitize
|
||||||
slim
|
slim
|
||||||
standardrb
|
standardrb
|
||||||
timecop
|
timecop
|
||||||
|
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
|
# auto_register: false
|
||||||
|
|
||||||
require "rexml/parsers/pullparser"
|
require "rexml/parsers/pullparser"
|
||||||
|
require "sanitize"
|
||||||
|
|
||||||
module Adamantium
|
module Adamantium
|
||||||
module Decorators
|
module Decorators
|
||||||
@@ -58,6 +59,10 @@ module Adamantium
|
|||||||
photos? ? "<div>#{photos.map { |p| "<img src='#{p["value"]}'/>" }.join("")} #{content}</div>" : content
|
photos? ? "<div>#{photos.map { |p| "<img src='#{p["value"]}'/>" }.join("")} #{content}</div>" : content
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def raw_content
|
||||||
|
Sanitize.fragment(content)
|
||||||
|
end
|
||||||
|
|
||||||
def excerpt
|
def excerpt
|
||||||
truncate_html(content, 140, true)
|
truncate_html(content, 140, true)
|
||||||
end
|
end
|
||||||
|
@@ -55,6 +55,7 @@ module Adamantium
|
|||||||
def post_listing(limit: nil)
|
def post_listing(limit: nil)
|
||||||
posts
|
posts
|
||||||
.where(post_type: "post", location: nil)
|
.where(post_type: "post", location: nil)
|
||||||
|
.exclude(name: nil)
|
||||||
.published
|
.published
|
||||||
.combine(:tags)
|
.combine(:tags)
|
||||||
.order(Sequel.desc(:published_at))
|
.order(Sequel.desc(:published_at))
|
||||||
@@ -93,6 +94,25 @@ module Adamantium
|
|||||||
query ? base.where(Sequel.ilike(:name, "%#{query}%")).to_a : base.to_a
|
query ? base.where(Sequel.ilike(:name, "%#{query}%")).to_a : base.to_a
|
||||||
end
|
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
|
def last_location
|
||||||
posts
|
posts
|
||||||
.where(post_type: "checkin")
|
.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-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"
|
div class="mb-4 flex max-w-prose mx-auto"
|
||||||
h2 class="text-l text-gray-600 dark:text-gray-200" Recent posts
|
h2 class="text-l" Posts
|
||||||
a class="text-right flex-1 text-blue-400" href="/posts" See all →
|
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"
|
div class="mb-12 max-w-prose mx-auto"
|
||||||
- posts.each do |post|
|
- 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
|
||||||
end
|
end
|
||||||
|
|
||||||
|
expose :latest_status do
|
||||||
|
Decorators::Posts::Decorator.new(post_repo.latest_status)
|
||||||
|
end
|
||||||
|
|
||||||
expose :last_location do
|
expose :last_location do
|
||||||
Decorators::Posts::Decorator.new(post_repo.last_location)
|
Decorators::Posts::Decorator.new(post_repo.last_location)
|
||||||
end
|
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
|
@@ -25,6 +25,7 @@ module Adamantium
|
|||||||
|
|
||||||
get "/photos", to: "photos.index"
|
get "/photos", to: "photos.index"
|
||||||
get "/places", to: "places.index"
|
get "/places", to: "places.index"
|
||||||
|
get "/statuses", to: "statuses.index"
|
||||||
|
|
||||||
get "/tagged/:slug", to: "tags.show"
|
get "/tagged/:slug", to: "tags.show"
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user