X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=src%2FApp.vue;h=d97df0cc18d1f5ad5ff1af3ba5f8c8b1a059619c;hb=d1b29caaa62ef19e9dd68babf334ec25a966f945;hp=b13b98ff7e8a2029405e148861a423a9d95fe0a4;hpb=ae73d7a5a0a3ae38c99f30b85275b3b253f0bd08;p=github%2Fbastienwirtz%2Fhomer.git diff --git a/src/App.vue b/src/App.vue index b13b98f..d97df0c 100644 --- a/src/App.vue +++ b/src/App.vue @@ -14,7 +14,7 @@
{{ config.subtitle }} @@ -26,7 +26,7 @@ @@ -40,9 +40,9 @@
@@ -51,7 +51,7 @@
@@ -150,16 +150,36 @@ export default { }, created: async function () { const defaults = jsyaml.load(defaultConfig); - let config = await this.getConfig(); + let config; + try { + config = await this.getConfig(); + } catch (error) { + console.log(error); + config = this.handleErrors("⚠️ Error loading configuration", error); + } this.config = merge(defaults, config); this.services = this.config.services; - document.title = `${this.config.title} | ${this.config.subtitle}`; + document.title = + this.config.documentTitle || + `${this.config.title} | ${this.config.subtitle}`; + if (this.config.stylesheet) { + let stylesheet = ""; + for (const file of this.config.stylesheet) { + stylesheet += `@import "${file}";`; + } + this.createStylesheet(stylesheet); + } }, methods: { getConfig: function (path = "assets/config.yml") { return fetch(path).then((response) => { + if (response.redirected) { + // This allows to work with authentication proxies. + window.location.href = response.url; + return; + } if (!response.ok) { - throw Error(response.statusText); + throw Error(`${response.statusText}: ${response.body}`); } const that = this; @@ -173,9 +193,6 @@ export default { return that.getConfig(config.externalConfig); } return config; - }) - .catch((error) => { - return this.handleErrors("⚠️ Error loading configuration", error); }); }); }, @@ -227,6 +244,11 @@ export default { }, }; }, + createStylesheet: function (css) { + let style = document.createElement("style"); + style.appendChild(document.createTextNode(css)); + document.head.appendChild(style); + }, }, };