diff --git a/.github/workflows/reviewdog.yml b/.github/workflows/reviewdog.yml index 58d50002cce..3af37b18225 100644 --- a/.github/workflows/reviewdog.yml +++ b/.github/workflows/reviewdog.yml @@ -11,6 +11,8 @@ jobs: rubocop: name: Rubocop runs-on: ubuntu-latest + env: + BUNDLE_ONLY: linters steps: - name: Check out code uses: actions/checkout@v4 @@ -21,7 +23,7 @@ jobs: bundler-cache: true - name: rubocop - uses: reviewdog/action-rubocop@2f726ae5dd8df72b4faa9d93669cdab96aeb2153 + uses: reviewdog/action-rubocop@2c8048e3169487eccc1eed812daaa6e5275a809f with: use_bundler: true reporter: github-pr-check @@ -30,6 +32,8 @@ jobs: erb-lint: name: ERB Lint runner runs-on: ubuntu-latest + env: + BUNDLE_ONLY: linters steps: - name: Check out code uses: actions/checkout@v4 diff --git a/app/controllers/series_controller.rb b/app/controllers/series_controller.rb index d5b5a9722a1..697bff6d2c6 100644 --- a/app/controllers/series_controller.rb +++ b/app/controllers/series_controller.rb @@ -43,7 +43,7 @@ def index # GET /series/1 # GET /series/1.xml def show - @works = @series.works_in_order.posted.select(&:visible?) + @works = @series.works_in_order.posted.select(&:visible?).paginate(page: params[:page]) # sets the page title with the data for the series @page_title = @series.unrevealed? ? ts("Mystery Series") : get_page_title(@series.allfandoms.collect(&:name).join(', '), @series.anonymous? ? ts("Anonymous") : @series.allpseuds.collect(&:byline).join(', '), @series.title) diff --git a/app/helpers/validation_helper.rb b/app/helpers/validation_helper.rb index a73e12f55c2..7e7e72fb60d 100644 --- a/app/helpers/validation_helper.rb +++ b/app/helpers/validation_helper.rb @@ -42,9 +42,11 @@ def error_messages_for(object) end def error_messages_formatted(errors, intro = "") - return unless errors && !errors.empty? - error_messages = errors.map { |msg| content_tag(:li, msg.gsub(/^(.*)\^/, '').html_safe) }.join("\n").html_safe - content_tag(:div, intro.html_safe + content_tag(:ul, error_messages), id:"error", class:"error") + return unless errors.present? + + error_messages = errors.map { |msg| content_tag(:li, msg.gsub(/^(.*?)\^/, "").html_safe) } + .join("\n").html_safe + content_tag(:div, intro.html_safe + content_tag(:ul, error_messages), id: "error", class: "error") end # use to make sure we have consistent name throughout diff --git a/app/models/comment.rb b/app/models/comment.rb index 250a4c0df12..23fb2b02879 100644 --- a/app/models/comment.rb +++ b/app/models/comment.rb @@ -495,7 +495,7 @@ def mark_unhidden! end def sanitized_content - sanitize_field self, :comment_content + sanitize_field(self, :comment_content, strip_images: ultimate_parent.is_a?(AdminPost)) end include Responder end diff --git a/app/models/feedback_reporters/abuse_reporter.rb b/app/models/feedback_reporters/abuse_reporter.rb index 2d1159ebfb7..628258102e5 100644 --- a/app/models/feedback_reporters/abuse_reporter.rb +++ b/app/models/feedback_reporters/abuse_reporter.rb @@ -30,6 +30,8 @@ def subject end def ticket_description - description.present? ? description.html_safe : "No comment submitted." + return "No comment submitted." if description.blank? + + strip_images(description.html_safe) end end diff --git a/app/models/feedback_reporters/support_reporter.rb b/app/models/feedback_reporters/support_reporter.rb index 70c8a45d090..e4f3074985f 100644 --- a/app/models/feedback_reporters/support_reporter.rb +++ b/app/models/feedback_reporters/support_reporter.rb @@ -31,6 +31,8 @@ def subject end def ticket_description - description.present? ? description.html_safe : "No description submitted." + return "No description submitted." if description.blank? + + strip_images(description.html_safe) end end diff --git a/app/models/work.rb b/app/models/work.rb index 292d6957c55..da0501e4f98 100755 --- a/app/models/work.rb +++ b/app/models/work.rb @@ -183,10 +183,34 @@ def new_recipients_allow_gifts self.new_gifts.each do |gift| next if gift.pseud.blank? next if gift.pseud&.user&.preference&.allow_gifts? - next if self.challenge_assignments.map(&:requesting_pseud).include?(gift.pseud) - next if self.challenge_claims.reject { |c| c.request_prompt.anonymous? }.map(&:requesting_pseud).include?(gift.pseud) + next if challenge_bypass(gift) - self.errors.add(:base, ts("%{byline} does not accept gifts.", byline: gift.pseud.byline)) + self.errors.add(:base, :blocked_gifts, byline: gift.pseud.byline) + end + end + + validate :new_recipients_have_not_blocked_gift_giver + def new_recipients_have_not_blocked_gift_giver + return if self.new_gifts.blank? + + self.new_gifts.each do |gift| + # Already dealt with in #new_recipients_allow_gifts + next if gift.pseud&.user&.preference && !gift.pseud.user.preference.allow_gifts? + + next if challenge_bypass(gift) + + blocked_users = gift.pseud&.user&.blocked_users || [] + next if blocked_users.empty? + + pseuds_after_saving.each do |pseud| + next unless blocked_users.include?(pseud.user) + + if User.current_user == pseud.user + self.errors.add(:base, :blocked_your_gifts, byline: gift.pseud.byline) + else + self.errors.add(:base, :blocked_gifts, byline: gift.pseud.byline) + end + end end end @@ -1258,4 +1282,14 @@ def nonfiction def allow_collection_invitation? users.any? { |user| user.preference.allow_collection_invitation } end + + private + + def challenge_bypass(gift) + self.challenge_assignments.map(&:requesting_pseud).include?(gift.pseud) || + self.challenge_claims + .reject { |c| c.request_prompt.anonymous? } + .map(&:requesting_pseud) + .include?(gift.pseud) + end end diff --git a/app/views/admin/_header.html.erb b/app/views/admin/_header.html.erb index 0f319e124dc..e2e16dca705 100644 --- a/app/views/admin/_header.html.erb +++ b/app/views/admin/_header.html.erb @@ -1,72 +1,73 @@ -

