Skip to content
49 changes: 25 additions & 24 deletions src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ export default {
const whichTheme = ref(`${import.meta.env.VITE_APP_THEME}`.length === 0 ? 'red' : `${import.meta.env.VITE_APP_THEME}`)
const theme = ref('')
const customCss = shallowRef({})
const cssPath = ref('')

const dtsRootCollectionId = ref('')
const rootCollectionIdentifier = ref('')
Expand All @@ -116,39 +115,40 @@ export default {
// localStorage.setItem('theme', whichTheme.value)
console.log('App.vue setup theme : ', whichTheme.value)

const mergeSettings = () => {
const appSettings = import.meta.glob('confs/*.conf.json', { eager: true })
const mergeSettings = async () => {
// convert configuration pathes to collection names (e.g. '${VITE_APP_CUSTOM_SETTINGS_PATH}/theater.conf.json' -> theater
const appSettings = Object.fromEntries(Object.entries(import.meta.glob('confs/*.conf.json', { eager: true })).map(([key, value])=> {
const newKey = key.split("/").at(-1).replace(".conf.json", "")
return [newKey, value]
}));
console.log('App.vue setup appSettings', appSettings)
const appCssSettings = import.meta.glob('confs/*.conf.css', { eager: true })
console.log('App.vue setup appCssSettings', appCssSettings)

const defaultSettings = import.meta.glob('./settings/default.conf.json', { eager: true })
appSettings['./settings/default.conf.json'] = defaultSettings['./settings/default.conf.json']
const defaultSettings = await import('./settings/default.conf.json')
appSettings.default = defaultSettings

// Check if a default custom collection exists in Custom settings
let defaultCustomSettings = {}
if (`${import.meta.env.VITE_APP_CUSTOM_SETTINGS_PATH}`.length > 0) {
defaultCustomSettings = import.meta.glob('confs/custom.conf.json', { eager: true })
defaultCustomSettings = Object.entries(import.meta.glob("confs/custom.conf.json", { eager: true})).map(([key, value]) => value)[0]
console.log('App.vue setup defaultCustomSettings', defaultCustomSettings)
appSettings['./settings/default.conf.json'] = defaultCustomSettings ? _.merge({}, appSettings['./settings/default.conf.json'], defaultCustomSettings[`${import.meta.env.VITE_APP_CUSTOM_SETTINGS_PATH}/custom.conf.json`]) : appSettings['./settings/default.conf.json']
console.log('App.vue setup appSettings[\'./settings/default.conf.json\'] updated with custom default', appSettings['./settings/default.conf.json'])
appSettings.default = defaultCustomSettings ? _.merge({}, appSettings.default, defaultCustomSettings) : appSettings.default
console.log('App.vue setup appSettings.default updated with custom default', appSettings.default)
}
const defaultMatch = appSettings['./settings/default.conf.json'].default
const defaultMatch = appSettings.default.default
defaultMatch.collectionId = rootCollectionIdentifier.value
Object.assign(appConfig.value, defaultMatch)
console.log('App.vue setup defaultMatch', defaultMatch)
console.log('App.vue setup appConfig.value', appConfig.value)
// delete appSettings['./settings/default.conf.json']
console.log('App.vue setup appSettings after update', appSettings)
console.log('App.vue setup appSettings after update 1', appSettings)
appConfig.value.collectionsConf = []
appConfig.value.collectionsConf.push(appSettings['./settings/default.conf.json'].default.genericConf)
delete appSettings['./settings/default.conf.json']
console.log('App.vue setup appSettings after update', appSettings)
appConfig.value.collectionsConf.push(appSettings.default.default.genericConf)
delete appSettings.default
console.log('App.vue setup appSettings after update 2', appSettings)
for (let i = 0; i < Object.keys(appSettings).length; i += 1) {
console.log('App.vue setup appSettings collection iteration', appSettings[Object.keys(appSettings)[i]])
appConfig.value.collectionsConf.push(appSettings[Object.keys(appSettings)[i]])
}
console.log('App.vue setup appConfig.value after update', appConfig.value)
console.log('App.vue setup appConfig.value after update 3', appConfig.value)
}

const getDtsRootResponse = async (source) => {
Expand Down Expand Up @@ -200,7 +200,7 @@ export default {
const getCurrentCollection = async (route) => {
console.log('App.vue getCurrentCollection origin route', origin, route)
console.log('this is where it fails')
mergeSettings()
await mergeSettings()
let metadataResponse = {}
if (rootCollectionIdentifier.value === dtsRootCollectionId.value && rootCollectionIdentifier.value === collectionId.value) {
metadataResponse = await fetchMetadata('app.vue getCurrentCollection fetchMetadata (no id)', null, 'Collection', route)
Expand Down Expand Up @@ -235,15 +235,17 @@ export default {

const getCustomCss = async () => {
if (collConfig.value.collectionCustomCss) {
const appCssConfs = import.meta.glob('confs/**/*.customCss.css', { eager: false })
console.log('App.vue getCustomCss appCssConfs', appCssConfs)
const appCssConfs = Object.fromEntries(Object.entries(import.meta.glob('confs/**/*.customCss.css', { eager: false })).map(([key, value]) => {
const newKey = key.split("/").at(-1).replace(".customCss.css", "")
return [newKey, value]
}))
console.log('App.vue getCustomCss appCssConfs ', appCssConfs)
console.log('App.vue getCustomCss collConfig.value.collectionCustomCss', collConfig.value.collectionCustomCss)
console.log('App.vue getCustomCss get in if')
cssPath.value = `confs/${collConfig.value.collectionId}/assets/css/${collConfig.value.collectionId}.customCss.css`
console.log('App.vue getCustomCss path', `${import.meta.env.VITE_APP_CUSTOM_SETTINGS_PATH}/${collConfig.value.collectionId}/assets/css/${collConfig.value.collectionId}.customCss.css`)

if (collConfig.value.collectionCustomCss && appCssConfs[`${import.meta.env.VITE_APP_CUSTOM_SETTINGS_PATH}/${collConfig.value.collectionCustomCss}/assets/css/${collConfig.value.collectionCustomCss}.customCss.css`]) {
console.log('App.vue getCustomCss from collection and customCss exists : ', collConfig.value.collectionCustomCss, appCssConfs[`${import.meta.env.VITE_APP_CUSTOM_SETTINGS_PATH}/${collConfig.value.collectionCustomCss}/assets/css/${collConfig.value.collectionCustomCss}.customCss.css`])
if (collConfig.value.collectionCustomCss && appCssConfs[collConfig.value.collectionId]) {
console.log('App.vue getCustomCss from collection and customCss exists : ', collConfig.value.collectionCustomCss, appCssConfs[collConfig.value.collectionId])
customCss.value = await import(`confs/${collConfig.value.collectionCustomCss}/assets/css/${collConfig.value.collectionCustomCss}.customCss.css?raw`)
const style = document.createElement('style')
style.textContent = customCss.value.default
Expand Down Expand Up @@ -570,7 +572,6 @@ export default {
getBreadcrumb,
breadCrumb,
mergeSettings,
cssPath,
getCustomCss,
removeCustomCss
}
Expand Down
43 changes: 22 additions & 21 deletions src/components/AppNavbar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ import { ref, computed, onMounted, onBeforeUnmount, reactive, watch } from 'vue'
import Burger from './Burger.vue'
import { useRoute } from 'vue-router'
import { useStore } from 'vuex'
import defaultLogo from '@/assets/images/logo_dots_circle.svg'

export default {
name: 'AppNavbar',
Expand Down Expand Up @@ -190,7 +191,10 @@ export default {
) {
console.log('AppNavbar ImgUrl found : ', sourceConfig.homePageSettings.appNavBar.appNavBarLogo.imgName)
// Get all images from the settings repo
const images = import.meta.glob('confs/*/assets/images/*.*', { eager: true })
const images = Object.fromEntries(Object.entries(import.meta.glob('confs/*/assets/images/*.*', { eager: true })).map(([key, value]) => {
const newKey = key.split("/").slice(-4).join("/")
return [newKey, value]
}))
console.log('AppNavbar ImgUrl images: ', images)

// If the AppNavBar image is not defined on the collection, need to identify the root collection image path where it may be defined
Expand All @@ -202,18 +206,15 @@ export default {
// If an AppNavBar image is set on the root collection, set it as rootCollImg to be used
if (rootCollConfig.value) {
console.log('AppNavbar ImgUrl rootCollConfig : ', rootCollConfig)
rootCollImg = images[`${import.meta.env.VITE_APP_CUSTOM_SETTINGS_PATH}/${rootCollectionId.value}/assets/images/${rootCollConfig.value.homePageSettings.appNavBar.appNavBarLogo.imgName}`]
rootCollImg = images[`${rootCollectionId.value}/assets/images/${rootCollConfig.value.homePageSettings.appNavBar.appNavBarLogo.imgName}`]
console.log('AppNavbar ImgUrl rootCollImg : ', rootCollImg)
}
// Setting the default AppNavBar image (dots) if none is defined at root or collection level
const defaultSettings = import.meta.glob('@/assets/images/logo_dots_circle.svg', { eager: true })
console.log('AppNavbar ImgUrl defaultSettings: ', defaultSettings)
images['/src/assets/images/logo_dots_circle.svg'] = defaultSettings['/src/assets/images/logo_dots_circle.svg']
images.default = defaultLogo

// Match the collection AppNavBar image if any
const match = images[`${import.meta.env.VITE_APP_CUSTOM_SETTINGS_PATH}/${sourceConfig.collectionId}/assets/images/${sourceConfig.homePageSettings.appNavBar.appNavBarLogo.imgName}`]
const match = images[`${sourceConfig.collectionId}/assets/images/${sourceConfig.homePageSettings.appNavBar.appNavBarLogo.imgName}`]
console.log('AppNavbar ImgUrl match: ', match)
const defaultImg = images['/src/assets/images/logo_dots_circle.svg']
// Use the collection AppNavBar image if any
if (match) {
if (sourceConfig.homePageSettings.appNavBar.appNavBarLogo.imgName.includes('https')) {
Expand All @@ -238,16 +239,16 @@ export default {
return rootCollImg.default
}
// Otherwise use the default (dots) AppNavBar image
} else if (defaultImg) {
} else {
if (sourceConfig.homePageSettings.appNavBar.appNavBarLogo.imgName.includes('https')) {
imgHref.value = sourceConfig.homePageSettings.appNavBar.appNavBarLogo.href
return sourceConfig.homePageSettings.appNavBar.appNavBarLogo.imgName
} else {
imgHref.value = sourceConfig.homePageSettings.appNavBar.appNavBarLogo.href
console.log('AppNavbar ImgUrl default appNavBarLogo.imgName : ', `${sourceConfig.homePageSettings.appNavBar.appNavBarLogo.imgName}`)
console.log('AppNavbar ImgUrl default imgHref.value : ', imgHref.value)
console.log('AppNavbar ImgUrl default defaultImg : ', defaultImg)
return defaultImg.default
console.log('AppNavbar ImgUrl default defaultLogo : ', defaultLogo)
return defaultLogo
}
}
} else {
Expand All @@ -263,7 +264,10 @@ export default {
) {
console.log('AppNavbar apiImgUrl found : ', sourceConfig.homePageSettings.appNavBar.appNavBarApiLogo.imgName)
// Get all images from the settings repo
const images = import.meta.glob('confs/*/assets/images/*.*', { eager: true })
const images = Object.fromEntries(Object.entries(import.meta.glob('confs/*/assets/images/*.*', { eager: true })).map(([key, value]) => {
const newKey = key.split("/").slice(-4).join("/")
return [newKey, value]
}))
console.log('AppNavbar apiImgUrl images: ', images)

// If the AppNavBar image is not defined on the collection, need to identify the root collection image path where it may be defined
Expand All @@ -275,18 +279,15 @@ export default {
// If an AppNavBar image is set on the root collection, set it as rootCollImg to be used
if (rootCollConfig.value) {
console.log('AppNavbar apiImgUrl rootCollConfig.value : ', rootCollConfig.value)
rootCollImg = images[`${import.meta.env.VITE_APP_CUSTOM_SETTINGS_PATH}/${rootCollectionId.value}/assets/images/${rootCollConfig.value.homePageSettings.appNavBar.appNavBarApiLogo.imgName}`]
rootCollImg = images[`${rootCollectionId.value}/assets/images/${rootCollConfig.value.homePageSettings.appNavBar.appNavBarApiLogo.imgName}`]
console.log('AppNavbar apiImgUrl rootCollImg : ', rootCollImg)
}
// Setting the default AppNavBar image (dots) if none is defined at root or collection level
const defaultSettings = import.meta.glob('@/assets/images/logo_dots_circle.svg')
console.log('AppNavbar apiImgUrl defaultSettings: ', defaultSettings)
images['/src/assets/images/logo_dots_circle.svg'] = defaultSettings['/src/assets/images/logo_dots_circle.svg']
images.defaultLogo = defaultLogo

// Match the collection AppNavBar image if any
const match = images[`${import.meta.env.VITE_APP_CUSTOM_SETTINGS_PATH}/${sourceConfig.collectionId}/assets/images/${sourceConfig.homePageSettings.appNavBar.appNavBarApiLogo.imgName}`]
const match = images[`${sourceConfig.collectionId}/assets/images/${sourceConfig.homePageSettings.appNavBar.appNavBarApiLogo.imgName}`]
console.log('AppNavbar apiImgUrl match: ', match)
const defaultImg = images['/src/assets/images/logo_dots_circle.svg']
// Use the collection AppNavBar image if any
if (match) {
if (sourceConfig.homePageSettings.appNavBar.appNavBarApiLogo.imgName.includes('https')) {
Expand All @@ -295,7 +296,7 @@ export default {
} else {
apiImgHref.value = sourceConfig.homePageSettings.appNavBar.appNavBarApiLogo.href
console.log('AppNavbar apiImgUrl apiImgHref.value : ', apiImgHref.value)
console.log('AppNavbar apiImgUrl match : ', match)
console.log('AppNavbar apiImgUrl match 2: ', match)
return match.default
}
// Otherwise use the root collection AppNavBar image if any
Expand All @@ -311,16 +312,16 @@ export default {
return rootCollImg.default
}
// Otherwise use the default (dots) AppNavBar image
} else if (defaultImg) {
} else {
if (sourceConfig.homePageSettings.appNavBar.appNavBarApiLogo.imgName.includes('https')) {
apiImgHref.value = sourceConfig.homePageSettings.appNavBar.appNavBarApiLogo.href
return sourceConfig.homePageSettings.appNavBar.appNavBarApiLogo.imgName
} else {
apiImgHref.value = sourceConfig.homePageSettings.appNavBar.appNavBarApiLogo.href
console.log('AppNavbar apiImgUrl default appNavBarLogo.imgName : ', `${sourceConfig.homePageSettings.appNavBar.appNavBarApiLogo.imgName}`)
console.log('AppNavbar apiImgUrl default apiImgHref.value : ', apiImgHref.value)
console.log('AppNavbar apiImgUrl default defaultImg : ', defaultImg)
return defaultImg.default
console.log('AppNavbar apiImgUrl default defaultLogo : ', defaultLogo)
return defaultLogo
}
}
} else {
Expand Down
9 changes: 6 additions & 3 deletions src/components/CollectionTOC.vue
Original file line number Diff line number Diff line change
Expand Up @@ -471,9 +471,12 @@ export default {
&& imgSourceConfig.homePageSettings.listSection && Object.keys(imgSourceConfig.homePageSettings.listSection).includes('logo')
&& imgSourceConfig.homePageSettings.listSection.logo.length) {
// console.log('HomePage ImgUrl found : ', imgSourceConfig.homePageSettings.listSection.logo)
const images = import.meta.glob('confs/*/assets/images/*.*', { eager: true })
// console.log('HomePage ImgUrl images: ', images)
const match = images[`${import.meta.env.VITE_APP_CUSTOM_SETTINGS_PATH}/${imgSourceConfig.collectionId}/assets/images/${imgSourceConfig.homePageSettings.listSection.logo}`]
const images = Object.fromEntries(Object.entries(import.meta.glob('confs/*/assets/images/*.*', { eager: true })).map(([key, value]) => {
const newKey = key.split("/").slice(-4).join("/")
return [newKey, value]
}))
console.log('HomePage ImgUrl images: ', images)
const match = images[`${imgSourceConfig.collectionId}/assets/images/${imgSourceConfig.homePageSettings.listSection.logo}`]
// console.log('HomePage ImgUrl match: ', match)
if (imgSourceConfig.homePageSettings.listSection.logo.includes('https')) {
return imgSourceConfig.homePageSettings.listSection.logo
Expand Down
9 changes: 6 additions & 3 deletions src/views/AboutPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,13 @@ export default {
let component
console.log('AboutPage collConfig.value.collectionId', collConfig.value.collectionId)
console.log('AboutPage collConfig.value.aboutPageSettings', collConfig.value.aboutPageSettings)
const comps = import.meta.glob('confs/**/*.vue')
const comps = Object.fromEntries(Object.entries(import.meta.glob('confs/*/*.vue')).map(([key, value])=> {
const newKey = key.split("/").slice(-2).join("/")
return [newKey, value]
}))
console.log('comps test : ', comps)
const match = comps[`${import.meta.env.VITE_APP_CUSTOM_SETTINGS_PATH}/${collConfig.value.collectionId}/${aboutSettings.value[i].compName}.vue`]
const matchRootCollection = comps[`${import.meta.env.VITE_APP_CUSTOM_SETTINGS_PATH}/${rootCollectionId.value}/${aboutSettings.value[i].compName}.vue`]
const match = comps[`${collConfig.value.collectionId}/${aboutSettings.value[i].compName}.vue`]
const matchRootCollection = comps[`${rootCollectionId.value}/${aboutSettings.value[i].compName}.vue`]
// matching About pages for exact collection if defined
console.log('match test : ', match)
if (match) {
Expand Down
7 changes: 5 additions & 2 deletions src/views/HomePage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -364,9 +364,12 @@ export default {
&& sourceConfig.homePageSettings.listSection && Object.keys(sourceConfig.homePageSettings.listSection).includes('logo')
&& sourceConfig.homePageSettings.listSection.logo.length) {
console.log('HomePage ImgUrl found : ', sourceConfig.homePageSettings.listSection.logo)
const images = import.meta.glob('confs/*/assets/images/*.*', { eager: true })
const images = Object.fromEntries(Object.entries(import.meta.glob('confs/*/assets/images/*.*', { eager: true })).map(([key, value]) => {
const newKey = key.split("/").slice(-4).join("/")
return [newKey, value]
}))
console.log('HomePage ImgUrl images: ', images)
const match = images[`${import.meta.env.VITE_APP_CUSTOM_SETTINGS_PATH}/${sourceConfig.collectionId}/assets/images/${sourceConfig.homePageSettings.listSection.logo}`]
const match = images[`${sourceConfig.collectionId}/assets/images/${sourceConfig.homePageSettings.listSection.logo}`]
console.log('HomePage ImgUrl match: ', match)
if (sourceConfig.homePageSettings.listSection.logo.includes('https')) {
return sourceConfig.homePageSettings.listSection.logo
Expand Down