mirror of
https://github.com/moparisthebest/android.moparisthebest.org
synced 2024-11-16 06:05:00 -05:00
Using protocol relative URLs for Twitter, GitHub and Pinboard feeds
This commit is contained in:
parent
3f842465bd
commit
9f7425a953
@ -165,9 +165,9 @@ var octopress = (function(){
|
||||
|
||||
function linkifyTweet(text, url) {
|
||||
// Linkify urls, usernames, hashtags
|
||||
text = text.replace(/(https?:\/\/)([\w\-:;?&=+.%#\/]+)/gi, '<a href="$1$2">$2</a>')
|
||||
.replace(/(^|\W)@(\w+)/g, '$1<a href="http://twitter.com/$2">@$2</a>')
|
||||
.replace(/(^|\W)#(\w+)/g, '$1<a href="http://search.twitter.com/search?q=%23$2">#$2</a>');
|
||||
text = text.replace(/(https?:)(\/\/)([\w\-:;?&=+.%#\/]+)/gi, '<a href="$2$3">$3</a>')
|
||||
.replace(/(^|\W)@(\w+)/g, '$1<a href="//twitter.com/$2">@$2</a>')
|
||||
.replace(/(^|\W)#(\w+)/g, '$1<a href="//search.twitter.com/search?q=%23$2">#$2</a>');
|
||||
|
||||
// Use twitter's api to replace t.co shortened urls with expanded ones.
|
||||
for (var u in url) {
|
||||
@ -186,7 +186,7 @@ var octopress = (function(){
|
||||
content = '';
|
||||
|
||||
for (var t in tweets) {
|
||||
content += '<li>'+'<p>'+'<a href="http://twitter.com/'+twitter_user+'/status/'+tweets[t].id_str+'">'+octopress.prettyDate(tweets[t].created_at)+'</a>'+linkifyTweet(tweets[t].text.replace(/\n/g, '<br>'), tweets[t].entities.urls)+'</p>'+'</li>';
|
||||
content += '<li>'+'<p>'+'<a href="//twitter.com/'+twitter_user+'/status/'+tweets[t].id_str+'">'+octopress.prettyDate(tweets[t].created_at)+'</a>'+linkifyTweet(tweets[t].text.replace(/\n/g, '<br>'), tweets[t].entities.urls)+'</p>'+'</li>';
|
||||
}
|
||||
timeline.innerHTML = content;
|
||||
}
|
||||
@ -199,7 +199,7 @@ var octopress = (function(){
|
||||
var count = parseInt(target.attr('data-count'), 10);
|
||||
var replies = target.attr('data-replies') == 'true';
|
||||
$.ajax({
|
||||
url: "http://api.twitter.com/1/statuses/user_timeline/" + user + ".json?trim_user=true&count=" + (count + 20) + "&include_entities=1&exclude_replies=" + (replies ? "0" : "1") + "&callback=?"
|
||||
url: "//api.twitter.com/1/statuses/user_timeline/" + user + ".json?trim_user=true&count=" + (count + 20) + "&include_entities=1&exclude_replies=" + (replies ? "0" : "1") + "&callback=?"
|
||||
, dataType: 'jsonp'
|
||||
, error: function (err) { $('#tweets li.loading').addClass('error').text("Twitter's busted"); }
|
||||
, success: function(data) { render(data.slice(0, count), user); }
|
||||
@ -235,7 +235,7 @@ var octopress = (function(){
|
||||
var count = parseInt(target.attr('data-count'))
|
||||
var skip_forks = target.attr('data-skip') == 'true';
|
||||
$.ajax({
|
||||
url: "https://api.github.com/users/"+user+"/repos?callback=?"
|
||||
url: "//api.github.com/users/"+user+"/repos?callback=?"
|
||||
, dataType: 'jsonp'
|
||||
, error: function (err) { target.find('.loading').addClass('error').text("Error loading feed"); }
|
||||
, success: function(data) {
|
||||
|
@ -39,7 +39,7 @@ var pinboard = (function(){
|
||||
if (it.t.length > 0) {
|
||||
for (var i = 0; i < it.t.length; i++) {
|
||||
var tag = it.t[i];
|
||||
str += " <a class=\"pin-tag\" href=\"http://pinboard.in/u:"+ this.cook(it.a) + "/t:" + this.cook(tag) + "\">" + this.cook(tag).replace(/^\s+|\s+$/g, '') + "</a> ";
|
||||
str += " <a class=\"pin-tag\" href=\"//pinboard.in/u:"+ this.cook(it.a) + "/t:" + this.cook(tag) + "\">" + this.cook(tag).replace(/^\s+|\s+$/g, '') + "</a> ";
|
||||
}
|
||||
}
|
||||
str += "</p></li>\n";
|
||||
@ -50,7 +50,7 @@ var pinboard = (function(){
|
||||
return {
|
||||
getFeed: function(options) {
|
||||
this.element = options.target;
|
||||
fetch("http://feeds.pinboard.in/json/v1/u:"+options.user+"/?cb=pinboard.render\&count="+options.count);
|
||||
fetch("//feeds.pinboard.in/json/v1/u:"+options.user+"/?cb=pinboard.render\&count="+options.count);
|
||||
},
|
||||
|
||||
render: function(data) {
|
||||
|
Loading…
Reference in New Issue
Block a user