bugfixes and improvements for #369

- only show imgops on image/* mimetype
- fix an issue with meta url, imgops links and notifications

improve post notifications, show image/badge/icon, trying thumbs and respecting spoilers
jschan
Thomas Lynch 3 years ago
parent a9833f7662
commit e24cdcb815
  1. 5
      gulp/res/js/hover.js
  2. 3
      gulp/res/js/live.js
  3. 22
      gulp/res/js/yous.js
  4. 1
      gulpfile.js
  5. 4
      views/mixins/post.pug

@ -131,7 +131,10 @@ window.addEventListener('DOMContentLoaded', (event) => {
if (!postJson) {
return; //post was deleted or missing
}
const postHtml = post({ post: postJson });
const postHtml = post({
post: postJson,
meta: metaLocal,
});
const wrap = document.createElement('div');
wrap.innerHTML = postHtml;
hoveredPost = wrap.firstChild.nextSibling;

@ -39,7 +39,8 @@ window.addEventListener('settingsReady', function(event) { //after domcontentloa
modview: isModView,
manage: (isRecent && !isGlobalRecent),
globalmanage: isGlobalRecent,
upLevel: isThread
upLevel: isThread,
meta: metaLocal,
});
let insertPoint;
if (isRecent) {

@ -69,9 +69,27 @@ const handleNewYous = (e) => {
try {
console.log('attempting to send notification', postYou);
const postData = e.detail.json;
new Notification(`${quotesYou ? 'New quote in: ' : ''}${document.title}`, {
const notificationOptions = {
body: postData.nomarkup ? postData.nomarkup.substring(0,100) : ''
});
}
if (postData.files.length > 0 && !postData.spoiler) {
//tries to use a thumb instead of full files, will be lighter on bandwidth and able to show for video and some audio too
const notificationFile = postData.files.find(f => (!f.spoiler && (f.hasThumb === true || f.mimetype.startsWith('image/'))));
if (notificationFile) {
let notificationImageURL;
if (notificationFile.hasThumb) {
notificationImageURL = `/file/thumb/${notificationFile.hash}${notificationFile.thumbextension}`;
} else {
notificationImageURL = `/file/${notificationFile.filename}`;
}
if (notificationImageURL) {
notificationOptions.image = notificationImageURL;
notificationOptions.badge = notificationImageURL;
notificationOptions.icon = notificationImageURL;
}
}
}
new Notification(`${quotesYou ? 'New quote in: ' : ''}${document.title}`, notificationOptions);
} catch (e) {
// notification cant send for some reason -- user revoked perms in browser?
console.log('failed to send notification', e);

@ -386,6 +386,7 @@ const captchaGridSize = ${config.get.captchaOptions.grid.size};
const SERVER_TIMEZONE = '${Intl.DateTimeFormat().resolvedOptions().timeZone}';
const ipHashPermLevel = ${config.get.ipHashPermLevel};
const settings = ${JSON.stringify(config.get.frontendScriptDefault)};
const metaLocal = ${JSON.stringify(config.get.meta)};
`;
fs.writeFileSync('gulp/res/js/locals.js', locals);
fs.writeFileSync('gulp/res/js/post.js', pug.compileFileClient(`${paths.pug.src}/includes/post.pug`, { compileDebug: false, debug: false, name: 'post' }));

@ -76,6 +76,7 @@ mixin post(post, truncate, manage=false, globalmanage=false, ban=false, overboar
.post-files(class=(post.files.length > 1 ? 'fn' : ''))
each file, fileindex in post.files
.post-file
- const type = file.mimetype.split('/')[0]
span.post-file-info
span: a(href='/file/'+file.filename title='Download '+file.originalFilename download=file.originalFilename) #{post.spoiler || file.spoiler ? 'Spoiler File' : file.originalFilename}
|
@ -97,10 +98,9 @@ mixin post(post, truncate, manage=false, globalmanage=false, ban=false, overboar
if file.durationString
| , #{file.durationString}
| )
if (board && board.settings.reverseImageSearchLinks === true) || overboard || manage || globalmanage
if type === 'image' && ((board && board.settings.reverseImageSearchLinks === true) || overboard || manage || globalmanage)
|
span: a(href=`https://imgops.com/${meta.url}/file/${file.filename}` title='ImgOps' target='_blank') ImgOps
- const type = file.mimetype.split('/')[0]
.post-file-src(data-type=type data-attachment=(file.attachment ? "true" : "false"))
a(target='_blank' href=`/file/${file.filename}`)
if post.spoiler || file.spoiler

Loading…
Cancel
Save