#1866: support wikia source redirection

included support for different image servers
This commit is contained in:
ghostrigger
2014-06-18 15:17:43 +08:00
parent 20bac78f87
commit f9cc0f0c88

View File

@@ -326,7 +326,12 @@ class Post < ActiveRecord::Base
when %r{\Ahttp://(?:(?:s?img|cdn|www)\d?\.)?gelbooru\.com/{1,2}(?:images|samples)/\d+/(?:sample_)?([a-f0-9]{32})\.}i
"http://gelbooru.com/index.php?page=post&s=list&md5=#{$1}"
when %r{\Ahttps?://(?:slot\d*\.)?im(?:g|ages)\d*\.wikia\.nocookie\.net/(?:_{2}cb\d{14}/)?([^/]+)/images/(?:(?:thumb|archive)?/)?[a-f0-9]/[a-f0-9]{2}/([^/]+)}i
subdomain = $1
filename = $2
"http://#{subdomain}.wikia.com/wiki/File:#{filename}"
else
source
end