cnvrtr 1.0.0

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/.bnsignore ADDED
@@ -0,0 +1,18 @@
1
+ # The list of files that should be ignored by Mr Bones.
2
+ # Lines that start with '#' are comments.
3
+ #
4
+ # A .gitignore file can be used instead by setting it as the ignore
5
+ # file in your Rakefile:
6
+ #
7
+ # Bones {
8
+ # ignore_file '.gitignore'
9
+ # }
10
+ #
11
+ # For a project with a C extension, the following would be a good set of
12
+ # exclude patterns (uncomment them if you want to use them):
13
+ # *.[oa]
14
+ # *~
15
+ announcement.txt
16
+ coverage
17
+ doc
18
+ pkg
data/History.txt ADDED
@@ -0,0 +1,4 @@
1
+ == 1.0.0 / 2009-11-17
2
+
3
+ * 1 major enhancement
4
+ * Birthday!
data/README.txt ADDED
@@ -0,0 +1,56 @@
1
+ cnvrtr
2
+ by ELC Technologies
3
+ http://elctech.com
4
+
5
+ == DESCRIPTION:
6
+
7
+ Cnvrtr.com gem provides view helpers to allow trivial integration with http://cnvrtr.com/ thing-of-many-talents backend-conversion-service.
8
+
9
+ == FEATURES/PROBLEMS:
10
+
11
+ * [Feature] Adds link_to_cnvrtr(image_path, opts={}) helper that produces Cnvrtr.com links for assets.
12
+
13
+ * [Feature] Adds cnvrtr_widget(image_path, opts={}) helper, like cnvrtrize, but returns a <SCRIPT> block that embeds a cnvrtrize viewer.
14
+
15
+ * [Todo] Add authenticated URLs.
16
+
17
+ * [Todo] Add token customization.
18
+
19
+ == SYNOPSIS:
20
+
21
+ Here is my asset: http://cnvrtr.com/logo.jpg
22
+
23
+ Here is my asset as a pdf: <%= cnvrtrize("http://cnvrtr.com/logo.jpg", {:format => "pdf"}%>
24
+
25
+ Assumes public token if none specified.
26
+
27
+ == REQUIREMENTS:
28
+
29
+ * None
30
+
31
+ == INSTALL:
32
+
33
+ * sudo gem install cnvrtr
34
+
35
+ == LICENSE:
36
+
37
+ Copyright (c) 2009 ELC Technologies
38
+
39
+ Permission is hereby granted, free of charge, to any person obtaining
40
+ a copy of this software and associated documentation files (the
41
+ 'Software'), to deal in the Software without restriction, including
42
+ without limitation the rights to use, copy, modify, merge, publish,
43
+ distribute, sublicense, and/or sell copies of the Software, and to
44
+ permit persons to whom the Software is furnished to do so, subject to
45
+ the following conditions:
46
+
47
+ The above copyright notice and this permission notice shall be
48
+ included in all copies or substantial portions of the Software.
49
+
50
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
51
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
52
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
53
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
54
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
55
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
56
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Rakefile ADDED
@@ -0,0 +1,23 @@
1
+
2
+ begin
3
+ require 'bones'
4
+ rescue LoadError
5
+ abort '### Please install the "bones" gem ###'
6
+ end
7
+
8
+ ensure_in_path 'lib'
9
+ require 'cnvrtr'
10
+
11
+ task :default => 'test:run'
12
+ task 'gem:release' => 'test:run'
13
+
14
+ Bones {
15
+ name 'cnvrtr'
16
+ authors 'ELC Technologies'
17
+ email 'info@elctech.com'
18
+ url 'http://elctech.com'
19
+ version Cnvrtr::VERSION
20
+ ignore_file '.gitignore'
21
+ }
22
+
23
+ # EOF
data/bin/cnvrtr ADDED
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require File.expand_path(
4
+ File.join(File.dirname(__FILE__), %w[.. lib cnvrtr]))
5
+
6
+ # Put your code here
7
+
Binary file
@@ -0,0 +1,95 @@
1
+ # gem 'right_aws'
2
+ # require 'right_aws'
3
+ module Cnvrtr
4
+ module Helpers
5
+ def link_to_cnvrtr(title, href=nil, opts={}, cnvrtr_opts={})
6
+ href = title if href.nil?
7
+ #options = params.extract_options!.symbolize_keys
8
+ #options[:controller] = self
9
+ raise "Invalid usage." unless href.is_a?(String)
10
+ link_to(title,url_for_cnvrtr(href,cnvrtr_opts),opts)
11
+ end
12
+ def url_for_cnvrtr(href,cnvrtr_opts={})
13
+ document = CGI.escape(href)
14
+ # server = RightAws::S3Interface.new(cnvrtr_opts[:access_id], cnvrtr_opts[:secret_id],cnvrtr_opts)
15
+ # req = server.generate_rest_request('GET',{:url=>document})
16
+ # raise req[:request].path
17
+ # req[:request].path
18
+ "http://vrt.cc/public/#{document}/cached.swf?sig=XXX"
19
+ end
20
+ =begin
21
+ Copying S3's operation for presigned URLs...
22
+ http://docs.amazonwebservices.com/AmazonS3/latest/index.html?RESTAuthentication.html
23
+ Signature = URL-Encode( Base64( HMAC-SHA1( YourSecretAccessKeyID, UTF-8-Encoding-Of( StringToSign ) ) ) );
24
+
25
+ StringToSign = HTTP-VERB + "\n" +
26
+ Content-MD5 + "\n" +
27
+ Content-Type + "\n" +
28
+ Expires + "\n" +
29
+ CanonicalizedAmzHeaders +
30
+ CanonicalizedResource;
31
+ =end
32
+
33
+ def embedded_cnvrtr(document = "http://upload.wikimedia.org/wikipedia/en/a/a6/PDF.png", o = {})
34
+ options = opts(o)
35
+ document = url_for_cnvrtr(document)
36
+ # server = RightAws::S3Interface.new(options[:access_id], options[:secret_id],options)
37
+ # req = server.generate_rest_request('GET',{:src=>document})
38
+ # sig = req[:authorization]
39
+ sig = ""
40
+
41
+ # filename : required : specifies the location of the pdf/swf
42
+ # fileHeightOverride : optional : allows you to set the document height within the viewer. Any value less than 0 will be ignored.
43
+ # fileWidthOverride : optional : allows you to set the document width within the viewer. Any value less than 0 will be ignored.
44
+ # logoURL : optional : specifies the location of the logo. This supports swf/jpg/png/gif and even mov.
45
+ # logoCoordinateX : optional : by default this is set to 0 (flushed to the left border)
46
+ # logoCoordinateY : optional : by default this is set to 50 (locate right below the navigation bar)
47
+ # logoHeightOverride : optional : allows you to manually set logo height. Any value less than 0 will be ignored.
48
+ # logoWidthOverride : optional : allows you to manually set logo width. Any value less than 0 will be ignored.
49
+
50
+ flash_vars = {}
51
+ flash_vars = {:filename => CGI.escape(document),
52
+ :logoURL => CGI.escape("http://ftopia.com/images/logo.png"),
53
+ :format => "swf",
54
+ :signature => sig}
55
+ swf_object("http://vrt.cc/swfs/viewer.swf",
56
+ "document_preview",
57
+ "600", "825", "9.0.0",
58
+ flash_vars,
59
+ {:wmode => 'transparent', :quality => 'high', :allowFullScreen => 'true'},
60
+ {},
61
+ true)
62
+ end
63
+
64
+ def swf_object(swf, id, width, height, flash_version, flashvars = {}, params = {}, attributes = {}, create_div = false)
65
+ output = ''
66
+ if create_div
67
+ output << "<div id='#{id}'>This website requires <a href='http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash&promoid=BIOW' target='_blank'>Flash player</a> #{flash_version
68
+ } or higher.</div>"
69
+ end
70
+ output << "<script src='http://vrt.cc/javascripts/swfobject.js' type='text/javascript'></script>"
71
+ output << "<script type='text/javascript'>"
72
+ output << "var flashvars = {};"
73
+ flashvars.each {|key, value| output << "flashvars.#{key} = '#{value}';"}
74
+ output << "var params = {};"
75
+ params.each {|key, value| output << "params.#{key} = '#{value}';"}
76
+ output << "var attributes = {};"
77
+ attributes.each {|key, value| output << "attributes.#{key} = '#{value}';"}
78
+ output << "swfobject.embedSWF('#{swf}', '#{id}', '#{width}', '#{height}', '#{flash_version}', 'expressInstall.swf', flashvars, params, attributes);"
79
+ output << "</script>"
80
+ output
81
+ end
82
+
83
+ def opts(o)
84
+ { :access_id => "access_id", :secret_id => "secret_id",
85
+ :server => "vrt.cc",
86
+ :port => "443", :expires => 1.hour.from_now }.merge(o)
87
+ end
88
+
89
+ end
90
+ end
91
+ # Include in views and controller
92
+ ActionController::Base.send(:include, Cnvrtr::Helpers) if defined?(ActionController)
93
+ class ActionView::Base
94
+ include Cnvrtr::Helpers
95
+ end if defined?(ActionView)
data/lib/cnvrtr.rb ADDED
@@ -0,0 +1,48 @@
1
+
2
+ module Cnvrtr
3
+
4
+ # :stopdoc:
5
+ VERSION = '1.0.0'
6
+ LIBPATH = ::File.expand_path(::File.dirname(__FILE__)) + ::File::SEPARATOR
7
+ PATH = ::File.dirname(LIBPATH) + ::File::SEPARATOR
8
+ # :startdoc:
9
+
10
+ # Returns the version string for the library.
11
+ #
12
+ def self.version
13
+ VERSION
14
+ end
15
+
16
+ # Returns the library path for the module. If any arguments are given,
17
+ # they will be joined to the end of the libray path using
18
+ # <tt>File.join</tt>.
19
+ #
20
+ def self.libpath( *args )
21
+ args.empty? ? LIBPATH : ::File.join(LIBPATH, args.flatten)
22
+ end
23
+
24
+ # Returns the lpath for the module. If any arguments are given,
25
+ # they will be joined to the end of the path using
26
+ # <tt>File.join</tt>.
27
+ #
28
+ def self.path( *args )
29
+ args.empty? ? PATH : ::File.join(PATH, args.flatten)
30
+ end
31
+
32
+ # Utility method used to require all files ending in .rb that lie in the
33
+ # directory below this file that has the same name as the filename passed
34
+ # in. Optionally, a specific _directory_ name can be passed in such that
35
+ # the _filename_ does not have to be equivalent to the directory.
36
+ #
37
+ def self.require_all_libs_relative_to( fname, dir = nil )
38
+ dir ||= ::File.basename(fname, '.*')
39
+ search_me = ::File.expand_path(
40
+ ::File.join(::File.dirname(fname), dir, '**', '*.rb'))
41
+
42
+ Dir.glob(search_me).sort.each {|rb| require rb}
43
+ end
44
+
45
+ end # module Cnvrtr
46
+
47
+ Cnvrtr.require_all_libs_relative_to(__FILE__)
48
+
@@ -0,0 +1,6 @@
1
+
2
+ require File.join(File.dirname(__FILE__), %w[spec_helper])
3
+
4
+ describe Cnvrtr do
5
+ end
6
+
@@ -0,0 +1,15 @@
1
+
2
+ require File.expand_path(
3
+ File.join(File.dirname(__FILE__), %w[.. lib cnvrtr]))
4
+
5
+ Spec::Runner.configure do |config|
6
+ # == Mock Framework
7
+ #
8
+ # RSpec uses it's own mocking framework by default. If you prefer to
9
+ # use mocha, flexmock or RR, uncomment the appropriate line:
10
+ #
11
+ # config.mock_with :mocha
12
+ # config.mock_with :flexmock
13
+ # config.mock_with :rr
14
+ end
15
+
File without changes
metadata ADDED
@@ -0,0 +1,78 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: cnvrtr
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - ELC Technologies
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-11-18 00:00:00 +00:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: bones
17
+ type: :development
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: 3.0.1
24
+ version:
25
+ description: Cnvrtr.com gem provides view helpers to allow trivial integration with http://cnvrtr.com/ thing-of-many-talents backend-conversion-service.
26
+ email: info@elctech.com
27
+ executables:
28
+ - cnvrtr
29
+ extensions: []
30
+
31
+ extra_rdoc_files:
32
+ - History.txt
33
+ - README.txt
34
+ - bin/cnvrtr
35
+ - lib/cnvrtr/helpers/.view.rb.swp
36
+ files:
37
+ - .bnsignore
38
+ - History.txt
39
+ - README.txt
40
+ - Rakefile
41
+ - bin/cnvrtr
42
+ - lib/cnvrtr.rb
43
+ - lib/cnvrtr/helpers/.view.rb.swp
44
+ - lib/cnvrtr/helpers/view.rb
45
+ - spec/cnvrtr_spec.rb
46
+ - spec/spec_helper.rb
47
+ - test/test_cnvrtr.rb
48
+ has_rdoc: true
49
+ homepage: http://elctech.com
50
+ licenses: []
51
+
52
+ post_install_message:
53
+ rdoc_options:
54
+ - --main
55
+ - README.txt
56
+ require_paths:
57
+ - lib
58
+ required_ruby_version: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - ">="
61
+ - !ruby/object:Gem::Version
62
+ version: "0"
63
+ version:
64
+ required_rubygems_version: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: "0"
69
+ version:
70
+ requirements: []
71
+
72
+ rubyforge_project: cnvrtr
73
+ rubygems_version: 1.3.5
74
+ signing_key:
75
+ specification_version: 3
76
+ summary: Cnvrtr
77
+ test_files:
78
+ - test/test_cnvrtr.rb