simplificator-rwebthumb 0.1.1 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/README CHANGED
@@ -1,7 +1,8 @@
1
1
  == rwebthumb
2
2
 
3
3
  = what is it
4
- A Ruby wrapper for the webthumb API from http://webthumb.bluga.net
4
+ A Ruby wrapper for the webthumb API from http://webthumb.bluga.net and a generator
5
+ for the easythumb API
5
6
 
6
7
  = dependencies
7
8
  * tzinfo:http://tzinfo.rubyforge.org (install: sudo gem install tzinfo)
@@ -44,3 +45,10 @@ wt.job_status(JOB_ID)
44
45
 
45
46
  # check the status of your account
46
47
  wt.status
48
+
49
+
50
+ # generate a Easythumb URL
51
+ et = Easythumb.new('YOUR_API_KEY', 'YOUR_USER_ID')
52
+ # This returns an URL which you can directly use in your webpage
53
+ et.build_url(:url => 'http://simplificator.com', :size => :large, :cache => 1)
54
+
data/init.rb CHANGED
@@ -1,2 +1 @@
1
1
  require 'rwebthumb'
2
- puts "****"
@@ -18,7 +18,7 @@ module Simplificator
18
18
  # api_key: the Webthumb api key, not nil and not blank
19
19
  #
20
20
  def initialize(api_key, api_endpoint = 'http://webthumb.bluga.net/api.php')
21
- raise WebthumbException.new('Need an noot nil and not blank api_key') if api_key == nil || api_key == ''
21
+ raise WebthumbException.new('Need an not nil and not blank api_key') if api_key == nil || api_key == ''
22
22
  @api_key = api_key
23
23
  @api_endpoint = api_endpoint
24
24
  @api_uri = URI.parse(@api_endpoint)
@@ -0,0 +1,27 @@
1
+ require 'cgi'
2
+ require 'digest/md5'
3
+ module Simplificator
4
+ module Webthumb
5
+ class Easythumb
6
+ VALID_SIZES = [:small, :medium, :medium2, :large]
7
+ def initialize(api_key, user_id, api_endpoint = 'http://webthumb.bluga.net/easythumb.php')
8
+ @api_key = api_key
9
+ @user_id = user_id
10
+ @api_endpoint = api_endpoint
11
+ end
12
+
13
+ # Build an Easythumb URL
14
+ # options are
15
+ # url: the url to take a snapshot from. required.
16
+ # size: the size of the thumbnail to take (VALID_SIZES). Defaults to :medium
17
+ # cache: the maximum allowed age in the cache (1-30). Defaults to 15
18
+ def build_url(options = {})
19
+ raise WebthumbException.new(':url is required') if (options[:url] == nil || options[:url] == '')
20
+ options[:size] ||= :medium
21
+ options[:cache] ||= 15
22
+ hash_out = Digest::MD5.hexdigest("#{Time.now.strftime('%Y%m%d')}#{options[:url]}#{@api_key}")
23
+ "#{@api_endpoint}?user=#{@user_id}&cache=#{options[:cache]}&size=#{options[:size]}&url=#{CGI.escape(options[:url])}&hash=#{hash_out}"
24
+ end
25
+ end
26
+ end
27
+ end
data/lib/rwebthumb.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  require 'tzinfo'
2
2
  require 'rwebthumb/base'
3
3
  require 'rwebthumb/job'
4
- require 'rwebthumb/webthumb'
4
+ require 'rwebthumb/webthumb'
5
+ require 'rwebthumb/easythumb'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simplificator-rwebthumb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Simplificator GmbH
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-07-11 00:00:00 -07:00
12
+ date: 2008-08-05 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies: []
15
15
 
@@ -30,6 +30,7 @@ files:
30
30
  - test/helper.rb
31
31
  - test/job_test.rb
32
32
  - test/webthumb_test.rb
33
+ - lib/rwebthumb/easythumb.rb
33
34
  - README
34
35
  - init.rb
35
36
  has_rdoc: false