aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorluixal <luixal@gmail.com>2021-01-07 09:39:58 +0100
committerluixal <luixal@gmail.com>2021-01-07 09:39:58 +0100
commite3bd2ecc2ca874270282c3c42813b8053d67dcbd (patch)
treea1248fd1c62273e3afd68e2059243e1f091d098a
parent3786f80dae2df7780d19ba8ffd9374ef3c2fc30f (diff)
downloadhomer-e3bd2ecc2ca874270282c3c42813b8053d67dcbd.tar.gz
homer-e3bd2ecc2ca874270282c3c42813b8053d67dcbd.tar.zst
homer-e3bd2ecc2ca874270282c3c42813b8053d67dcbd.zip
Adds multiple pages based on different config files
-rw-r--r--docs/configuration.md5
-rw-r--r--public/assets/page2.yml39
-rw-r--r--src/App.vue9
-rw-r--r--src/components/ConnectivityChecker.vue2
4 files changed, 53 insertions, 2 deletions
diff --git a/docs/configuration.md b/docs/configuration.md
index a43d7f1..81de590 100644
--- a/docs/configuration.md
+++ b/docs/configuration.md
@@ -81,6 +81,11 @@ links:
81 - name: "link 2" 81 - name: "link 2"
82 icon: "fas fa-book" 82 icon: "fas fa-book"
83 url: "https://github.com/bastienwirtz/homer" 83 url: "https://github.com/bastienwirtz/homer"
84 # this will link to a second homer page that will load config from page2.yml and keep default config values as in config.yml file
85 # see url field and assets/page.yml used in this example:
86 - name: "Second Page"
87 icon: "fas fa-file-alt"
88 url: "/page2"
84 89
85# Services 90# Services
86# First level array represents a group. 91# First level array represents a group.
diff --git a/public/assets/page2.yml b/public/assets/page2.yml
new file mode 100644
index 0000000..e10d706
--- /dev/null
+++ b/public/assets/page2.yml
@@ -0,0 +1,39 @@
1# this config is used by a page linked in the navbar
2# this pages will use the same configuration from config.yml, but will overwrite fields present here
3
4# this overwrites title and subtitle:
5title: "Page2"
6subtitle: "this is the second page"
7
8# this overwrites message config. Setting it to empty to remove message from this page and keep it only in the main one:
9message:
10
11# as we want to include a differente link here (so we can get back to home page), we need to replicate all links or they will be revome when overwriting the links field:
12links:
13 - name: "Home"
14 icon: "fas fa-home"
15 url: "/"
16 - name: "Contribute"
17 icon: "fab fa-github"
18 url: "https://github.com/bastienwirtz/homer"
19 target: "_blank" # optional html a tag target attribute
20 - name: "Wiki"
21 icon: "fas fa-book"
22 url: "https://www.wikipedia.org/"
23
24# we keep the first group from the main page, but remove the second group. We need to replicate that first group or it will be removed:
25services:
26 - name: "NEW"
27 icon: "fas fa-cloud"
28 items:
29 - name: "Awesome app"
30 logo: "assets/tools/sample.png"
31 subtitle: "Bookmark example"
32 tag: "app"
33 url: "https://www.reddit.com/r/selfhosted/"
34 target: "_blank"
35 - name: "Another one"
36 logo: "assets/tools/sample2.png"
37 subtitle: "Another application"
38 tag: "app"
39 url: "#"
diff --git a/src/App.vue b/src/App.vue
index dc473ca..03970ed 100644
--- a/src/App.vue
+++ b/src/App.vue
@@ -13,7 +13,7 @@
13 <section v-if="config.header" class="first-line"> 13 <section v-if="config.header" class="first-line">
14 <div v-cloak class="container"> 14 <div v-cloak class="container">
15 <div class="logo"> 15 <div class="logo">
16 <img v-if="config.logo" :src="config.logo" alt="dashboard logo" /> 16 <a href="/"><img v-if="config.logo" :src="config.logo" alt="dashboard logo" /></a>
17 <i v-if="config.icon" :class="config.icon"></i> 17 <i v-if="config.icon" :class="config.icon"></i>
18 </div> 18 </div>
19 <div class="dashboard-title"> 19 <div class="dashboard-title">
@@ -153,6 +153,13 @@ export default {
153 let config; 153 let config;
154 try { 154 try {
155 config = await this.getConfig(); 155 config = await this.getConfig();
156 const path = (window.location.pathname != '/') ? window.location.pathname : null;
157 if (path) {
158 let pathConfig = await this.getConfig(`assets${path}.yml`); // the slash (/) is included in the pathname
159 for (const prop in pathConfig) config[prop] = pathConfig[prop];
160 }
161 // config = await this.getConfig(path ? `assets/${path}.yml` : null);
162 //config = await (path ? this.getConfig(`assets/${path}.yml`) : this.getConfig())
156 } catch (error) { 163 } catch (error) {
157 console.log(error); 164 console.log(error);
158 config = this.handleErrors("⚠️ Error loading configuration", error); 165 config = this.handleErrors("⚠️ Error loading configuration", error);
diff --git a/src/components/ConnectivityChecker.vue b/src/components/ConnectivityChecker.vue
index d41c443..e0e88bb 100644
--- a/src/components/ConnectivityChecker.vue
+++ b/src/components/ConnectivityChecker.vue
@@ -33,7 +33,7 @@ export default {
33 methods: { 33 methods: {
34 checkOffline: function () { 34 checkOffline: function () {
35 let that = this; 35 let that = this;
36 return fetch(window.location.href + "?alive", { 36 return fetch(window.location.origin + "?alive", {
37 method: "HEAD", 37 method: "HEAD",
38 cache: "no-store", 38 cache: "no-store",
39 }) 39 })