mirror of
				https://github.com/flynx/pWiki.git
				synced 2025-10-30 18:40:08 +00:00 
			
		
		
		
	added update/delete page events and some template tweaking...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
		
							parent
							
								
									e3b104f9cc
								
							
						
					
					
						commit
						bb04752e7a
					
				| @ -427,8 +427,9 @@ object.Constructor('BasePage', { | |||||||
| 	//*/
 | 	//*/
 | ||||||
| 	resolve: relMatchProxy('resolve'), | 	resolve: relMatchProxy('resolve'), | ||||||
| 
 | 
 | ||||||
| 
 | 	delete: types.event.Event('delete',  | ||||||
| 	delete: async function(path='.', base=true){ | 		async function(handle, path='.', base=true){ | ||||||
|  | 			handle(false) | ||||||
| 			if(path === true || path === false){ | 			if(path === true || path === false){ | ||||||
| 				base = path | 				base = path | ||||||
| 				path = '.'	} | 				path = '.'	} | ||||||
| @ -440,7 +441,8 @@ object.Constructor('BasePage', { | |||||||
| 					this.__delete__(p) } | 					this.__delete__(p) } | ||||||
| 			} else { | 			} else { | ||||||
| 				this.__delete__(path) } | 				this.__delete__(path) } | ||||||
| 		return this }, | 			handle() | ||||||
|  | 			return this }), | ||||||
| 	// XXX should these be implemented here or proxy to .store???
 | 	// XXX should these be implemented here or proxy to .store???
 | ||||||
| 	// XXX do we sanity check to no not contain '*'???
 | 	// XXX do we sanity check to no not contain '*'???
 | ||||||
