mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-05-23 17:19:37 +02:00
Make Template Gallery optional; rename environment variables
This commit is contained in:
@@ -407,7 +407,7 @@ export default async function (webRouter, privateApiRouter, publicApiRouter) {
|
||||
labsEnabled: Settings.labs && Settings.labs.enable,
|
||||
wikiEnabled: Settings.overleaf != null || Settings.proxyLearn,
|
||||
templatesEnabled:
|
||||
Settings.overleaf != null || Boolean(Settings.moduleImportSequence.includes('template-gallery')),
|
||||
Settings.overleaf != null || Boolean(Settings.templates),
|
||||
cioWriteKey: Settings.analytics?.cio?.writeKey,
|
||||
cioSiteId: Settings.analytics?.cio?.siteId,
|
||||
}
|
||||
|
||||
@@ -67,7 +67,7 @@ const Features = {
|
||||
case 'oauth':
|
||||
return Boolean(Settings.oauth)
|
||||
case 'templates-server-pro':
|
||||
return Boolean(Settings.moduleImportSequence.includes('template-gallery'))
|
||||
return Boolean(Settings.templates)
|
||||
case 'affiliations':
|
||||
case 'analytics':
|
||||
return Boolean(_.get(Settings, ['apis', 'v1', 'url']))
|
||||
|
||||
@@ -150,15 +150,16 @@ nav.navbar.navbar-default.navbar-main.navbar-expand-lg(
|
||||
// logged out
|
||||
if !getSessionUser()
|
||||
// templates link
|
||||
li
|
||||
a(
|
||||
href="/templates"
|
||||
event-tracking="menu-click"
|
||||
event-tracking-action="clicked"
|
||||
event-tracking-trigger="click"
|
||||
event-tracking-mb="true"
|
||||
event-segmentation={ page: currentUrl, item: 'templates', location: 'top-menu' }
|
||||
) #{translate('templates')}
|
||||
if settings.templates
|
||||
li
|
||||
a(
|
||||
href="/templates"
|
||||
event-tracking="menu-click"
|
||||
event-tracking-action="clicked"
|
||||
event-tracking-trigger="click"
|
||||
event-tracking-mb="true"
|
||||
event-segmentation={ page: currentUrl, item: 'templates', location: 'top-menu' }
|
||||
) #{translate('templates')}
|
||||
|
||||
// register link
|
||||
if hasFeature('registration-page')
|
||||
|
||||
@@ -5,6 +5,8 @@ export default function GalleryPopularTags() {
|
||||
const { t } = useTranslation()
|
||||
const { templateLinks } = getMeta('ol-ExposedSettings') || []
|
||||
|
||||
if(!templateLinks || templateLinks.length < 2) return null
|
||||
|
||||
return (
|
||||
<div className="popular-tags">
|
||||
<h1>{t('categories')}</h1>
|
||||
|
||||
@@ -29,7 +29,7 @@ function TemplatePageContent() {
|
||||
const footerProps = getMeta('ol-footer')
|
||||
const { template } = useTemplateContext()
|
||||
const { templateLinks } = getMeta('ol-ExposedSettings') || []
|
||||
const categoryName = templateLinks?.find(link => link.url === template.category)?.name || t('all_templates')
|
||||
const categoryName = templateLinks?.find(link => link.url === template.category)?.name
|
||||
|
||||
return (
|
||||
<>
|
||||
@@ -38,15 +38,15 @@ function TemplatePageContent() {
|
||||
<div className="container">
|
||||
<OLRow className="previous-page-link-container">
|
||||
<OLCol lg={6}>
|
||||
<a className="previous-page-link" href={template.category}>
|
||||
<a className="previous-page-link" href={'/templates/all'}>
|
||||
<i className="material-symbols material-symbols-rounded" aria-hidden="true">arrow_left_alt</i>
|
||||
{categoryName}
|
||||
{t('all_templates')}
|
||||
</a>
|
||||
{template.category !== '/templates/all' && (
|
||||
{categoryName && template.category !== '/templates/all' && (
|
||||
<>
|
||||
<span className="mx-2">/</span>
|
||||
<a className="previous-page-link" href={'/templates/all'}>
|
||||
{t('all_templates')}
|
||||
<a className="previous-page-link" href={template.category}>
|
||||
{categoryName}
|
||||
</a>
|
||||
</>
|
||||
)}
|
||||
|
||||
@@ -4,6 +4,7 @@ import type { NavbarSessionUser } from '@/shared/components/types/navbar'
|
||||
import NavLinkItem from '@/shared/components/navbar/nav-link-item'
|
||||
import { AccountMenuItems } from './account-menu-items'
|
||||
import { useSendProjectListMB } from '@/features/project-list/components/project-list-events'
|
||||
import getMeta from '@/utils/meta'
|
||||
|
||||
export default function LoggedInItems({
|
||||
sessionUser,
|
||||
@@ -14,14 +15,18 @@ export default function LoggedInItems({
|
||||
}) {
|
||||
const { t } = useTranslation()
|
||||
const sendProjectListMB = useSendProjectListMB()
|
||||
const { templatesEnabled } = getMeta('ol-ExposedSettings')
|
||||
|
||||
return (
|
||||
<>
|
||||
<NavLinkItem href="/project" className="nav-item-projects">
|
||||
{t('projects')}
|
||||
</NavLinkItem>
|
||||
<NavLinkItem href="/templates" className="nav-item-templates">
|
||||
{t('templates')}
|
||||
</NavLinkItem>
|
||||
{templatesEnabled && (
|
||||
<NavLinkItem href="/templates" className="nav-item-templates">
|
||||
{t('templates')}
|
||||
</NavLinkItem>
|
||||
)}
|
||||
<NavDropdownMenu
|
||||
title={t('Account')}
|
||||
className="nav-item-account"
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import NavLinkItem from '@/shared/components/navbar/nav-link-item'
|
||||
import { useSendProjectListMB } from '@/features/project-list/components/project-list-events'
|
||||
import getMeta from '@/utils/meta'
|
||||
|
||||
export default function LoggedOutItems({
|
||||
showSignUpLink,
|
||||
@@ -9,12 +10,15 @@ export default function LoggedOutItems({
|
||||
}) {
|
||||
const { t } = useTranslation()
|
||||
const sendMB = useSendProjectListMB()
|
||||
const { templatesEnabled } = getMeta('ol-ExposedSettings')
|
||||
|
||||
return (
|
||||
<>
|
||||
<NavLinkItem href="/templates" className="nav-item-templates">
|
||||
{t('templates')}
|
||||
</NavLinkItem>
|
||||
{templatesEnabled && (
|
||||
<NavLinkItem href="/templates" className="nav-item-templates">
|
||||
{t('templates')}
|
||||
</NavLinkItem>
|
||||
)}
|
||||
{showSignUpLink ? (
|
||||
<NavLinkItem
|
||||
href="/register"
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
import Settings from '@overleaf/settings'
|
||||
import TemplateGalleryRouter from './app/src/TemplateGalleryRouter.mjs'
|
||||
const TemplateGalleryModule = {
|
||||
router: TemplateGalleryRouter,
|
||||
}
|
||||
|
||||
function boolFromEnv(env) {
|
||||
if (env === undefined || env === null) return undefined
|
||||
@@ -11,23 +8,35 @@ function boolFromEnv(env) {
|
||||
if (envLower === 'true') return true
|
||||
if (envLower === 'false') return false
|
||||
}
|
||||
throw new Error("Invalid value for boolean envirionment variable")
|
||||
throw new Error("Invalid value for boolean environment variable")
|
||||
}
|
||||
|
||||
Settings.templates = {
|
||||
nonAdminCanManage: boolFromEnv(process.env.OVERLEAF_NON_ADMIN_CAN_MANAGE_TEMPLATES)
|
||||
}
|
||||
let TemplateGalleryModule = {}
|
||||
|
||||
Settings.templateLinks = (`${process.env.OVERLEAF_TEMPLATE_KEYS} all`).split(/\s+/).map(key => {
|
||||
const envKeyBase = key.toUpperCase().replace(/-/g, "_")
|
||||
const name = process.env[`TEMPLATE_${envKeyBase}_NAME`]
|
||||
const description = process.env[`TEMPLATE_${envKeyBase}_DESCRIPTION`]
|
||||
|
||||
return {
|
||||
name: name || key,
|
||||
url: `/templates/${key}`,
|
||||
description: description || "Templates category"
|
||||
if (process.env.OVERLEAF_TEMPLATE_GALLERY === 'true') {
|
||||
TemplateGalleryModule = {
|
||||
router: TemplateGalleryRouter,
|
||||
}
|
||||
})
|
||||
|
||||
Settings.templates = {
|
||||
nonAdminCanManage: boolFromEnv(process.env.OVERLEAF_NON_ADMIN_CAN_PUBLISH_TEMPLATES)
|
||||
}
|
||||
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user