Compare commits

...

No commits in common. "4bce3ba852d4783756d785514bf94612b8e8fa93" and "1a1f039be54f70d6f569d42bcb8d57d87fca8792" have entirely different histories.

3 changed files with 64 additions and 33 deletions

View File

@ -464,9 +464,9 @@ function mkSpamImgElement(img_description) {
console.log('img_description.illegal', img_description.illegal); console.log('img_description.illegal', img_description.illegal);
if (illegal) { if (illegal) {
thumb_url = `/bin/?path=${GlobalVars.settings.redacted_thumbnail_path}&mimetype=image/jpeg` thumb_url = "/static/redacted.jpg";
} else if (mime == "audio/mpeg") { } else if (mime == "audio/mpeg") {
thumb_url = `/bin/?path=${GlobalVars.settings.audio_mpeg_thumbnail_path}&mimetype=image/jpeg` thumb_url = '/static/mpg.png';
} else { } else {
thumb_url = `/bin/?path=${GlobalVars.settings.content_directory}/${img_description.md5_hash}_thumbnail.jpg&mimetype=image/jpeg` thumb_url = `/bin/?path=${GlobalVars.settings.content_directory}/${img_description.md5_hash}_thumbnail.jpg&mimetype=image/jpeg`
} }
@ -538,11 +538,25 @@ function isIllegal(post) {
return result; return result;
} }
async function onClickMarkIllegal(phashes, e) { function onClickMarkIllegal(phashes, e) {
console.log('CLICK', phashes);
e.stopPropagation(); e.stopPropagation();
e.preventDefault(); e.preventDefault();
console.log('CLICK', phashes, e.target.hash);
// Get the whole post div (parent of the anchor tag)
const postDiv = e.target.closest('.post');
const img_elems = postDiv.querySelectorAll('.post--image_container img');
window.requestAnimationFrame(function() {
img_elems.forEach(function(elem) {
elem.classList.add('censored');
});
window.requestAnimationFrame(async function() {
const alert_result = confirm("Warning! This action deletes all image file data for images similar to the ones you selected. This action is irreversible. Image fingerprints will be kept for matching in the future. Do you want to proceed?");
if (alert_result) {
const url = new URL('/illegal', window.location.origin); const url = new URL('/illegal', window.location.origin);
phashes.forEach(function(p) { phashes.forEach(function(p) {
console.log('onClickMarkIllegal', typeof p, p); console.log('onClickMarkIllegal', typeof p, p);
@ -551,15 +565,24 @@ async function onClickMarkIllegal(phashes, e) {
await post(url.toString(), null, cancel) await post(url.toString(), null, cancel)
.then(function() { .then(function() {
location.hash = e.target.hash;
location.reload(); location.reload();
}) })
.catch(caught.bind(this, "Failed to mark post illegal because:")); .catch(caught.bind(this, "Failed to mark post illegal because:"));
} else {
img_elems.forEach(function(elem) {
elem.classList.remove('censored');
});
}
});
});
} }
function renderPostElem(post) { function renderPostElem(post) {
const postContainer = div(); const postContainer = div();
postContainer.classList.add('post'); postContainer.classList.add('post');
const identifier = "text_post_" + post.text_post_id;
postContainer.id = identifier;
// Header with timestamp, link to the thread // Header with timestamp, link to the thread
const postHeader = div(); const postHeader = div();
@ -593,7 +616,7 @@ function renderPostElem(post) {
mark_illegal_a.appendChild(text('Mark Illegal')); mark_illegal_a.appendChild(text('Mark Illegal'));
mark_illegal_a.setAttribute('href', '#'); mark_illegal_a.setAttribute('href', '#' + identifier);
mark_illegal_a.setAttribute('title', 'Permanently delete associated pictures and thumbnails but keep metadata for future matching'); mark_illegal_a.setAttribute('title', 'Permanently delete associated pictures and thumbnails but keep metadata for future matching');
mark_illegal.appendChild(text('[')); mark_illegal.appendChild(text('['));
mark_illegal.appendChild(mark_illegal_a); mark_illegal.appendChild(mark_illegal_a);
@ -687,6 +710,7 @@ function renderReasons(post) {
var container = div(h3(text('Reasons for being considered spam:'))); var container = div(h3(text('Reasons for being considered spam:')));
container.appendChild(renderReasonsUl(post)); container.appendChild(renderReasonsUl(post));
var reasonDetails = post.reason_details; var reasonDetails = post.reason_details;
var illegal = isIllegal(post);
if (reasonDetails) { if (reasonDetails) {
var reasonDetailsContainer = div(); var reasonDetailsContainer = div();
@ -695,6 +719,8 @@ function renderReasons(post) {
if (reasonDetails.frequent_attachment_details) { if (reasonDetails.frequent_attachment_details) {
reasonDetailsContainer.appendChild(h4(text('Previously posted matching attachments:'))); reasonDetailsContainer.appendChild(h4(text('Previously posted matching attachments:')));
reasonDetails.frequent_attachment_details.forEach(function (attachment) { reasonDetails.frequent_attachment_details.forEach(function (attachment) {
attachment.illegal = illegal;
reasonDetailsContainer.appendChild( reasonDetailsContainer.appendChild(
renderAttachmentReason(attachment, post.known_spam_post_attachment) renderAttachmentReason(attachment, post.known_spam_post_attachment)
); );
@ -727,7 +753,10 @@ var REASONS = {
RECENTLY_POSTED_TEXT_ABOVE_RATE : 1 << 4, RECENTLY_POSTED_TEXT_ABOVE_RATE : 1 << 4,
TEXT_IS_URL : 1 << 5, TEXT_IS_URL : 1 << 5,
TEXT_IS_ONE_LONG_WORD : 1 << 6, TEXT_IS_ONE_LONG_WORD : 1 << 6,
TEXT_IS_RANDOM_WORDS: 1 << 7 TEXT_IS_RANDOM_WORDS : 1 << 7,
ATTACHMENT_MATCHES_KNOWN_SPAM : 1 << 8,
TEXT_MANUALLY_MARKED_AS_SPAM : 1 << 9,
ATTACHMENT_MANUALLY_MARKED_AS_SPAM : 1 << 10
}; };
function reasonsFromBitmap(n) { function reasonsFromBitmap(n) {
@ -794,6 +823,13 @@ function loadKnownSpamPosts(params) {
}); });
mainElem.appendChild(controlsB); mainElem.appendChild(controlsB);
if (window.location.hash) {
const elem = document.querySelector(window.location.hash);
if (elem) {
elem.scrollIntoView();
}
}
} }
createPagination(pageNum, url, pageName, 25, renderContent); createPagination(pageNum, url, pageName, 25, renderContent);
@ -898,14 +934,6 @@ function onUrlChange(e) {
resolvePath(ROUTES, path, e.detail.query); resolvePath(ROUTES, path, e.detail.query);
} }
function aClickNav(e) {
e.preventDefault();
e.stopPropagation();
console.log(this, this.href);
window.history.pushState(null, "", this.href);
onRealUrlChange();
}
function bindEventHandlers() { function bindEventHandlers() {
window.addEventListener('urlchange', onUrlChange); window.addEventListener('urlchange', onUrlChange);
window.addEventListener('popstate', onRealUrlChange); window.addEventListener('popstate', onRealUrlChange);

View File

@ -2,7 +2,6 @@
"postgrest_url": "http://192.168.4.6:3000", "postgrest_url": "http://192.168.4.6:3000",
"postgrest_url": "http://10.4.0.96:3000", "postgrest_url": "http://10.4.0.96:3000",
"jwt": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJyb2xlIjoic3BhbV9ub3RpY2VyIn0.j6-6HSBh-Wf5eQovT9cF1ZCNuxkQOqzBFtE3C8aTG3A", "jwt": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJyb2xlIjoic3BhbV9ub3RpY2VyIn0.j6-6HSBh-Wf5eQovT9cF1ZCNuxkQOqzBFtE3C8aTG3A",
"audio_mpeg_thumbnail_path": "/var/www/static/mpg.png",
"website_urls": { "website_urls": {
"leftychan.net": "https://leftychan.net" "leftychan.net": "https://leftychan.net"
}, },

View File

@ -82,3 +82,7 @@ nav a {
margin: 1rem; margin: 1rem;
font-size: 1.5em; font-size: 1.5em;
} }
img.censored {
opacity: 0;
}