aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--app/controllers/general_controller.rb18
-rw-r--r--app/views/general/blog.rhtml23
-rw-r--r--app/views/layouts/default.rhtml1
-rw-r--r--config/routes.rb3
-rw-r--r--public/stylesheets/main.css6
5 files changed, 49 insertions, 2 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') %>
diff --git a/config/routes.rb b/config/routes.rb
index bdf91a7e6..fb363a419 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -4,7 +4,7 @@
# Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved.
# Email: francis@mysociety.org; WWW: http://www.mysociety.org/
#
-# $Id: routes.rb,v 1.89 2009-07-01 11:07:19 francis Exp $
+# $Id: routes.rb,v 1.90 2009-09-09 23:52:06 francis Exp $
ActionController::Routing::Routes.draw do |map|
@@ -16,6 +16,7 @@ ActionController::Routing::Routes.draw do |map|
map.with_options :controller => 'general' do |general|
general.frontpage '/', :action => 'frontpage'
+ general.blog '/blog', :action => 'blog'
general.search_redirect '/search', :action => 'search_redirect'
# XXX combined is the search query, and then if sorted a "/newest" at the end.
diff --git a/public/stylesheets/main.css b/public/stylesheets/main.css
index b9716bc75..6a86f230a 100644
--- a/public/stylesheets/main.css
+++ b/public/stylesheets/main.css
@@ -336,6 +336,12 @@ dd { margin: 0.6em 0 2em 4em; width: 33em; }
list-style: none;
}
+/*-----------------------------blog----------------*/
+
+.blog_post {
+ margin-bottom: 2em;
+}
+
/*-----------------------------list sidebars----------------*/
#list_sidebar
{