diff --git a/pwiki/path.js b/pwiki/path.js index bd96094..ba6603a 100755 --- a/pwiki/path.js +++ b/pwiki/path.js @@ -50,6 +50,13 @@ module = { // XXX or can we? SYSTEM_PATH: '/.system', + // XXX EXPERIMENTAL + encode: function(str){ + return str + .replace(/[#:*%]/g, encodeURIComponent) }, + decode: function(str){ + return decodeURIComponent(str) }, + /*/ XXX NORMCACHE... __normalized_cache_threshold: 100, __normalized_cache_size: 4096, diff --git a/pwiki/store/base.js b/pwiki/store/base.js index f9dd1a3..56e3343 100755 --- a/pwiki/store/base.js +++ b/pwiki/store/base.js @@ -140,6 +140,9 @@ module.BaseStore = { // XXX revise naming... next: undefined, + onUpdate: types.event.Event('update'), + onDelete: types.event.Event('delete'), + // NOTE: .data is not part of the spec and can be implementation-specific, // only .____(..) use it internally... (XXX check this) __data: undefined, @@ -542,6 +545,7 @@ module.BaseStore = { await this.__update__(path, data, mode) // XXX CACHED this.__cache_add(path) + this.onUpdate(path) return this }, __delete__: async function(path){ delete this.data[path] }, @@ -554,7 +558,8 @@ module.BaseStore = { if(path){ await this.__delete__(path) // XXX CACHED - this.__cache_remove(path) } + this.__cache_remove(path) + this.onDelete(path) } return this }, // XXX NEXT might be a good idea to have an API to move pages from diff --git a/pwiki2.js b/pwiki2.js index eedac5f..453683d 100755 --- a/pwiki2.js +++ b/pwiki2.js @@ -6,10 +6,15 @@ * - fs store/export in browser or a simple way to export/import... * * +* XXX need page names to contain odd characters when created by user, for +* example: note titles... +* ...and need this to work through all the i/o... +* ....this might be an argument towards the .title attr, at least +* for notes... * XXX need basic system events: -* .onUpdate(path, data?) -* .onUreate(path, data?) -* .onDelete(path) +* .onUpdate(path, data?) +* .onCreate(path, data?) +* .onDelete(path) * ..stores should also be able to trigger these when external * updates are detected... * XXX CACHE strategy and architecture