Initial commit
This commit is contained in:
@@ -0,0 +1,121 @@
|
||||
const router = require('express-promise-router')()
|
||||
const dictionary = require('../controllers/dictionaries')
|
||||
const user = require('../controllers/users')
|
||||
const portal = require('../controllers/portals')
|
||||
|
||||
// All routes require an authenticated user.
|
||||
router.use((req, res, next) => {
|
||||
if (req.isAuthenticated()) return next()
|
||||
res.redirect('/')
|
||||
})
|
||||
|
||||
// Menu entry point. Redirect based on role.
|
||||
router.get('/', (req, res, next) => {
|
||||
const { user, baseUrl } = req
|
||||
if (user.hasRole('portal admin')) {
|
||||
return res.redirect(`${baseUrl}/nastavitve/portal`)
|
||||
} else if (user.hasRole('dictionaries admin')) {
|
||||
return res.redirect(`${baseUrl}/slovarji`)
|
||||
}
|
||||
res.redirect('/')
|
||||
})
|
||||
|
||||
// Authorize endpoints for portal admin.
|
||||
router.use(
|
||||
['/nastavitve', '/povezave', '/uporabniki', '/komentarji'],
|
||||
(req, res, next) => {
|
||||
if (req.user.hasRole('portal admin')) return next()
|
||||
res.redirect('/')
|
||||
}
|
||||
)
|
||||
|
||||
// Authorize endpoints for dictionaries admin.
|
||||
router.use(['/slovarji', '/podrocja'], (req, res, next) => {
|
||||
if (req.user.hasRole('dictionaries admin')) return next()
|
||||
res.redirect('/')
|
||||
})
|
||||
|
||||
router.get('/nastavitve/portal', portal.instanceSettings)
|
||||
|
||||
router.post('/nastavitve/portal', portal.updateInstaceSettings)
|
||||
|
||||
router.get('/nastavitve/slovarji', portal.instanceDictSettings)
|
||||
|
||||
router.post('/nastavitve/slovarji', portal.updateInstanceDictSettings)
|
||||
|
||||
router.get('/nastavitve/svetovalnica', portal.instanceConsultancySettings)
|
||||
|
||||
router.post('/nastavitve/svetovalnica', portal.updateInstanceConusltacySettings)
|
||||
|
||||
router.get('/povezave/seznam', portal.list)
|
||||
|
||||
router.get('/povezave/nova', portal.new)
|
||||
|
||||
router.get('/povezave/slovarji', portal.fetchAllLinkedDictionaries)
|
||||
|
||||
router.post('/povezave/slovarji', portal.updateAllDictionaries)
|
||||
|
||||
router.get('/povezave/seznam/:portalId', portal.fetchSelectedLinkedDictionaries)
|
||||
|
||||
router.post('/povezave/seznam/:portalId', portal.updateSelectedDictionaries)
|
||||
|
||||
router.get('/povezava/:portalId/urejanje', portal.fetchPortal)
|
||||
|
||||
router.post('/povezava/:portalId/urejanje', portal.updatePortal)
|
||||
|
||||
// Show a list of user's dictionaries.
|
||||
router.get('/slovarji', dictionary.listAdminDictionaries)
|
||||
|
||||
router.get('/slovarji/:dictionaryId/podatki', dictionary.adminEditDescription)
|
||||
|
||||
router.post(
|
||||
'/slovarji/:dictionaryId/podatki',
|
||||
dictionary.updateAdminDescription
|
||||
)
|
||||
|
||||
router.get('/slovarji/:dictionaryId/uporabniki', dictionary.editUsers)
|
||||
|
||||
router.post('/slovarji/:dictionaryId/uporabniki', dictionary.updateUsers)
|
||||
|
||||
router.get('/slovarji/:dictionaryId/struktura', dictionary.editStructure)
|
||||
|
||||
router.post('/slovarji/:dictionaryId/struktura', dictionary.updateStructure)
|
||||
|
||||
router.get(
|
||||
'/slovarji/:dictionaryId/podrocne-oznake',
|
||||
dictionary.editDomainLabels
|
||||
)
|
||||
|
||||
router.get('/slovarji/:dictionaryId/napredno', dictionary.editAdvanced)
|
||||
|
||||
router.get('/slovarji/:dictionaryId/komentarji', dictionary.comments)
|
||||
|
||||
router.get('/slovarji/:dictionaryId/izvoz', dictionary.showExportToFileForm)
|
||||
|
||||
router.get(
|
||||
'/slovarji/:dictionaryId/uvoz/datoteka',
|
||||
dictionary.showImportFromFileForm
|
||||
)
|
||||
|
||||
router.get(
|
||||
'/slovarji/:dictionaryId/uvoz/luscenje',
|
||||
dictionary.showImportFromExtractionForm
|
||||
)
|
||||
|
||||
router.get('/uporabniki/portal', user.listAllWithPortalRoles)
|
||||
|
||||
router.post('/uporabniki/portal', user.updateRoles)
|
||||
|
||||
router.get('/uporabniki/seznam', user.list)
|
||||
|
||||
// Show an admin form to edit specific user's data.
|
||||
router.get('/uporabniki/:userId/urejanje', user.adminEdit)
|
||||
|
||||
// Validate and update specific user's data as admin.
|
||||
router.post('/uporabniki/:userId/urejanje', user.adminUpdate)
|
||||
|
||||
router.get('/podpodrocja', dictionary.showSecondaryDomains)
|
||||
|
||||
router.get('/komentarji', portal.comments)
|
||||
|
||||
module.exports = router
|
||||
@@ -0,0 +1,13 @@
|
||||
const router = require('express-promise-router')()
|
||||
const v1Router = require('./v1')
|
||||
|
||||
// Mark all api calls for conditional special treatment.
|
||||
router.use((req, res, next) => {
|
||||
req.isAjax = true
|
||||
next()
|
||||
})
|
||||
|
||||
// TODO Make sure all API endpoints have proper authorization protection (at a later point).
|
||||
router.use('/v1', v1Router)
|
||||
|
||||
module.exports = router
|
||||
@@ -0,0 +1,32 @@
|
||||
const router = require('express-promise-router')()
|
||||
|
||||
const {
|
||||
listComments,
|
||||
createComment,
|
||||
seedComments,
|
||||
clearComments,
|
||||
updateStatus
|
||||
} = require('../../../controllers/api/v1/comments')
|
||||
|
||||
// List comments (one page).
|
||||
router.get('/', listComments)
|
||||
|
||||
// TEMP - Seed comments.
|
||||
router.get('/seed/:commentCount', seedComments)
|
||||
|
||||
// TEMP - Clear comments.
|
||||
router.get('/clear', clearComments)
|
||||
|
||||
// All further routes are only available to authenticated users.
|
||||
router.use((req, res, next) => {
|
||||
if (req.isAuthenticated()) return next()
|
||||
res.status(400).end()
|
||||
})
|
||||
|
||||
// Create new comment.
|
||||
router.post('/', createComment)
|
||||
|
||||
// Change comment's visibility status
|
||||
router.post('/updateStatus', updateStatus)
|
||||
|
||||
module.exports = router
|
||||
@@ -0,0 +1,77 @@
|
||||
const router = require('express-promise-router')()
|
||||
|
||||
const {
|
||||
assign,
|
||||
listEntries,
|
||||
listNewEntries,
|
||||
createQuestion,
|
||||
deleteQuestion,
|
||||
updateDomain,
|
||||
insertConsultantAndHisDomainsByUsername,
|
||||
insertNonModerator,
|
||||
deleteConsultantForEntry,
|
||||
getSharedAuthors,
|
||||
getSharedAuthorsBeforePublish,
|
||||
removeConsultant,
|
||||
reject,
|
||||
sendToReview,
|
||||
publish,
|
||||
updateQuestion,
|
||||
updateSharedAuthors
|
||||
} = require('../../../controllers/api/v1/consultancy')
|
||||
|
||||
// All routes require an authenticated user.
|
||||
router.use((req, res, next) => {
|
||||
if (req.isAuthenticated()) return next()
|
||||
res.status(400).send('Unauthenticated')
|
||||
})
|
||||
|
||||
router.get('/entry', listEntries)
|
||||
|
||||
router.get('/new-entry', listNewEntries)
|
||||
|
||||
router.post('/entry', createQuestion)
|
||||
|
||||
router.put('/entry', updateQuestion)
|
||||
|
||||
// Authorize endpoints for portal admin below.
|
||||
router.use((req, res, next) => {
|
||||
if (req.user.hasRole('portal admin')) return next()
|
||||
res.status(400).send('Unauthorized')
|
||||
})
|
||||
|
||||
// router.use(checkUserAdminPrivilegeUltility)
|
||||
|
||||
router.post(
|
||||
'/add-consultant-by-username',
|
||||
insertConsultantAndHisDomainsByUsername
|
||||
)
|
||||
|
||||
router.post('/add-non-moderator', insertNonModerator)
|
||||
|
||||
// Remove user from role "consultant"
|
||||
// body params: id -> user's id
|
||||
|
||||
router.get('/get-shared-authors', getSharedAuthorsBeforePublish)
|
||||
|
||||
router.get('/get-shared-authors-publish', getSharedAuthors)
|
||||
|
||||
router.put('/update-consultant-domain', updateDomain)
|
||||
|
||||
router.put('/update-shared-authors', updateSharedAuthors)
|
||||
|
||||
router.put('/assign', assign)
|
||||
|
||||
router.put('/reject', reject)
|
||||
|
||||
router.put('/review', sendToReview)
|
||||
|
||||
router.put('/publish', publish)
|
||||
|
||||
router.delete('/delete-consultant', removeConsultant)
|
||||
|
||||
router.delete('/delete-consultant-author', deleteConsultantForEntry)
|
||||
|
||||
router.delete('/delete', deleteQuestion)
|
||||
|
||||
module.exports = router
|
||||
@@ -0,0 +1,7 @@
|
||||
const router = require('express-promise-router')()
|
||||
const demoPaginacija = require('../../../controllers/api/v1/demo-paginacija')
|
||||
|
||||
// Tale endpoint vrača rezultate.
|
||||
router.get('/list', demoPaginacija.list)
|
||||
|
||||
module.exports = router
|
||||
@@ -0,0 +1,35 @@
|
||||
const router = require('express-promise-router')()
|
||||
|
||||
const dictionaries = require('../../../controllers/api/v1/dictionaries')
|
||||
|
||||
// Update domain labels.
|
||||
router.post('/update-domain-labels', dictionaries.updateDomainLabels)
|
||||
|
||||
// Update secondary domains
|
||||
router.post('/renovateSecondaryDomains', dictionaries.renovateSecondaryDomains)
|
||||
|
||||
// Delete specific dictionary.
|
||||
router.delete('/:dictionaryId', dictionaries.delete)
|
||||
|
||||
// Change page in pagination
|
||||
router.get('/listAllDictionaries', dictionaries.listDictionaries)
|
||||
|
||||
// Change page in pagination
|
||||
router.get('/:dictionaryId/listDomainLabels', dictionaries.listDomainLabels)
|
||||
|
||||
// Change page in pagination
|
||||
router.get('/listSecondaryDomains', dictionaries.listSecondaryDomains)
|
||||
|
||||
// Delete all entries of specific dictionary.
|
||||
router.delete('/:dictionaryId/entries/all', dictionaries.deleteAllEntries)
|
||||
|
||||
// Publish all entries of specific dictionary.
|
||||
router.put('/:dictionaryId/entries/all/publish', dictionaries.publishAllEntries)
|
||||
|
||||
// Import term candidates from extraction.
|
||||
router.post(
|
||||
'/:id/import/extraction/:extractionId',
|
||||
dictionaries.extractionImport
|
||||
)
|
||||
|
||||
module.exports = router
|
||||
@@ -0,0 +1,33 @@
|
||||
// This page refers to dictionary entries, not consultancy or other entries
|
||||
const router = require('express-promise-router')()
|
||||
|
||||
const {
|
||||
getEntry,
|
||||
updateEntry,
|
||||
createEntry,
|
||||
fetchEntries,
|
||||
deleteEntry,
|
||||
getEntryVersionSnapshot
|
||||
} = require('../../../controllers/api/v1/dictionaries')
|
||||
|
||||
// TODO Add authorization.
|
||||
|
||||
// Render entry data for the selected entry
|
||||
router.get('/', getEntry)
|
||||
|
||||
// Create entry
|
||||
router.post('/create', createEntry)
|
||||
|
||||
// Update entry
|
||||
router.post('/update', updateEntry)
|
||||
|
||||
// Get all entries
|
||||
router.get('/fetch-terms', fetchEntries)
|
||||
|
||||
// Delete selected entry
|
||||
router.delete('/delete-entry', deleteEntry)
|
||||
|
||||
// Get single entry version history snapshot.
|
||||
router.get('/:entryId/version-snapshots/:version', getEntryVersionSnapshot)
|
||||
|
||||
module.exports = router
|
||||
@@ -0,0 +1,54 @@
|
||||
const router = require('express-promise-router')()
|
||||
|
||||
const extraction = require('../../../controllers/api/v1/extraction')
|
||||
|
||||
// TODO In final version test authentication and authorization.
|
||||
// TODO Also try to lock file editing or other operations once extraction was started.
|
||||
|
||||
// Delete extraction.
|
||||
router.delete('/:id', extraction.delete)
|
||||
|
||||
// List documents.
|
||||
router.get('/:id/documents', extraction.docsList)
|
||||
|
||||
// Update documents.
|
||||
router.put('/:id/documents', extraction.docsUpdate)
|
||||
|
||||
// Delete a specific document.
|
||||
router.delete('/:id/documents/:filename', extraction.docDelete)
|
||||
|
||||
// List stop term files.
|
||||
router.get('/:id/stop-terms', extraction.stopTermsList)
|
||||
|
||||
// Update stop term files.
|
||||
router.put('/:id/stop-terms', extraction.stopTermsUpdate)
|
||||
|
||||
// Delete a specific stop term file.
|
||||
router.delete('/:id/stop-terms/:filename', extraction.stopTermDelete)
|
||||
|
||||
// Save oss params.
|
||||
router.post('/:id/oss-save-params', extraction.ossSaveParams)
|
||||
|
||||
// Execute search by oss params.
|
||||
router.put('/:id/oss-search', extraction.ossSearch)
|
||||
|
||||
// Confirm oss params.
|
||||
router.put('/:id/oss-confirm-params', extraction.ossConfirmParams)
|
||||
|
||||
// Begin extraction.
|
||||
router.put('/:id/begin', extraction.begin)
|
||||
|
||||
// Duplicate extraction.
|
||||
router.post('/:id/duplicate', extraction.duplicate)
|
||||
|
||||
// Export term candidates.
|
||||
router.get('/:id/term-candidates-export', extraction.termCandidatesExport)
|
||||
|
||||
// List all finished extractions for current user.
|
||||
// TODO Is this enpoint even necessarry?
|
||||
router.get('/finished-for-user', extraction.listFinishedForUser)
|
||||
|
||||
// List term candidates for specific extraction.
|
||||
router.get('/:id/term-candidates', extraction.listTermCandidates)
|
||||
|
||||
module.exports = router
|
||||
@@ -0,0 +1,24 @@
|
||||
const router = require('express-promise-router')()
|
||||
const commentsRouter = require('./comments')
|
||||
const systemRouter = require('./system')
|
||||
const usersRouter = require('./users')
|
||||
const entriesRouter = require('./entries')
|
||||
const dictionariesRouter = require('./dictionaries')
|
||||
const portalsRouter = require('./portals')
|
||||
const searchRouter = require('./search')
|
||||
const consultancyRouter = require('./consultancy')
|
||||
const demoPaginacijaRouter = require('./demo-paginacija')
|
||||
const extractionRouter = require('./extraction')
|
||||
|
||||
router.use('/comments', commentsRouter)
|
||||
router.use('/system', systemRouter)
|
||||
router.use('/users', usersRouter)
|
||||
router.use('/entries', entriesRouter)
|
||||
router.use('/dictionaries', dictionariesRouter)
|
||||
router.use('/portals', portalsRouter)
|
||||
router.use('/search', searchRouter)
|
||||
router.use('/consultancy', consultancyRouter)
|
||||
router.use('/demo-paginacija', demoPaginacijaRouter)
|
||||
router.use('/extraction', extractionRouter)
|
||||
|
||||
module.exports = router
|
||||
@@ -0,0 +1,34 @@
|
||||
const router = require('express-promise-router')()
|
||||
|
||||
const {
|
||||
create,
|
||||
syncRemoteDictionaries,
|
||||
fetchDictionary,
|
||||
updatePortalStatus,
|
||||
listSelectedLinkedDicts,
|
||||
listAllLinkedDicts,
|
||||
deleteLinkedDictionary
|
||||
} = require('../../../controllers/api/v1/portals')
|
||||
|
||||
// Create new portal connection
|
||||
router.post('/createPortal', create)
|
||||
|
||||
// Synchronize all dictionaries (without entries) for linked portal.
|
||||
router.put('/:linkedPortalId/dictionaries', syncRemoteDictionaries)
|
||||
|
||||
// Delete linked portal.
|
||||
router.delete('/:linkedPortalId/deleteLinkedDictionary', deleteLinkedDictionary)
|
||||
|
||||
// Fetch all dictionaries for selected portal
|
||||
router.get('/getMyDictionaries', fetchDictionary)
|
||||
|
||||
// Update selected portal status (enable or disable)
|
||||
router.post('/updatePortalStatus', updatePortalStatus)
|
||||
|
||||
// Fetch new page of dictionaries for pagination
|
||||
router.get('/:portalId/listSelectedLinkedDicts', listSelectedLinkedDicts)
|
||||
|
||||
// Fetch new page of all linked dictionaries for pagination
|
||||
router.get('/listAllLinkedDicts', listAllLinkedDicts)
|
||||
|
||||
module.exports = router
|
||||
@@ -0,0 +1,20 @@
|
||||
const router = require('express-promise-router')()
|
||||
const search = require('../../../controllers/api/v1/search')
|
||||
const user = require('../../../middleware/user')
|
||||
|
||||
// Return search results for main search.
|
||||
router.get('/main', search.listMainEntries)
|
||||
|
||||
// TODO This route assumes existance of user. Make sure to pre check it.
|
||||
// Return search results for editor search.
|
||||
router.get(
|
||||
'/editor/:dictionaryId',
|
||||
user.isDictionaryEditor,
|
||||
search.listEditorEntries
|
||||
)
|
||||
|
||||
router.get('/dictionaries', search.listFilteredDictionaries)
|
||||
|
||||
router.get('/term-filters', search.showModalFilterResults)
|
||||
|
||||
module.exports = router
|
||||
@@ -0,0 +1,23 @@
|
||||
const router = require('express-promise-router')()
|
||||
const system = require('../../../controllers/api/v1/system')
|
||||
const {
|
||||
listDictionaries,
|
||||
syncDictionary
|
||||
} = require('../../../controllers/api/v1/inter_instance_sync')
|
||||
|
||||
// Receive Content Security Policy violation reports.
|
||||
router.post('/csp-reports', system.handleCspReports)
|
||||
|
||||
// Trigger synchronization with Eurotermbank.
|
||||
router.get('/eurotermbank-sync-push', system.syncWithEurotermbank)
|
||||
|
||||
// List dictionaries (one page).
|
||||
router.get('/inter-instance-sync/dictionaries', listDictionaries)
|
||||
|
||||
// List dictionary entries updated since....
|
||||
router.get(
|
||||
'/inter-instance-sync/dictionary/:dictionaryId/entries',
|
||||
syncDictionary
|
||||
)
|
||||
|
||||
module.exports = router
|
||||
@@ -0,0 +1,19 @@
|
||||
const router = require('express-promise-router')()
|
||||
const user = require('../../../controllers/users')
|
||||
const users = require('../../../controllers/api/v1/users')
|
||||
|
||||
// Validate and create a new user.
|
||||
router.post('/register', user.register)
|
||||
|
||||
// Validate and log the user in.
|
||||
router.post('/login', user.login)
|
||||
|
||||
router.get('/addUser', user.findByUsernameOrEmail)
|
||||
|
||||
router.get('/listAllUsers', users.listUsers)
|
||||
|
||||
router.post('/hitsPerPage', users.updateHitsPerPage)
|
||||
|
||||
router.post('/nameAndSurname', users.updateFristNameAndSurname)
|
||||
|
||||
module.exports = router
|
||||
@@ -0,0 +1,34 @@
|
||||
const router = require('express-promise-router')()
|
||||
|
||||
const { consultancy, consultancyAdmin } = require('../controllers/consultancy')
|
||||
|
||||
router.get('/', consultancy.index)
|
||||
|
||||
router.get('/iskanje', consultancy.search)
|
||||
|
||||
router.get('/vprasanje/novo', consultancy.new)
|
||||
|
||||
router.get('/vprasanje/:id', consultancy.specificQuestion)
|
||||
|
||||
router.use((req, res, next) => {
|
||||
if (req.isAuthenticated()) return next()
|
||||
res.redirect('/')
|
||||
})
|
||||
|
||||
router.get('/vprasanje/admin/novo', consultancyAdmin.new)
|
||||
|
||||
router.get('/vprasanje/admin/uporabniki', consultancyAdmin.users)
|
||||
|
||||
router.get('/vprasanje/admin/zavrnjeno', consultancyAdmin.rejected)
|
||||
|
||||
router.get('/vprasanje/admin/objavljeno', consultancyAdmin.published)
|
||||
|
||||
router.get('/vprasanje/admin/pripravljeno', consultancyAdmin.prepared)
|
||||
|
||||
router.get('/vprasanje/admin/v-delu', consultancyAdmin.inProgress)
|
||||
|
||||
router.get('/vprasanje/admin/statistika', consultancyAdmin.statistics)
|
||||
|
||||
router.get('/vprasanje/admin/urejanje/:id', consultancyAdmin.edit)
|
||||
|
||||
module.exports = router
|
||||
@@ -0,0 +1,130 @@
|
||||
const router = require('express-promise-router')()
|
||||
const dictionary = require('../controllers/dictionaries')
|
||||
const user = require('../middleware/user')
|
||||
// const debug = require('debug')('termPortal:routers/dictionary')
|
||||
|
||||
// Show a list of user's dictionaries.
|
||||
router.get('/moji', dictionary.list)
|
||||
|
||||
router.get('/', dictionary.dictionaryList)
|
||||
|
||||
router.get('/:dictionaryId/o-slovarju', dictionary.dictionaryDetails)
|
||||
|
||||
// All further routes are only available to authenticated users.
|
||||
router.use((req, res, next) => {
|
||||
if (req.isAuthenticated()) return next()
|
||||
res.redirect(req.baseUrl)
|
||||
})
|
||||
|
||||
// Show a form to create a new dictionary.
|
||||
router.get('/nov', dictionary.new)
|
||||
|
||||
// Validate and create a new dictionary.
|
||||
router.post('/nov', dictionary.create)
|
||||
|
||||
// Show a form to add/edit the title and the description of a dictionary.
|
||||
router.get(
|
||||
'/:dictionaryId/podatki',
|
||||
user.isDictionaryAdmin,
|
||||
dictionary.editDescription
|
||||
)
|
||||
|
||||
// Validate and update existing dictionary title and description.
|
||||
router.post(
|
||||
'/:dictionaryId/podatki',
|
||||
user.isDictionaryAdmin,
|
||||
dictionary.updateDescription
|
||||
)
|
||||
|
||||
// Show a form to add/edit users of a dictionary and their roles.
|
||||
router.get(
|
||||
'/:dictionaryId/uporabniki',
|
||||
user.isDictionaryAdmin,
|
||||
dictionary.editUsers
|
||||
)
|
||||
|
||||
// Validate and update existing dictionary user settings.
|
||||
router.post(
|
||||
'/:dictionaryId/uporabniki',
|
||||
user.isDictionaryAdmin,
|
||||
dictionary.updateUsers
|
||||
)
|
||||
|
||||
// Show a form to edit the structure of a dictionary.
|
||||
router.get(
|
||||
'/:dictionaryId/struktura',
|
||||
user.isDictionaryAdmin,
|
||||
dictionary.editStructure
|
||||
)
|
||||
|
||||
// Validate and update existing dictionary structure.
|
||||
router.post(
|
||||
'/:dictionaryId/struktura',
|
||||
user.isDictionaryAdmin,
|
||||
dictionary.updateStructure
|
||||
)
|
||||
|
||||
// Show a form to create new or edit existing domain labels of the selected dictionary.
|
||||
router.get(
|
||||
'/:dictionaryId/podrocne-oznake',
|
||||
user.isDictionaryAdmin,
|
||||
dictionary.editDomainLabels
|
||||
)
|
||||
|
||||
// Show a form with advanced dictionary settings.
|
||||
router.get(
|
||||
'/:dictionaryId/napredno',
|
||||
user.isDictionaryAdmin,
|
||||
dictionary.editAdvanced
|
||||
)
|
||||
|
||||
// Show comments for the given dicitonary.
|
||||
router.get(
|
||||
'/:dictionaryId/komentarji',
|
||||
user.isDictionaryAdmin,
|
||||
dictionary.comments
|
||||
)
|
||||
|
||||
// Show a page to preview, create or edit dictionary entries and their comments.
|
||||
router.get(
|
||||
'/:dictionaryId/vsebina',
|
||||
user.isDictionaryEditor,
|
||||
dictionary.showContent
|
||||
)
|
||||
|
||||
// Validate and update dictionary content entries.
|
||||
// router.post(
|
||||
// '/:dictionaryId/vsebina',
|
||||
// user.isDictionaryEditor,
|
||||
// dictionary.updateContent
|
||||
// )
|
||||
|
||||
// Show a form to export a dictionary.
|
||||
router.get(
|
||||
'/:dictionaryId/izvoz',
|
||||
user.isDictionaryEditor,
|
||||
dictionary.showExportToFileForm
|
||||
)
|
||||
|
||||
// Show a form to import dictionary data from file.
|
||||
router.get(
|
||||
'/:dictionaryId/uvoz/datoteka',
|
||||
user.isDictionaryEditor,
|
||||
dictionary.showImportFromFileForm
|
||||
)
|
||||
|
||||
// Validate and import dictionary data from file.
|
||||
router.post(
|
||||
'/:dictionaryId/uvoz/datoteka',
|
||||
user.isDictionaryEditor,
|
||||
dictionary.importFromFile
|
||||
)
|
||||
|
||||
// Show a form to import dictionary data from extraction process.
|
||||
router.get(
|
||||
'/:dictionaryId/uvoz/luscenje',
|
||||
user.isDictionaryEditor,
|
||||
dictionary.showImportFromExtractionForm
|
||||
)
|
||||
|
||||
module.exports = router
|
||||
@@ -0,0 +1,27 @@
|
||||
const router = require('express-promise-router')()
|
||||
const extraction = require('../controllers/extraction-poc')
|
||||
|
||||
// TODO In final version test authentication and authorization.
|
||||
|
||||
// List all extractions.
|
||||
router.get('/', extraction.list)
|
||||
|
||||
// Create new extraction.
|
||||
router.post('/', extraction.create)
|
||||
|
||||
// Edit extraction.
|
||||
router.get('/:id', extraction.edit)
|
||||
|
||||
// Update extraction (own documents).
|
||||
router.post('/:id', extraction.updateOwn)
|
||||
|
||||
// Edit documents.
|
||||
router.get('/:id/besedila', extraction.docsEdit)
|
||||
|
||||
// Edit stop terms.
|
||||
router.get('/:id/stop-termini', extraction.stopTermsEdit)
|
||||
|
||||
// List term candidates for extraction and display export interface.
|
||||
router.get('/:id/kandidati', extraction.listTermCandidates)
|
||||
|
||||
module.exports = router
|
||||
@@ -0,0 +1,61 @@
|
||||
const router = require('express-promise-router')()
|
||||
const extraction = require('../controllers/extraction')
|
||||
const extractionPocRouter = require('./extraction-poc')
|
||||
|
||||
// List all extractions.
|
||||
router.get('/', extraction.list)
|
||||
|
||||
// All further routes are only available to authenticated users.
|
||||
router.use((req, res, next) => {
|
||||
if (req.isAuthenticated()) return next()
|
||||
res.redirect(req.baseUrl)
|
||||
})
|
||||
|
||||
// Create new extraction.
|
||||
router.post('/', extraction.create)
|
||||
|
||||
router.use('/poc', extractionPocRouter)
|
||||
|
||||
// Edit extraction.
|
||||
router.get('/:id', extraction.edit)
|
||||
|
||||
// Update extraction (own documents).
|
||||
router.post('/:id', extraction.updateOwn)
|
||||
|
||||
// Edit documents.
|
||||
router.get('/:id/besedila', extraction.docsEdit)
|
||||
|
||||
// Edit stop terms.
|
||||
router.get('/:id/stop-termini', extraction.stopTermsEdit)
|
||||
|
||||
// List term candidates for extraction and display export interface.
|
||||
router.get('/:id/kandidati', extraction.listTermCandidates)
|
||||
|
||||
// // TODO: Ask Luka or Miro what to do with this page.
|
||||
// router.get('/id_luscenja/kandidati', (req, res) => {
|
||||
// res.render('pages/extraction/terms', {
|
||||
// title: 'Terminološki kandidati'
|
||||
// })
|
||||
// })
|
||||
|
||||
// // Show a form to export a dictionary
|
||||
// router.get('/id_luscenja/dokumenti/besedila', (req, res) => {
|
||||
// res.render('pages/extraction/docs-edit', {
|
||||
// title: 'Besedila'
|
||||
// })
|
||||
// })
|
||||
|
||||
// // Show a form to export a dictionary
|
||||
// router.get('/id_luscenja/oss', (req, res) => {
|
||||
// res.render('pages/extraction/edit-oss', {
|
||||
// title: 'KAS + dokumenti'
|
||||
// })
|
||||
// })
|
||||
|
||||
// router.get('/id_luscenja/dokumenti/termini', (req, res) => {
|
||||
// res.render('pages/extraction/stop-terms-edit', {
|
||||
// title: 'Termini'
|
||||
// })
|
||||
// })
|
||||
|
||||
module.exports = router
|
||||
@@ -0,0 +1,116 @@
|
||||
const router = require('express-promise-router')()
|
||||
const db = require('../models/db')
|
||||
const cache = require('../models/cache')
|
||||
const { searchEngineClient } = require('../models/search-engine')
|
||||
const index = require('../controllers/index')
|
||||
const user = require('../controllers/users')
|
||||
const demoPaginacija = require('../controllers/demo-paginacija')
|
||||
|
||||
// TODO Some of these endpoints might need authorization protection. Review and clean up at a later point.
|
||||
|
||||
/* GET home page. */
|
||||
router.get('/', index.index)
|
||||
|
||||
// Show a list of search results.
|
||||
router.get('/iskanje', index.search)
|
||||
|
||||
// Show a list of search results.
|
||||
router.get('/termin/:entryId', index.entryDetails)
|
||||
|
||||
/*
|
||||
router.get('/termin/id_termina', (req, res) => {
|
||||
res.render('pages/search/result-detail')
|
||||
})
|
||||
*/
|
||||
|
||||
router.get('/keys', (req, res) => {
|
||||
res.render('pages/search/special-keys-demo-rm-this')
|
||||
})
|
||||
|
||||
router.get('/demo', (req, res) => {
|
||||
res.render('pages/admin')
|
||||
})
|
||||
|
||||
router.get('/select', (req, res) => {
|
||||
res.render('pages/search-root')
|
||||
})
|
||||
|
||||
router.get('/dictionaries', (req, res) => {
|
||||
res.render('pages/my-dictionaries-root')
|
||||
})
|
||||
|
||||
router.get('/db-query-demo', async (req, res) => {
|
||||
const queryResult = await db.query("SELECT 'yes' as does_it_work")
|
||||
res.send(queryResult.rows[0])
|
||||
})
|
||||
|
||||
router.get('/test-seje', (req, res) => {
|
||||
// req.session.before = { a: 1, b: 'yes' }
|
||||
const { sessionID, session } = req
|
||||
// req.session.after = { c: 2, d: 'no' }
|
||||
res.send({ sessionID, session })
|
||||
})
|
||||
|
||||
router.get('/test-cacha', async (req, res, next) => {
|
||||
const sRes = await cache.set('my key', 'also my val')
|
||||
const gRes = await cache.get('my key')
|
||||
res.send({ sRes, gRes })
|
||||
})
|
||||
|
||||
router.get('/test-iskalnika', async (req, res) => {
|
||||
const response = await searchEngineClient.ping()
|
||||
res.send(response)
|
||||
})
|
||||
|
||||
// Stran z demo implementacijo paginirane vsebine.
|
||||
router.get('/demo-paginacija', demoPaginacija.izrišiStran)
|
||||
|
||||
// Render help page
|
||||
router.get('/pomoc', (req, res) => {
|
||||
res.render('pages/help', { title: 'Pomoč' })
|
||||
})
|
||||
|
||||
// Create a route to download pdf
|
||||
router.get('/pomoc/pdf', (req, res) => {
|
||||
res.download('public/documents/Podrocja_TP_2022-11-28.pdf')
|
||||
})
|
||||
|
||||
// Create a route to download guidance pdf
|
||||
router.get('/pomoc/guidance-pdf', (req, res) => {
|
||||
res.download('public/documents/RSDO_smernice.pdf')
|
||||
})
|
||||
|
||||
// Render demo help pug page.
|
||||
router.get('/pomoc-pug-demo', (req, res) => {
|
||||
res.render('pages/help-pug-demo-frame', { title: 'Pomoč - pug demo' })
|
||||
})
|
||||
|
||||
// Activate user account.
|
||||
router.get('/users/activate', user.activateAccount)
|
||||
|
||||
// Log the user out.
|
||||
router.post('/users/logout', user.logout)
|
||||
|
||||
// Render privacy policy page
|
||||
router.get('/politika-zasebnosti', (req, res) => {
|
||||
res.render('pages/privacy-policy', { title: 'Politika zasebnosti' })
|
||||
})
|
||||
|
||||
// Render terms of use page
|
||||
router.get('/pogoji-uporabe', (req, res) => {
|
||||
res.render('pages/terms-of-use', { title: 'Pogoji uporabe' })
|
||||
})
|
||||
|
||||
// All routes require an authenticated user.
|
||||
router.use((req, res, next) => {
|
||||
if (req.isAuthenticated()) return next()
|
||||
res.redirect('/')
|
||||
})
|
||||
|
||||
router.get('/moj-racun', index.myProfile)
|
||||
|
||||
router.get('/spremeni-geslo', index.changePassword)
|
||||
|
||||
router.get('/nastavitve-racuna', index.userSettings)
|
||||
|
||||
module.exports = router
|
||||
Reference in New Issue
Block a user