From f8844ca46f338c43d7dc38e669279e25204b7ac7 Mon Sep 17 00:00:00 2001 From: Hannes Mannerheim Date: Mon, 12 May 2014 13:20:26 +0200 Subject: [PATCH] more uri-to-url-conversion --- js/dom-functions.js | 52 +++++++++++++++++++++++++++++++-------------- 1 file changed, 36 insertions(+), 16 deletions(-) diff --git a/js/dom-functions.js b/js/dom-functions.js index d28e57a..e5c22ca 100644 --- a/js/dom-functions.js +++ b/js/dom-functions.js @@ -1066,6 +1066,33 @@ function expandInlineQueetBox(box) { }); } + + +/* · + · + · Gnu social don't use url as uri anymore, we need to handle both cases + · + · · · · · · · · · · · · · */ + +function convertNewGNUSocialURItoURL(obj) { + + if(obj.uri.substring(0,4) != 'http') { + + // guess the url if we only have the non-url uri + if(typeof obj.url == 'undefined') { + var httpOrHttps = obj.user.statusnet_profile_url.substring(0,obj.user.statusnet_profile_url.indexOf('://')); + obj.uri = httpOrHttps + '://' + obj.uri.substring(4,obj.uri.indexOf(',')) + '/notice/' + obj.uri.substring(obj.uri.indexOf('noticeId=')+9,obj.uri.indexOf(':objectType')); + } + + // if an url record is present, use that + else { + obj.uri = obj.url; + } + } + return obj; + } + + /* · · @@ -1104,21 +1131,6 @@ function showConversation(qid) { in_reply_to_screen_name = obj.in_reply_to_screen_name; } - // gnu social don't use url as uri anymore, we need to handle both cases - if(obj.uri.substring(0,4) != 'http') { - - // guess the url if we only have the non-url uri - if(typeof obj.url == 'undefined') { - var httpOrHttps = obj.user.statusnet_profile_url.substring(0,obj.user.statusnet_profile_url.indexOf('://')); - obj.uri = httpOrHttps + '://' + obj.uri.substring(4,obj.uri.indexOf(',')) + '/notice/' + obj.uri.substring(obj.uri.indexOf('noticeId=')+9,obj.uri.indexOf(':objectType')); - } - - // if the new url record is present, use that - else { - obj.uri = obj.url; - } - } - // requeet or delete html var requeetedClass = ''; if(obj.user.id == window.myUserID) { @@ -1158,6 +1170,8 @@ function showConversation(qid) { if(obj.statusnet_in_groups !== false) { in_groups_html = '' + obj.statusnet_in_groups + ''; } + + obj = convertNewGNUSocialURItoURL(obj); if(obj.source == 'activity') { var queetHtml = '
' + $.trim(obj.statusnet_html) + '
'; @@ -1218,7 +1232,9 @@ function showConversation(qid) { if(obj.in_reply_to_screen_name != null && obj.in_reply_to_screen_name != obj.user.screen_name) { reply_to_html = '@' + obj.in_reply_to_screen_name + ' '; } - + + obj = convertNewGNUSocialURItoURL(obj); + if(obj.source == 'activity') { var queetHtml = '
' + $.trim(obj.statusnet_html) + '
'; } @@ -1500,6 +1516,7 @@ function addToFeed(feed, after, extraClasses) { attachment_html = '
' + attachment_html + '
'; } + obj.retweeted_status = convertNewGNUSocialURItoURL(obj.retweeted_status); var queetTime = parseTwitterDate(obj.retweeted_status.created_at); var queetHtml = '
' + attachment_html + '
' + $.trim(obj.retweeted_status.statusnet_html) + '
'; @@ -1621,6 +1638,9 @@ function addToFeed(feed, after, extraClasses) { if(attachment_html.length>0) { attachment_html = '
' + attachment_html + '
'; } + + + obj = convertNewGNUSocialURItoURL(obj); var queetTime = parseTwitterDate(obj.created_at); var queetHtml = '
' + attachment_html + '
' + $.trim(obj.statusnet_html) + '
';