show inkbunny descriptions, do not show files on public internet
This commit is contained in:
4
TODO.md
4
TODO.md
@@ -15,3 +15,7 @@
|
||||
- [ ] Create `belongs_to_log_entry` macro for ActiveRecord models
|
||||
- [ ] Use StaticFileJobHelper for Domain::Fa::Job::ScanFileJob
|
||||
- [ ] Unify HTTP client configs for all domains, so the same job type can be used for different domains
|
||||
- [ ] put abstract `external_url_for_view` in a module
|
||||
- [ ] backfill descriptions on inkbunny posts
|
||||
- [ ] store deep update json on inkbunny posts
|
||||
- [ ] limit number of users, or paginate for "users who favorited this post" page
|
||||
|
||||
@@ -158,7 +158,7 @@ class Domain::Post < ReduxApplicationRecord
|
||||
end
|
||||
|
||||
sig { abstract.returns(T.nilable(Addressable::URI)) }
|
||||
def domain_url_for_view
|
||||
def external_url_for_view
|
||||
end
|
||||
|
||||
sig { abstract.returns(T.nilable(Domain::PostFile)) }
|
||||
|
||||
@@ -117,7 +117,7 @@ class Domain::Post::E621Post < Domain::Post
|
||||
end
|
||||
|
||||
sig { override.returns(T.nilable(Addressable::URI)) }
|
||||
def domain_url_for_view
|
||||
def external_url_for_view
|
||||
if self.e621_id.present?
|
||||
Addressable::URI.parse("https://e621.net/posts/#{self.e621_id}")
|
||||
end
|
||||
|
||||
@@ -79,7 +79,7 @@ class Domain::Post::FaPost < Domain::Post
|
||||
end
|
||||
|
||||
sig { override.returns(T.nilable(Addressable::URI)) }
|
||||
def domain_url_for_view
|
||||
def external_url_for_view
|
||||
if self.fa_id.present?
|
||||
Addressable::URI.parse("https://www.furaffinity.net/view/#{self.fa_id}")
|
||||
end
|
||||
|
||||
@@ -105,6 +105,23 @@ class Domain::Post::InkbunnyPost < Domain::Post
|
||||
self.ib_id
|
||||
end
|
||||
|
||||
sig { override.returns(T.nilable(String)) }
|
||||
def description_for_view
|
||||
# TODO - this is a mess, need to backfill descriptions on inkbunny posts
|
||||
description || self.ib_detail_raw&.dig("submission_json", "description") ||
|
||||
begin
|
||||
contents = self.deep_update_log_entry&.response&.contents
|
||||
if contents.present?
|
||||
json = JSON.parse(contents)
|
||||
json["submissions"]
|
||||
.find { |s| s["submission_id"] == self.ib_id&.to_s }
|
||||
&.dig("description")
|
||||
end
|
||||
rescue StandardError
|
||||
nil
|
||||
end
|
||||
end
|
||||
|
||||
sig { override.returns(String) }
|
||||
def domain_abbreviation_for_view
|
||||
"IB"
|
||||
@@ -116,9 +133,9 @@ class Domain::Post::InkbunnyPost < Domain::Post
|
||||
end
|
||||
|
||||
sig { override.returns(T.nilable(Addressable::URI)) }
|
||||
def domain_url_for_view
|
||||
def external_url_for_view
|
||||
if self.ib_id.present?
|
||||
Addressable::URI.parse("https://inkbunny.net/post/#{self.ib_id}")
|
||||
Addressable::URI.parse("https://inkbunny.net/s/#{self.ib_id}")
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -165,7 +165,7 @@ class Domain::User < ReduxApplicationRecord
|
||||
end
|
||||
|
||||
sig { abstract.returns(T.nilable(String)) }
|
||||
def external_profile_url_for_view
|
||||
def external_url_for_view
|
||||
end
|
||||
|
||||
sig { abstract.returns(T.nilable(String)) }
|
||||
|
||||
@@ -51,7 +51,7 @@ class Domain::User::E621User < Domain::User
|
||||
end
|
||||
|
||||
sig { override.returns(T.nilable(String)) }
|
||||
def external_profile_url_for_view
|
||||
def external_url_for_view
|
||||
"https://e621.net/users/#{e621_id}" if e621_id.present?
|
||||
end
|
||||
|
||||
|
||||
@@ -132,7 +132,7 @@ class Domain::User::FaUser < Domain::User
|
||||
end
|
||||
|
||||
sig { override.returns(T.nilable(String)) }
|
||||
def external_profile_url_for_view
|
||||
def external_url_for_view
|
||||
"https://www.furaffinity.net/user/#{url_name}" if url_name.present?
|
||||
end
|
||||
|
||||
|
||||
@@ -55,8 +55,8 @@ class Domain::User::InkbunnyUser < Domain::User
|
||||
end
|
||||
|
||||
sig { override.returns(T.nilable(String)) }
|
||||
def external_profile_url_for_view
|
||||
"https://inkbunny.net/user/#{name}" if name.present?
|
||||
def external_url_for_view
|
||||
"https://inkbunny.net/#{name}" if name.present?
|
||||
end
|
||||
|
||||
sig { override.returns(T.nilable(String)) }
|
||||
|
||||
@@ -14,22 +14,22 @@ class Domain::PostPolicy < ApplicationPolicy
|
||||
|
||||
sig { returns(T::Boolean) }
|
||||
def view_file?
|
||||
user&.admin? || false
|
||||
user&.admin? || user&.moderator? || false
|
||||
end
|
||||
|
||||
sig { returns(T::Boolean) }
|
||||
def view_scan_metadata?
|
||||
user&.admin? || false
|
||||
user&.admin? || user&.moderator? || false
|
||||
end
|
||||
|
||||
sig { returns(T::Boolean) }
|
||||
def users_faving_post?
|
||||
user&.admin? || false
|
||||
user&.admin? || user&.moderator? || false
|
||||
end
|
||||
|
||||
sig { returns(T::Boolean) }
|
||||
def view_faved_by?
|
||||
user&.admin? || false
|
||||
user&.admin? || user&.moderator? || false
|
||||
end
|
||||
|
||||
sig { returns(T::Boolean) }
|
||||
|
||||
@@ -29,6 +29,6 @@ class Domain::UserPolicy < ApplicationPolicy
|
||||
|
||||
sig { returns(T::Boolean) }
|
||||
def view_page_scanned_at_timestamps?
|
||||
user&.admin? || false
|
||||
user&.admin? || user&.moderator? || false
|
||||
end
|
||||
end
|
||||
|
||||
@@ -19,10 +19,11 @@
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
<div class="flex items-center justify-center p-4">
|
||||
<% if thumbnail_file = gallery_file_for_post(post) %>
|
||||
<%= link_to domain_post_path(post) do %>
|
||||
<%= image_tag blob_path(
|
||||
<% if policy(post).view_file?%>
|
||||
<div class="flex items-center justify-center p-4 border-b border-slate-300">
|
||||
<% if thumbnail_file = gallery_file_for_post(post) %>
|
||||
<%= link_to domain_post_path(post) do %>
|
||||
<%= image_tag blob_path(
|
||||
HexUtil.bin2hex(thumbnail_file.log_entry.response_sha256),
|
||||
format: "jpg",
|
||||
thumb: "small",
|
||||
@@ -30,12 +31,13 @@
|
||||
class:
|
||||
"max-h-[300px] max-w-[300px] rounded-md border border-slate-300 object-contain shadow-md",
|
||||
alt: post.title_for_view %>
|
||||
<% end %>
|
||||
<% else %>
|
||||
<span>No file available</span>
|
||||
<% end %>
|
||||
<% else %>
|
||||
<span>No file available</span>
|
||||
<% end %>
|
||||
</div>
|
||||
<div class="border-t border-slate-300">
|
||||
</div>
|
||||
<% end %>
|
||||
<div class="">
|
||||
<h2 class="p-4 text-center text-lg">
|
||||
<%= link_to post.title_for_view, domain_post_path(post), class: "sky-link" %>
|
||||
</h2>
|
||||
|
||||
@@ -4,9 +4,9 @@
|
||||
title: domain_post_domain_icon_title(post) %>
|
||||
<% link_class =
|
||||
"flex items-center text-slate-500 hover:text-slate-700 decoration-dotted underline" %>
|
||||
<% url = post.domain_url_for_view %>
|
||||
<% url = post.external_url_for_view %>
|
||||
<% if url.present? %>
|
||||
<%= link_to url.to_s, target: "_blank", rel: "noopener", class: link_class do %>
|
||||
<%= link_to url.to_s, target: "_blank", rel: "noopener noreferrer", class: link_class do %>
|
||||
<span
|
||||
><%= post.domain_abbreviation_for_view %>
|
||||
#<%= post.domain_id_for_view %></span
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<%= image_tag domain_post_domain_icon_path(post), class: "w-6 h-6" %>
|
||||
<span class="truncate text-lg font-medium">
|
||||
<%= link_to post.title_for_view,
|
||||
post.domain_url_for_view.to_s,
|
||||
post.external_url_for_view.to_s,
|
||||
class: "text-blue-600 hover:underline",
|
||||
target: "_blank" %>
|
||||
</span>
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
} %>
|
||||
<% else %>
|
||||
<section class="sky-section">
|
||||
<%= link_to post.domain_url_for_view.to_s,
|
||||
<%= link_to post.external_url_for_view.to_s,
|
||||
target: "_blank",
|
||||
rel: "noopener noreferrer",
|
||||
class: "section-header flex items-center gap-2 hover:text-slate-600" do %>
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
</div>
|
||||
</div>
|
||||
<a
|
||||
href="<%= user.external_profile_url_for_view %>"
|
||||
href="<%= user.external_url_for_view %>"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
class="sky-link flex items-center gap-2"
|
||||
|
||||
@@ -17,8 +17,8 @@
|
||||
<% end %>
|
||||
</div>
|
||||
<div class="d-flex align-items-center ms-auto gap-2">
|
||||
<% if post.domain_url_for_view.present? %>
|
||||
<%= link_to post.domain_url_for_view.to_s,
|
||||
<% if post.external_url_for_view.present? %>
|
||||
<%= link_to post.external_url_for_view.to_s,
|
||||
class: "badge bg-secondary text-truncate-link",
|
||||
target: "_blank",
|
||||
rel: "noopener noreferrer nofollow" do %>
|
||||
|
||||
@@ -17,8 +17,8 @@
|
||||
<% end %>
|
||||
</div>
|
||||
<div class="d-flex align-items-center ms-auto gap-2">
|
||||
<% if user.external_profile_url_for_view.present? %>
|
||||
<%= link_to user.external_profile_url_for_view,
|
||||
<% if user.external_url_for_view.present? %>
|
||||
<%= link_to user.external_url_for_view,
|
||||
class: "badge bg-secondary text-truncate-link",
|
||||
target: "_blank",
|
||||
rel: "noopener noreferrer nofollow" do %>
|
||||
|
||||
@@ -5,7 +5,9 @@
|
||||
<div class="flex flex-wrap gap-x-4 text-sm text-slate-600">
|
||||
<span>
|
||||
<i class="fa-regular fa-file mr-1"></i>
|
||||
Type: <%= log_entry.content_type %>
|
||||
<% ct = log_entry.content_type %>
|
||||
<% ct = ct.split(";").first if ct %>
|
||||
Type: <%= ct %>
|
||||
</span>
|
||||
<span>
|
||||
<i class="fa-solid fa-weight-hanging mr-1"></i>
|
||||
@@ -13,7 +15,7 @@
|
||||
</span>
|
||||
<span>
|
||||
<i class="fa-solid fa-clock mr-1"></i>
|
||||
Response Time: <%= log_entry.response_time_ms %>ms
|
||||
Response Time: <%= log_entry.response_time_ms == -1 ? "(unknown)" : "#{log_entry.response_time_ms}ms" %>
|
||||
</span>
|
||||
<span>
|
||||
<i class="fa-solid fa-signal mr-1"></i>
|
||||
|
||||
Reference in New Issue
Block a user