Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

You get a feed! You get a feed! Feeds for everyone! #182

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
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
106 changes: 106 additions & 0 deletions _layouts/feed.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
---
layout: null
copyrite: "Copyright © Stack Overflow"
feedDescription: "free, community powered Q&A"
feedImage: http://cdn.sstatic.net/stackexchange/img/se-podcast-logo.png
feedImageName: Stack Overflow
feedEmail: [email protected]
teamName: The Stack Overflow Team
podcastEmail: [email protected]
podcastTitle: The Stack Overflow Podcast
podcastSubTitle: A look inside the Stack Exchange Network
podcastKeywords: "Programming, Stack, Exchange, Stack, Overflow, Computers, Technology, Information, Internet, Question, Answer, Q&A"
podcastSummary: "Hosted by Joel Spolsky with Jay Hanlon and David Fullerton, the Stack Overflow podcast lets you listen in on discussions and decisions about the Stack Exchange Network. The Stack Overflow podcast gives you an unparalleled view into how a startup is created and built.


About Stack Overflow:

Stack Overflow is the flagship property of a fast-growing network of over 100 question and answer sites on diverse topics from software programming to cooking to photography and gaming. We are an expert knowledge exchange: a place where physics researchers can ask each other about quantum entanglement, computer programmers can ask about JavaScript date formats, and photographers can share knowledge about taking great pictures in the snow."
---
<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
xmlns:wfw="http://wellformedweb.org/CommentAPI/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:atom="http://www.w3.org/2005/Atom"
xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd"
xmlns:media="http://search.yahoo.com/mrss/"
>
<channel>
{% if page.tag.name == 'podcasts' %}
<title>{{ page.podcastTitle }}</title>
<itunes:subtitle>{{ page.podcastSubTitle }}</itunes:subtitle>
<itunes:summary>{{ page.podcastSummary }}</itunes:summary>
<itunes:keywords>{{ page.podcastKeywords }}</itunes:keywords>
<itunes:category text="Technology">
<itunes:category text="Software How-To" />
</itunes:category>
<itunes:category text="Technology">
<itunes:category text="Podcasting" />
</itunes:category>
<itunes:category text="Business" />
<itunes:author>{{ page.teamName }}</itunes:author>
<itunes:owner>
<itunes:name>{{ page.teamName }}</itunes:name>
<itunes:email>{{ page.podcastEmail }}</itunes:email>
</itunes:owner>
<itunes:new-feed-url>{{ site.url }}/feed/podcast</itunes:new-feed-url>
<itunes:block>no</itunes:block>
<itunes:explicit>no</itunes:explicit>
<itunes:image href="{{ page.feedImage }}" />
{% else %}
{% if !page.tag.name %}
<title>{{ site.name }} - {{ page.tag.name | capitalize }}</title>
{% else %}
<title>{{ site.name }}</title>
{% endif %}
{% endif %}
<atom:link href="{{ site.url }}{{ page.dir }}" rel="self" type="application/rss+xml" />
<link>{{ site.url }}</link>
<description>{{ page.feedDescription }}</description>
<lastBuildDate>{{ site.time | date: "%a, %d %b %Y %T +0000" }}</lastBuildDate>
<language>en-US</language>
<sy:updatePeriod>hourly</sy:updatePeriod>
<sy:updateFrequency>1</sy:updateFrequency>
<copyright>{{ page.copyrite }}, {{ site.time | date: "%Y" }}</copyright>
<managingEditor>{{ page.feedEmail }} ({{ page.teamName }})</managingEditor>
<webMaster>{{ page.feedEmail }} ({{ page.teamName }})</webMaster>
<ttl>1440</ttl>
<image>
<url>{{ page.feedImage }}</url>
<title>{{ page.feedImageName }}</title>
<link>{{ site.url }}</link>
<width>144</width>
<height>144</height>
</image>
{% for post in page.posts %}
<item>
<title><![CDATA[{{ post.title | raw }}]]></title>
<link>{{ site.url }}{{ post.url }}</link>
<dc:creator><![CDATA[{{ post.full_author.name }}]]></dc:creator>
{% for category in post.tags %}
<category><![CDATA[{{ category }}]]></category>
{% endfor %}
<pubDate>{{ post.date | date: "%a, %d %b %Y %T +0000" }}</pubDate>
<description><![CDATA[{{ post.excerpt | raw }}]]></description>
<content:encoded><![CDATA[{{ post.content | raw }}]]></content:encoded>
{% if post.podcast %}
{% if post.wordpress_id %}
<guid isPermaLink="false">http://blog.stackoverflow.com/?p={{ post.wordpress_id }}</guid>
{% else %}
<guid isPermaLink="false">{{ site.url }}{{ post.url }}</guid>
{% endif %}
<enclosure type="audio/mpeg" url="{{ post.podcast }}" length="0"/>
{% endif %}
{% if page.tag.name == 'podcasts' %}
<itunes:author>page.teamName</itunes:author>
<itunes:explicit>{% if post.explicit %}yes{% else %}no{% endif %}</itunes:explicit>
<itunes:summary><![CDATA[{{ post.content | strip_html | unescapeHTML | truncate: 4000 }}]]></itunes:summary>
<itunes:subtitle><![CDATA[{{ post.excerpt | strip_html | unescapeHTML | truncate: 255 }}]]></itunes:subtitle>
{% endif %}
</item>
{% endfor %}
</channel>
</rss>
51 changes: 51 additions & 0 deletions _plugins/StackGen.rb
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,17 @@ def generate(site)
All.tags.each do |key, tag|
paginate_tags(site, '/tags/:tags', [key], 'tag.html', Hash['tag' => tag])
end

