Browse Source

Using https instead of protocol relative urls, for Pinboard and Twitter feeds

unreleased_contents
Brandon Mathis 12 years ago
parent
commit
bfbb8f32fb
  1. 4
      .themes/classic/source/javascripts/pinboard.js
  2. 10
      .themes/classic/source/javascripts/twitter.js

4
.themes/classic/source/javascripts/pinboard.js

@ -44,7 +44,7 @@ function Pinboard_Linkroll() {
if (it.t.length > 0) { if (it.t.length > 0) {
for (var i = 0; i < it.t.length; i++) { for (var i = 0; i < it.t.length; i++) {
var tag = it.t[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=\"https://pinboard.in/u:"+ this.cook(it.a) + "/t:" + this.cook(tag) + "\">" + this.cook(tag).replace(/^\s+|\s+$/g, '') + "</a> ";
} }
} }
str += "</p></li>\n"; str += "</p></li>\n";
@ -52,5 +52,5 @@ function Pinboard_Linkroll() {
} }
} }
Pinboard_Linkroll.prototype = new Pinboard_Linkroll(); Pinboard_Linkroll.prototype = new Pinboard_Linkroll();
pinboardNS_fetch_script("http://feeds.pinboard.in/json/v1/u:"+pinboard_user+"/?cb=pinboardNS_show_bmarks\&count="+pinboard_count); pinboardNS_fetch_script("https://feeds.pinboard.in/json/v1/u:"+pinboard_user+"/?cb=pinboardNS_show_bmarks\&count="+pinboard_count);

10
.themes/classic/source/javascripts/twitter.js

@ -41,9 +41,9 @@ function prettyDate(time) {
function linkifyTweet(text, url) { function linkifyTweet(text, url) {
// Linkify urls, usernames, hashtags // Linkify urls, usernames, hashtags
text = text.replace(/(https?:)(\/\/)([\w\-:;?&=+.%#\/]+)/gi, '<a href="$2$3">$3</a>') text = text.replace(/(https?:\/\/)([\w\-:;?&=+.%#\/]+)/gi, '<a href="$1$2">$2</a>')
.replace(/(^|\W)@(\w+)/g, '$1<a href="//twitter.com/$2">@$2</a>') .replace(/(^|\W)@(\w+)/g, '$1<a href="https://twitter.com/$2">@$2</a>')
.replace(/(^|\W)#(\w+)/g, '$1<a href="//search.twitter.com/search?q=%23$2">#$2</a>'); .replace(/(^|\W)#(\w+)/g, '$1<a href="https://search.twitter.com/search?q=%23$2">#$2</a>');
// Use twitter's api to replace t.co shortened urls with expanded ones. // Use twitter's api to replace t.co shortened urls with expanded ones.
for (var u in url) { for (var u in url) {
@ -62,7 +62,7 @@ function showTwitterFeed(tweets, twitter_user) {
content = ''; content = '';
for (var t in tweets) { for (var t in tweets) {
content += '<li>'+'<p>'+'<a href="//twitter.com/'+twitter_user+'/status/'+tweets[t].id_str+'">'+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="https://twitter.com/'+twitter_user+'/status/'+tweets[t].id_str+'">'+prettyDate(tweets[t].created_at)+'</a>'+linkifyTweet(tweets[t].text.replace(/\n/g, '<br>'), tweets[t].entities.urls)+'</p>'+'</li>';
} }
timeline.innerHTML = content; timeline.innerHTML = content;
} }
@ -70,7 +70,7 @@ function showTwitterFeed(tweets, twitter_user) {
function getTwitterFeed(user, count, replies) { function getTwitterFeed(user, count, replies) {
count = parseInt(count, 10); count = parseInt(count, 10);
$.ajax({ $.ajax({
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=?" url: "https://api.twitter.com/1/statuses/user_timeline/" + user + ".json?trim_user=true&count=" + (count + 20) + "&include_entities=1&exclude_replies=" + (replies ? "0" : "1") + "&callback=?"
, type: 'jsonp' , type: 'jsonp'
, error: function (err) { $('#tweets li.loading').addClass('error').text("Twitter's busted"); } , error: function (err) { $('#tweets li.loading').addClass('error').text("Twitter's busted"); }
, success: function(data) { showTwitterFeed(data.slice(0, count), user); } , success: function(data) { showTwitterFeed(data.slice(0, count), user); }

Loading…
Cancel
Save