patching up various things to do with audio support like default thumbnail, expanding, thumb extensions, live post template, catalog tiles, etc

merge-requests/208/head
fatchan 5 years ago
parent 632811c636
commit 0da1bacd4f
  1. BIN
      gulp/res/img/audio.png
  2. 19
      gulp/res/js/expand.js
  3. 16
      gulp/res/js/post.js
  4. 10
      models/forms/makepost.js
  5. 2
      schedules/prune.js
  6. 8
      views/mixins/catalogtile.pug

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

@ -1,9 +1,12 @@
window.addEventListener('DOMContentLoaded', (event) => { window.addEventListener('DOMContentLoaded', (event) => {
const isCatalog = window.location.pathname.endsWith('catalog.html');
if (!isCatalog) {
const thumbs = document.getElementsByClassName('post-file-src'); const thumbs = document.getElementsByClassName('post-file-src');
const toggle = function(thumb, exp, fn) { const toggle = function(thumb, exp, fn) {
const close = exp.previousSibling.innerText === 'Close video' ? exp.previousSibling : null; const close = exp.previousSibling.innerText === 'Close' ? exp.previousSibling : null;
if (thumb.style.display === 'none') { if (thumb.style.display === 'none') {
thumb.style.display = ''; thumb.style.display = '';
exp.style.display = 'none'; exp.style.display = 'none';
@ -33,18 +36,18 @@ window.addEventListener('DOMContentLoaded', (event) => {
const next = thumbElement.nextSibling; const next = thumbElement.nextSibling;
let expandedElement; let expandedElement;
if (next) { if (next) {
if (next.innerText === 'Close video') { if (next.innerText === 'Close') {
expandedElement = next.nextSibling; expandedElement = next.nextSibling;
} else { } else {
expandedElement = next; expandedElement = next;
} }
} }
if (!expandedElement && thumbElement.style.opacity !== '0.5') { if (!expandedElement && thumbElement.style.opacity !== '0.5') {
fileLink.style.minWidth = fileLink.offsetWidth+'px';
fileLink.style.minHeight = fileLink.offsetHeight+'px';
let source; let source;
switch(type) { switch(type) {
case 'image': case 'image':
fileLink.style.minWidth = fileLink.offsetWidth+'px';
fileLink.style.minHeight = fileLink.offsetHeight+'px';
thumbElement.style.opacity = '0.5'; thumbElement.style.opacity = '0.5';
thumbElement.style.cursor = 'wait' thumbElement.style.cursor = 'wait'
expandedElement = document.createElement('img'); expandedElement = document.createElement('img');
@ -57,9 +60,12 @@ window.addEventListener('DOMContentLoaded', (event) => {
} }
break; break;
case 'video': case 'video':
expandedElement = document.createElement('video'); fileLink.style.minWidth = fileLink.offsetWidth+'px';
fileLink.style.minHeight = fileLink.offsetHeight+'px';
case 'audio':
expandedElement = document.createElement(type);
close = document.createElement('div'); close = document.createElement('div');
close.innerText = 'Close video'; close.innerText = 'Close';
close.addEventListener('click', function(e) { close.addEventListener('click', function(e) {
e.preventDefault(); e.preventDefault();
e.stopPropagation(); e.stopPropagation();
@ -93,5 +99,6 @@ window.addEventListener('DOMContentLoaded', (event) => {
newthumbs[i].addEventListener('click', expand, false); newthumbs[i].addEventListener('click', expand, false);
} }
}); });
}
}); });

@ -81,11 +81,17 @@ pug_html = pug_html + ("\u003Cdiv class=\"post-file\"\u003E\u003Cspan class=\"po
if (file.durationString) { if (file.durationString) {
pug_html = pug_html + (", " + (pug_escape(null == (pug_interp = file.durationString) ? "" : pug_interp))); pug_html = pug_html + (", " + (pug_escape(null == (pug_interp = file.durationString) ? "" : pug_interp)));
} }
pug_html = pug_html + ")\u003C\u002Fspan\u003E\u003C\u002Fspan\u003E\u003Cdiv" + (" class=\"post-file-src\""+pug_attr("data-type", file.mimetype.split('/')[0], true, false)) + "\u003E\u003Ca" + (" target=\"_blank\""+pug_attr("href", `/img/${file.filename}`, true, false)) + "\u003E"; pug_html = pug_html + ")\u003C\u002Fspan\u003E\u003C\u002Fspan\u003E";
const type = file.mimetype.split('/')[0]
pug_html = pug_html + "\u003Cdiv" + (" class=\"post-file-src\""+pug_attr("data-type", type, true, false)) + "\u003E\u003Ca" + (" target=\"_blank\""+pug_attr("href", `/img/${file.filename}`, true, false)) + "\u003E";
if (post.spoiler) { if (post.spoiler) {
pug_html = pug_html + "\u003Cimg class=\"file-thumb\" src=\"\u002Fimg\u002Fspoiler.png\" width=\"200\" height=\"200\"\u002F\u003E"; pug_html = pug_html + "\u003Cimg class=\"file-thumb\" src=\"\u002Fimg\u002Fspoiler.png\" width=\"200\" height=\"200\"\u002F\u003E";
} }
else else
if (type === 'audio') {
pug_html = pug_html + "\u003Cimg class=\"file-thumb\" src=\"\u002Fimg\u002Faudio.png\" width=\"200\" height=\"200\"\u002F\u003E";
}
else
if (file.hasThumb) { if (file.hasThumb) {
pug_html = pug_html + "\u003Cimg" + (" class=\"file-thumb\""+pug_attr("src", `/img/thumb-${file.hash}${file.thumbextension}`, true, false)+pug_attr("height", file.geometry.thumbheight, true, false)+pug_attr("width", file.geometry.thumbwidth, true, false)) + "\u002F\u003E"; pug_html = pug_html + "\u003Cimg" + (" class=\"file-thumb\""+pug_attr("src", `/img/thumb-${file.hash}${file.thumbextension}`, true, false)+pug_attr("height", file.geometry.thumbheight, true, false)+pug_attr("width", file.geometry.thumbwidth, true, false)) + "\u002F\u003E";
} }
@ -103,11 +109,17 @@ pug_html = pug_html + ("\u003Cdiv class=\"post-file\"\u003E\u003Cspan class=\"po
if (file.durationString) { if (file.durationString) {
pug_html = pug_html + (", " + (pug_escape(null == (pug_interp = file.durationString) ? "" : pug_interp))); pug_html = pug_html + (", " + (pug_escape(null == (pug_interp = file.durationString) ? "" : pug_interp)));
} }
pug_html = pug_html + ")\u003C\u002Fspan\u003E\u003C\u002Fspan\u003E\u003Cdiv" + (" class=\"post-file-src\""+pug_attr("data-type", file.mimetype.split('/')[0], true, false)) + "\u003E\u003Ca" + (" target=\"_blank\""+pug_attr("href", `/img/${file.filename}`, true, false)) + "\u003E"; pug_html = pug_html + ")\u003C\u002Fspan\u003E\u003C\u002Fspan\u003E";
const type = file.mimetype.split('/')[0]
pug_html = pug_html + "\u003Cdiv" + (" class=\"post-file-src\""+pug_attr("data-type", type, true, false)) + "\u003E\u003Ca" + (" target=\"_blank\""+pug_attr("href", `/img/${file.filename}`, true, false)) + "\u003E";
if (post.spoiler) { if (post.spoiler) {
pug_html = pug_html + "\u003Cimg class=\"file-thumb\" src=\"\u002Fimg\u002Fspoiler.png\" width=\"200\" height=\"200\"\u002F\u003E"; pug_html = pug_html + "\u003Cimg class=\"file-thumb\" src=\"\u002Fimg\u002Fspoiler.png\" width=\"200\" height=\"200\"\u002F\u003E";
} }
else else
if (type === 'audio') {
pug_html = pug_html + "\u003Cimg class=\"file-thumb\" src=\"\u002Fimg\u002Faudio.png\" width=\"200\" height=\"200\"\u002F\u003E";
}
else
if (file.hasThumb) { if (file.hasThumb) {
pug_html = pug_html + "\u003Cimg" + (" class=\"file-thumb\""+pug_attr("src", `/img/thumb-${file.hash}${file.thumbextension}`, true, false)+pug_attr("height", file.geometry.thumbheight, true, false)+pug_attr("width", file.geometry.thumbwidth, true, false)) + "\u002F\u003E"; pug_html = pug_html + "\u003Cimg" + (" class=\"file-thumb\""+pug_attr("src", `/img/thumb-${file.hash}${file.thumbextension}`, true, false)+pug_attr("height", file.geometry.thumbheight, true, false)+pug_attr("width", file.geometry.thumbwidth, true, false)) + "\u002F\u003E";
} }

@ -159,16 +159,16 @@ module.exports = async (req, res, next) => {
mimetype: file.mimetype, mimetype: file.mimetype,
size: file.size, size: file.size,
extension, extension,
thumbextension: thumbExtension,
}; };
const type = processedFile.mimetype.split('/')[0];
if (type !== 'audio') {
processedFile.thumbextension = thumbExtension;
}
await Files.increment(processedFile); await Files.increment(processedFile);
//check if already exists //check if already exists
const existsFull = await pathExists(`${uploadDirectory}/img/${processedFile.filename}`); const existsFull = await pathExists(`${uploadDirectory}/img/${processedFile.filename}`);
switch (type) {
//handle video/image ffmpeg or graphicsmagick
switch (processedFile.mimetype.split('/')[0]) {
case 'image': { case 'image': {
const existsThumb = await pathExists(`${uploadDirectory}/img/thumb-${processedFile.hash}${processedFile.thumbextension}`); const existsThumb = await pathExists(`${uploadDirectory}/img/thumb-${processedFile.hash}${processedFile.thumbextension}`);
const imageData = await imageIdentify(req.files.file[i].tempFilePath, null, true); const imageData = await imageIdentify(req.files.file[i].tempFilePath, null, true);

@ -24,7 +24,7 @@ module.exports = async() => {
await Promise.all(files.map(async file => { await Promise.all(files.map(async file => {
return Promise.all( return Promise.all(
[remove(`${uploadDirectory}/img/${file._id}`)] [remove(`${uploadDirectory}/img/${file._id}`)]
.concat(file.exts.map(ext => { .concat(file.exts.filter(ext => ext).map(ext => {
remove(`${uploadDirectory}/img/thumb-${file._id.split('.')[0]}${ext}`) remove(`${uploadDirectory}/img/thumb-${file._id.split('.')[0]}${ext}`)
})) }))
) )

@ -13,11 +13,13 @@ mixin catalogtile(board, post, index)
if post.files.length > 0 if post.files.length > 0
.post-file-src .post-file-src
a(href=postURL) a(href=postURL)
- const file = post.files[0]
if post.spoiler if post.spoiler
img.catalog-thumb(src='/img/spoiler.png' width='64' height='64') img.catalog-thumb(src='/img/spoiler.png' width='64' height='64')
else else if file.mimetype.startsWith('audio')
if post.files[0].hasThumb img.catalog-thumb(src='/img/audio.png' width='64' height='64')
img.catalog-thumb(src=`/img/thumb-${post.files[0].hash}${post.files[0].thumbextension}` width='64' height='64') else if file.hasThumb
img.catalog-thumb(src=`/img/thumb-${file.hash}${file.thumbextension}` width='64' height='64')
else else
img.catalog-thumb(src=`/img/${post.files[0].filename}` width='64' height='64') img.catalog-thumb(src=`/img/${post.files[0].filename}` width='64' height='64')
if post.message if post.message

Loading…
Cancel
Save