Added version

This commit is contained in:
Magnus Åhall 2023-07-25 11:48:25 +00:00
parent 8863b4c139
commit 6b286431b7
4 changed files with 40 additions and 1 deletions

1
VERSION Normal file
View File

@ -0,0 +1 @@
v1

View File

@ -38,6 +38,18 @@ header .page {
font-weight: 500; font-weight: 500;
} }
footer {
position: absolute;
left: 0px;
right: 0px;
bottom: 0px;
text-align: center;
color: #f0f;
padding: 6px 0;
font-size: 0.75em;
font-weight: 500;
}
#page-label { #page-label {
font-weight: 500; font-weight: 500;
font-size: 1.25em; font-size: 1.25em;

View File

@ -28,5 +28,6 @@
<div id="theme"></div> <div id="theme"></div>
</header> </header>
<div id="sections"></div> <div id="sections"></div>
<footer></footer>
</body> </body>
</html> </html>

View File

@ -9,6 +9,8 @@ class App {
this.themes = { default: Theme.default() } this.themes = { default: Theme.default() }
this.sections = [] this.sections = []
this.retrieveVersion()
this.retrieveThemes() this.retrieveThemes()
.then(()=>this.retrieveConfig()) .then(()=>this.retrieveConfig())
.then(config=>this.parseConfig(config)) .then(config=>this.parseConfig(config))
@ -30,6 +32,18 @@ class App {
}) })
}) })
}//}}} }//}}}
retrieveVersion() {//{{{
return fetch('/VERSION')
.then(res=>{
if(res.ok)
return res.text()
throw `Error when fetching /${page}.yaml: ${res.status} ${res.statusText}`
})
.then(version=>{
this.version = version
document.querySelector('footer').innerHTML = `Dashie ${version}`
})
}//}}}
retrieveConfig() {//{{{ retrieveConfig() {//{{{
const urlParams = new URLSearchParams(window.location.search); const urlParams = new URLSearchParams(window.location.search);
let page = urlParams.get('page') let page = urlParams.get('page')
@ -103,6 +117,12 @@ class App {
let sectionHTML = this.sections.map(s=>s.html()) let sectionHTML = this.sections.map(s=>s.html())
document.getElementById('sections').innerHTML = sectionHTML.join('') document.getElementById('sections').innerHTML = sectionHTML.join('')
// Footer
let footer = document.querySelector('footer')
footer.style.display = t.colors.page.footer.show ? 'block' : 'none';
footer.style.color = t.colors.page.footer.text
footer.style.backgroundColor = t.colors.page.footer.background
}//}}} }//}}}
setTheme(theme) {//{{{ setTheme(theme) {//{{{
this.theme = theme this.theme = theme
@ -159,7 +179,12 @@ class Theme {
page: { page: {
text: '#fff', text: '#fff',
header: '#333', header: '#333',
background: '#fff' background: '#fff',
footer: {
show: true,
text: "#aaa",
background: "#eee"
}
}, },
page_select: { page_select: {