diff options
Diffstat (limited to 'app')
-rw-r--r-- | app/controllers/general_controller.rb | 18 | ||||
-rw-r--r-- | app/views/general/blog.rhtml | 23 | ||||
-rw-r--r-- | app/views/layouts/default.rhtml | 1 |
3 files changed, 41 insertions, 1 deletions
diff --git a/app/controllers/general_controller.rb b/app/controllers/general_controller.rb index 9041fd12e..013276984 100644 --- a/app/controllers/general_controller.rb +++ b/app/controllers/general_controller.rb @@ -5,7 +5,10 @@ # Copyright (c) 2008 UK Citizens Online Democracy. All rights reserved. # Email: francis@mysociety.org; WWW: http://www.mysociety.org/ # -# $Id: general_controller.rb,v 1.54 2009-09-09 00:03:09 francis Exp $ +# $Id: general_controller.rb,v 1.55 2009-09-09 23:52:05 francis Exp $ + +require 'xmlsimple' +require 'open-uri' class GeneralController < ApplicationController @@ -43,6 +46,19 @@ class GeneralController < ApplicationController cache_in_squid end + # 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"} ] + end + # Just does a redirect from ?query= search to /query def search_redirect @query = params[:query] diff --git a/app/views/general/blog.rhtml b/app/views/general/blog.rhtml new file mode 100644 index 000000000..7972cfcf6 --- /dev/null +++ b/app/views/general/blog.rhtml @@ -0,0 +1,23 @@ +<% @title = "WhatDoTheyKnow blog" %> + +<h1><%=@title %></h1> + +<div id="blog"> + +<%=@output%> + +<% for item in @items: %> + <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> + <div><%= item['encoded'] %></div> + <p><em> + <a href="<%=item['comments'][0]%>"><%=item['comments'][1]%> comments</a> + </em> + </p> + </div> +<% end %> + +<p><a href="<%=@all_url%>">See all posts</a></p> + +</div> diff --git a/app/views/layouts/default.rhtml b/app/views/layouts/default.rhtml index a76440d93..43715fea9 100644 --- a/app/views/layouts/default.rhtml +++ b/app/views/layouts/default.rhtml @@ -115,6 +115,7 @@ <% if @user %> <li><%=link_to "My requests", user_url(@user) %></li> <% end %> + <li><%= link_to "Read blog", blog_url %></li> <li><%= link_to "Help", about_url %></li> </ul> <% if not (controller.action_name == 'signin' or controller.action_name == 'signup') %> |