Skip to content

Commit

Permalink
Merge branch 'master' of github.com:voodoochild/gu-curating-the-curators
Browse files Browse the repository at this point in the history
  • Loading branch information
Lisa van Gelder committed Feb 3, 2012
2 parents 243fb7b + 2a1b88b commit bf758a6
Show file tree
Hide file tree
Showing 4 changed files with 77 additions and 25 deletions.
18 changes: 14 additions & 4 deletions app/static/css/curators.css
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,21 @@ a, a:visited, a:active, a:hover {
text-decoration: none;
}

h1 {
font-family: Merriweather, serif;
}

[role="banner"] {
color: #333;
color: orange;
font-size: 36px;
font-weight: 900;
margin-bottom: 2%;
text-transform: uppercase;
text-transform: lowercase;
}

[role="banner"] .light {
color: beige;
font-weight: 400;
}

[role="main"] {
Expand All @@ -32,14 +42,14 @@ a, a:visited, a:active, a:hover {
}

.feed header h1 {
color: #555;
color: #999;
font-size: 20px;
margin-bottom: 2%;
text-transform: uppercase;
}

.feed li {
background-color: #333;
background-position: 50% 50%;
font-family: "Open Sans", Arial, sans-serif;
height: 90px;
margin-bottom: 3%;
Expand Down
77 changes: 59 additions & 18 deletions app/static/js/curators.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,47 @@ Curators.Storify = (function() {
})();


Curators.Tweetminster = (function() {
var tmpl = '<li data-key="%key%">' +
'<a href="%permalink%"><h2>%title%</h2></a></li>';

/**
* Get latest Storify stories from the database.
*/
var getData = function(callback) {
$.ajax({
url: '/tweetminster-dummy-data/',
success: callback
});
};

/**
* Render the supplied story to a string using the template.
*/
var renderStory = function(story) {
return tmpl.replace('%key%', story['key'])
.replace('%permalink%', story['permalink'])
.replace('%title%', story['title']);
};

return {
'getData': getData,
'renderStory': renderStory
};
})();


Curators.Feeds = (function() {
var subscribed_feeds = [];
var feed_timers = {};
var update_every = 60; // seconds
var update_every = 10; // seconds
var update_loop;

/**
* Return an array listing all possible feeds that can
* be subscribed to. At the moment that's just Storify.
*/
var availableFeeds = function() {
return ['Storify'];
return ['Storify','Tweetminster'];
};

/**
Expand All @@ -53,7 +83,6 @@ Curators.Feeds = (function() {
var addFeed = function(feed) {
if (-1 !== availableFeeds().indexOf(feed)) {
subscribed_feeds.push(feed);
updateFeeds();
}
return false;
};
Expand All @@ -68,33 +97,45 @@ Curators.Feeds = (function() {
var $feed = $('[data-feed="' + feed + '"]');
$feed.find('header').append(ajax_gif);

Curators[feed].getData(function(data) {
var $stories = $feed.find('ol li');
var new_stories = '';

$.each(data['stories'], function(i, story) {
new_stories += Curators[feed].renderStory(story);
setTimeout(function() {
Curators[feed].getData(function(data) {
var $stories = $feed.find('ol li');
var new_stories = '';

$.each(data['stories'], function(i, story) {
new_stories += Curators[feed].renderStory(story);
});

var $new_stories = $(new_stories);
$feed.find('ol').prepend($new_stories.hide());
$stories.remove();
$new_stories.show();
});

var $new_stories = $(new_stories);
$feed.find('ol').prepend($new_stories.hide());
$stories.remove();
$new_stories.show();
});

$feed.find('header .ajax-loader').remove();
$feed.find('header .ajax-loader').remove();
}, 2000);
});
};

/**
* Start a loop running to update the feeds at the required interval.
*/
var startUpdates = function() {
clearInterval(update_loop);
update_loop = setInterval(updateFeeds, update_every * 1000);
};

return {
'availableFeeds': availableFeeds,
'addFeed': addFeed,
'updateFeeds': updateFeeds
'startUpdates': startUpdates
};

})();


$(document).ready(function() {
Curators.Feeds.addFeed('Storify');
Curators.Feeds.addFeed('Tweetminster');
Curators.Feeds.startUpdates();
});
2 changes: 1 addition & 1 deletion settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,4 +93,4 @@
'feeds',
)

STORIES_PER_FEED = 5
STORIES_PER_FEED = 6
5 changes: 3 additions & 2 deletions templates/app/dashboard.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@

{% block stylesheets %}
<link rel="stylesheet" href="http://fonts.googleapis.com/css?family=Open+Sans">
<link rel="stylesheet" href="http://fonts.googleapis.com/css?family=Merriweather:900,400">
{{ super() }}
{% endblock stylesheets %}

{% block content %}
<header role="banner">
<h1>Curating the Curators</h1>
<h1><span class="light">Curating the</span> Curators</h1>
</header>
{% for feed in feeds %}
{% if feed.title and feed.stories %}
Expand All @@ -17,7 +18,7 @@ <h1>{{ feed.title }}</h1>
</header>
<ol>
{% for story in feed.stories %}
<li data-key="{{ story.key }}"{% if story.thumbnail %}style="background-image:url({{ story.thumbnail }});{% endif %}">
<li data-key="{{ story.key }}" style="background-image:url({% if story.thumbnail %}{{ story.thumbnail }}{% endif %});">
<a href="{{ story.permalink }}">
<h2>{{ story.title }}</h2>
</a>
Expand Down

0 comments on commit bf758a6

Please sign in to comment.