mirror of
				https://github.com/flynx/pWiki.git
				synced 2025-10-31 19:10:08 +00:00 
			
		
		
		
	added energetic actions (experimental)...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
		
							parent
							
								
									ce7c1ed377
								
							
						
					
					
						commit
						12c602ff65
					
				| @ -166,18 +166,21 @@ object.Constructor('BasePage', { | ||||
| 	// page data...
 | ||||
| 	//
 | ||||
| 	strict: undefined, | ||||
| 	energetic: undefined, | ||||
| 	get data(){ return (async function(){ | ||||
| 		var that = this | ||||
| 		// NOTE: we need to make sure each page gets the chance to handle 
 | ||||
| 		// 		its context (i.e. bind action to page)....
 | ||||
| 		if(this.isPattern  | ||||
| 				// XXX ENERGETIC...
 | ||||
| 				&& !this.store.isEnergetic(this.path)){ | ||||
| 				&& !(this.energetic  | ||||
| 					|| await this.store.isEnergetic(this.path))){ | ||||
| 			return this | ||||
| 				.map(function(page){ | ||||
| 					return page.data }) } | ||||
| 		// single page...
 | ||||
| 		var res = await this.store.get(this.location, !!this.strict) | ||||
| 		// XXX ENERGETIC...
 | ||||
| 		var res = await this.store.get(this.location, !!this.strict, !!this.energetic) | ||||
| 		return typeof(res) == 'function' ? | ||||
| 			res.bind(this) | ||||
| 			: res }).call(this) }, | ||||
| @ -299,7 +302,8 @@ object.Constructor('BasePage', { | ||||
| 			: this.path | ||||
| 		var paths = path.includes('*')  | ||||
| 				// XXX ENERGETIC...
 | ||||
| 				&& !await this.store.isEnergetic(path) ? | ||||
| 				&& !(this.energetic | ||||
| 					|| await this.store.isEnergetic(path)) ? | ||||
| 			this.resolve(path) | ||||
| 			: path | ||||
| 		paths = paths instanceof Array ?  | ||||
| @ -1527,9 +1531,9 @@ module.System = { | ||||
| 	_view: { | ||||
| 		text: object.doc` | ||||
| 			<slot name="header"> | ||||
| 				<a href="#/list">☰</a> | ||||
| 				@source(./!path)  | ||||
| 				<a href="#@source(./!path)/_edit">(edit)</a> | ||||
| 				<a href="#/list">☰</a> | ||||
| 				@source(./path/!)  | ||||
| 				<a href="#@source(./path/!)/_edit">(edit)</a> | ||||
| 			</slot> | ||||
| 			<hr> | ||||
| 			<slot name="content"></slot> | ||||
| @ -1611,7 +1615,7 @@ module.System = { | ||||
| 	list: { | ||||
| 		text: object.doc` | ||||
| 			<slot name="header"> | ||||
| 				/list | ||||
| 				<a href="#/list">☰</a> | ||||
| 				<a href="#@source(../../path)/list">⇑</a> | ||||
| 				@source(../path) | ||||
| 			</slot> | ||||
| @ -1625,7 +1629,7 @@ module.System = { | ||||
| 						</else> | ||||
| 					</macro> | ||||
| 				</sup> | ||||
| 				(<a href="#@source(./path)/list">@include(./*/!count)</a>) | ||||
| 				(<a href="#@source(./path)/list">@include(./*/count/!)</a>) | ||||
| 				  | ||||
| 				<a href="#@source(./path)/delete">×</a> | ||||
| 			</macro>` }, | ||||
| @ -1712,11 +1716,6 @@ module.System = { | ||||
| 		return this.get('..').location }, | ||||
| 	path: function(){ | ||||
| 		return this.get('..').path }, | ||||
| 	// XXX ENERGETIC...
 | ||||
| 	'!path': Object.assign( | ||||
| 		function(){ | ||||
| 			return this.get('..').path }, | ||||
| 		{energetic: true}), | ||||
| 	rootpath: function(){ | ||||
| 		return this.root.path }, | ||||
| 	resolved: async function(){ | ||||
| @ -1731,11 +1730,6 @@ module.System = { | ||||
| 			?? p.name }, | ||||
| 	count: async function(){ | ||||
| 		return this.get('..').length }, | ||||
| 	// XXX ENERGETIC...
 | ||||
| 	'!count': Object.assign( | ||||
| 		async function(){ | ||||
| 			return this.get('..').length }, | ||||
| 		{energetic: true}), | ||||
| 	ctime: async function(){ | ||||
| 		var date = (await this.get('..').data).ctime  | ||||
| 		return date ? | ||||
| @ -1747,6 +1741,13 @@ module.System = { | ||||
| 			(new Date(date)).getTimeStamp() | ||||
| 			: date }, | ||||
| 
 | ||||
| 	// XXX ENERGETIC -- a better name???
 | ||||
| 	// XXX test this with pages...
 | ||||
| 	'!': Object.assign( | ||||
| 		async function(){ | ||||
| 			return this.get('..', {energetic: true}).raw }, | ||||
| 		{energetic: true}), | ||||
| 
 | ||||
| 	// XXX EXPERIMENTAL -- page types...
 | ||||
| 	type: async function(){ | ||||
| 		return await this.get('..').type }, | ||||
|  | ||||
| @ -354,13 +354,15 @@ module.BaseStore = { | ||||
| 	// XXX should this return a map for pattern matches???
 | ||||
| 	__get__: async function(key){ | ||||
| 		return this.data[key] }, | ||||
| 	get: async function(path, strict=false){ | ||||
| 	get: async function(path, strict=false, energetic=false){ | ||||
| 		var that = this | ||||
| 		/* XXX ENERGETIC... | ||||
| 		path = await this.resolve(path, strict) | ||||
| 		/*/ | ||||
| 		path = path.includes('*')  | ||||
| 			&& await this.isEnergetic(path) | ||||
| 			&& (energetic == true ? | ||||
| 				await this.find(path) | ||||
| 				: await this.isEnergetic(path)) | ||||
| 			|| await this.resolve(path, strict) | ||||
| 		//*/
 | ||||
| 		return path instanceof Array ? | ||||
|  | ||||
							
								
								
									
										92
									
								
								pwiki2.js
									
									
									
									
									
								
							
							
						
						
									
										92
									
								
								pwiki2.js
									
									
									
									
									
								
							| @ -1,20 +1,13 @@ | ||||
| /********************************************************************** | ||||
| *  | ||||
| * | ||||
| * XXX FEATURE need to be able to call some actions on the root page  | ||||
| * 		before it gets .each()'ed... | ||||
| * 		...for things like: | ||||
| * 			- count | ||||
| * 			- unexpandedpath (name?) | ||||
| * 			- ... | ||||
| * 		this can be done in one of two ways: | ||||
| * 			- syntax | ||||
| * 				+ will enable any action to be called energetically... | ||||
| * 				- a complication... | ||||
| * 			- special actions | ||||
| * 				+ transparent | ||||
| * 				- extra concept -- might be confusing | ||||
| * 				- duplicate actions | ||||
| * XXX ENERGETIC do we need to make this a path syntax thing??? | ||||
| * 		...i.e.  | ||||
| * 			/some/path/action/! (current)  | ||||
| * 		vs. | ||||
| * 			/some/path/!action | ||||
| * 			..."!" is removed before the <store>.__<name>__(..) calls... | ||||
| * XXX ENERGETIC revise naming... | ||||
| * XXX FEATURE tags and accompanying API... | ||||
| * 		- add tags to page -- macro/filter | ||||
| * 			<page>.text -> <page>.tags (cached on .update(..)) | ||||
| @ -22,6 +15,43 @@ | ||||
| * 		- tag cache <store>.tags | ||||
| * 		- tag-path filtering... | ||||
| * 			i.e. only show tags within a specific path/pattern... | ||||
| * 		- path integration... | ||||
| * 			i.e. a way to pass tags through path... | ||||
| * 				/some/path:tags=a,b,c | ||||
| * XXX FEATURE add a uniform way to track some state in links in pwiki  | ||||
| * 		for things like paging and the like with simple user/macro  | ||||
| * 		access (???)... | ||||
| * 		...the simplest that comes to mind is to store in in path  | ||||
| * 		somehow: | ||||
| * 			- <path>?<arg>=<value>&... | ||||
| * 				traditional "query string"... | ||||
| * 			- <path>/<arg>:<valu>/<arg>:<value>/.../<action> | ||||
| * 				stack-style arguments... | ||||
| * 				+ simple to implement | ||||
| * 				- goes through page search??? | ||||
| * 			- <path>:<value>:<name>=<value>:... | ||||
| * 			- ... | ||||
| * 		the general idea is to be: | ||||
| * 			- flexible enough to allow the basics done | ||||
| * 			- restrictive enough to prevent misuse | ||||
| * 		...the rest of the state can simply be stored in the root pwiki  | ||||
| * 		object in one of the following ways: | ||||
| * 			- directly (attrs/dict) | ||||
| * 			- a special page  | ||||
| * 				- virtual (path-specific) | ||||
| * 					e.g. | ||||
| * 						/some/path/@state/page -> 4 | ||||
| * 					...might be fun to implement a basic json editor | ||||
| * 					and viewer with this api... | ||||
| * 					...controlled via js  | ||||
| * 					...or special actions: | ||||
| * 						/some/path/@state/page/next (increment) | ||||
| * 						/some/path/@state/page/prev (decrement) | ||||
| * 						/some/path/@state/page=10	(assign) | ||||
| * 						... | ||||
| * 				- session | ||||
| * 				- stored (config) | ||||
| * 		...css selector as path.... | ||||
| * XXX revise/update sort... | ||||
| * XXX fs store: metadata and cache... | ||||
| * XXX sub/nested store mixing...  | ||||
| @ -67,40 +97,6 @@ | ||||
| * XXX FEATURE self-doc:  | ||||
| * 			- some thing lile Action(<name>, <doc>, <func>|<str>) | ||||
| * 			- System/doc -- show <doc> for action... | ||||
| * XXX FEATURE add a uniform way to track some state in links in pwiki  | ||||
| * 		for things like paging and the like with simple user/macro  | ||||
| * 		access (???)... | ||||
| * 		...the simplest that comes to mind is to store in in path  | ||||
| * 		somehow: | ||||
| * 			- <path>?<arg>=<value>&... | ||||
| * 				traditional "query string"... | ||||
| * 			- <path>/<arg>:<valu>/<arg>:<value>/.../<action> | ||||
| * 				stack-style arguments... | ||||
| * 				+ simple to implement | ||||
| * 				- goes through page search??? | ||||
| * 			- <path>:<value>:<name>=<value>:... | ||||
| * 			- ... | ||||
| * 		the general idea is to be: | ||||
| * 			- flexible enough to allow the basics done | ||||
| * 			- restrictive enough to prevent misuse | ||||
| * 		...the rest of the state can simply be stored in the root pwiki  | ||||
| * 		object in one of the following ways: | ||||
| * 			- directly (attrs/dict) | ||||
| * 			- a special page  | ||||
| * 				- virtual (path-specific) | ||||
| * 					e.g. | ||||
| * 						/some/path/@state/page -> 4 | ||||
| * 					...might be fun to implement a basic json editor | ||||
| * 					and viewer with this api... | ||||
| * 					...controlled via js  | ||||
| * 					...or special actions: | ||||
| * 						/some/path/@state/page/next (increment) | ||||
| * 						/some/path/@state/page/prev (decrement) | ||||
| * 						/some/path/@state/page=10	(assign) | ||||
| * 						... | ||||
| * 				- session | ||||
| * 				- stored (config) | ||||
| * 		...css selector as path.... | ||||
| * XXX GENERATOR make pattern path parsing a generator... | ||||
| * 		...experiment with a controllable iterator/range thing... | ||||
| * 		This would require: | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user