diff --git a/Gemfile b/Gemfile
index 53cdae9..d070718 100644
--- a/Gemfile
+++ b/Gemfile
@@ -33,6 +33,7 @@ gem "pinboard", git: "https://github.com/dnitza/pinboard", branch: "master"
gem "ogpr"
gem "ruby-filemagic", git: "https://github.com/dnitza/ruby-filemagic", branch: "master"
gem "webmention"
+gem "sanitize"
group :cli, :development do
gem "hanami-reloader"
diff --git a/Gemfile.lock b/Gemfile.lock
index aa929b5..99714fe 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -56,6 +56,7 @@ GEM
sshkit (~> 1.3)
coderay (1.1.3)
concurrent-ruby (1.2.0)
+ crass (1.0.6)
database_cleaner-core (2.0.1)
database_cleaner-sequel (2.0.2)
database_cleaner-core (~> 2.0.0)
@@ -339,6 +340,9 @@ GEM
rubocop-ast (>= 0.4.0)
ruby-progressbar (1.11.0)
ruby2_keywords (0.0.5)
+ sanitize (6.0.1)
+ crass (~> 1.0.2)
+ nokogiri (>= 1.12.0)
sequel (5.65.0)
shellany (0.0.1)
slim (5.0.0)
@@ -405,6 +409,7 @@ DEPENDENCIES
rom-factory
rom-sql
ruby-filemagic!
+ sanitize
slim
standardrb
timecop
diff --git a/app/actions/statuses/index.rb b/app/actions/statuses/index.rb
new file mode 100644
index 0000000..fc39186
--- /dev/null
+++ b/app/actions/statuses/index.rb
@@ -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
diff --git a/app/decorators/posts/decorator.rb b/app/decorators/posts/decorator.rb
index 8124759..4658c73 100644
--- a/app/decorators/posts/decorator.rb
+++ b/app/decorators/posts/decorator.rb
@@ -3,6 +3,7 @@
# auto_register: false
require "rexml/parsers/pullparser"
+require "sanitize"
module Adamantium
module Decorators
@@ -58,6 +59,10 @@ module Adamantium
photos? ? "
#{photos.map { |p| "

" }.join("")} #{content}
" : content
end
+ def raw_content
+ Sanitize.fragment(content)
+ end
+
def excerpt
truncate_html(content, 140, true)
end
diff --git a/app/repos/post_repo.rb b/app/repos/post_repo.rb
index 205570b..ee3ffbe 100644
--- a/app/repos/post_repo.rb
+++ b/app/repos/post_repo.rb
@@ -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")
diff --git a/app/templates/site/home.html.slim b/app/templates/site/home.html.slim
index e6de270..691d298 100644
--- a/app/templates/site/home.html.slim
+++ b/app/templates/site/home.html.slim
@@ -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|
diff --git a/app/templates/statuses/index.html.slim b/app/templates/statuses/index.html.slim
new file mode 100644
index 0000000..e6b9a8d
--- /dev/null
+++ b/app/templates/statuses/index.html.slim
@@ -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"
diff --git a/app/views/site/home.rb b/app/views/site/home.rb
index 96741b9..9ad364a 100644
--- a/app/views/site/home.rb
+++ b/app/views/site/home.rb
@@ -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
diff --git a/app/views/statuses/index.rb b/app/views/statuses/index.rb
new file mode 100644
index 0000000..b5c61aa
--- /dev/null
+++ b/app/views/statuses/index.rb
@@ -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
diff --git a/config/routes.rb b/config/routes.rb
index 516f5f3..479fb00 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -25,6 +25,7 @@ module Adamantium
get "/photos", to: "photos.index"
get "/places", to: "places.index"
+ get "/statuses", to: "statuses.index"
get "/tagged/:slug", to: "tags.show"