added popular exploration, added order:rank
This commit is contained in:
@@ -4,7 +4,7 @@ class PixivProxy
|
||||
end
|
||||
|
||||
def self.get(url)
|
||||
if url =~ /\/(\d+)(_m)?\.(jpg|jpeg|png|gif)/i
|
||||
if url =~ /\/(\d+)(_m|_p\d+)?\.(jpg|jpeg|png|gif)/i
|
||||
url = "http://www.pixiv.net/member_illust.php?mode=medium&illust_id=#{$1}"
|
||||
get_single(url)
|
||||
elsif url =~ /member_illust\.php/ && url =~ /illust_id=/
|
||||
|
||||
@@ -3,7 +3,7 @@ module PostSets
|
||||
attr_reader :artist
|
||||
|
||||
def initialize(artist)
|
||||
super(:tags => artist.name)
|
||||
super(artist.name)
|
||||
@artist = artist
|
||||
end
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@ module PostSets
|
||||
end
|
||||
|
||||
def artist
|
||||
nil
|
||||
end
|
||||
|
||||
def is_single_tag?
|
||||
|
||||
48
app/logical/post_sets/popular.rb
Normal file
48
app/logical/post_sets/popular.rb
Normal file
@@ -0,0 +1,48 @@
|
||||
module PostSets
|
||||
class Popular < Base
|
||||
attr_reader :date, :scale
|
||||
|
||||
def initialize(date, scale)
|
||||
@date = date.blank? ? Date.today : date.to_date
|
||||
@scale = scale
|
||||
end
|
||||
|
||||
def posts
|
||||
::Post.where("created_at between ? and ?", min_date, max_date + 1).order("score desc").limit(limit)
|
||||
end
|
||||
|
||||
def limit
|
||||
25
|
||||
end
|
||||
|
||||
def min_date
|
||||
case scale
|
||||
when "week"
|
||||
date.beginning_of_week
|
||||
|
||||
when "month"
|
||||
date.beginning_of_month
|
||||
|
||||
else
|
||||
date
|
||||
end
|
||||
end
|
||||
|
||||
def max_date
|
||||
case scale
|
||||
when "week"
|
||||
date.end_of_week
|
||||
|
||||
when "month"
|
||||
date.end_of_month
|
||||
|
||||
else
|
||||
date
|
||||
end
|
||||
end
|
||||
|
||||
def presenter
|
||||
::PostSetPresenters::Popular.new(self)
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user