diff --git a/QvitterPlugin.php b/QvitterPlugin.php index e91162d..3b327cb 100644 --- a/QvitterPlugin.php +++ b/QvitterPlugin.php @@ -567,6 +567,66 @@ class QvitterPlugin extends Plugin { } } + // quoted notices + if (!empty($twitter_status['attachments'])) { + foreach ($twitter_status['attachments'] as &$attachment) { + + $quoted_notice = false; + + // if this attachment has an url this might be a notice url + if (isset($attachment['url'])) { + $noticeurl = common_path('notice/', StatusNet::isHTTPS()); + $instanceurl = common_path('', StatusNet::isHTTPS()); + + // local notice urls + if(stristr($attachment['url'], $noticeurl)) { + $possible_notice_id = str_replace($noticeurl,'',$attachment['url']); + if(ctype_digit($possible_notice_id)) { + $quoted_notice = Notice::getKV('id',$possible_notice_id);; + } + } + // remote. but we don't want to lookup every url in the db, + // so only do this if we have reason to believe this might + // be a remote notice url + elseif(!stristr($attachment['url'], $instanceurl) && stristr($attachment['url'],'/notice/')) { + $quoted_notice = Notice::getKV('url',$attachment['url']); + } + + // include the quoted notice in the attachment + if($quoted_notice instanceof Notice) { + $quoted_notice_author = Profile::getKV('id',$quoted_notice->profile_id); + if($quoted_notice_author instanceof Profile) { + $attachment['quoted_notice']['id'] = $quoted_notice->id; + $attachment['quoted_notice']['content'] = $quoted_notice->content; + $attachment['quoted_notice']['nickname'] = $quoted_notice_author->nickname; + $attachment['quoted_notice']['fullname'] = $quoted_notice_author->fullname; + $quoted_notice_attachments = $quoted_notice->attachments(); + foreach($quoted_notice_attachments as $q_attach) { + if(is_object($q_attach)) { + try { + $qthumb = $q_attach->getThumbnail(); + $thumb_url = File_thumbnail::url($qthumb->filename); + $attachment['quoted_notice']['attachments'][] = array('thumb_url'=>$thumb_url, + 'attachment_id'=>$q_attach->id); + } catch (Exception $e) { + common_debug('Qvitter: exception: '.$e.' – could not get thumbnail for attachment id='.$q_attach->id.' in quoted notice id='.$quoted_notice->id); + } + } + } + } + } + } + } + } + + + try { + $twitter_status['external_url'] = $notice->getUrl(true); + } catch (InvalidUrlException $e) { + common_debug('Qvitter: No URL available for external notice: id='.$notice->id); + } + + // reply-to profile url try { $reply = $notice->getParent(); diff --git a/actions/qvitter.php b/actions/qvitter.php index 16e8600..f98fc3c 100644 --- a/actions/qvitter.php +++ b/actions/qvitter.php @@ -652,7 +652,9 @@ class QvitterAction extends ApiAction span.inline-reply-caret, .stream-item.expanded .stream-item.first-visible-after-parent, #popup-faq #faq-container p.indent, - .post-to-group { + .post-to-group, + .quoted-notice:hover, + .stream-item:hover:not(.expanded) .quoted-notice:hover { border-color:/*LIGHTERBORDERCOLORSTART*/rgb(155,206,224)/*LIGHTERBORDERCOLOREND*/; } span.inline-reply-caret .caret-inner { diff --git a/css/qvitter.css b/css/qvitter.css index 702087b..3541136 100644 --- a/css/qvitter.css +++ b/css/qvitter.css @@ -2005,6 +2005,83 @@ body.rtl .queet.rtl .expanded-content { display:block; } +.quoted-notices { + width:100%; + position:relative; +} +.quoted-notice { + width:100%; + border: 1px solid #eee; + border-radius: 4px; + cursor: pointer; + display: table; + table-layout: fixed; + padding: 12px; + box-sizing: border-box; + margin-top:12px; + color:#292f33 !important; + overflow: hidden; + } +.stream-item:hover:not(.expanded) .quoted-notice { + border: 1px solid #ddd; + } + +.quoted-notice-attachments { + width:100%; + position: relative; + overflow:hidden; + } +.quoted-notice-attachments-num-1 { + height: 102px; + width: 102px; + margin-right: 12px; + float: left; + } + +.quoted-notice-img-container { + height: 102px; + width: 102px; + display: inline-block; + margin-right: 7px; + margin-top:7px; + background-size:cover; + background-repeat:no-repeat; + background-position: center; + } + +.quoted-notice-attachments-num-1 .quoted-notice-img-container { + height: 100%; + width: 100%; + margin:0; + } + +.quoted-notice-img { + height: 100%; + opacity: 0; + width: 100%; + } + +.quoted-notice-header { + line-height:20px; + margin-bottom:5px; + } +.quoted-notice-author-fullname { + font-weight: bold; + } +.quoted-notice-author-nickname { + font-size:13px; + color:#999; + } +.quoted-notice-author-nickname::before { + content:"@"; + } + +.quoted-notice-body { + white-space: pre-wrap; + word-wrap: break-word; + } + + .queet .queet-thumbs { -webkit-transition: max-height 0s linear; -moz-transition: max-height 0s linear; @@ -2537,7 +2614,7 @@ ul.queet-actions li .icon { position: relative; } ul.queet-actions li:not(:first-child) .icon { - margin-left:26px; + margin-left:52px; } .queet.rtl ul.queet-actions .icon { margin-left:26px; diff --git a/js/dom-functions.js b/js/dom-functions.js index 7eb911d..bd7f051 100644 --- a/js/dom-functions.js +++ b/js/dom-functions.js @@ -1955,6 +1955,17 @@ function buildQueetHtml(obj, idInStream, extraClasses, requeeted_by, isConversat URItoUse += '-activity-notice'; } + // attachment html and attachment url's to hide + var attachmentBuild = buildAttachmentHTML(obj.attachments); + var statusnetHTML = $('
').html(obj.statusnet_html); + $.each(statusnetHTML.find('a'),function(){ + if(attachmentBuild.urlsToHide.indexOf($(this).text()) > -1) { + $(this).css('display','none'); + } + }); + statusnetHTML = statusnetHTML.html(); + + // external var ostatusHtml = ''; if(obj.is_local === false) { @@ -1988,8 +1999,8 @@ function buildQueetHtml(obj, idInStream, extraClasses, requeeted_by, isConversat ' + queetTime + '\ \
\ -
' + $.trim(obj.statusnet_html) + '
\ - ' + buildAttachmentHTML(obj.attachments) + '\ +
' + $.trim(statusnetHTML) + '
\ + ' + attachmentBuild.html + '\ \ @@ -2016,12 +2027,57 @@ function buildQueetHtml(obj, idInStream, extraClasses, requeeted_by, isConversat function buildAttachmentHTML(attachments){ var attachment_html = ''; + var quotedNoticeHTML = ''; var attachmentNum = 0; + var urlsToHide = []; if(typeof attachments != "undefined") { $.each(attachments, function(){ - if(typeof this.thumb_url != 'undefined' + + // quoted notices + if(typeof this.quoted_notice != 'undefined') { + + var quotedContent = this.quoted_notice.content; + + // quoted notice's attachments' thumb urls + var quotedAttachmentsHTML = ''; + var quotedAttachmentsHTMLbefore = ''; + var quotedAttachmentsHTMLafter = ''; + if(typeof this.quoted_notice.attachments != 'undefined' && this.quoted_notice.attachments.length > 0) { + quotedAttachmentsHTML += '
' + $.each(this.quoted_notice.attachments,function(k,qAttach){ + quotedAttachmentsHTML += '
'; + // remove attachment string from content + quotedContent = quotedContent.split(window.siteInstanceURL + 'attachment/' + qAttach.attachment_id).join(''); + }); + quotedAttachmentsHTML += '
'; + + // if there is only one attachment, it goes before, otherwise after + if(this.quoted_notice.attachments.length == 1) { + quotedAttachmentsHTMLbefore = quotedAttachmentsHTML; + } + else { + quotedAttachmentsHTMLafter = quotedAttachmentsHTML; + } + } + + // hide the notice url in the queet text + urlsToHide.push(this.url); + + quotedNoticeHTML += '\ + ' + quotedAttachmentsHTMLbefore + '\ +
\ + ' + this.quoted_notice.fullname + '\ + ' + this.quoted_notice.nickname + '\ +
\ +
' + $.trim(quotedContent) + '
\ + ' + quotedAttachmentsHTMLafter + '\ +
'; + } + + // if there's a local thumb_url we assume this is a image or video + else if(typeof this.thumb_url != 'undefined' && this.thumb_url !== null - && isLocalURL(this.thumb_url)) { // if there's a local thumb_url we assume this is a image or video + && isLocalURL(this.thumb_url)) { var bigThumbW = 1000; var bigThumbH = 3000; if(bigThumbW > window.siteMaxThumbnailSize) { @@ -2069,13 +2125,16 @@ function buildAttachmentHTML(attachments){ } attachment_html = attachment_html + ''; + urlsToHide.push(window.siteInstanceURL + 'attachment/' + this.id); // hide this attachment url from the queet text attachmentNum++; } else if (this.mimetype == 'image/svg+xml') { attachment_html = attachment_html + ''; + urlsToHide.push(window.siteInstanceURL + 'attachment/' + this.id); // hide this attachment url from the queet text attachmentNum++; } }); } - return '
' + attachment_html + '
'; + return {html: '
' + quotedNoticeHTML + '
' + attachment_html + '
', + urlsToHide: urlsToHide }; }