mirror of
				https://github.com/flynx/pWiki.git
				synced 2025-10-30 18:40:08 +00:00 
			
		
		
		
	making things a bit more intuitive -- location/argstr actions now inherit parent arguments by default...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
		
							parent
							
								
									c4b77f231f
								
							
						
					
					
						commit
						1e32383c26
					
				| @ -63,6 +63,7 @@ object.Constructor('BasePage', { | |||||||
| 		'path', | 		'path', | ||||||
| 		'name', | 		'name', | ||||||
| 		'dir', | 		'dir', | ||||||
|  | 		'argstr', | ||||||
| 		'title', | 		'title', | ||||||
| 		'resolved', | 		'resolved', | ||||||
| 		'rootpath', | 		'rootpath', | ||||||
| @ -71,6 +72,13 @@ object.Constructor('BasePage', { | |||||||
| 		'ctime', | 		'ctime', | ||||||
| 		'mtime', | 		'mtime', | ||||||
| 	]), | 	]), | ||||||
|  | 	// These actions will be default get :$ARGS appended if no args are 
 | ||||||
|  | 	// explicitly given...
 | ||||||
|  | 	// XXX INHERIT_ARGS
 | ||||||
|  | 	actions_inherit_args: new Set([ | ||||||
|  | 		'location', | ||||||
|  | 		'argstr', | ||||||
|  | 	]), | ||||||
| 
 | 
 | ||||||
| 	 | 	 | ||||||
| 	// NOTE: this can be inherited...
 | 	// NOTE: this can be inherited...
 | ||||||
| @ -854,6 +862,11 @@ object.Constructor('Page', BasePage, { | |||||||
| 						await base.parse(args.src, state)) | 						await base.parse(args.src, state)) | ||||||
| 				if(!src){ | 				if(!src){ | ||||||
| 					return } | 					return } | ||||||
|  | 				// XXX INHERIT_ARGS special-case: inherit args by default...
 | ||||||
|  | 				if(this.actions_inherit_args  | ||||||
|  | 						&& this.actions_inherit_args.has(pwpath.basename(src)) | ||||||
|  | 						&& this.get(pwpath.dirname(src)).path == this.path){ | ||||||
|  | 					src += ':$ARGS' } | ||||||
| 				var recursive = args.recursive ?? body | 				var recursive = args.recursive ?? body | ||||||
| 				var isolated = args.isolated  | 				var isolated = args.isolated  | ||||||
| 				var strict = args.strict | 				var strict = args.strict | ||||||
| @ -972,6 +985,11 @@ object.Constructor('Page', BasePage, { | |||||||
| 				src = src ?  | 				src = src ?  | ||||||
| 					await base.parse(src, state) | 					await base.parse(src, state) | ||||||
| 					: src | 					: src | ||||||
|  | 				// XXX INHERIT_ARGS special-case: inherit args by default...
 | ||||||
|  | 				if(this.actions_inherit_args  | ||||||
|  | 						&& this.actions_inherit_args.has(pwpath.basename(src)) | ||||||
|  | 						&& this.get(pwpath.dirname(src)).path == this.path){ | ||||||
|  | 					src += ':$ARGS' } | ||||||
| 				var expandactions = args.expandactions | 				var expandactions = args.expandactions | ||||||
| 
 | 
 | ||||||
| 				var depends = state.depends =  | 				var depends = state.depends =  | ||||||
| @ -1227,12 +1245,20 @@ object.Constructor('Page', BasePage, { | |||||||
| 						[text, join] = state.macros[name] } } | 						[text, join] = state.macros[name] } } | ||||||
| 
 | 
 | ||||||
