forked from id774/automaticruby
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathtumblr_resize.rb
More file actions
40 lines (36 loc) · 1.04 KB
/
tumblr_resize.rb
File metadata and controls
40 lines (36 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# -*- coding: utf-8 -*-
# Name:: Automatic::Plugin::Filter::TumblrResize
# Author:: 774 <http://id774.net>
# Created:: Feb 28, 2012
# Updated:: Apr 5, 2013
# Copyright:: Copyright (c) 2012-2013 Automatic Ruby Developers.
# License:: Licensed under the GNU GENERAL PUBLIC LICENSE, Version 3.0.
module Automatic::Plugin
class FilterTumblrResize
def initialize(config, pipeline=[])
@config = config
@pipeline = pipeline
end
def run
@return_feeds = []
@pipeline.each {|feeds|
img_url = ""
unless feeds.nil?
feeds.items.each {|feed|
feed.link = resize(feed.link) unless feed.link.nil?
}
end
@return_feeds << feeds
}
@return_feeds
end
private
def resize(string)
string = string.gsub("_75sq\.", "_1280\.")
string = string.gsub("_100\.", "_1280\.")
string = string.gsub("_250\.", "_1280\.")
string = string.gsub("_400\.", "_1280\.")
string = string.gsub("_500\.", "_1280\.")
end
end
end