diff --git a/lib/gst-kitchen.rb b/lib/gst-kitchen.rb
index 1e84a70..18cd36a 100644
--- a/lib/gst-kitchen.rb
+++ b/lib/gst-kitchen.rb
@@ -9,6 +9,7 @@
require "gst-kitchen/version"
require "gst-kitchen/podcast"
require "gst-kitchen/feed"
+require "gst-kitchen/flattr"
require "gst-kitchen/chapter"
require "gst-kitchen/episode"
require "gst-kitchen/media"
diff --git a/lib/gst-kitchen/episode.rb b/lib/gst-kitchen/episode.rb
index c8cb007..b6561a7 100644
--- a/lib/gst-kitchen/episode.rb
+++ b/lib/gst-kitchen/episode.rb
@@ -86,6 +86,10 @@ def rfc_2822_date
self.published_at.rfc2822
end
+ def flattr_auto_submit_link
+ Flattr.auto_submit_link(podcast, podcast.deep_link_url(self), self.name, self.subtitle)
+ end
+
def duration
hours = length / (60 * 60)
minutes = (length - hours * 60 * 60) / 60
diff --git a/lib/gst-kitchen/flattr.rb b/lib/gst-kitchen/flattr.rb
new file mode 100644
index 0000000..9706b12
--- /dev/null
+++ b/lib/gst-kitchen/flattr.rb
@@ -0,0 +1,12 @@
+module Flattr
+ def Flattr.auto_submit_link(podcast, url, title, description)
+ "https://flattr.com/submit/auto" +
+ "?user_id=#{podcast.flattr["user_id"]}" +
+ "&url=#{CGI.escape url}" +
+ "&title=#{CGI.escape title}" +
+ "&description=#{CGI.escape description}" +
+ "&language=#{podcast.flattr["language"]}" +
+ "&tags=#{podcast.flattr["tags"].join(',')}" +
+ "&category=#{podcast.flattr["category"]}"
+ end
+end
diff --git a/lib/gst-kitchen/podcast.rb b/lib/gst-kitchen/podcast.rb
index 4285219..eb33c32 100644
--- a/lib/gst-kitchen/podcast.rb
+++ b/lib/gst-kitchen/podcast.rb
@@ -12,7 +12,8 @@ class Podcast
:episodes,
:explicit,
:rss_output_path,
- :episodes_path
+ :episodes_path,
+ :flattr
attr_accessor :formats
@@ -29,6 +30,7 @@ def self.from_yaml(yaml_file="podcast.yml")
podcast.handle = hash["handle"]
podcast.website = hash["website"]
podcast.cover = hash["cover"]
+ podcast.flattr = hash["flattr"]
podcast.media_url = hash["media_url"]
podcast.explicit = hash["explicit"] || false
podcast.formats = hash["formats"].map { |format| Media.format(format) }
@@ -80,6 +82,10 @@ def deep_link_url(episode)
url.to_s
end
+ def flattr_auto_submit_link
+ Flattr.auto_submit_link(self, self.website, self.title, self.subtitle)
+ end
+
def podcast
self
end
diff --git a/spec/episode_spec.rb b/spec/episode_spec.rb
index bc7c1ed..b4dc64c 100644
--- a/spec/episode_spec.rb
+++ b/spec/episode_spec.rb
@@ -50,7 +50,6 @@
end
end
-
it "should have a handle" do
podcast = double("podcast")
podcast.stub(:handle).and_return("GST")
@@ -61,6 +60,20 @@
subject.handle.should == "GST042"
end
+ it "should generate flattr urls" do
+ podcast = double("podcast")
+ podcast.stub(:flattr).and_return({"user_id" => "gst-podcast", "language" => "de_DE", "tags" => %w(geek stammtisch podcast), "category" => "audio"})
+ podcast.stub(:deep_link_url) { "http://geekstammtisch.de/#GST001" }
+
+ subject.podcast = podcast
+ subject.name = "GST001 - Meine Tolle Folge"
+ subject.subtitle = "Eine tolle Folge mit viel Blafasel"
+
+ Flattr.should_receive(:auto_submit_link).with(podcast, "http://geekstammtisch.de/#GST001", "GST001 - Meine Tolle Folge", "Eine tolle Folge mit viel Blafasel")
+
+ subject.flattr_auto_submit_link
+ end
+
it "should have a title" do
podcast = double("podcast")
podcast.stub(:handle).and_return("GST")
diff --git a/spec/flattr_spec.rb b/spec/flattr_spec.rb
new file mode 100644
index 0000000..3f92604
--- /dev/null
+++ b/spec/flattr_spec.rb
@@ -0,0 +1,11 @@
+require "spec_helper"
+
+describe Flattr do
+ it "creates a valid flattr auto submit url" do
+ podcast = double("podcast")
+ podcast.stub(:flattr).and_return({"user_id" => "gst-podcast", "language" => "de_DE", "tags" => %w(geek stammtisch podcast), "category" => "audio"})
+ expected_url = "https://flattr.com/submit/auto?user_id=gst-podcast&url=http%3A%2F%2Fwww.test.de&title=Some+random+Title&description=Some+very+random+description&language=de_DE&tags=geek,stammtisch,podcast&category=audio"
+
+ Flattr.auto_submit_link(podcast, "http://www.test.de", "Some random Title", "Some very random description").should == expected_url
+ end
+end
diff --git a/templates/episodes.rss.erb b/templates/episodes.rss.erb
index 14f6fe0..b5d205f 100644
--- a/templates/episodes.rss.erb
+++ b/templates/episodes.rss.erb
@@ -7,6 +7,7 @@
<% @podcast.other_formats(@format).each do |format| %>
<% end %>
+
<%= @podcast.language %>
gst-kitchen
<%= @podcast.author %>, cc-by-nc-sa
@@ -44,6 +45,7 @@
]]>
]]>
+
<% unless episode.chapters.nil? %>