mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-11-12 21:23:45 +01:00
Make Template Gallery optional; rename environment variables
Refactor Template Gallery; resolves #38 and #39:
- replace free-text license input with a select box
- improve visual presentation of modals and enhance keyboard interaction
Template Gallery: replace markdown-it with marked
Fix template publishing to align with upstream project context changes
Template gallery: ui components were moved to shared folder
Fix style of Templates button in navbar
Template gallery: Fix `OLModal` usage (see upstream commit 19b3834)
Template gallery: Fix import after upstream converted `CompileManager`, `ClsiManager` and `RateLimiterMiddleware` to ESM
Template gallery: Fix import after upstream converted `AuthenticationController`, `ProjectGetter`, ProjectLocator` and `DocumentUpdaterHandler` to ESM
Template Gallery: migration to 6.1.0
- enable menu for editor redisign
- move frontend code to modules
Template gallery: add template management authorization middleware
- middleware to enforce template access rules
- introduce template manager role
- fix minor issues
Template Gallery: fix for 6.2.0
Template Gallery: fix for 6.3.0 and show language in the details
44 lines
1.3 KiB
JavaScript
44 lines
1.3 KiB
JavaScript
import Settings from '@overleaf/settings'
|
|
import TemplateGalleryRouter from './app/src/TemplateGalleryRouter.mjs'
|
|
|
|
function boolFromEnv(env) {
|
|
if (env === undefined || env === null) return undefined
|
|
if (typeof env === "string") {
|
|
const envLower = env.toLowerCase()
|
|
if (envLower === 'true') return true
|
|
if (envLower === 'false') return false
|
|
}
|
|
throw new Error("Invalid value for boolean environment variable")
|
|
}
|
|
|
|
let TemplateGalleryModule = {}
|
|
|
|
if (process.env.OVERLEAF_TEMPLATE_GALLERY === 'true') {
|
|
TemplateGalleryModule = {
|
|
router: TemplateGalleryRouter,
|
|
}
|
|
|
|
Settings.templates = {
|
|
nonAdminCanManage: boolFromEnv(process.env.OVERLEAF_NON_ADMIN_CAN_PUBLISH_TEMPLATES),
|
|
user_id: process.env.OVERLEAF_TEMPLATES_USER_ID
|
|
}
|
|
|
|
const templateKeys = process.env.OVERLEAF_TEMPLATE_CATEGORIES
|
|
? process.env.OVERLEAF_TEMPLATE_CATEGORIES + ' all'
|
|
: 'all'
|
|
|
|
Settings.templateLinks = templateKeys.split(/\s+/).map(key => {
|
|
const envKeyBase = key.toUpperCase().replace(/-/g, "_")
|
|
const name = process.env[`TEMPLATE_${envKeyBase}_NAME`] || ( key === 'all' ? 'All templates' : key)
|
|
const description = process.env[`TEMPLATE_${envKeyBase}_DESCRIPTION`] || ''
|
|
|
|
return {
|
|
name,
|
|
url: `/templates/${key}`,
|
|
description
|
|
}
|
|
})
|
|
}
|
|
|
|
export default TemplateGalleryModule
|