Jekyll.logger.info "Generating main feed:"
feed_tags(site)
Jekyll.logger.info "Generating feed pages for #{All.tags.count} tag(s):"
All.tags.each do |key, tag|
if key == 'podcasts'
feed_tags(site, '/feed/podcast', [key], 'feed.xml', Hash['tag' => tag],0) #Podcast feed has a specific location and no post limit
else
feed_tags(site, '/feed/:tags', [key], 'feed.xml', Hash['tag' => tag])
end
end
end

def paginate_channels(site, category, channels)
Expand Down Expand Up @@ -302,6 +313,46 @@ def paginate_inner(site, path, posts, category_tags, layout_source, page_data =
site.pages << newpage
end
end

# Creates a feed for posts by tags. Renders the <layout_source> or <path>/feed.xml.
#
# site - The Site.
# path - The directory to render to.
# catgory_tags - The tag hierarchy to render
# laytout_source - The /_layouts/<layoutsource> to use as a template
# page_data - The data to applend to the page object for liquid
# limit - The number of posts to include in the feed
#
def feed_tags(site, path = '/feed/:tags', category_tags = [], layout_source = 'feed.xml', page_data = nil, limit = 40)
path = path.sub(':tags', category_tags.join("/"))

posts = All.posts
for tag in category_tags
posts = posts.find_all{|post| post.tags.include?(tag)}
end
posts = posts.sort_by {|post| -post.date.to_f}
if limit > 0
posts = posts.first(limit)
end

# Output for the console
Jekyll.logger.info(" [#{(category_tags.count == 0 ? "<all>" : category_tags.join(","))}] (#{path}) => #{posts.count} post(s)")
# Generate feed
newpage = Page.new(site, site.source, layout_source ? site.config['layouts'] : path + "/", layout_source || '/feed/index.xml')
unless page_data.nil?
page_data.each do |key, value|
newpage.data[key] = value
end
end

newpage.data['posts'] = posts #Append the post data
newpage.dir = path
# This may seem irrelevant, but because of how Jekyll::Post generates the path, it's necessary to not have the generated
# page in a sub-folder of the source file name. e.g. /company/page3/company/index.html will result from company.html
# being used as the layout source
newpage.basename = 'index'
site.pages << newpage
end
end
end

Expand Down
84 changes: 0 additions & 84 deletions category/podcasts/feed/index.xml

This file was deleted.

85 changes: 0 additions & 85 deletions feed/index.xml

This file was deleted.

Loading