aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--app/controllers/general_controller.rb29
-rw-r--r--app/views/general/blog.rhtml68
-rw-r--r--config/general-example7
-rw-r--r--public/images/rss.pngbin14005 -> 6171 bytes
-rw-r--r--public/images/twitter.pngbin3276 -> 1486 bytes
-rw-r--r--public/stylesheets/main.css17
6 files changed, 65 insertions, 56 deletions
diff --git a/app/controllers/general_controller.rb b/app/controllers/general_controller.rb
index 17f39740f..6e5c8c3fd 100644
--- a/app/controllers/general_controller.rb
+++ b/app/controllers/general_controller.rb
@@ -66,23 +66,18 @@ class GeneralController < ApplicationController
# Display WhatDoTheyKnow category from mySociety blog
def blog
- feed_url = 'http://www.mysociety.org/category/projects/whatdotheyknow/feed/'
- content = open(feed_url).read
- @data = XmlSimple.xml_in(content)
- @channel = @data['channel'][0]
- @items = @channel['item']
-
- @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]) }
+ @feed_autodetect = []
+ feed_url = MySociety::Config.get('BLOG_FEED', '')
+ if not feed_url.empty?
+ content = open(feed_url).read
+ @data = XmlSimple.xml_in(content)
+ @channel = @data['channel'][0]
+ @blog_items = @channel['item']
+ @feed_autodetect = [ { :url => feed_url, :title => "WhatDoTheyKnow blog"} ]
+ else
+ @blog_items = []
+ end
+ @twitter_user = MySociety::Config.get('TWITTER_USERNAME', '')
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 3f3abf42a..843d31c0f 100644
--- a/app/views/general/blog.rhtml
+++ b/app/views/general/blog.rhtml
@@ -1,16 +1,47 @@
-<% @title = "WhatDoTheyKnow blog and tweets" %>
-
-<div id="blog_sidebar">
- <h1><img src="/images/twitter.png" alt=""> <a href="http://www.twitter.com/whatdotheyknow">Follow us on twitter</a></h1>
- <h1><img src="/images/rss.png" alt=""> <a href="http://www.mysociety.org/category/projects/whatdotheyknow/feed/">Subscribe to blog</h1>
-</div>
+<% @title = "#{site_name} blog and tweets" %>
<h1><%=@title %></h1>
+ <img src="/images/twitter.png" alt="twitter icon" valign="middle"> <a href="http://www.twitter.com/whatdotheyknow">Follow us on twitter</a>&nbsp;
+ <img src="/images/rss.png" alt="RSS icon" valign="middle"> <a href="http://www.mysociety.org/category/projects/whatdotheyknow/feed/">Subscribe to blog</a>
+<% if !@twitter_user.empty? %>
+<div id="twitter">
+<script src="http://widgets.twimg.com/j/2/widget.js"></script>
+<script>
+new TWTR.Widget({
+ version: 2,
+ type: 'profile',
+ rpp: 15,
+ interval: 6000,
+ width: 'auto',
+ height: 500,
+ theme: {
+ shell: {
+ background: '#eaeaea',
+ color: '#000000'
+ },
+ tweets: {
+ background: '#ffffff',
+ color: '#000000',
+ links: '#0b004a'
+ }
+ },
+ features: {
+ scrollbar: false,
+ loop: false,
+ live: false,
+ hashtags: true,
+ timestamp: true,
+ avatars: false,
+ behavior: 'all'
+ }
+}).render().setUser('<%=@twitter_user %>').start();
+</script>
-<div id="blog">
+</div>
+<% end %>
-<% for item in @items: %>
- <% if item['comments'] %>
+<div id="blog">
+ <% for item in @blog_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>
@@ -20,18 +51,9 @@
</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="http://www.mysociety.org/category/projects/whatdotheyknow/">All blog posts</a> |
- <a href="http://www.twitter.com/whatdotheyknow">@whatdotheyknow on twitter</a>
-</p>
-
+ <% end %>
+ <p>
+ <a href="http://www.mysociety.org/category/projects/whatdotheyknow/">All blog posts</a>
+ </p>
</div>
+
diff --git a/config/general-example b/config/general-example
index ddc738906..ab33dd342 100644
--- a/config/general-example
+++ b/config/general-example
@@ -37,6 +37,10 @@ define('OPTION_CONTACT_NAME', 'Alaveteli Webmaster');
// Workflow settings
define('OPTION_REPLY_LATE_AFTER_DAYS', 20);
+// Blog and Twitter
+define('OPTION_BLOG_FEED', 'http://www.mysociety.org/category/projects/whatdotheyknow/feed/');
+define('OPTION_TWITTER_USERNAME', 'whatdotheyknow');
+
// Incoming email
define('OPTION_INCOMING_EMAIL_DOMAIN', 'localhost'); // e.g. 'foifa.com'
@@ -48,9 +52,10 @@ define('OPTION_BLACKHOLE_PREFIX', 'do-not-reply-to-this-address'); // used as en
// To completely skip admin authentication, set these to empty strings
define('OPTION_ADMIN_USERNAME', 'adminxxxx');
define('OPTION_ADMIN_PASSWORD', 'passwordx');
-
define('OPTION_ADMIN_BASE_URL', '/admin/');
+
+
// Where /stylesheets sits under for admin pages. See asset_host in
// config/environment.rb. Can be full domain or relative path (not an absolute path beginning with /).
define('OPTION_ADMIN_PUBLIC_URL', '');
diff --git a/public/images/rss.png b/public/images/rss.png
index 66ab927e4..a88ac93f5 100644
--- a/public/images/rss.png
+++ b/public/images/rss.png
Binary files differ
diff --git a/public/images/twitter.png b/public/images/twitter.png
index e3fa814a1..6589824af 100644
--- a/public/images/twitter.png
+++ b/public/images/twitter.png
Binary files differ
diff --git a/public/stylesheets/main.css b/public/stylesheets/main.css
index 78a6088f3..76a7f7c9b 100644
--- a/public/stylesheets/main.css
+++ b/public/stylesheets/main.css
@@ -171,7 +171,7 @@ body
#topnav
{
position: relative;
- top: 103px;
+ top: 77px;
left: 0px;
width: 100%;
height: auto;
@@ -404,7 +404,7 @@ dd { margin: 0.6em 0 2em 4em; width: 33em; }
/*-----------------------------blog----------------*/
-div#blog_sidebar
+div#twitter
{
float: right;
clear: none;
@@ -412,24 +412,11 @@ div#blog_sidebar
background-color: #EAEAEA;
padding: 0.5em;
margin: 0 0 1em 1em;
-
- border-color: #AEAEAE;
- border-width: 1px;
- border-style: solid;
-}
-div#blog_sidebar h1
-{
-}
-div#blog_sidebar img
-{
- vertical-align: middle;
}
.blog_post {
margin-bottom: 2em;
}
-.twitter_post {
-}
/*-----------------------------list sidebars----------------*/
#list_sidebar