cnvrtr 1.0.0 → 1.0.1
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/Rakefile +2 -0
- data/lib/cnvrtr/helpers/.view.rb.swp +0 -0
- data/lib/cnvrtr/helpers/view.rb +26 -3
- data/lib/cnvrtr.rb +1 -1
- metadata +1 -1
data/Rakefile
CHANGED
Binary file
|
data/lib/cnvrtr/helpers/view.rb
CHANGED
@@ -2,20 +2,43 @@
|
|
2
2
|
# require 'right_aws'
|
3
3
|
module Cnvrtr
|
4
4
|
module Helpers
|
5
|
-
|
5
|
+
private
|
6
|
+
# :width => 50, :height => 50, :format => 'png',
|
7
|
+
# :filter => [:thumb => {:background => '#000'}, :polaroid => {:rotate => 15}]
|
8
|
+
def parse(obj)
|
9
|
+
return obj if obj.is_a?(String)
|
10
|
+
raise "Invalid Format" unless obj.is_a?(Hash) && obj[:format]
|
11
|
+
obj.stringify_keys!
|
12
|
+
base = (obj[:width] && obj[:height]) ? "#{obj[:width]}x#{obj[:height]}" : ""
|
13
|
+
if obj[:filter]
|
14
|
+
base += "_thumb" if obj[:filter][:thumb]
|
15
|
+
base += "_polaroid" if obj[:filter][:polaroid]
|
16
|
+
end
|
17
|
+
base = "base" if base.blank?
|
18
|
+
"#{base}.#{obj[:format]}"
|
19
|
+
end
|
20
|
+
|
21
|
+
public
|
22
|
+
def link_to_cnvrtr(title, href=nil, opts={}, cnvrtr_opts={})
|
6
23
|
href = title if href.nil?
|
7
24
|
#options = params.extract_options!.symbolize_keys
|
8
25
|
#options[:controller] = self
|
9
26
|
raise "Invalid usage." unless href.is_a?(String)
|
10
27
|
link_to(title,url_for_cnvrtr(href,cnvrtr_opts),opts)
|
11
28
|
end
|
12
|
-
|
29
|
+
|
30
|
+
# url_for_cnvrtr(original_asset_url, shortcut_string)
|
31
|
+
# or
|
32
|
+
# url_for_cnvrtr(original_asset_url, opts = {})
|
33
|
+
def url_for_cnvrtr(*params)
|
34
|
+
href = params.first
|
13
35
|
document = CGI.escape(href)
|
36
|
+
opts_as_string = parse(params.second)
|
14
37
|
# server = RightAws::S3Interface.new(cnvrtr_opts[:access_id], cnvrtr_opts[:secret_id],cnvrtr_opts)
|
15
38
|
# req = server.generate_rest_request('GET',{:url=>document})
|
16
39
|
# raise req[:request].path
|
17
40
|
# req[:request].path
|
18
|
-
"http://vrt.cc/public/#{document}
|
41
|
+
"http://vrt.cc/public/#{document}/#{opts_as_string}?sig=XXX"
|
19
42
|
end
|
20
43
|
=begin
|
21
44
|
Copying S3's operation for presigned URLs...
|
data/lib/cnvrtr.rb
CHANGED