Skip to content
This repository was archived by the owner on Dec 27, 2018. It is now read-only.
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions gst-kitchen.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ Gem::Specification.new do |gem|
gem.add_dependency "trollop"
gem.add_dependency "rake"
gem.add_dependency "redcarpet"
gem.add_dependency "sanitize", "~> 2.0.6"

gem.add_development_dependency "debugger"
gem.add_development_dependency "rspec"
Expand Down
6 changes: 6 additions & 0 deletions lib/gst-kitchen/episode.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
require 'sanitize'

class Episode < Struct.new(:number, :name, :subtitle, :length, :media, :auphonic_uuid, :published_at, :summary, :chapters)
include Comparable

Expand Down Expand Up @@ -86,6 +88,10 @@ def rfc_2822_date
self.published_at.rfc2822
end

def flattr_auto_submit_link
"https://flattr.com/submit/auto?user_id=#{podcast.flattr["user_id"]}&url=#{CGI.escape podcast.deep_link_url(self)}&title=#{CGI.escape self.title}&description=#{CGI.escape Sanitize.clean(self.subtitle)}&language=#{podcast.flattr["language"]}&tags=#{podcast.flattr["tags"].join(',')}&category=#{podcast.flattr["category"]}"
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I see this correctly, this is almost the same as in Podcast#flattr_auto_submit_link. Maybe we can factor this out into a helper, or something. I'm thinking about including ActiveSupport to get Hash#to_param to make this readable.

end

def duration
hours = length / (60 * 60)
minutes = (length - hours * 60 * 60) / 60
Expand Down
8 changes: 7 additions & 1 deletion lib/gst-kitchen/podcast.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ class Podcast
:episodes,
:explicit,
:rss_output_path,
:episodes_path
:episodes_path,
:flattr

attr_accessor :formats

Expand All @@ -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) }
Expand Down Expand Up @@ -80,6 +82,10 @@ def deep_link_url(episode)
url.to_s
end

def flattr_auto_submit_link
"https://flattr.com/submit/auto?user_id=#{self.flattr["user_id"]}&url=#{CGI.escape self.website}&title=#{CGI.escape self.title}&description=#{CGI.escape self.subtitle}&language=#{podcast.flattr["language"]}&tags=#{self.flattr["tags"].join(',')}&category=#{self.flattr["category"]}"
end

def podcast
self
end
Expand Down
2 changes: 2 additions & 0 deletions templates/episodes.rss.erb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
<% @podcast.other_formats(@format).each do |format| %>
<atom:link rel="alternate" href="<%= @podcast.feed_url(format) %>" type="application/rss+xml" title="<%= format.file_ext.upcase %> Audio"/>
<% end %>
<atom:link rel="payment" href="<%= @podcast.flattr_auto_submit_link%>" />
<language><%= @podcast.language %></language>
<generator>gst-kitchen</generator>
<copyright><%= @podcast.author %>, cc-by-nc-sa</copyright>
Expand Down Expand Up @@ -44,6 +45,7 @@
<itunes:summary><![CDATA[<%= episode.summary %>]]></itunes:summary>
<description><![CDATA[<%= render_as_markdown episode.summary %>]]></description>
<atom:link rel="http://podlove.org/deep-link" href="<%= @podcast.deep_link_url(episode) %>" />
<atom:link rel="payment" href="<%= episode.flattr_auto_submit_link%>" />

<% unless episode.chapters.nil? %>
<psc:chapters>
Expand Down