-
Notifications
You must be signed in to change notification settings - Fork 85
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fe0dcda
commit c82a2c4
Showing
1 changed file
with
42 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
|
||
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 |