thumbnails in oembed response and better looking rendering of oembed coming from other qvitter instances
This commit is contained in:
parent
eb3a2af822
commit
98f831dd20
|
@ -108,16 +108,38 @@ class ApiQvitterOembedNoticeAction extends ApiAction
|
||||||
$oembed['version']='1.0';
|
$oembed['version']='1.0';
|
||||||
$oembed['provider_name']=common_config('site', 'name');
|
$oembed['provider_name']=common_config('site', 'name');
|
||||||
$oembed['provider_url']=common_root_url();
|
$oembed['provider_url']=common_root_url();
|
||||||
|
$oembed['type']='link';
|
||||||
|
|
||||||
// TRANS: oEmbed title. %1$s is the author name, %2$s is the creation date.
|
// TRANS: oEmbed title. %1$s is the author name, %2$s is the creation date.
|
||||||
$oembed['title'] = sprintf(_('%1$s\'s status on %2$s'),
|
$oembed['title'] = ApiAction::dateTwitter($notice->created).' (Qvitter)';
|
||||||
$authorname,
|
|
||||||
common_exact_date($notice->created));
|
|
||||||
$oembed['author_name']=$authorname;
|
$oembed['author_name']=$authorname;
|
||||||
$oembed['author_url']=$profile->profileurl;
|
$oembed['author_url']=$profile->profileurl;
|
||||||
$oembed['url']=$notice->getUrl();
|
$oembed['url']=$notice->getUrl();
|
||||||
$oembed['html']=$notice->getRendered();
|
$oembed['html']=$notice->getRendered();
|
||||||
|
|
||||||
|
// maybe add thumbnail
|
||||||
|
$attachments = $notice->attachments();
|
||||||
|
if (!empty($attachments)) {
|
||||||
|
foreach ($attachments as $attachment) {
|
||||||
|
if(is_object($attachment)) {
|
||||||
|
try {
|
||||||
|
$thumb = $attachment->getThumbnail();
|
||||||
|
} catch (ServerException $e) {
|
||||||
|
//
|
||||||
|
}
|
||||||
|
if(method_exists('File_thumbnail','url')) {
|
||||||
|
try {
|
||||||
|
$thumb_url = File_thumbnail::url($thumb->filename);
|
||||||
|
$oembed['thumbnail_url'] = $thumb_url;
|
||||||
|
break; // only first one
|
||||||
|
} catch (ClientException $e) {
|
||||||
|
//
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if($this->format == 'json') {
|
if($this->format == 'json') {
|
||||||
$this->initDocument('json');
|
$this->initDocument('json');
|
||||||
print json_encode($oembed);
|
print json_encode($oembed);
|
||||||
|
|
|
@ -2132,7 +2132,7 @@ body.rtl .queet.rtl .expanded-content {
|
||||||
text-overflow: ellipsis;
|
text-overflow: ellipsis;
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
}
|
}
|
||||||
.oembed-twitter-username {
|
.oembed-username {
|
||||||
font-size:13px;
|
font-size:13px;
|
||||||
color:#999;
|
color:#999;
|
||||||
font-weight:normal;
|
font-weight:normal;
|
||||||
|
|
|
@ -2202,7 +2202,7 @@ function buildAttachmentHTML(attachments){
|
||||||
|
|
||||||
var twitterHTML = '<div class="oembed-item-header">\
|
var twitterHTML = '<div class="oembed-item-header">\
|
||||||
<span class="oembed-item-title">' + this.oembed.author_name + '</span>\
|
<span class="oembed-item-title">' + this.oembed.author_name + '</span>\
|
||||||
<span class="oembed-twitter-username">' + this.oembed.title + '</span>\
|
<span class="oembed-username">' + this.oembed.title + '</span>\
|
||||||
</div>\
|
</div>\
|
||||||
<div class="oembed-item-body">' + this.oembed.oembedHTML + '</div>\
|
<div class="oembed-item-body">' + this.oembed.oembedHTML + '</div>\
|
||||||
<div class="oembed-item-footer">\
|
<div class="oembed-item-footer">\
|
||||||
|
@ -2248,12 +2248,28 @@ function buildAttachmentHTML(attachments){
|
||||||
else {
|
else {
|
||||||
var oembedProvider = this.oembed.provider;
|
var oembedProvider = this.oembed.provider;
|
||||||
var oembedProviderURL = removeProtocolFromUrl(this.oembed.provider_url);
|
var oembedProviderURL = removeProtocolFromUrl(this.oembed.provider_url);
|
||||||
|
// remove trailing /
|
||||||
|
if(oembedProviderURL.slice(-1) == '/') {
|
||||||
|
oembedProviderURL = oembedProviderURL.slice(0,-1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If the oembed data is generated by Qvitter, we know a better way of showing the title
|
||||||
|
var oembedTitle = this.oembed.title;
|
||||||
|
var oembedTitleHTML = '<span class="oembed-item-title">' + oembedTitle + '</span>';
|
||||||
|
if(oembedTitle.slice(-10) == ' (Qvitter)') {
|
||||||
|
var oembedTimePosted = parseTwitterLongDate(oembedTitle.slice(0,-10));
|
||||||
|
var oembedGNUsocialUsername = this.oembed.author_name.substring(this.oembed.author_name.lastIndexOf('(')+1,this.oembed.author_name.lastIndexOf(')'));
|
||||||
|
var oembedGNUsocialFullname = this.oembed.author_name.slice(0,-(oembedGNUsocialUsername.length+3));
|
||||||
|
oembedTitleHTML = '<span class="oembed-item-title">' + oembedGNUsocialFullname + '</span>\
|
||||||
|
<span class="oembed-username">@' + oembedGNUsocialUsername + '</span>';
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
oembedHTML += '<a href="' + this.url + '" class="oembed-item">\
|
oembedHTML += '<a href="' + this.url + '" class="oembed-item">\
|
||||||
' + oembedImage + '\
|
' + oembedImage + '\
|
||||||
<div class="oembed-item-header">\
|
<div class="oembed-item-header">\
|
||||||
<span class="oembed-item-title">' + this.oembed.title + '</span>\
|
' + oembedTitleHTML + '\
|
||||||
</div>\
|
</div>\
|
||||||
<div class="oembed-item-body">' + oembedBody + '</div>\
|
<div class="oembed-item-body">' + oembedBody + '</div>\
|
||||||
<div class="oembed-item-footer">\
|
<div class="oembed-item-footer">\
|
||||||
|
|
Loading…
Reference in New Issue
Block a user