-
Notifications
You must be signed in to change notification settings - Fork 122
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add podcast rss feed of video recordings
- Loading branch information
Showing
3 changed files
with
120 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,8 @@ | ||
--- | ||
title: Video Recordings Podcast RSS Feed | ||
index: false | ||
--- | ||
<%= podcast_feed( | ||
:events => @items.select{|i| event?(i)}, | ||
:excerpt_limit => 100, | ||
) %> |
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 |
---|---|---|
|
@@ -2,6 +2,114 @@ | |
# encoding: utf-8 | ||
|
||
module Fosdem | ||
def podcast_feed(params = {}) | ||
require 'builder' | ||
|
||
# Extract parameters | ||
events = params[:events] || [] | ||
excerpt_limit = params.fetch(:excerpt_limit) | ||
|
||
# Define how to find webm video once and reuse | ||
webm_link = lambda do |e| | ||
e[:links].find { |link| link[:title].start_with?('Video (WEBM)') } | ||
end | ||
|
||
# Filter and sort events by video publish date | ||
events.select!(&webm_link) | ||
events = events.sort_by do |e| | ||
webm_link.call(e)[:created_at] or | ||
raise RuntimeError.new("Cannot build Podcast RSS feed: event with id #{e[:event_id]} has a webm video link with no created_at attr") | ||
end.reverse | ||
|
||
# Check config attributes | ||
if @site.config[:base_url].nil? | ||
raise RuntimeError.new('Cannot build RSS feed: site configuration has no base_url') | ||
end | ||
|
||
last_update = webm_link.call(events.first)[:created_at] | ||
last_update = Date.parse(last_update).rfc822() # rss preferred format | ||
|
||
buffer = '' | ||
xml = Builder::XmlMarkup.new(:target => buffer, :indent => 2) | ||
|
||
year = days.first[:conference_day].year.to_s | ||
title = "FOSDEM #{year}" | ||
description = 'Video recordings of FOSDEM talks - new episodes are released when videos become available. '\ | ||
'FOSDEM is a free event for software developers to meet, share ideas and collaborate. '\ | ||
'Every year, thousands of developers of free and open source software from all over the world gather at the event in Brussels.' | ||
organization = 'FOSDEM VZW' | ||
author_email = '[email protected]' | ||
author_email_rfc = "#{author_email} (FOSDEM Info)" | ||
root_url = @site.config[:base_url] | ||
year_url = root_url + "/#{year}" | ||
podcast_image = "#{year_url}/support/promote/box.png" | ||
|
||
# Build feed | ||
xml.instruct! | ||
xml.rss(version: '2.0', 'xmlns:atom' => 'http://www.w3.org/2005/Atom', | ||
'xmlns:itunes' => 'http://www.itunes.com/dtds/podcast-1.0.dtd', | ||
'xmlns:podcast' => 'https://podcastindex.org/namespace/1.0') do | ||
xml.channel do | ||
xml.link "#{year_url}/" | ||
# http://validator.w3.org/appc/docs/warning/MissingAtomSelfLink.html | ||
xml.atom :link, href: root_url + @item.path, rel: 'self', type: 'application/rss+xml' | ||
xml.title title | ||
xml.description description | ||
xml.language 'en-us' | ||
xml.copyright "#{year} #{organization}" | ||
xml.podcast :locked, 'yes' | ||
xml.podcast :funding, | ||
'While FOSDEM is primarily funded by sponsors and the sale of t-shirts, '\ | ||
'we also gratefully accept voluntary donations.', | ||
url: "#{year_url}/support/donate/" | ||
xml.lastBuildDate(last_update) | ||
xml.pubDate(last_update) | ||
xml.ttl('1800') | ||
xml.image do | ||
xml.url podcast_image | ||
xml.title title | ||
xml.link "#{year_url}/" | ||
end | ||
xml.itunes :type, 'episodic' | ||
xml.itunes :subtitle, "All the recordings from this year's event in Brussels." | ||
xml.itunes :category, text: 'Technology' | ||
xml.itunes :author, organization | ||
xml.itunes :summary, description | ||
xml.itunes :image, href: podcast_image | ||
xml.itunes :owner do | ||
xml.itunes :name, organization | ||
xml.itunes :email, author_email | ||
end | ||
|
||
# Add event recordings as podcast items | ||
events.each do |e| | ||
video_link = webm_link.call(e) | ||
excerpt = excerpt_words(html_to_text(e[:abstract]), excerpt_limit) | ||
url = url_for(e) | ||
next if url.nil? | ||
|
||
xml.item do | ||
xml.title e[:title] | ||
xml.guid url | ||
xml.pubDate Date.parse(video_link[:created_at]).rfc822() | ||
xml.author author_email_rfc | ||
xml.link url | ||
xml.description excerpt | ||
xml.enclosure url: video_link[:url], type: 'video/webm' | ||
xml.podcast :transcript, url: video_link[:url].sub(/.av1.webm$/, '.vtt'), type: 'text/vtt' | ||
xml.itunes :episodetype, 'full' | ||
xml.itunes :author, organization | ||
unless e[:subtitle].to_s.strip.empty? | ||
xml.itunes :subtitle, e[:subtitle] | ||
end | ||
end | ||
end | ||
end | ||
end | ||
|
||
buffer | ||
end | ||
|
||
def rss_feed(params = {}) | ||
require 'builder' | ||
|
||
|
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