| 	copy: async function(to, base=true){ | 	copy: async function(to, base=true){ | ||||||
| @ -687,8 +689,9 @@ object.Constructor('BasePage', { | |||||||
| 	// 		...right now this will write what-ever is given, even if it
 | 	// 		...right now this will write what-ever is given, even if it
 | ||||||
| 	// 		will never be explicitly be accessible...
 | 	// 		will never be explicitly be accessible...
 | ||||||
| 	// XXX sync/async???
 | 	// XXX sync/async???
 | ||||||
| 	update: function(...data){ | 	update: types.event.Event('update', | ||||||
| 		return Object.assign(this, ...data) }, | 		function(_, ...data){ | ||||||
|  | 			return Object.assign(this, ...data) }), | ||||||
| 
 | 
 | ||||||
| 	// XXX should this take an options/dict argument????
 | 	// XXX should this take an options/dict argument????
 | ||||||
| 	__init__: function(path, referrer, store){ | 	__init__: function(path, referrer, store){ | ||||||
| @ -1359,7 +1362,7 @@ object.Constructor('Page', BasePage, { | |||||||
| 				text = typeof(text) == 'string' ? | 				text = typeof(text) == 'string' ? | ||||||
| 					[...this.__parser__.group(this, text+'</macro>', 'macro')] | 					[...this.__parser__.group(this, text+'</macro>', 'macro')] | ||||||
| 					: text | 					: text | ||||||
| 				var join | 				var join, itext | ||||||
| 				var iargs = {} | 				var iargs = {} | ||||||
| 
 | 
 | ||||||
| 				// stored macros...
 | 				// stored macros...
 | ||||||
| @ -1383,7 +1386,7 @@ object.Constructor('Page', BasePage, { | |||||||
| 				// XXX is there a point in overloading text???
 | 				// XXX is there a point in overloading text???
 | ||||||
| 				text = text.length > 0 ?  | 				text = text.length > 0 ?  | ||||||
| 					text  | 					text  | ||||||
| 					: itext | 					: itext ?? text | ||||||
| 				var sort = (args.sort  | 				var sort = (args.sort  | ||||||
| 						?? iargs.sort  | 						?? iargs.sort  | ||||||
| 						?? '') | 						?? '') | ||||||
| @ -1441,7 +1444,7 @@ object.Constructor('Page', BasePage, { | |||||||
| 								seen: state.seen,  | 								seen: state.seen,  | ||||||
| 								depends, | 								depends, | ||||||
| 								renderer: state.renderer, | 								renderer: state.renderer, | ||||||
| 								macros: args.inheritmacros ? | 								macros: inheritmacros ? | ||||||
| 									{__proto__: macros} | 									{__proto__: macros} | ||||||
| 									: {}, | 									: {}, | ||||||
| 							} | 							} | ||||||
| @ -2102,7 +2105,9 @@ module.System = { | |||||||
| 					<div class="item"> | 					<div class="item"> | ||||||
| 						<a class="tree-page-title" href="#@source(s ./path)">@source(./title)</a> | 						<a class="tree-page-title" href="#@source(s ./path)">@source(./title)</a> | ||||||
| 						<a class="show-on-hover" href="#@source(s ./path)/info">🛈</a> | 						<a class="show-on-hover" href="#@source(s ./path)/info">🛈</a> | ||||||
| 						<a class="show-on-hover" href="#@source(s ./path)/delete">×</a> | 						<a class="show-on-hover"  | ||||||
|  | 							href="javascript:pwiki.delete('@source(s ./path)')" | ||||||
|  | 							>×</a> | ||||||
| 					</div> | 					</div> | ||||||
| 					<div style="padding-left: 30px"> | 					<div style="padding-left: 30px"> | ||||||
| 						@include("./tree:$ARGS") | 						@include("./tree:$ARGS") | ||||||
|  | |||||||
| @ -35,7 +35,7 @@ module.BaseParser = { | |||||||
| 	//
 | 	//
 | ||||||
| 	MACRO_ARGS: ['(\\s*(',[ | 	MACRO_ARGS: ['(\\s*(',[ | ||||||
| 				// arg='val' | arg="val" | arg=val
 | 				// arg='val' | arg="val" | arg=val
 | ||||||
| 				'(?<PREFIXArgName>[a-z-]+)\\s*=\\s*(?<PREFIXArgValue>'+([ | 				'(?<PREFIXArgName>[a-z:-]+)\\s*=\\s*(?<PREFIXArgValue>'+([ | ||||||
| 					// XXX CHROME/NODE BUG: this does not work yet...
 | 					// XXX CHROME/NODE BUG: this does not work yet...
 | ||||||
| 					//'\\s+(?<quote>[\'"])[^\\k<quote>]*\\k<quote>',
 | 					//'\\s+(?<quote>[\'"])[^\\k<quote>]*\\k<quote>',
 | ||||||
| 					'"(?<PREFIXDoubleQuotedValue>(\\"|[^"])*?)"', | 					'"(?<PREFIXDoubleQuotedValue>(\\"|[^"])*?)"', | ||||||
|  | |||||||
| @ -276,7 +276,7 @@ module.BaseStore = { | |||||||
| 			return data },  | 			return data },  | ||||||
| 		remove: async function(data, path){ | 		remove: async function(data, path){ | ||||||
| 			var {tags, paths} = await data | 			var {tags, paths} = await data | ||||||
| 			for(var tag of paths[path]){ | 			for(var tag of paths[path] ?? []){ | ||||||
| 				tags[tag].delete(path) } | 				tags[tag].delete(path) } | ||||||
| 			return data }, }), | 			return data }, }), | ||||||
| 	get tags(){ | 	get tags(){ | ||||||
| @ -609,8 +609,11 @@ module.BaseStore = { | |||||||
| 	// 		...this could be a sign of problems with index -- needs more 
 | 	// 		...this could be a sign of problems with index -- needs more 
 | ||||||
| 	// 		tought...
 | 	// 		tought...
 | ||||||
| 	update: types.event.Event('update',  | 	update: types.event.Event('update',  | ||||||
| 		function(handler, path, data, mode='update'){ | 		async function(handler, path, data, mode='update'){ | ||||||
| 			return this.__update(...[...arguments].slice(1)) }), | 			handler(false) | ||||||
|  | 			var res = await this.__update(...[...arguments].slice(1))  | ||||||
|  | 			handler() | ||||||
|  | 			return res }), | ||||||
| 
 | 
 | ||||||
| 	__delete__: async function(path){ | 	__delete__: async function(path){ | ||||||
| 		delete this.data[path] }, | 		delete this.data[path] }, | ||||||
| @ -625,8 +628,11 @@ module.BaseStore = { | |||||||
| 			this.index('remove', path) } | 			this.index('remove', path) } | ||||||
| 		return this }, | 		return this }, | ||||||
| 	delete: types.event.Event('delete',  | 	delete: types.event.Event('delete',  | ||||||
| 		function(handler, path){ | 		async function(handler, path){ | ||||||
| 			return this.__delete(path) }), | 			handler(false) | ||||||
|  | 			var res = await this.__delete(path)  | ||||||
|  | 			handler() | ||||||
|  | 			return res }), | ||||||
| 
 | 
 | ||||||
| 	// XXX NEXT might be a good idea to have an API to move pages from 
 | 	// XXX NEXT might be a good idea to have an API to move pages from 
 | ||||||
| 	// 		current store up the chain...
 | 	// 		current store up the chain...
 | ||||||
|  | |||||||
| @ -97,7 +97,7 @@ a:hover { | |||||||
| 
 | 
 | ||||||
| /* Spinner... */ | /* Spinner... */ | ||||||
| .spinner { | .spinner { | ||||||
| 	position: absolute; | 	position: fixed; | ||||||
| 	display: flex; | 	display: flex; | ||||||
| 	text-align: center; | 	text-align: center; | ||||||
| 	left: 50%; | 	left: 50%; | ||||||
| @ -411,6 +411,7 @@ require(['./browser'], function(browser){ | |||||||
| 			//		when the hash is actually changed... | 			//		when the hash is actually changed... | ||||||
| 			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) } }) | ||||||
|  | 		.delete(refresh) | ||||||
| 
 | 
 | ||||||
| 	// handle special file updates... | 	// handle special file updates... | ||||||
| 	// NOTE: the actual updates are done .navigate(..) | 	// NOTE: the actual updates are done .navigate(..) | ||||||
|  | |||||||
| @ -18,6 +18,8 @@ | |||||||
| * 		- CLI										-  | * 		- CLI										-  | ||||||
| * | * | ||||||
| * | * | ||||||
|  | * XXX macros: add @defmacro(<name> ..) to be exactly as @macro(<name> ..)  | ||||||
|  | * 		but defines a @<name>(..) macro... | ||||||
| * XXX BUG: parser: | * XXX BUG: parser: | ||||||
| * 		This will break: | * 		This will break: | ||||||
| * 			await pwiki.parse('<macro src=../tags join=", ">@source(.)</macro>') | * 			await pwiki.parse('<macro src=../tags join=", ">@source(.)</macro>') | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user