supplier client sections working with problematic authentication still active

This commit is contained in:
2020-02-27 15:44:43 -05:00
parent 9e86b18c3e
commit 2149345d3d
33 changed files with 456 additions and 281 deletions
+7 -7
View File
@@ -3,10 +3,10 @@ require 'rqrcode'
require 'rqrcode-rails3/size_calculator.rb'
require 'rqrcode-rails3/renderers/svg.rb'
module RQRCode
Mime::Type.register "image/svg+xml", :svg unless Mime::Type.lookup_by_extension(:svg)
Mime::Type.register "image/png", :png unless Mime::Type.lookup_by_extension(:png)
Mime::Type.register "image/svg+xml", :svg unless Mime::Type.lookup_by_extension(:svg)
Mime::Type.register "image/png", :png unless Mime::Type.lookup_by_extension(:png)
module RQRCode
extend SizeCalculator
ActionController::Renderers.add :qrcode do |string, options|
@@ -14,11 +14,10 @@ module RQRCode
size = options[:size] || RQRCode.minimum_qr_size_from_string(string)
level = options[:level] || :h
qrcode = RQRCode::QRCode.new(string, :size => size, :level => level)
qrcode = RQRCode::QRCode.new(string, size: size, level: level)
svg = RQRCode::Renderers::SVG::render(qrcode, options)
data = \
if format == :png
data = if format == :png
image = MiniMagick::Image.read(svg) { |i| i.format "svg" }
image.format "png"
png = image.to_blob
@@ -26,6 +25,7 @@ module RQRCode
svg
end
self.response_body = render_to_string(:text => data, :template => nil)
#self.response_body = render_to_string(text: data, template: nil)
send_data data, type: content_type
end
end
+7 -7
View File
@@ -15,29 +15,29 @@ module RQRCode
unit = options[:unit] || 11
# height and width dependent on offset and QR complexity
dimension = (qrcode.module_count*unit) + (2*offset)
dimension = (qrcode.modules.count*unit) + (2*offset)
xml_tag = %{<?xml version="1.0" standalone="yes"?>}
open_tag = %{<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:ev="http://www.w3.org/2001/xml-events" width="#{dimension}" height="#{dimension}">}
close_tag = "</svg>"
result = []
for c in 0...qrcode.module_count
for c in 0...qrcode.modules.count
tmp = []
for r in 0...qrcode.module_count
for r in 0...qrcode.modules.count
y = c*unit + offset
x = r*unit + offset
next unless qrcode.dark?(c, r)
next unless qrcode.qrcode.checked?(c, r)
tmp << %{<rect width="#{unit}" height="#{unit}" x="#{x}" y="#{y}" style="fill:##{color}"/>}
end
end
result << tmp.join("\n")
end
if options[:fill]
result.unshift %{<rect width="#{dimension}" height="#{dimension}" x="0" y="0" style="fill:##{options[:fill]}"/>}
end
return [xml_tag, open_tag, result, close_tag].flatten.join("\n") unless options[:qcontainer]
svg = File.read(File.expand_path('../../qr_container.svg', __FILE__))
svg.gsub!(/#table_number/, options[:table_number].to_s)