eBooru/app/logical/post_search_context.rb

14 lines
488 B
Ruby
Raw Normal View History

# frozen_string_literal: true
2013-02-25 12:09:02 -05:00
class PostSearchContext
attr_reader :post
2013-03-19 08:10:10 -04:00
2013-02-25 12:09:02 -05:00
def initialize(params)
tags = params[:q].presence || params[:tags].presence || ""
tags += " rating:s" if CurrentUser.safe_mode?
tags += " -status:deleted" unless TagQuery.has_metatag?(tags, "status", "-status")
pagination_mode = params[:seq] == "prev" ? "a" : "b"
@post = Post.tag_match(tags).paginate("#{pagination_mode}#{params[:id]}", limit: 1).first || Post.find(params[:id])
2013-02-25 12:09:02 -05:00
end
end