| ... | ... |
@@ -1,12 +1,12 @@ |
| 1 | 1 |
// JSON-P Twitter fetcher for Octopress |
| 2 |
-// (c) Brandon Mathis // MIT Lisence |
|
| 2 |
+// (c) Brandon Mathis // MIT License |
|
| 3 | 3 |
|
| 4 | 4 |
/* Sky Slavin, Ludopoli. MIT license. * based on JavaScript Pretty Date * Copyright (c) 2008 John Resig (jquery.com) * Licensed under the MIT license. */ |
| 5 | 5 |
function prettyDate(time) {
|
| 6 | 6 |
if (navigator.appName === 'Microsoft Internet Explorer') {
|
| 7 | 7 |
return "<span>∞</span>"; // because IE date parsing isn't fun. |
| 8 | 8 |
} |
| 9 |
- |
|
| 9 |
+ console.log(time); |
|
| 10 | 10 |
var say = {
|
| 11 | 11 |
just_now: " now", |
| 12 | 12 |
minute_ago: "1m", |
| ... | ... |
@@ -15,6 +15,7 @@ function prettyDate(time) {
|
| 15 | 15 |
hours_ago: "h", |
| 16 | 16 |
yesterday: "1d", |
| 17 | 17 |
days_ago: "d", |
| 18 |
+ last_week: "1w", |
|
| 18 | 19 |
weeks_ago: "w" |
| 19 | 20 |
}; |
| 20 | 21 |
|
| ... | ... |
@@ -35,6 +36,7 @@ function prettyDate(time) {
|
| 35 | 35 |
diff < 86400 && Math.floor(diff / 3600) + say.hours_ago) || |
| 36 | 36 |
day_diff === 1 && say.yesterday || |
| 37 | 37 |
day_diff < 7 && day_diff + say.days_ago || |
| 38 |
+ day_diff === 7 && say.last_week || |
|
| 38 | 39 |
day_diff > 7 && Math.ceil(day_diff / 7) + say.weeks_ago; |
| 39 | 40 |
} |
| 40 | 41 |
|
| ... | ... |
@@ -47,8 +49,10 @@ function linkifyTweet(text, url) {
|
| 47 | 47 |
// Use twitter's api to replace t.co shortened urls with expanded ones. |
| 48 | 48 |
for (var u in url) {
|
| 49 | 49 |
if(url[u].expanded_url != null){
|
| 50 |
- var shortUrl = new RegExp( url[u].url.replace(/https?:\/\//, ''), 'g'); |
|
| 51 |
- text = text.replace(shortUrl, url[u].display_url); |
|
| 50 |
+ var shortUrl = new RegExp(url[u].url, 'g'); |
|
| 51 |
+ text = text.replace(shortUrl, url[u].expanded_url); |
|
| 52 |
+ var shortUrl = new RegExp(">"+(url[u].url.replace(/https?:\/\//, '')), 'g');
|
|
| 53 |
+ text = text.replace(shortUrl, ">"+url[u].display_url); |
|
| 52 | 54 |
} |
| 53 | 55 |
} |
| 54 | 56 |
return text |