Created
August 15, 2012 04:06
-
-
Save tbjers/3355761 to your computer and use it in GitHub Desktop.
Xorcode QR tag for Google Play items
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'cgi' | |
module Xorcode | |
module Liquid | |
class QrCodeTag < ::Liquid::Tag | |
def initialize(tag_name, id, tokens) | |
@url = "https://market.android.com/details?id=#{id.strip}" | |
super | |
end | |
def render(context) | |
img_uri = "https://chart.googleapis.com/chart?cht=qr&chs=150x150&chl=#{CGI.escape(@url)}&choe=UTF-8&chld=M|0" | |
<<MARKUP.strip | |
<p><a href="#{@url}"><img src="#{img_uri}"></a></p> | |
<p><a href="#{@url}" class="btn btn-large btn-primary">Download from Android Market</a></p> | |
MARKUP | |
end | |
end | |
end | |
end | |
Liquid::Template.register_tag('qr', Xorcode::Liquid::QrCodeTag) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment