aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--app/controllers/general_controller.rb14
-rw-r--r--app/views/general/blog.rhtml17
2 files changed, 24 insertions, 7 deletions
diff --git a/app/controllers/general_controller.rb b/app/controllers/general_controller.rb
index efab26fad..3bf113efb 100644
--- a/app/controllers/general_controller.rb
+++ b/app/controllers/general_controller.rb
@@ -49,14 +49,22 @@ class GeneralController < ApplicationController
# Display WhatDoTheyKnow category from mySociety blog
def blog
feed_url = 'http://www.mysociety.org/category/projects/whatdotheyknow/feed/'
- all_url = 'http://www.mysociety.org/category/projects/whatdotheyknow/'
- @output = ''
content = open(feed_url).read
@data = XmlSimple.xml_in(content)
@channel = @data['channel'][0]
@items = @channel['item']
- @feed_autodetect = [ { :url => @channel['link'][0]['href'], :title => "WhatDoTheyKnow blog"} ]
+ @feed_autodetect = [ { :url => feed_url, :title => "WhatDoTheyKnow blog"} ]
+
+ twitter_url = 'http://api.twitter.com/1/statuses/user_timeline/whatdotheyknow.rss' # @whatdotheyknow
+ content = open(twitter_url).read
+ @data = XmlSimple.xml_in(content)
+ @channel = @data['channel'][0]
+ @items = @channel['item'] + @items
+
+ @feed_autodetect += [ { :url => twitter_url, :title => "WhatDoTheyKnow tweets"} ]
+
+ @items.sort! { |a,b| Time.parse(b['pubDate'][0]) <=> Time.parse(a['pubDate'][0]) }
end
# Just does a redirect from ?query= search to /query
diff --git a/app/views/general/blog.rhtml b/app/views/general/blog.rhtml
index 7972cfcf6..a01af3894 100644
--- a/app/views/general/blog.rhtml
+++ b/app/views/general/blog.rhtml
@@ -1,12 +1,11 @@
-<% @title = "WhatDoTheyKnow blog" %>
+<% @title = "WhatDoTheyKnow blog and tweets" %>
<h1><%=@title %></h1>
<div id="blog">
-<%=@output%>
-
<% for item in @items: %>
+ <% if item['comments'] %>
<div class="blog_post">
<h2><a href="<%=item['link']%>"><%=h item['title'] %></a></h2>
<p class="subtitle">Posted on <%= simple_date(Time.parse(item['pubDate'][0])) %> by <%=h item['creator'] %></p>
@@ -16,8 +15,18 @@
</em>
</p>
</div>
+ <% else %>
+ <div class="twitter_post">
+ <h2><a href="<%=item['link']%>">@whatdotheyknow on <%= simple_date(Time.parse(item['pubDate'][0])) %></a></h2>
+ <p><%=MySociety::Format.make_clickable(h(item['title'][0].sub("WhatDoTheyKnow: ", ""))) %></a></p>
+ <div>
+ <% end %>
+
<% end %>
-<p><a href="<%=@all_url%>">See all posts</a></p>
+<p>
+ <a href="http://www.mysociety.org/category/projects/whatdotheyknow/">All blog posts</a> |
+ <a href="http://www.twitter.com/whatdotheyknow">@whatdotheyknow on twitter</a>
+</p>
</div>