Commit c5534bcf by yPhil

Merge branch 'mastodon'

parents 4433e8e1 d0ca77de
Pipeline #47970 passed with stage
in 37 seconds
......@@ -1093,13 +1093,31 @@ li.feed-item {
word-wrap: break-word;
}
li.feed-item > div.itemDiv > a > img {
li.feed-item > div.itemDiv > a > .ptl-img {
float:left;
margin: 0 .2rem .2rem 0;
width:30%;
max-width:30%;
}
li.feed-item > div.itemDiv > a > img.full {
li.feed-item > div.itemDiv > a > div.ptl-img > a > img {
margin: 0 .2rem .2rem 0;
width:30%;
max-width:30%;
}
li.feed-item > div.itemDiv > a > div.ptl-img {
float:none;
width: 100%;
max-width: 100%;
}
li.feed-item > div.itemDiv > a > div.ptl-img > a {
display: inline;
}
li.feed-item > div.itemDiv > a > .ptl-img.full > a img,
li.feed-item > div.itemDiv > a > .ptl-img.full {
min-width:100%;
}
......@@ -1137,7 +1155,7 @@ li.feed:hover div.feed-body {
border-color: var(--color-den);
}
li.feed-item > div.itemDiv > a > img:hover {
li.feed-item img:hover {
outline: 1px solid var(--color-sec);
}
......
......@@ -31,7 +31,7 @@ PTL.dialog = {
$(this).find('.help-button').button();
$(this).find('.help-bookmarklet').attr('href', 'javascript:void(window.open("' + document.domain + '?add=" + window.location.href))');
$(this).find('.help-bookmarklet').attr('href', 'javascript:void(window.open("' + window.location.href + '?add=" + window.location.href))');
$('.help-tour').on('click', function() {
PTL.sideMenu('close');
......
......@@ -247,8 +247,11 @@ PTL.feed = {
if (index == parseInt(feedLimit)) return false;
console.log('i: (%s)', JSON.stringify(item));
var $description = $.parseHTML(item.description),
imageUrl,
imageUrls = [],
imgTypes = ['image',
'image/jpg',
'image/jpeg',
......@@ -261,7 +264,7 @@ PTL.feed = {
$commentsLink = $('<a>').attr('target', '_blank'),
$commentsIcon = $('<i>'),
$soundIcon = $('<i>'),
$image = $('<img>'),
$image,
$summary = $('<null>').append(item.summary || item.description).text(),
$itemDiv = $('<div>').attr('class', 'itemDiv'),
$feedItem = $('<li>').attr('class', 'feed-item').attr('title', $summary.trim());
......@@ -278,7 +281,20 @@ PTL.feed = {
var $tempDom = $('<null>').append($description);
if (item.image && typeof item.image.url !== 'undefined') {
if (item['mastodon:scope']) {
if (item['activity:object']) {
var links = item['activity:object'].link;
for (var i = 0, len = links.length; i < len; i++) {
console.log('links[i]: %s (%s, %s)', links[i]['@'].type, $summary.trim(), links[i]['@'].href);
if (imgTypes.indexOf(links[i]['@'].type) > -1) {
imageUrl = links[i]['@'].href;
imageUrls.push(links[i]['@'].href);
}
}
}
}
if (!imageUrl && item.image && typeof item.image.url !== 'undefined') {
imageUrl = item.image.url;
}
......@@ -319,7 +335,26 @@ PTL.feed = {
.attr('href', item.link)
.append(item['mastodon:scope'] ? $summary.trim() : item.title);
if (imageUrl) {
if (imageUrls) {
$image = $('<div>')
.attr('class', 'ptl-img')
.appendTo($imageLink);
for (var i = 0, len = imageUrls.length; i < len; i++) {
console.log('imageUrls: (%s)', imageUrls[i]);
$('<a>')
.attr('href', imageUrls[i])
.attr('data-fancybox', 'gallery')
.attr('data-caption', '<a class="ui-button ui-corner-all" href="' + item.link + '">' + $summary.trim() + '</a>')
.appendTo($image)
.append($('<img>')
.attr('src', imageUrls[i])
.appendTo($image));
}
} else if (imageUrl) {
if (!PTL.util.isUrl(imageUrl)) {
imageUrl = feedHost + '/' + imageUrl.substring(imageUrl.indexOf("/") + 1);
......@@ -328,18 +363,19 @@ PTL.feed = {
$imageLink
.attr('href', imageUrl)
.attr('data-fancybox', 'gallery')
.attr('data-fancybox-group', $panel.attr('id'))
.attr('data-caption', '<a class="ui-button ui-corner-all" href="' + item.link + '">' + item.title + '</a>');
$image
$image = $('<img>')
.attr('src', imageUrl)
.attr('class', 'ptl-img')
.appendTo($imageLink);
if (!new RegExp('^(?:[a-z]+:)?//', 'i').test(imageUrl)) imageUrl = feedHost + imageUrl;
if (feedType == 'photo') $image.addClass('full');
if (feedType !== 'text') $imageLink.appendTo($itemDiv);
}
if (!new RegExp('^(?:[a-z]+:)?//', 'i').test(imageUrl)) imageUrl = feedHost + imageUrl;
if ($image && feedType == 'photo') $image.addClass('full');
if (feedType !== 'text') $imageLink.appendTo($itemDiv);
$itemLink.appendTo($itemDiv);
$itemDiv.appendTo($feedItem);
$feedItem.appendTo($feedBody);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment