Files
danbooru/app/helpers/posts_helper.rb
evazion 07bdc6eab0 comments: rework thresholded comments.
Previously thresholded comments were hidden completely. You had to click
the "Show X hidden comments" button to unhide all hidden comments in a
thread. Now it works like this:

* When a comment is below your threshold, the comment text is hidden and
  replaced by a `[hidden]` link, which you can click to unhide the comment.

* When a comment is at half your threshold (for example, your threshold
  is -8 but the comment is at -4), then the comment is greyed out.

This means that comments aren't completely hidden, they're just
collapsed, so you can see the commenter and the score without unhiding
the comment. It also means you don't have to scroll back up to unhide a
comment, and threads aren't disrupted by comments being secretly
hidden (which is confusing when people are replying to hidden comments,
which forces you to go back up and unhide to find).
2021-01-19 04:07:33 -06:00

52 lines
1.6 KiB
Ruby

module PostsHelper
def reportbooru_enabled?
Danbooru.config.reportbooru_server.present? && Danbooru.config.reportbooru_key.present?
end
def discover_mode?
params[:tags] =~ /order:rank/ || params[:action] =~ /searches|viewed/
end
def missed_post_search_count_js(tags)
return unless reportbooru_enabled?
sig = generate_reportbooru_signature(tags)
render "posts/partials/index/missed_search_count", sig: sig
end
def post_search_count_js(tags)
return unless reportbooru_enabled?
sig = generate_reportbooru_signature("ps-#{tags}")
render "posts/partials/index/search_count", sig: sig
end
def post_view_count_js
return unless reportbooru_enabled?
msg = generate_reportbooru_signature(params[:id])
render "posts/partials/show/view_count", msg: msg
end
def generate_reportbooru_signature(value)
verifier = ActiveSupport::MessageVerifier.new(Danbooru.config.reportbooru_key, serializer: JSON, digest: "SHA256")
verifier.generate("#{value},#{session[:session_id]}")
end
def post_source_tag(source, normalized_source = source)
# Only allow http:// and https:// links. Disallow javascript: links.
if source =~ %r!\Ahttps?://!i
external_link_to(normalized_source, strip: :subdomain) + " ".html_safe + link_to("»", source, rel: "external noreferrer nofollow")
else
source
end
end
def is_pool_selected?(pool)
return false if params.key?(:q)
return false if params.key?(:favgroup_id)
return false if !params.key?(:pool_id)
return params[:pool_id].to_i == pool.id
end
end