<%= ts("Admin Navigation", key: "header") %>

- <% end %> - <% unless bookmark.bookmarker_notes.blank? %> + <% if bookmark.bookmarker_notes.present? %>
<%= ts("Bookmark Notes:") %>
- <%=raw sanitize_field(bookmark, :bookmarker_notes) %> + <%= raw sanitize_field(bookmark, :bookmarker_notes, strip_images: true) %>
<% end %> diff --git a/app/views/bookmarks/_bookmark_user_module.html.erb b/app/views/bookmarks/_bookmark_user_module.html.erb index 45faac2fbca..60330591694 100644 --- a/app/views/bookmarks/_bookmark_user_module.html.erb +++ b/app/views/bookmarks/_bookmark_user_module.html.erb @@ -45,10 +45,10 @@ <% end %> - <% unless bookmark.bookmarker_notes.blank? %> + <% if bookmark.bookmarker_notes.present? %>
<%= ts('Bookmarker\'s Notes') %>
- <%=raw sanitize_field(bookmark, :bookmarker_notes) %> + <%= raw sanitize_field(bookmark, :bookmarker_notes, strip_images: true) %>
<% end %> <% # end of information added by the bookmark owner %> diff --git a/app/views/collections/_collection_blurb.html.erb b/app/views/collections/_collection_blurb.html.erb index ea6ea2b066b..055927b3be7 100644 --- a/app/views/collections/_collection_blurb.html.erb +++ b/app/views/collections/_collection_blurb.html.erb @@ -72,8 +72,8 @@ <% end %> <% if !collection.user_is_owner?(current_user) && collection.moderated? && !(collection.challenge && collection.challenge.signup_open) %>
  • - <% if (@participant ||= collection.get_participants_for_user(current_user).first) %> - <%= link_to ts("Leave"), collection_participant_path(collection, @participant), + <% if (participant = collection.get_participants_for_user(current_user).first) %> + <%= link_to ts("Leave"), collection_participant_path(collection, participant), data: {confirm: ts('Are you certain you want to leave this collection?')}, :method => :delete %>
  • <% else %> diff --git a/app/views/comments/_single_comment.html.erb b/app/views/comments/_single_comment.html.erb index 19d8cb027f6..72085c022c2 100644 --- a/app/views/comments/_single_comment.html.erb +++ b/app/views/comments/_single_comment.html.erb @@ -55,7 +55,9 @@ <% if single_comment.hidden_by_admin? %>

    <%= ts("This comment has been hidden by an admin.") %>

    <% end %> -
    <%=raw sanitize_field(single_comment, :comment_content) %>
    +
    + <%= raw sanitize_field(single_comment, :comment_content, strip_images: single_comment.ultimate_parent.is_a?(AdminPost)) %> +
    <% end %> <% if single_comment.edited_at.present? %>

    diff --git a/app/views/inbox/_inbox_comment_contents.html.erb b/app/views/inbox/_inbox_comment_contents.html.erb index 6fa2eb974fc..0cb14c5a21d 100644 --- a/app/views/inbox/_inbox_comment_contents.html.erb +++ b/app/views/inbox/_inbox_comment_contents.html.erb @@ -26,7 +26,6 @@ <% end %> -<% # This feedback_comment used to be inbox_comment... not sure why %>

    - <%= raw sanitize_field(feedback_comment, :comment_content) %> + <%= raw sanitize_field(feedback_comment, :comment_content, strip_images: feedback_comment.ultimate_parent.is_a?(AdminPost)) %>
    diff --git a/app/views/layouts/_banner.html.erb b/app/views/layouts/_banner.html.erb index 745779d2186..25115ff1f6b 100644 --- a/app/views/layouts/_banner.html.erb +++ b/app/views/layouts/_banner.html.erb @@ -1,25 +1,20 @@ -<% # BACK END this seems giant and messy and confusing, pls can we review? - # FRONT END yes let us rewrite this -%> -<% unless current_user && current_user.try(:preference).try(:banner_seen) %> -<% if @admin_banner && @admin_banner.active? %> -<% unless current_user.nil? && session[:hide_banner] %> -
    -
    - <%=raw sanitize_field(@admin_banner, :content) %> -
    - <% if current_user.nil? %> -

    - <%= link_to "×".html_safe, current_path_with(hide_banner: true), :class => 'showme action', :title => ts("hide banner") %> -

    - <% else %> - <%= form_tag end_banner_user_path(current_user), :method => :post, :remote => true do %> +<% if @admin_banner&.active? %> + <% unless session[:hide_banner] || current_user&.preference&.banner_seen %> +
    +
    + <%= raw sanitize_field(@admin_banner, :content, strip_images: true) %> +
    + <% if current_user.nil? %>

    - <%= submit_tag "×".html_safe, :title => ts("hide banner") %> + <%= link_to "×".html_safe, current_path_with(hide_banner: true), class: "showme action", title: ts("hide banner") %>

    + <% else %> + <%= form_tag end_banner_user_path(current_user), method: :post, remote: true do %> +

    + <%= submit_tag "×".html_safe, title: ts("hide banner") %> +

    + <% end %> <% end %> - <% end %> -
    -<% end %> -<% end %> +
    + <% end %> <% end %> diff --git a/app/views/layouts/_header.html.erb b/app/views/layouts/_header.html.erb index 52a2772f383..3ad014b410d 100644 --- a/app/views/layouts/_header.html.erb +++ b/app/views/layouts/_header.html.erb @@ -1,10 +1,4 @@ - - - + <% if @collection %> @@ -12,67 +6,68 @@ <% end %> - + <%= render "layouts/banner" %> diff --git a/app/views/menu/_menu_about.html.erb b/app/views/menu/_menu_about.html.erb index e3bfc2260a4..e6959b9f4b2 100644 --- a/app/views/menu/_menu_about.html.erb +++ b/app/views/menu/_menu_about.html.erb @@ -1,7 +1,7 @@ -