Another batch of important updates and fixes

This commit is contained in:
Luka Romih
2026-02-23 15:29:58 +01:00
parent d0e53fee3b
commit fd02e25719
40 changed files with 216 additions and 71 deletions
+1 -1
View File
@@ -13,7 +13,7 @@ PORTAL_ADMIN_INITIAL_PASSWORD="admin"
# The endpoint where you've made Term Candidate Extraction API available. # The endpoint where you've made Term Candidate Extraction API available.
# It is required for the extraction module to work properly. # It is required for the extraction module to work properly.
EXTRACTION_API_ORIGIN="http://rsdo.lhrs.feri.um.si:8080" EXTRACTION_API_ORIGIN="https://rsdo.lhrs.si"
# The main port, which will be exposed on localhost of the of host running the Docker Engine. # The main port, which will be exposed on localhost of the of host running the Docker Engine.
+1 -1
View File
@@ -25,6 +25,6 @@ exports.TEMP_EXPORT_PATH = `${DATA_FILES_PATH}/export_temp`
exports.MAX_EXTRACTIONS_PER_USER = 5 exports.MAX_EXTRACTIONS_PER_USER = 5
exports.ACTIVATION_TOKEN_VALID_DAYS = 7 exports.ACTIVATION_TOKEN_VALID_DAYS = 2
exports.CHANGE_EMAIL_TOKEN_VALID_DAYS = 7 exports.CHANGE_EMAIL_TOKEN_VALID_DAYS = 7
+9
View File
@@ -12,6 +12,15 @@ exports.listComments = async (req, res) => {
} }
if (filters.ctxType === 'entry_dict_int') { if (filters.ctxType === 'entry_dict_int') {
if (!filters.ctxId) {
const NO_COMMENTS_OBJECT = {
page: 1,
numberOfAllPages: 1,
comments: [],
commentCount: 0
}
return res.send(NO_COMMENTS_OBJECT)
}
const { dictionary_id: dictionaryId } = await Entry.fetch(filters.ctxId) const { dictionary_id: dictionaryId } = await Entry.fetch(filters.ctxId)
const isEditor = req.user.hasAnyDictionaryRole(dictionaryId) const isEditor = req.user.hasAnyDictionaryRole(dictionaryId)
const isPortalAdmin = req.user.hasRole('portal admin') const isPortalAdmin = req.user.hasRole('portal admin')
+16 -5
View File
@@ -123,6 +123,8 @@ consultancy.createQuestion = async (req, res) => {
subject: subjectText, subject: subjectText,
html: emailHtml html: emailHtml
}) })
// eslint-disable-next-line no-console
console.log(`Sent email to ${emails} (subject: ${subjectText})`)
res.status(201).send() res.status(201).send()
} }
@@ -233,11 +235,14 @@ consultancy.assign = async (req, res) => {
const emailHtml = await renderAsync('email/consultancy-assigned') const emailHtml = await renderAsync('email/consultancy-assigned')
// TODO i18n - What language are the email title and content (we already have email translated) // TODO i18n - What language are the email title and content (we already have email translated)
const emailSubject = req.t('Novo terminološko vprašanje')
await email.send({ await email.send({
to: emails, to: emails,
subject: req.t('Novo terminološko vprašanje'), subject: emailSubject,
html: emailHtml html: emailHtml
}) })
// eslint-disable-next-line no-console
console.log(`Sent email to ${emails} (subject: ${emailSubject})`)
res.send() res.send()
} }
@@ -289,11 +294,14 @@ consultancy.sendToReview = async (req, res) => {
const emailHtml = await renderAsync('email/consultancy-item-review') const emailHtml = await renderAsync('email/consultancy-item-review')
// TODO i18n - What language are the email title and content (we already have email translated) // TODO i18n - What language are the email title and content (we already have email translated)
const emailSubject = req.t('Potrditev objave')
await email.send({ await email.send({
to: emails, to: emails,
subject: req.t('Potrditev objave'), subject: emailSubject,
html: emailHtml html: emailHtml
}) })
// eslint-disable-next-line no-console
console.log(`Sent email to ${emails} (subject: ${emailSubject})`)
res.send() res.send()
} }
@@ -318,13 +326,16 @@ consultancy.publish = async (req, res) => {
portalName portalName
} }
) )
const emailSubject = i18next.t('Objava terminološkega vprašanja', {
lng: author.language
})
await email.send({ await email.send({
to: author.email, to: author.email,
subject: i18next.t('Objava terminološkega vprašanja', { subject: emailSubject,
lng: author.language
}),
html: emailHtml html: emailHtml
}) })
// eslint-disable-next-line no-console
console.log(`Sent email to ${author.email} (subject: ${emailSubject})`)
await ConsultancyEntry.publish(questionId, answerAuthors) await ConsultancyEntry.publish(questionId, answerAuthors)
await ConsultancyEntry.indexIntoSearchEngine(questionId, true) await ConsultancyEntry.indexIntoSearchEngine(questionId, true)
+1 -1
View File
@@ -55,7 +55,7 @@ dictionary.updateEntry = async (req, res) => {
} }
dictionary.fetchEntries = async (req, res) => { dictionary.fetchEntries = async (req, res) => {
const dictionaryId = req.query.id const { dictionaryId } = req.query
const hitsQuery = genEditorAllQuery(dictionaryId) const hitsQuery = genEditorAllQuery(dictionaryId)
const hits = await searchEntryIndex(hitsQuery) const hits = await searchEntryIndex(hitsQuery)
+4 -1
View File
@@ -218,11 +218,14 @@ extraction.begin = async (req, res) => {
extractionLink extractionLink
} }
) )
const emailSubject = i18next.t('Luščenje končano', { lng: authorLanguage })
await email.send({ await email.send({
to: authorEmail, to: authorEmail,
subject: i18next.t('Luščenje končano', { lng: authorLanguage }), subject: emailSubject,
html: emailHtml html: emailHtml
}) })
// eslint-disable-next-line no-console
console.log(`Sent email to ${authorEmail} (subject: ${emailSubject})`)
} catch (error) { } catch (error) {
// eslint-disable-next-line no-console // eslint-disable-next-line no-console
console.error(error) console.error(error)
+10 -3
View File
@@ -18,7 +18,8 @@ users.listUsers = async (req, res) => {
const { pages_total: numberOfAllPages, results } = await User.fetchAll( const { pages_total: numberOfAllPages, results } = await User.fetchAll(
resultsPerPage, resultsPerPage,
page page,
true
) )
res.send({ page, numberOfAllPages, results }) res.send({ page, numberOfAllPages, results })
@@ -63,11 +64,14 @@ users.updateBasicData = async (req, res) => {
changeEmailLink changeEmailLink
} }
) )
const emailSubject = req.t('Sprememba elektronskega naslova')
await email.send({ await email.send({
to: newEmail, to: newEmail,
subject: req.t('Sprememba elektronskega naslova'), subject: emailSubject,
html: emailHtml html: emailHtml
}) })
// eslint-disable-next-line no-console
console.log(`Sent email to ${newEmail} (subject: ${emailSubject})`)
const message = const message =
req.t( req.t(
@@ -103,11 +107,14 @@ users.updatePassword = async (req, res) => {
username: req.user.userName username: req.user.userName
} }
) )
const emailSubject = req.t('Sprememba gesla')
await email.send({ await email.send({
to: req.user.email, to: req.user.email,
subject: req.t('Sprememba gesla'), subject: emailSubject,
html: emailHtml html: emailHtml
}) })
// eslint-disable-next-line no-console
console.log(`Sent email to ${req.user.email} (subject: ${emailSubject})`)
req.flash('info', 'Geslo je bilo spremenjeno.') req.flash('info', 'Geslo je bilo spremenjeno.')
res.send() res.send()
+8 -2
View File
@@ -76,11 +76,14 @@ exports.minEntriesRequirementCheckAndAct = {
}) })
// TODO i18n - What language are the email title and content (we already have email translated) // TODO i18n - What language are the email title and content (we already have email translated)
const emailSubject = __('Obvestilo o številu gesel')
await email.send({ await email.send({
to: allEmails, to: allEmails,
subject: __('Obvestilo o številu gesel'), subject: emailSubject,
html: emailHtml html: emailHtml
}) })
// eslint-disable-next-line no-console
console.log(`Sent email to ${allEmails} (subject: ${emailSubject})`)
await minEntriesEmailBookmark.set(dictionaryId) await minEntriesEmailBookmark.set(dictionaryId)
}, },
@@ -207,9 +210,12 @@ async function renderAndSendStatusChangeEmails(
}) })
// TODO i18n - What language are the email title and content (we already have email translated) // TODO i18n - What language are the email title and content (we already have email translated)
const emailSubject = __('Sprememba stanja slovarja')
await email.send({ await email.send({
to: targetEmails, to: targetEmails,
subject: __('Sprememba stanja slovarja'), subject: emailSubject,
html: emailHtml html: emailHtml
}) })
// eslint-disable-next-line no-console
console.log(`Sent email to ${targetEmails} (subject: ${emailSubject})`)
} }
+19 -3
View File
@@ -445,15 +445,28 @@ exports.entryDetails = async (req, res) => {
entry.foreignEntries[idx] = await entry.foreignEntries[idx] = await
}) */ }) */
const langs = await Dictionary.fetchLanguages( const allowedLangauges = await Dictionary.fetchLanguages(
entryData.dictionary_id, entryData.dictionary_id,
req.determinedLanguage req.determinedLanguage
) )
const allowedLanguageIDs = allowedLangauges.reduce((agg, el, index) => {
agg[el.id] = el.name
return agg
}, {})
if (entryData.foreign_entries) {
entryData.foreign_entries = entryData.foreign_entries.filter(item => {
return Object.keys(allowedLanguageIDs).includes(`${item.language_id}`)
})
entryData.foreign_entries.forEach((val, idx) => { entryData.foreign_entries.forEach((val, idx) => {
try { try {
entry.foreign_entries[idx].name = langs[idx].name entry.foreign_entries[idx].name =
allowedLanguageIDs[entry.foreign_entries[idx].language_id]
} catch (e) {} } catch (e) {}
}) })
}
res.render('pages/search/result-detail', { res.render('pages/search/result-detail', {
allPrimaryDomains, allPrimaryDomains,
@@ -515,11 +528,14 @@ exports.changeEmail = async (req, res) => {
username: user.username username: user.username
} }
) )
const emailSubject = req.t('Sprememba elektronskega naslova - uspeh')
await email.send({ await email.send({
to: user.email, to: user.email,
subject: req.t('Sprememba elektronskega naslova - uspeh'), subject: emailSubject,
html: emailHtml html: emailHtml
}) })
// eslint-disable-next-line no-console
console.log(`Sent email to ${user.email} (subject: ${emailSubject})`)
req.flash('info', req.t('Uspešno ste spremenili svoj elektronski naslov.')) req.flash('info', req.t('Uspešno ste spremenili svoj elektronski naslov.'))
if (req.user) return res.redirect(303, '/moj-racun') if (req.user) return res.redirect(303, '/moj-racun')
+20 -4
View File
@@ -2,6 +2,7 @@ const { randomBytes } = require('crypto')
const { promisify } = require('util') const { promisify } = require('util')
const passport = require('passport') const passport = require('passport')
const User = require('../models/user') const User = require('../models/user')
const Misc = require('../models/system/misc')
const email = require('../models/email') const email = require('../models/email')
const { logout: logoutUser } = require('../middleware/user') const { logout: logoutUser } = require('../middleware/user')
const { origin } = require('../config/keys') const { origin } = require('../config/keys')
@@ -14,6 +15,11 @@ const user = {}
user.register = async (req, res) => { user.register = async (req, res) => {
// TODO Add validation. // TODO Add validation.
if (req.body.userTag) {
await Misc.logHoneypotCatch(req.body)
return res.send(req.t('Registracija uspešna'))
}
const userId = await User.create( const userId = await User.create(
{ {
...req.body, ...req.body,
@@ -32,11 +38,14 @@ user.register = async (req, res) => {
username, username,
activationLink activationLink
}) })
const emailSubject = req.t('Aktivacija računa')
await email.send({ await email.send({
to: userEmail, to: userEmail,
subject: req.t('Aktivacija računa'), subject: emailSubject,
html: emailHtml html: emailHtml
}) })
// eslint-disable-next-line no-console
console.log(`Sent email to ${userEmail} (subject: ${emailSubject})`)
res.send(req.t('Registracija uspešna')) res.send(req.t('Registracija uspešna'))
} }
@@ -136,11 +145,14 @@ user.generateResetPasswordToken = async (req, res) => {
resetPasswordLink resetPasswordLink
} }
) )
const emailSubject = req.t('Ponastavitev gesla')
await email.send({ await email.send({
to: userEmail, to: userEmail,
subject: req.t('Ponastavitev gesla'), subject: emailSubject,
html: emailHtml html: emailHtml
}) })
// eslint-disable-next-line no-console
console.log(`Sent email to ${userEmail} (subject: ${emailSubject})`)
res.send() res.send()
} }
@@ -162,11 +174,14 @@ user.changePassword = async (req, res) => {
username: user.username username: user.username
} }
) )
const emailSubject = req.t('Uspešna ponastavitev gesla')
await email.send({ await email.send({
to: user.email, to: user.email,
subject: req.t('Uspešna ponastavitev gesla'), subject: emailSubject,
html: emailHtml html: emailHtml
}) })
// eslint-disable-next-line no-console
console.log(`Sent email to ${user.email} (subject: ${emailSubject})`)
req.flash('info', req.t('Vaše geslo je bilo uspešno ponastavljeno.')) req.flash('info', req.t('Vaše geslo je bilo uspešno ponastavljeno.'))
@@ -186,7 +201,8 @@ user.list = async (req, res) => {
const { pages_total: numberOfAllPages, results } = await User.fetchAll( const { pages_total: numberOfAllPages, results } = await User.fetchAll(
resultsPerPage, resultsPerPage,
1 1,
true
) )
res.render('pages/admin/user-list', { res.render('pages/admin/user-list', {
title: req.t('Seznam uporabnikov'), title: req.t('Seznam uporabnikov'),
+9
View File
@@ -1,4 +1,5 @@
const { getInstanceSetting } = require('../models/helpers') const { getInstanceSetting } = require('../models/helpers')
const Entry = require('../models/entry')
exports.enhanceLocals = async (req, res, next) => { exports.enhanceLocals = async (req, res, next) => {
res.locals.portalCode = await getInstanceSetting('portal_code') res.locals.portalCode = await getInstanceSetting('portal_code')
@@ -12,3 +13,11 @@ exports.adjustHeaders = async (req, res, next) => {
next() next()
} }
exports.setDerivedDictionaryIdFromEntryId = async (req, res, next) => {
const { entryId } = req.query
const { dictionary_id: dictionaryId } = await Entry.fetch(entryId)
req.derivedDictionaryId = dictionaryId
next()
}
+7 -2
View File
@@ -53,7 +53,8 @@ user.isDictionaryEditor = (req, res, next) => {
} }
user.canAdministrateDictionary = (req, res, next) => { user.canAdministrateDictionary = (req, res, next) => {
const dictionaryId = req.params.dictionaryId || req.dictionaryId const dictionaryId =
req.params.dictionaryId || req.query.dictionaryId || req.dictionaryId
const isAdmin = req.user.hasDictionaryRole(dictionaryId, 'administration') const isAdmin = req.user.hasDictionaryRole(dictionaryId, 'administration')
const isPortalAdmin = req.user.hasRole('portal admin') const isPortalAdmin = req.user.hasRole('portal admin')
const isDictionariesAdmin = req.user.hasRole('dictionaries admin') const isDictionariesAdmin = req.user.hasRole('dictionaries admin')
@@ -73,7 +74,11 @@ user.canAdministrateDictionaries = (req, res, next) => {
} }
user.canContentEdit = (req, res, next) => { user.canContentEdit = (req, res, next) => {
const { dictionaryId } = req.params const dictionaryId =
req.params.dictionaryId ||
req.query.dictionaryId ||
req.body.dictionaryId ||
req.derivedDictionaryId
const isEditor = req.user.hasAnyDictionaryRole(dictionaryId) const isEditor = req.user.hasAnyDictionaryRole(dictionaryId)
const isPortalAdmin = req.user.hasRole('portal admin') const isPortalAdmin = req.user.hasRole('portal admin')
const isDictionariesAdmin = req.user.hasRole('dictionaries admin') const isDictionariesAdmin = req.user.hasRole('dictionaries admin')
+10
View File
@@ -0,0 +1,10 @@
const db = require('../db')
const Misc = {}
// Log a successful honeypot catch.
Misc.logHoneypotCatch = async body => {
await db.query('INSERT INTO honeypot_log (body_content) VALUES ($1)', [body])
}
module.exports = Misc
+11 -3
View File
@@ -330,7 +330,15 @@ User.fetchDeserializedDataById = async userId => {
} }
// Fetch all registered users on the portal // Fetch all registered users on the portal
User.fetchAll = async (resultsPerPage, page) => { User.fetchAll = async (resultsPerPage, page, hideInactive) => {
// hideInactive was added to hide bot spammed accounts. Using the 'inactive' status might be more appropriate as a filtering criteria in the future.
const whereClause = `WHERE status ${
hideInactive
? `= 'active' OR (status = 'registered' AND NOW() - time_registered < '${ACTIVATION_TOKEN_VALID_DAYS} days')`
: "<> 'closed'"
}`
const { const {
rows: [{ result }] rows: [{ result }]
} = await db.query( } = await db.query(
@@ -339,7 +347,7 @@ User.fetchAll = async (resultsPerPage, page) => {
'pages_total', ( 'pages_total', (
SELECT CEIL(COUNT(*) / $1::float) SELECT CEIL(COUNT(*) / $1::float)
FROM "user" FROM "user"
WHERE status <> 'closed' ${whereClause}
), ),
'results', ARRAY( 'results', ARRAY(
SELECT jsonb_build_object( SELECT jsonb_build_object(
@@ -349,7 +357,7 @@ User.fetchAll = async (resultsPerPage, page) => {
'status', status 'status', status
) )
FROM "user" FROM "user"
WHERE status <> 'closed' ${whereClause}
ORDER BY username ORDER BY username
LIMIT $1 LIMIT $1
OFFSET $2 OFFSET $2
+18 -17
View File
@@ -9,8 +9,8 @@ window.addEventListener('load', () => {
function initComments() { function initComments() {
const ce = {} const ce = {}
ce.updatePager = initPagination('pagination', onPageChange)
window.commentElements = ce window.commentElements = ce
ce.updatePager = initPagination('pagination', onPageChange)
ce.commentsCountEl = document.getElementById('comments-count') ce.commentsCountEl = document.getElementById('comments-count')
ce.commentsContainerEl = document.getElementById('comments-container') ce.commentsContainerEl = document.getElementById('comments-container')
ce.commentForm = document.getElementById('comment-form') ce.commentForm = document.getElementById('comment-form')
@@ -58,16 +58,20 @@ function initComments() {
if (/\/slovarji\/\d+\/vsebina/.test(pageURL)) { if (/\/slovarji\/\d+\/vsebina/.test(pageURL)) {
ce.terminsList = document.getElementById('term-list') ce.terminsList = document.getElementById('term-list')
if (ce.terminsList) { if (ce.terminsList) {
ce.terminsList.addEventListener('click', displayComments) ce.terminsList.addEventListener('click', () =>
changeEntryCommentSection()
)
} }
const ctxBtns = document.getElementsByName('comments-type') const ctxBtns = document.getElementsByName('comments-type')
if (ctxBtns) { if (ctxBtns) {
const ctxBtnsArray = Array.from(ctxBtns) const ctxBtnsArray = Array.from(ctxBtns)
ctxBtnsArray.forEach(el => el.addEventListener('click', displayComments)) ctxBtnsArray.forEach(el =>
el.addEventListener('click', () => changeEntryCommentSection())
)
} }
} }
ce.commentMessageInput && ce.commentReplyInput && clearMessageInput() ce.commentMessageInput && ce.commentReplyInput && clearMessageInput()
displayComments() changeEntryCommentSection()
} }
function autoGrow({ target: inputToResize }) { function autoGrow({ target: inputToResize }) {
@@ -496,24 +500,16 @@ function normalCommentColors(selectedText, btnEyeOffEl) {
selectedText.classList.remove('comment-white-text') selectedText.classList.remove('comment-white-text')
} }
// function getCtxId({ target }) {
// console.log(target)
// const termBtn = target.closest('.terms-label')
// console.log(termBtn)
// if (termBtn) {
// console.log(termBtn)
// displayComments()
// }
// }
const ctxBtns = document.getElementsByName('comments-type') const ctxBtns = document.getElementsByName('comments-type')
const commentsTab = document.getElementById('content-comments') const commentsTab = document.getElementById('content-comments')
if (ctxBtns) { if (ctxBtns) {
const ctxBtnsArray = Array.from(ctxBtns) const ctxBtnsArray = Array.from(ctxBtns)
ctxBtnsArray.forEach(el => el.addEventListener('click', displayComments)) ctxBtnsArray.forEach(el =>
el.addEventListener('click', () => changeEntryCommentSection())
)
} }
if (commentsTab) { if (commentsTab) {
commentsTab.addEventListener('click', displayComments) commentsTab.addEventListener('click', () => changeEntryCommentSection())
} }
function getCtxTypeId(type) { function getCtxTypeId(type) {
@@ -572,10 +568,15 @@ function checkButton(type) {
return checked return checked
} }
async function changeEntryCommentSection() {
await onPageChange()
}
async function onPageChange(newPage) { async function onPageChange(newPage) {
const { updatePager } = window.commentElements const { updatePager } = window.commentElements
try { try {
const { page, numberOfAllPages } = await displayComments(newPage) let { page, numberOfAllPages } = await displayComments(newPage)
numberOfAllPages ||= 1
updatePager(page, numberOfAllPages) updatePager(page, numberOfAllPages)
} catch (error) { } catch (error) {
let message = i18next.t('Prišlo je do napake.') let message = i18next.t('Prišlo je do napake.')
+4 -3
View File
@@ -544,6 +544,7 @@ function initDictionaries() {
} }
function handleClick({ target }) { function handleClick({ target }) {
// TODO Fix leaks and related server request spam. Many click action create a new object or attach a new event listener on every click.
const term = target.closest('.terms-label') const term = target.closest('.terms-label')
const versionEl = target.closest('.date-element') const versionEl = target.closest('.date-element')
const deleteEntryEl = target.closest('#delete-entry') const deleteEntryEl = target.closest('#delete-entry')
@@ -652,11 +653,11 @@ function initDictionaries() {
} = window.dictionaryElements } = window.dictionaryElements
event?.preventDefault() event?.preventDefault()
const dictionaryIdElem = document.getElementById('hidden-dictionary-id') const dictionaryIdElem = document.getElementById('hidden-dictionary-id')
const dictctionaryId = dictionaryIdElem.value const dictionaryId = dictionaryIdElem.value
const deleteEntry = document.getElementById('delete-entry') const deleteEntry = document.getElementById('delete-entry')
try { try {
const { data } = await axios.get('/api/v1/entries', { const { data } = await axios.get('/api/v1/entries', {
params: { id: entryId, dictctionaryId: dictctionaryId } params: { id: entryId, dictionaryId }
}) })
insertTermData(entryId, data) insertTermData(entryId, data)
const isPublishedEl = data.entry.is_published const isPublishedEl = data.entry.is_published
@@ -947,7 +948,7 @@ function initDictionaries() {
const dictionaryId = hiddenEl.value const dictionaryId = hiddenEl.value
try { try {
const { data } = await axios.get('/api/v1/entries/fetch-terms', { const { data } = await axios.get('/api/v1/entries/fetch-terms', {
params: { id: dictionaryId } params: { dictionaryId }
}) })
renderTerms(data, entryId) renderTerms(data, entryId)
} catch (error) { } catch (error) {
+10
View File
@@ -677,11 +677,21 @@ function initPagination(paginationRootElIds, onPageChange, currentPage = 1) {
function initControls(paginationRootElId) { function initControls(paginationRootElId) {
const rootEl = document.getElementById(paginationRootElId) const rootEl = document.getElementById(paginationRootElId)
if (!rootEl) {
return
}
const btnFirstPage = rootEl.querySelector('.first-page') const btnFirstPage = rootEl.querySelector('.first-page')
const btnPreviousPage = rootEl.querySelector('.previous-page') const btnPreviousPage = rootEl.querySelector('.previous-page')
const btnNextPage = rootEl.querySelector('.next-page') const btnNextPage = rootEl.querySelector('.next-page')
const btnLastPage = rootEl.querySelector('.last-page') const btnLastPage = rootEl.querySelector('.last-page')
const formEl = rootEl.querySelector('form') const formEl = rootEl.querySelector('form')
if (!formEl) {
return
}
const pageInputEl = formEl.querySelector('input') const pageInputEl = formEl.querySelector('input')
const pagesCountDisplayEl = formEl.querySelector('.pages-total') const pagesCountDisplayEl = formEl.querySelector('.pages-total')
-1
View File
@@ -118,7 +118,6 @@
"ID Slovarja": "Dictionary ID", "ID Slovarja": "Dictionary ID",
"ID: Ni idja": "ID: No ID", "ID: Ni idja": "ID: No ID",
"IDEKSIRAJ": "INDEX", "IDEKSIRAJ": "INDEX",
"Imate neshranjene spremebe. Ali jih želite shraniti?": "Your changes have not been saved. Do you want to save them?",
"Imate neshranjene spremembe. Ali jih želite shraniti?": "Your changes have not been saved. Do you want to save them?", "Imate neshranjene spremembe. Ali jih želite shraniti?": "Your changes have not been saved. Do you want to save them?",
"Ime": "First name", "Ime": "First name",
"IME": "FIRST NAME", "IME": "FIRST NAME",
-1
View File
@@ -118,7 +118,6 @@
"ID Slovarja": "ID Slovarja", "ID Slovarja": "ID Slovarja",
"ID: Ni idja": "ID: Ni idja", "ID: Ni idja": "ID: Ni idja",
"IDEKSIRAJ": "IDEKSIRAJ", "IDEKSIRAJ": "IDEKSIRAJ",
"Imate neshranjene spremebe. Ali jih želite shraniti?": "Imate neshranjene spremebe. Ali jih želite shraniti?",
"Imate neshranjene spremembe. Ali jih želite shraniti?": "Imate neshranjene spremembe. Ali jih želite shraniti?", "Imate neshranjene spremembe. Ali jih želite shraniti?": "Imate neshranjene spremembe. Ali jih želite shraniti?",
"Ime": "Ime", "Ime": "Ime",
"IME": "IME", "IME": "IME",
@@ -158,6 +158,10 @@ form#register-form {
input { input {
border: none; border: none;
} }
&.pt-6 {
display: none;
}
} }
} }
+2
View File
@@ -6,6 +6,8 @@ const {
updateStatus updateStatus
} = require('../../../controllers/api/v1/comments') } = require('../../../controllers/api/v1/comments')
// TODO Add correct authorization for different contexts.
// List comments (one page). // List comments (one page).
router.get('/', listComments) router.get('/', listComments)
+6 -1
View File
@@ -1,6 +1,9 @@
// This page refers to dictionary entries, not consultancy or other entries // This page refers to dictionary entries, not consultancy or other entries
const router = require('express-promise-router')() const router = require('express-promise-router')()
const user = require('../../../middleware/user') const user = require('../../../middleware/user')
const {
setDerivedDictionaryIdFromEntryId
} = require('../../../middleware/index')
const { const {
getEntry, getEntry,
@@ -12,7 +15,9 @@ const {
} = require('../../../controllers/api/v1/dictionaries') } = require('../../../controllers/api/v1/dictionaries')
// All further routes are only available to authenticated users with dictionary content editing rights. // All further routes are only available to authenticated users with dictionary content editing rights.
router.use(user.isAuthenticated, user.canContentEdit) router.use(user.isAuthenticated)
router.use('/delete-entry', setDerivedDictionaryIdFromEntryId)
router.use(user.canContentEdit)
// Render entry data for the selected entry // Render entry data for the selected entry
router.get('/', getEntry) router.get('/', getEntry)
+7 -2
View File
@@ -196,7 +196,12 @@ function updateDictionaries(done) {
) )
}, },
function (cbwd) { function (cbwd) {
fetchUpdates(ldict, errd => { fetchUpdates(ldict, (errd, body) => {
if (body && body.error)
console.error(
'skipping dictionary update due to ',
body.error
)
cbwd(errd) cbwd(errd)
}) })
}, },
@@ -304,7 +309,7 @@ function fetchUpdates(ldict, done) {
if (error) return done(error) if (error) return done(error)
if (body.error) { if (body.error) {
// server side error message // server side error message
return done(body) return done(null, body)
} }
// the body will contain decoded JSON array of dictionary items to update // the body will contain decoded JSON array of dictionary items to update
if (Array.isArray(body)) { if (Array.isArray(body)) {
@@ -182,6 +182,18 @@
.row.pt-1 .row.pt-1
.col.pe-0 .col.pe-0
p#error-password-repeat.mb-0.repeat.error-text.text-end= t('Geslo se ne ujema') p#error-password-repeat.mb-0.repeat.error-text.text-end= t('Geslo se ne ujema')
//- Honeypot. Hidden by css selector form#register-form .row.pt-6.
.row.pt-6
.col-2.d-flex.align-items-center.justify-content-center.pe-4
img(src="/images/user.svg" alt="")
.col-8.input-floor.ps-0
label.loginregisterlabel(for="register-user-tag") OZNAKA
input#register-user-tag.w-100.input-lr(name="userTag")
.col-2.input-floor.d-flex.justify-content-end.pe-0
img.error-icon.error-user-tag.align-self-end.d-flex(
src="/images/x_red.svg"
alt="X"
)
.row.mt-1.pt-0 .row.mt-1.pt-0
.col-2.d-flex.align-items-center.justify-content-center.pe-4 .col-2.d-flex.align-items-center.justify-content-center.pe-4
.col-8.ps-0 .col-8.ps-0
+1 -1
View File
@@ -1,4 +1,4 @@
p Dear #{ username }, p Dear #{ username },
p You have received this massage because a new user account has been created on the Slovenian Terminology Portal using this e-mail address. p You have received this massage because a new user account has been created on the Slovenian Terminology Portal using this e-mail address.
p To activate your account, you must confirm that this is the correct e-mail address. The link will be active for 7 days. p To activate your account, you must confirm that this is the correct e-mail address. The link will be active for 2 days.
a(href=activationLink) I confirm my e-mail address. a(href=activationLink) I confirm my e-mail address.
+1 -1
View File
@@ -1,4 +1,4 @@
p Pozdravljeni #{ username }, p Pozdravljeni #{ username },
p to sporočilo ste prejeli, ker ste na Slovenskem terminološkem portalu registrirali nov uporabniški račun s tem elektronskim naslovom. p to sporočilo ste prejeli, ker ste na Slovenskem terminološkem portalu registrirali nov uporabniški račun s tem elektronskim naslovom.
p Za uporabo računa potrebujete le še potrditi, da je to res vaš elektronski naslov. Povezava je veljavna 7 dni. p Za uporabo računa potrebujete le še potrditi, da je to res vaš elektronski naslov. Povezava je veljavna 2 dni.
a(href=activationLink) Potrjujem svoj naslov a(href=activationLink) Potrjujem svoj naslov
+1 -1
View File
@@ -82,4 +82,4 @@ block body
include /utilities/modal-alert include /utilities/modal-alert
include /utilities/modal-alert-mixin include /utilities/modal-alert-mixin
+alertModal('unsaved-data', t('Shrani'), t('Ne'), 'modal-save-btn', 'modal-dont-save-btn', t('Imate neshranjene spremebe. Ali jih želite shraniti?')) +alertModal('unsaved-data', t('Shrani'), t('Ne'), 'modal-save-btn', 'modal-dont-save-btn', t('Imate neshranjene spremembe. Ali jih želite shraniti?'))
@@ -18,4 +18,4 @@ block body
+dictionary-description(dictionary.id) +dictionary-description(dictionary.id)
include /utilities/modal-alert include /utilities/modal-alert
include /utilities/modal-alert-mixin include /utilities/modal-alert-mixin
+alertModal('unsaved-data', t('Shrani'), t('Ne'), 'modal-save-btn', 'modal-dont-save-btn', t('Imate neshranjene spremebe. Ali jih želite shraniti?')) +alertModal('unsaved-data', t('Shrani'), t('Ne'), 'modal-save-btn', 'modal-dont-save-btn', t('Imate neshranjene spremembe. Ali jih želite shraniti?'))
@@ -20,4 +20,4 @@ block body
include /utilities/dictionary-structure-input include /utilities/dictionary-structure-input
include /common/footer include /common/footer
include /utilities/modal-alert-mixin include /utilities/modal-alert-mixin
+alertModal('unsaved-data', t('Shrani'), t('Ne'), 'modal-save-btn', 'modal-dont-save-btn', t('Imate neshranjene spremebe. Ali jih želite shraniti?')) +alertModal('unsaved-data', t('Shrani'), t('Ne'), 'modal-save-btn', 'modal-dont-save-btn', t('Imate neshranjene spremembe. Ali jih želite shraniti?'))
@@ -210,6 +210,7 @@ block body
span.new-user-info= t('NOV UPORABNIK') span.new-user-info= t('NOV UPORABNIK')
.row.d-flex.justify-content-lg-start.align-items-center.mt-2.ms-0.ps-0 .row.d-flex.justify-content-lg-start.align-items-center.mt-2.ms-0.ps-0
.col-lg-6.ms-0.ps-0.me-2 .col-lg-6.ms-0.ps-0.me-2
input(type="hidden" name="dictionaryId" value=dictionary.id)
input.name-input.d-inline.form-control.ms-0.ps-0( input.name-input.d-inline.form-control.ms-0.ps-0(
type="text" type="text"
name="userNameEmail" name="userNameEmail"
@@ -279,4 +280,4 @@ block body
include /utilities/modal-response include /utilities/modal-response
+responseModal +responseModal
include /utilities/modal-alert-mixin include /utilities/modal-alert-mixin
+alertModal('unsaved-data', 'Shrani', 'Ne', 'modal-save-btn', 'modal-dont-save-btn', 'Imate neshranjene spremebe. Ali jih želite shraniti?') +alertModal('unsaved-data', 'Shrani', 'Ne', 'modal-save-btn', 'modal-dont-save-btn', 'Imate neshranjene spremembe. Ali jih želite shraniti?')
@@ -78,4 +78,4 @@ block body
span.d-md-inline.d-block.smaller-gray-info.ms-xxl-3.ms-md-3= t('Vnesite naslov spletnega mesta, kjer so zbrani vsi odgovori terminološke svetovalnice.') span.d-md-inline.d-block.smaller-gray-info.ms-xxl-3.ms-md-3= t('Vnesite naslov spletnega mesta, kjer so zbrani vsi odgovori terminološke svetovalnice.')
include /common/footer include /common/footer
include /utilities/modal-alert-mixin include /utilities/modal-alert-mixin
+alertModal('unsaved-data', t('Shrani'), t('Ne'), 'modal-save-btn', 'modal-dont-save-btn', t('Imate neshranjene spremebe. Ali jih želite shraniti?')) +alertModal('unsaved-data', t('Shrani'), t('Ne'), 'modal-save-btn', 'modal-dont-save-btn', t('Imate neshranjene spremembe. Ali jih želite shraniti?'))
+1 -1
View File
@@ -137,4 +137,4 @@ block body
span.d-md-inline.d-block.smaller-gray-info= t('Modul za svetovanje pri terminoloških zagatah.') span.d-md-inline.d-block.smaller-gray-info= t('Modul za svetovanje pri terminoloških zagatah.')
include /common/footer include /common/footer
include /utilities/modal-alert-mixin include /utilities/modal-alert-mixin
+alertModal('unsaved-data', t('Shrani'), t('Ne'), 'modal-save-btn', 'modal-dont-save-btn', t('Imate neshranjene spremebe. Ali jih želite shraniti?')) +alertModal('unsaved-data', t('Shrani'), t('Ne'), 'modal-save-btn', 'modal-dont-save-btn', t('Imate neshranjene spremembe. Ali jih želite shraniti?'))
@@ -107,4 +107,4 @@ block body
span.d-md-inline.d-block.smaller-gray-info.ms-md-2= t('Poleg objave slovarskega sestavka v fazi "Urejeno" je omogočena tudi objava v fazi "V urejanju".') span.d-md-inline.d-block.smaller-gray-info.ms-md-2= t('Poleg objave slovarskega sestavka v fazi "Urejeno" je omogočena tudi objava v fazi "V urejanju".')
include /common/footer include /common/footer
include /utilities/modal-alert-mixin include /utilities/modal-alert-mixin
+alertModal('unsaved-data', t('Shrani'), t('Ne'), 'modal-save-btn', 'modal-dont-save-btn', t('Imate neshranjene spremebe. Ali jih želite shraniti?')) +alertModal('unsaved-data', t('Shrani'), t('Ne'), 'modal-save-btn', 'modal-dont-save-btn', t('Imate neshranjene spremembe. Ali jih želite shraniti?'))
+1 -1
View File
@@ -111,4 +111,4 @@ block body
include /utilities/modal-response include /utilities/modal-response
+responseModal +responseModal
include /utilities/modal-alert-mixin include /utilities/modal-alert-mixin
+alertModal('unsaved-data', t('Shrani'), t('Ne'), 'modal-save-btn', 'modal-dont-save-btn', t('Imate neshranjene spremebe. Ali jih želite shraniti?')) +alertModal('unsaved-data', t('Shrani'), t('Ne'), 'modal-save-btn', 'modal-dont-save-btn', t('Imate neshranjene spremembe. Ali jih želite shraniti?'))
@@ -146,4 +146,4 @@ block body
#offset-main.ps-2.pe-2 #offset-main.ps-2.pe-2
p #{ t('Nimate ustreznih pravic') } p #{ t('Nimate ustreznih pravic') }
include /utilities/modal-alert-mixin include /utilities/modal-alert-mixin
+alertModal('unsaved-data', 'Shrani', 'Ne', 'modal-save-btn', 'modal-dont-save-btn', t('Imate neshranjene spremebe. Ali jih želite shraniti?')) +alertModal('unsaved-data', 'Shrani', 'Ne', 'modal-save-btn', 'modal-dont-save-btn', t('Imate neshranjene spremembe. Ali jih želite shraniti?'))
@@ -18,4 +18,4 @@ block body
+dictionary-description +dictionary-description
include /utilities/modal-alert include /utilities/modal-alert
include /utilities/modal-alert-mixin include /utilities/modal-alert-mixin
+alertModal('unsaved-data', t('Shrani'), t('Ne'), 'modal-save-btn', 'modal-dont-save-btn', t('Imate neshranjene spremebe. Ali jih želite shraniti?')) +alertModal('unsaved-data', t('Shrani'), t('Ne'), 'modal-save-btn', 'modal-dont-save-btn', t('Imate neshranjene spremembe. Ali jih želite shraniti?'))
@@ -20,4 +20,4 @@ block body
include /utilities/dictionary-structure-input include /utilities/dictionary-structure-input
include /common/footer include /common/footer
include /utilities/modal-alert-mixin include /utilities/modal-alert-mixin
+alertModal('unsaved-data', t('Shrani'), t('Ne'), 'modal-save-btn', 'modal-dont-save-btn', t('Imate neshranjene spremebe. Ali jih želite shraniti?')) +alertModal('unsaved-data', t('Shrani'), t('Ne'), 'modal-save-btn', 'modal-dont-save-btn', t('Imate neshranjene spremembe. Ali jih želite shraniti?'))
+2 -1
View File
@@ -210,6 +210,7 @@ block body
span.new-user-info= t('NOV UPORABNIK') span.new-user-info= t('NOV UPORABNIK')
.row.d-flex.justify-content-lg-start.align-items-center.mt-2.ms-0.ps-0 .row.d-flex.justify-content-lg-start.align-items-center.mt-2.ms-0.ps-0
.col-lg-6.ms-0.ps-0.me-2 .col-lg-6.ms-0.ps-0.me-2
input(type="hidden" name="dictionaryId" value=dictionary.id)
input.name-input.d-inline.form-control.ms-0.ps-0( input.name-input.d-inline.form-control.ms-0.ps-0(
type="text" type="text"
name="userNameEmail" name="userNameEmail"
@@ -279,4 +280,4 @@ block body
include /utilities/modal-response include /utilities/modal-response
+responseModal +responseModal
include /utilities/modal-alert-mixin include /utilities/modal-alert-mixin
+alertModal('unsaved-data', t('Shrani'), t('Ne'), 'modal-save-btn', 'modal-dont-save-btn', t('Imate neshranjene spremebe. Ali jih želite shraniti?')) +alertModal('unsaved-data', t('Shrani'), t('Ne'), 'modal-save-btn', 'modal-dont-save-btn', t('Imate neshranjene spremembe. Ali jih želite shraniti?'))
@@ -89,4 +89,4 @@ mixin dictionary-domain-labels
include /common/footer include /common/footer
include /utilities/modal-alert include /utilities/modal-alert
include /utilities/modal-alert-mixin include /utilities/modal-alert-mixin
+alertModal('unsaved-data', t('Shrani'), t('Ne'), 'modal-save-btn', 'modal-dont-save-btn', t('Imate neshranjene spremebe. Ali jih želite shraniti?')) +alertModal('unsaved-data', t('Shrani'), t('Ne'), 'modal-save-btn', 'modal-dont-save-btn', t('Imate neshranjene spremembe. Ali jih želite shraniti?'))
+5
View File
@@ -0,0 +1,5 @@
CREATE TABLE honeypot_log (
id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
time_created TIMESTAMPTZ NOT NULL DEFAULT NOW(),
body_content JSONB
);