Browse code

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

Brandon Mathis authored on 01/10/2012 at 12:28:30
Showing 2 changed files
... ...
@@ -44,7 +44,7 @@ function Pinboard_Linkroll() {
44 44
     if (it.t.length > 0) {
45 45
       for (var i = 0; i < it.t.length; i++) {
46 46
         var tag = it.t[i];
47
-        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> ";
47
+        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> ";
48 48
       }
49 49
     }
50 50
     str += "</p></li>\n";
... ...
@@ -52,5 +52,5 @@ function Pinboard_Linkroll() {
52 52
   }
53 53
 }
54 54
 Pinboard_Linkroll.prototype = new Pinboard_Linkroll();
55
-pinboardNS_fetch_script("http://feeds.pinboard.in/json/v1/u:"+pinboard_user+"/?cb=pinboardNS_show_bmarks\&count="+pinboard_count);
55
+pinboardNS_fetch_script("https://feeds.pinboard.in/json/v1/u:"+pinboard_user+"/?cb=pinboardNS_show_bmarks\&count="+pinboard_count);
56 56
 
... ...
@@ -41,9 +41,9 @@ function prettyDate(time) {
41 41
 
42 42
 function linkifyTweet(text, url) {
43 43
   // Linkify urls, usernames, hashtags
44
-  text = text.replace(/(https?:)(\/\/)([\w\-:;?&=+.%#\/]+)/gi, '<a href="$2$3">$3</a>')
45
-    .replace(/(^|\W)@(\w+)/g, '$1<a href="//twitter.com/$2">@$2</a>')
46
-    .replace(/(^|\W)#(\w+)/g, '$1<a href="//search.twitter.com/search?q=%23$2">#$2</a>');
44
+  text = text.replace(/(https?:\/\/)([\w\-:;?&=+.%#\/]+)/gi, '<a href="$1$2">$2</a>')
45
+    .replace(/(^|\W)@(\w+)/g, '$1<a href="https://twitter.com/$2">@$2</a>')
46
+    .replace(/(^|\W)#(\w+)/g, '$1<a href="https://search.twitter.com/search?q=%23$2">#$2</a>');
47 47
 
48 48
   // Use twitter's api to replace t.co shortened urls with expanded ones.
49 49
   for (var u in url) {
... ...
@@ -62,7 +62,7 @@ function showTwitterFeed(tweets, twitter_user) {
62 62
       content = '';
63 63
 
64 64
   for (var t in tweets) {
65
-    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>';
65
+    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>';
66 66
   }
67 67
   timeline.innerHTML = content;
68 68
 }
... ...
@@ -70,7 +70,7 @@ function showTwitterFeed(tweets, twitter_user) {
70 70
 function getTwitterFeed(user, count, replies) {
71 71
   count = parseInt(count, 10);
72 72
   $.ajax({
73
-      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=?"
73
+      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=?"
74 74
     , type: 'jsonp'
75 75
     , error: function (err) { $('#tweets li.loading').addClass('error').text("Twitter's busted"); }
76 76
     , success: function(data) { showTwitterFeed(data.slice(0, count), user); }