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 + '\ \ \ -