Skip to content
Browse files

fooling around with png render on the plane back from baltimore

  • Loading branch information...
1 parent e7ddc36 commit 53e7a4b89b1184d0c5d3ed73848f5bbc3cb289f0 @samvincent samvincent committed
View
101 Gemfile.lock
@@ -1,101 +0,0 @@
-GEM
- remote: http://rubygems.org/
- specs:
- abstract (1.0.0)
- actionmailer (3.0.5)
- actionpack (= 3.0.5)
- mail (~> 2.2.15)
- actionpack (3.0.5)
- activemodel (= 3.0.5)
- activesupport (= 3.0.5)
- builder (~> 2.1.2)
- erubis (~> 2.6.6)
- i18n (~> 0.4)
- rack (~> 1.2.1)
- rack-mount (~> 0.6.13)
- rack-test (~> 0.5.7)
- tzinfo (~> 0.3.23)
- activemodel (3.0.5)
- activesupport (= 3.0.5)
- builder (~> 2.1.2)
- i18n (~> 0.4)
- activerecord (3.0.5)
- activemodel (= 3.0.5)
- activesupport (= 3.0.5)
- arel (~> 2.0.2)
- tzinfo (~> 0.3.23)
- activeresource (3.0.5)
- activemodel (= 3.0.5)
- activesupport (= 3.0.5)
- activesupport (3.0.5)
- arel (2.0.9)
- builder (2.1.2)
- capybara (0.4.1.2)
- celerity (>= 0.7.9)
- culerity (>= 0.2.4)
- mime-types (>= 1.16)
- nokogiri (>= 1.3.3)
- rack (>= 1.0.0)
- rack-test (>= 0.5.4)
- selenium-webdriver (>= 0.0.27)
- xpath (~> 0.1.3)
- celerity (0.8.9)
- childprocess (0.1.6)
- ffi (~> 0.6.3)
- culerity (0.2.14)
- erubis (2.6.6)
- abstract (>= 1.0.0)
- ffi (0.6.3)
- rake (>= 0.8.7)
- i18n (0.4.2)
- json_pure (1.4.6)
- mail (2.2.15)
- activesupport (>= 2.3.6)
- i18n (>= 0.4.0)
- mime-types (~> 1.16)
- treetop (~> 1.4.8)
- mime-types (1.16)
- nokogiri (1.4.4)
- polyglot (0.3.1)
- rack (1.2.2)
- rack-mount (0.6.13)
- rack (>= 1.0.0)
- rack-test (0.5.7)
- rack (>= 1.0)
- rails (3.0.5)
- actionmailer (= 3.0.5)
- actionpack (= 3.0.5)
- activerecord (= 3.0.5)
- activeresource (= 3.0.5)
- activesupport (= 3.0.5)
- bundler (~> 1.0)
- railties (= 3.0.5)
- railties (3.0.5)
- actionpack (= 3.0.5)
- activesupport (= 3.0.5)
- rake (>= 0.8.7)
- thor (~> 0.14.4)
- rake (0.8.7)
- rqrcode (0.3.3)
- rubyzip (0.9.4)
- selenium-webdriver (0.1.2)
- childprocess (~> 0.1.5)
- ffi (~> 0.6.3)
- json_pure
- rubyzip
- sqlite3 (1.3.3)
- thor (0.14.6)
- treetop (1.4.9)
- polyglot (>= 0.3.1)
- tzinfo (0.3.24)
- xpath (0.1.3)
- nokogiri (~> 1.3)
-
-PLATFORMS
- ruby
-
-DEPENDENCIES
- capybara (>= 0.4.0)
- rails (= 3.0.5)
- rqrcode
- sqlite3
View
17 lib/rqrcode_rails3.rb
@@ -1,14 +1,27 @@
require "action_controller"
require 'rqrcode'
-require 'rqrcode_rails3/svg_renderer'
+require 'rqrcode_rails3/renderers/*.rb'
module RQRCode
Mime::Type.register "image/svg+xml", :svg
Mime::Type.register "image/png", :png
ActionController::Renderers.add :qrcode do |string, options|
+ format = self.request.format.symbol
+
qrcode = RQRCode::QRCode.new(string)
svg = RQRCode::Renderers::SVG::render(qrcode)
- self.response_body = render_to_string(:text => svg, :template => nil)
+
+ if format == :png
+ # Need to convert svg to png with mini magic
+ path = File.join(File.dirname(__FILE__), '../test/support/data/qrcode.png')
+ png = File.read path
+
+ content_data = png
+ else
+ content_data = svg
+ end
+
+ self.response_body = render_to_string(:text => content_data, :template => nil)
end
end
View
0 lib/rqrcode_rails3/svg_renderer.rb → lib/rqrcode_rails3/renderers/svg.rb
File renamed without changes.
View
6 rqrcode_svg.gemspec → rqrcode_rails3.gemspec
@@ -1,9 +1,9 @@
# Provide a simple gemspec so you can easily use your enginex
# project in your rails apps through git.
Gem::Specification.new do |s|
- s.name = "rqrcode_svg"
- s.summary = "Insert Rqrcode-svg summary."
- s.description = "Insert Rqrcode-svg description."
+ s.name = "rqrcode-rails3"
+ s.summary = "Render QRCodes within your Rails 3 application."
+ s.description = "Render QRCodes within your Rails 3 application."
s.files = Dir["{app,lib,config}/**/*"] + ["MIT-LICENSE", "Rakefile", "Gemfile", "README.rdoc"]
s.version = "0.0.1"
end
View
4 test/dummy/app/controllers/home_controller.rb
@@ -2,8 +2,8 @@ class HomeController < ApplicationController
def index
respond_to do |format|
format.html
- format.svg { render :qrcode => "http://helloworld.com", :format => :svg }
- format.png { render :qrcode => "http://helloworld.com", :format => :png }
+ format.svg { render :qrcode => "http://helloworld.com" }
+ format.png { render :qrcode => "http://helloworld.com" }
end
end
end
View
BIN test/support/data/qrcode.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 53e7a4b

Please sign in to comment.
Something went wrong with that request. Please try again.