2024-02-25 12:15:55 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2010-03-17 19:20:44 -04:00
|
|
|
class UploadPresenter < Presenter
|
2018-09-30 12:32:30 -04:00
|
|
|
attr_reader :upload
|
|
|
|
delegate :inline_tag_list_html, to: :tag_set_presenter
|
|
|
|
|
2010-03-17 19:20:44 -04:00
|
|
|
def initialize(upload)
|
|
|
|
@upload = upload
|
|
|
|
end
|
2018-09-30 12:32:30 -04:00
|
|
|
|
|
|
|
def tag_set_presenter
|
2024-04-06 00:29:19 -04:00
|
|
|
@tag_set_presenter ||= TagSetPresenter.new(normalize_tags(upload.tag_string.split))
|
|
|
|
end
|
|
|
|
|
|
|
|
def strip_metatags(tags)
|
|
|
|
tags.grep_v(/\A(?:rating|-?parent|-?locked|-?pool|newpool|-?set|-?fav|-?child|upvote|downvote):/i)
|
|
|
|
end
|
|
|
|
|
|
|
|
def normalize_tags(tags)
|
|
|
|
tags = tags.map(&:downcase)
|
|
|
|
tags = strip_metatags(tags)
|
|
|
|
tags.map { |tag| tag.gsub(/(?:#{TagCategory::ALL_NAMES_REGEX}):/, "") }
|
2018-09-30 12:32:30 -04:00
|
|
|
end
|
2010-03-17 19:20:44 -04:00
|
|
|
end
|