Sha256: ed529e92e817e599142dbdd50dad2fc40cd3a737d232b338ec1fbd3adbd3c4d0

Contents?: true

Size: 1.8 KB

Versions: 49

Compression:

Stored size: 1.8 KB

Contents

module Awestruct
  module Extensions
    class Flattr

      def execute(site)
        site.pages.each{|p| p.extend Flattrable }
      end

      module Flattrable
        def flattr_javascript()
          html = %Q|<script type='text/javascript'> /* <![CDATA[ */     (function() {\n|
          html += %Q|var s = document.createElement('script'), t = document.getElementsByTagName('script')[0];|
          html += %Q|s.type = 'text/javascript';\n|
          html += %Q|s.async = true;\n|
          html += %Q|s.src = 'http://api.flattr.com/js/0.6/load.js?mode=auto&uid=#{site.flattr_username}&category=text';\n|
          html += %Q|t.parentNode.insertBefore(s, t);\n|
          html += %Q|})(); /* ]]> */ </script>|
          html
        end
        def flattr_large_counter(param={})
          url = param[:url] ? param[:url] : site.base_url + self.url
          title = param[:title] ? param[:title] : self.title
          category = param[:category] ? param[:category] : "text"
          tags = param[:tags] ? "tags:" + param[:tags] + ";" : ""
          html = %Q|<a class="FlattrButton" style="display:none;" href="#{url}" title="#{title}" |
          html += %Q|rev="flattr;uid:#{site.flattr_username};category:#{category};#{tags}"></a>|
          html
        end
        def flattr_compact_counter(param={})
          url = param[:url] ? param[:url] : site.base_url + self.url
          title = param[:title] ? param[:title] : self.title
          category = param[:category] ? param[:category] : "text"
          tags = param[:tags] ? "tags:" + param[:tags] + ";" : ""
          html = %Q|<a class="FlattrButton" style="display:none;" href="#{url}" title="#{title}" |
          html += %Q|rev="flattr;button:compact;uid:#{site.flattr_username};category:#{category};#{tags}"></a>|
          html
        end
      end

    end
  end
end

Version data entries

49 entries across 49 versions & 2 rubygems

Version Path
awestruct-0.5.6.beta8 lib/awestruct/extensions/flattr.rb
awestruct-0.5.6.beta7 lib/awestruct/extensions/flattr.rb
awestruct-0.5.6.beta6 lib/awestruct/extensions/flattr.rb
awestruct-0.5.6.beta5 lib/awestruct/extensions/flattr.rb
awestruct-0.5.6.beta4 lib/awestruct/extensions/flattr.rb
awestruct-0.5.6.beta3 lib/awestruct/extensions/flattr.rb
awestruct-0.5.6.beta2 lib/awestruct/extensions/flattr.rb
awestruct-0.5.6.beta lib/awestruct/extensions/flattr.rb
awestruct-0.5.5 lib/awestruct/extensions/flattr.rb
awestruct-0.5.4.2 lib/awestruct/extensions/flattr.rb
awestruct-0.5.4.1 lib/awestruct/extensions/flattr.rb
awestruct-0.5.4 lib/awestruct/extensions/flattr.rb
awestruct-0.5.4.rc3 lib/awestruct/extensions/flattr.rb
awestruct-0.5.4.rc2 lib/awestruct/extensions/flattr.rb
awestruct-0.5.4.rc lib/awestruct/extensions/flattr.rb
awestruct-0.5.4.beta1 lib/awestruct/extensions/flattr.rb
awestruct-0.5.3 lib/awestruct/extensions/flattr.rb
awestruct-0.5.2.1 lib/awestruct/extensions/flattr.rb
awestruct-0.5.2 lib/awestruct/extensions/flattr.rb
awestruct-0.5.1 lib/awestruct/extensions/flattr.rb