| 				if(src){ | 				if(src){ | ||||||
|  | 					src = await base.parse(src, state) | ||||||
|  | 					// XXX INHERIT_ARGS special-case: inherit args by default...
 | ||||||
|  | 					if(this.actions_inherit_args  | ||||||
|  | 							&& this.actions_inherit_args.has(pwpath.basename(src)) | ||||||
|  | 							&& this.get(pwpath.dirname(src)).path == this.path){ | ||||||
|  | 						src += ':$ARGS' } | ||||||
|  | 
 | ||||||
| 					join = _getBlock('join')  | 					join = _getBlock('join')  | ||||||
| 						?? join  | 						?? join  | ||||||
| 					join = join | 					join = join | ||||||
| 						&& await base.parse(join, state) | 						&& await base.parse(join, state) | ||||||
| 
 | 
 | ||||||
| 					var match = this.get(await base.parse(src, state)) | 					//var match = this.get(await base.parse(src, state))
 | ||||||
|  | 					var match = this.get(src) | ||||||
| 
 | 
 | ||||||
| 					// NOTE: thie does not introduce a dependency on each 
 | 					// NOTE: thie does not introduce a dependency on each 
 | ||||||
| 					// 		of the iterated pages, that is handled by the 
 | 					// 		of the iterated pages, that is handled by the 
 | ||||||
| @ -1744,14 +1770,14 @@ module.System = { | |||||||
| 	// XXX /rootpath here is not relative -- makes reuse harder...
 | 	// XXX /rootpath here is not relative -- makes reuse harder...
 | ||||||
| 	_view: { | 	_view: { | ||||||
| 		// XXX can we avoid explicitly passing args to ./location ????
 | 		// XXX can we avoid explicitly passing args to ./location ????
 | ||||||
| 		// 		i.e.:
 | 		// 		i.e. do:
 | ||||||
| 		//			<a href="#@source(./location)">@source(./path)</a>
 | 		//			@source(./location)
 | ||||||
| 		//		instead of (current):
 | 		//		instead of (current):
 | ||||||
| 		//			<a href="#@source(./location:$ARGS)">@source(./path)</a>
 | 		//			@source(./location:$ARGS)
 | ||||||
| 		text: object.doc` | 		text: object.doc` | ||||||
| 			<slot name="header"> | 			<slot name="header"> | ||||||
| 				<a href="#/list">☰</a> | 				<a href="#/list">☰</a> | ||||||
| 				<a href="#@source(./location)">@source(./path)</a> | 				@source(./location) | ||||||
| 				<a href="#@source(./path)/_edit">✎</a> | 				<a href="#@source(./path)/_edit">✎</a> | ||||||
| 			</slot> | 			</slot> | ||||||
| 			<hr> | 			<hr> | ||||||
|  | |||||||
							
								
								
									
										27
									
								
								pwiki2.js
									
									
									
									
									
								
							
							
						
						
									
										27
									
								
								pwiki2.js
									
									
									
									
									
								
							| @ -1,11 +1,28 @@ | |||||||
| /********************************************************************** | /********************************************************************** | ||||||
| *  | *  | ||||||
| * | * | ||||||
| * XXX can we avoid explicitly passing args to ./location ???? | * XXX EXPERIMENTAL DOC INHERIT_ARGS added a special-case... | ||||||
| * 		i.e.: | * 		as basename will get appended :$ARGS if no args are given... | ||||||
| * 		<a href="#@source(./location)">@source(./path)</a> | * 		...this only applies to paths referring to the current context  | ||||||
| * 	instead of (current): | * 		page, i.e.:  | ||||||
| * 		<a href="#@source(./location:$ARGS)">@source(./path)</a> | * 			await pwiki | ||||||
|  | * 				.get('/page:x:y:z') | ||||||
|  | * 				// this will get the args...
 | ||||||
|  | * 				.parse('@source(./location)') | ||||||
|  | * | ||||||
|  | * 			await pwiki | ||||||
|  | * 				.get('/page:x:y:z') | ||||||
|  | * 				// this will not get the args -- different page...
 | ||||||
|  | * 				.parse('@source(./x/location)') | ||||||
|  | * | ||||||
|  | * 			await pwiki | ||||||
|  | * 				.get('/page:x:y:z') | ||||||
|  | * 				// this will get explicitly given empty args...
 | ||||||
|  | * 				.parse('@source(./location:)') | ||||||
|  | * | ||||||
|  | * 		special args that auto-inherit are given in .actions_inherit_args | ||||||
|  | * 		XXX this is currently implemented on the level of macro parsing, | ||||||
|  | * 			should this be in a more general way??? | ||||||
| * XXX BUG: | * XXX BUG: | ||||||
| * 			/System/info | * 			/System/info | ||||||
| * 		and: | * 		and: | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user