Permalink
Browse files

Added sidebar widget to show latest App.net posts

  • Loading branch information...
bsag committed Jan 30, 2013
1 parent 3d5df83 commit ff19e1eaf21e440eebdee8ffd001370278bf4a59
View
@@ -7,7 +7,7 @@ require "stringex"
ssh_user = "bsag@rousette.org.uk"
document_root = "/srv/http/rousette.org.uk/public_html/blog"
ssh_port = "22"
rsync_delete = true
rsync_delete = false
deploy_default = "rsync"
# This will be configured for you when you run config_deploy
View
@@ -49,7 +49,7 @@ titlecase: true # Converts page and post titles to tilecase
# list each of the sidebar modules you want to include, in the order you want them to appear.
# To add custom asides, create files in /source/_includes/custom/asides/ and add them to the list like 'custom/asides/custom_aside_name.html'
default_asides: [custom/asides/elsewhere.html, asides/recent_posts.html, asides/twitter.html, asides/pinboard.html]
default_asides: [custom/asides/elsewhere.html, asides/recent_posts.html, custom/asides/adn.html, asides/twitter.html, asides/pinboard.html]
# Each layout uses the default asides, but they can have their own asides instead. Simply uncomment the lines below
# and add an array with the asides you want to use.
@@ -3,3 +3,4 @@
@import "sidebar/googleplus";
@import "sidebar/pinboard";
@import "sidebar/delicious";
@import "sidebar/adn";
@@ -0,0 +1,34 @@
#adn {
.loading {
background: inline-image('bird_32_gray.png') no-repeat center .5em;
color: darken($sidebar-bg, 18);
text-shadow: $main-bg 0 1px;
text-align: center;
padding: 2.5em 0 .5em;
&.error {
background: inline-image('bird_32_gray_fail.png') no-repeat center .5em;
}
}
p {
position: relative;
padding-right: 1em;
}
a[href*=post]:first-child {
color: $twitter-status-link;
float: right;
padding: 0 0 .1em 1em;
position: relative; right: -1.3em;
text-shadow: #fff 0 1px;
font-size: .7em;
span { font-size: 1.5em; }
text-decoration: none;
&:hover {
color: $sidebar-link-color-subdued-hover;
text-decoration: none;
}
}
a[href*='alpha.app.net']{
@extend .aside-alt-link;
@include hover-link;
}
}
@@ -0,0 +1,15 @@
<section>
<h1>App.net posts</h1>
<ul id="adn">
<li class="loading">Status updating&#8230;</li>
</ul>
<script type="text/javascript">
$.domReady(function(){
getADNFeed();
});
</script>
<script src="{{ root_url }}/javascripts/adn.js" type="text/javascript"> </script>
<a href="https://alpha.app.net/bsag">Follow @bsag on ADN</a>
</section>
@@ -1,3 +1,10 @@
<script type="text/javascript" src="http://use.typekit.com/pkq3bvb.js"></script>
<script type="text/javascript">try{Typekit.load();}catch(e){}</script>
<!-- Javascripts for custom ADN aside -->
<script type="text/javascript" src="javascripts/jquery.js"></script>
<script type="text/javascript">
// Avoid conflict with ender.js.
jQuery.noConflict();
</script>
<script type="text/javascript" src="javascripts/jquery.jfeed.js"></script>
View
@@ -0,0 +1,71 @@
// App.net post fetcher, modified from Brandon Mathis' Twitter script for Octopress
// Uses jFeed: https://github.com/jfhovinne/jFeed
//
/* Sky Slavin, Ludopoli. MIT license. * based on JavaScript Pretty Date * Copyright (c) 2008 John Resig (jquery.com) * Licensed under the MIT license. */
function prettyDate(time) {
if (navigator.appName === 'Microsoft Internet Explorer') {
return "<span>&infin;</span>"; // because IE date parsing isn't fun.
}
var say = {
just_now: " now",
minute_ago: "1m",
minutes_ago: "m",
hour_ago: "1h",
hours_ago: "h",
yesterday: "1d",
days_ago: "d",
last_week: "1w",
weeks_ago: "w"
};
var current_date = new Date(),
current_date_time = current_date.getTime(),
current_date_full = current_date_time + (1 * 60000),
date = new Date(time),
diff = ((current_date_full - date.getTime()) / 1000),
day_diff = Math.floor(diff / 86400);
if (isNaN(day_diff) || day_diff < 0) { return "<span>&infin;</span>"; }
return day_diff === 0 && (
diff < 60 && say.just_now ||
diff < 120 && say.minute_ago ||
diff < 3600 && Math.floor(diff / 60) + say.minutes_ago ||
diff < 7200 && say.hour_ago ||
diff < 86400 && Math.floor(diff / 3600) + say.hours_ago) ||
day_diff === 1 && say.yesterday ||
day_diff < 7 && day_diff + say.days_ago ||
day_diff === 7 && say.last_week ||
day_diff > 7 && Math.ceil(day_diff / 7) + say.weeks_ago;
}
function getADNFeed() {
jQuery.getFeed({
url: 'data/adn.xml',
error: function (err) { $('#adn li.loading').addClass('error').text("Something is broken"); },
success: function(feed, count) {
var timeline = document.getElementById('adn'), content = '';
for(var i = 0; i < feed.items.length && i < 5; i++) {
var item = feed.items[i];
var pubDate = new Date(item.updated);
content += '<li>'
+ '<p>'
+ '<a href="'
+ item.link
+ '">'
+ prettyDate(pubDate)
+ '</a>'
+ item.description
+ '</p>'
+ '</li>';
}
timeline.innerHTML = content;
}
});
}
@@ -0,0 +1,170 @@
/* jFeed : jQuery feed parser plugin
* Copyright (C) 2007 Jean-François Hovinne - http://www.hovinne.com/
* Dual licensed under the MIT (MIT-license.txt)
* and GPL (GPL-license.txt) licenses.
*/
jQuery.getFeed = function(options) {
options = jQuery.extend({
url: null,
data: null,
cache: true,
success: null,
failure: null,
error: null,
global: true
}, options);
if (options.url) {
if (jQuery.isFunction(options.failure) && jQuery.type(options.error)==='null') {
// Handle legacy failure option
options.error = function(xhr, msg, e){
options.failure(msg, e);
}
} else if (jQuery.type(options.failure) === jQuery.type(options.error) === 'null') {
// Default error behavior if failure & error both unspecified
options.error = function(xhr, msg, e){
window.console&&console.log('getFeed failed to load feed', xhr, msg, e);
}
}
return jQuery.ajax({
type: 'GET',
url: options.url,
data: options.data,
cache: options.cache,
dataType: (jQuery.browser.msie) ? "text" : "xml",
success: function(xml) {
var feed = new JFeed(xml);
if (jQuery.isFunction(options.success)) options.success(feed);
},
error: options.error,
global: options.global
});
}
};
function JFeed(xml) {
if (xml) this.parse(xml);
}
;
JFeed.prototype = {
type: '',
version: '',
title: '',
link: '',
description: '',
parse: function(xml) {
if (jQuery.browser.msie) {
var xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
xmlDoc.loadXML(xml);
xml = xmlDoc;
}
if (jQuery('channel', xml).length == 1) {
this.type = 'rss';
var feedClass = new JRss(xml);
} else if (jQuery('feed', xml).length == 1) {
this.type = 'atom';
var feedClass = new JAtom(xml);
}
if (feedClass) jQuery.extend(this, feedClass);
}
};
function JFeedItem() {};
JFeedItem.prototype = {
title: '',
link: '',
description: '',
updated: '',
id: ''
};
function JAtom(xml) {
this._parse(xml);
};
JAtom.prototype = {
_parse: function(xml) {
var channel = jQuery('feed', xml).eq(0);
this.version = '1.0';
this.title = jQuery(channel).find('title:first').text();
this.link = jQuery(channel).find('link:first').attr('href');
this.description = jQuery(channel).find('subtitle:first').text();
this.language = jQuery(channel).attr('xml:lang');
this.updated = jQuery(channel).find('updated:first').text();
this.items = new Array();
var feed = this;
jQuery('entry', xml).each( function() {
var item = new JFeedItem();
item.title = jQuery(this).find('title').eq(0).text();
item.link = jQuery(this).find('link').eq(0).attr('href');
item.description = jQuery(this).find('content').eq(0).text();
item.updated = jQuery(this).find('updated').eq(0).text();
item.id = jQuery(this).find('id').eq(0).text();
feed.items.push(item);
});
}
};
function JRss(xml) {
this._parse(xml);
};
JRss.prototype = {
_parse: function(xml) {
if(jQuery('rss', xml).length == 0) this.version = '1.0';
else this.version = jQuery('rss', xml).eq(0).attr('version');
var channel = jQuery('channel', xml).eq(0);
this.title = jQuery(channel).find('title:first').text();
this.link = jQuery(channel).find('link:first').text();
this.description = jQuery(channel).find('description:first').text();
this.language = jQuery(channel).find('language:first').text();
this.updated = jQuery(channel).find('lastBuildDate:first').text();
this.items = new Array();
var feed = this;
jQuery('item', xml).each( function() {
var item = new JFeedItem();
item.title = jQuery(this).find('title').eq(0).text();
item.link = jQuery(this).find('link').eq(0).text();
item.description = jQuery(this).find('description').eq(0).text();
item.updated = jQuery(this).find('pubDate').eq(0).text();
item.id = jQuery(this).find('guid').eq(0).text();
feed.items.push(item);
});
}
};

Large diffs are not rendered by default.

Oops, something went wrong.

0 comments on commit ff19e1e

Please sign in to comment.