added loading styles from the pwiki -- see: /.config/Style

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2022-10-28 01:34:58 +03:00
parent e574e2cc2f
commit 2c6c3d367b
3 changed files with 50 additions and 3 deletions

View File

@ -2361,7 +2361,11 @@ module.Config = {
text: '<button onclick="exportData()">Export</button>' }, text: '<button onclick="exportData()">Export</button>' },
// XXX // XXX
Config: { Config: {
text: '{}' }, text: object.doc`{
}` },
Style: {
text: object.doc`
` },
} }

View File

@ -165,6 +165,11 @@ body.loading .page.spinner span {
} }
</style> </style>
<!--
Do not edit here...
This is loaded with the style defined by the system
-->
<style id="style"></style>
<!-- XXX do we need this??? --> <!-- XXX do we need this??? -->
<script src="bootstrap.js"></script> <script src="bootstrap.js"></script>
@ -234,6 +239,21 @@ require.config({
//--------------------------------------------------------------------- //---------------------------------------------------------------------
// Editor -- save changes... // Editor -- save changes...
// XXX might be a good idea to make this a method of pwiki???
var STYLE_UPDATED = false
var updateStyle = async function(){
document.querySelector('#style').innerHTML =
await pwiki.get('/.config/Style/_raw').text }
// XXX might be a good idea to make this a method of pwiki???
var CONFIG_UPDATED = false
var updateConfig = async function(){
// XXX need to set this to something...
// XXX
// XXX need to use a parser that supports comments and stuff...
return JSON.parse(await pwiki.get('/.config/Config/_raw').text) }
// XXX versioning?? // XXX versioning??
var SAVE_LIVE_TIMEOUT = 5000 var SAVE_LIVE_TIMEOUT = 5000
var SAVE_LIVE_QUEUE = {} var SAVE_LIVE_QUEUE = {}
@ -347,6 +367,14 @@ require(['./browser'], function(browser){
+(this.hash ? +(this.hash ?
'#'+this.hash '#'+this.hash
: '')) : ''))
// style...
if(STYLE_UPDATED){
STYLE_UPDATED = false
await updateStyle() }
// config...
if(CONFIG_UPDATED){
CONFIG_UPDATED = false
await updateConfig() }
// NOTE: we are intentionally not awaiting for this -- this // NOTE: we are intentionally not awaiting for this -- this
// separates the navigate and load events... // separates the navigate and load events...
logTime( logTime(
@ -379,12 +407,24 @@ require(['./browser'], function(browser){
for(var lnk of this.dom.querySelectorAll(`a[href="${location.hash}"]`)){ for(var lnk of this.dom.querySelectorAll(`a[href="${location.hash}"]`)){
lnk.addEventListener('click', refresh) } }) lnk.addEventListener('click', refresh) } })
// handle special file updates...
// NOTE: the actual updates are done .onNavigate(..)
pwiki.store
.update(function(_, path){
if(path == '/.config/Style'){
STYLE_UPDATED = true }
if(path == '/.config/Config'){
CONFIG_UPDATED = true } })
// wait for stuff to finish... // wait for stuff to finish...
browser.setup.then(async function(){ browser.setup.then(async function(){
// index... // index...
await logTime( await logTime(
pwiki.store.index(), pwiki.store.index(),
'Indexing') 'Indexing')
// setup global stuff...
updateStyle()
updateConfig()
// show current page... // show current page...
pwiki.location = decodeURI(location.hash).slice(1) }) }) pwiki.location = decodeURI(location.hash).slice(1) }) })

View File

@ -18,6 +18,7 @@
* - CLI - * - CLI -
* *
* *
* XXX NAMING: revise .onNavigate(..) and .onBeforeNavigate(..) event names...
* XXX BUG: parser: * XXX BUG: parser:
* This will break: * This will break:
* <macro src=../tags join=", ">@source(.)</macro><br> * <macro src=../tags join=", ">@source(.)</macro><br>
@ -28,13 +29,15 @@
* - add tags to page -- macro/filter * - add tags to page -- macro/filter
* - <page>.text -> <page>.tags (cached on .update(..)) * - <page>.text -> <page>.tags (cached on .update(..))
* - ??? * - ???
* - manual - DONE * - manual/API - DONE
* - editor -
* - a way to list tags -- folder like? - DONE * - a way to list tags -- folder like? - DONE
* - tag cache <store>.tags - DONE * - tag cache <store>.tags - DONE
* - tag-path filtering... - DONE * - tag-path filtering... - DONE
* XXX TAGS add a more advanced query -- e.g. "/**:tagged=y,z:untagged=x" ??? * XXX TAGS add a more advanced query -- e.g. "/**:tagged=y,z:untagged=x" ???
* XXX TAGS do we need page actions to tag/untag pages??? * XXX TAGS do we need page actions to tag/untag pages???
* XXX INDEX store index (IndexedDB?) and update as the stores are updated... * XXX INDEX persistent index -- store index (IndexedDB?) and update as
* the stores are updated...
* XXX INDEX DOC can index validation be async??? * XXX INDEX DOC can index validation be async???
* ...likely no * ...likely no
* XXX INDEX add option to set default action (get/lazy/cached) * XXX INDEX add option to set default action (get/lazy/cached)