mirror of
				https://github.com/flynx/pWiki.git
				synced 2025-11-04 04:50:09 +00:00 
			
		
		
		
	experimenting with path argument syntaxes...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
		
							parent
							
								
									561de44f54
								
							
						
					
					
						commit
						b96174ed7f
					
				@ -1507,7 +1507,7 @@ module.System = {
 | 
				
			|||||||
		this.render_root
 | 
							this.render_root
 | 
				
			||||||
			&& (this.render_root.location = to.path)
 | 
								&& (this.render_root.location = to.path)
 | 
				
			||||||
		return this.render_root.path },
 | 
							return this.render_root.path },
 | 
				
			||||||
 | 
						//
 | 
				
			||||||
	// syntax:
 | 
						// syntax:
 | 
				
			||||||
	// 		/<path-from>/to:<path-to>/move
 | 
						// 		/<path-from>/to:<path-to>/move
 | 
				
			||||||
	//
 | 
						//
 | 
				
			||||||
@ -1526,6 +1526,10 @@ module.System = {
 | 
				
			|||||||
			&& (this.render_root.location = to)
 | 
								&& (this.render_root.location = to)
 | 
				
			||||||
		return '' },
 | 
							return '' },
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						//
 | 
				
			||||||
 | 
						test_path: function(){
 | 
				
			||||||
 | 
						},
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// XXX System/back
 | 
						// XXX System/back
 | 
				
			||||||
	// XXX System/forward
 | 
						// XXX System/forward
 | 
				
			||||||
	// XXX System/sort
 | 
						// XXX System/sort
 | 
				
			||||||
 | 
				
			|||||||
@ -402,7 +402,7 @@ module.BaseParser = {
 | 
				
			|||||||
	expand: async function*(page, ast, state={}){
 | 
						expand: async function*(page, ast, state={}){
 | 
				
			||||||
		ast = ast == null ?
 | 
							ast = ast == null ?
 | 
				
			||||||
				//this.group(page)
 | 
									//this.group(page)
 | 
				
			||||||
				this.group(page, await page.raw)
 | 
									this.group(page, await page.raw ?? '')
 | 
				
			||||||
			: typeof(ast) == 'string' ?
 | 
								: typeof(ast) == 'string' ?
 | 
				
			||||||
				this.group(page, ast)
 | 
									this.group(page, ast)
 | 
				
			||||||
			: ast instanceof types.Generator ?
 | 
								: ast instanceof types.Generator ?
 | 
				
			||||||
 | 
				
			|||||||
@ -221,6 +221,55 @@ module = {
 | 
				
			|||||||
		if(alt_pages){
 | 
							if(alt_pages){
 | 
				
			||||||
			for(var page of [...this.ALTERNATIVE_PAGES]){
 | 
								for(var page of [...this.ALTERNATIVE_PAGES]){
 | 
				
			||||||
				yield* this.paths(path.concat(page), seen) }} },
 | 
									yield* this.paths(path.concat(page), seen) }} },
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						// XXX EXPERIMENTAL...
 | 
				
			||||||
 | 
						//
 | 
				
			||||||
 | 
						//	.splitSrgs(<path>)
 | 
				
			||||||
 | 
						//		-> <spec>
 | 
				
			||||||
 | 
						//
 | 
				
			||||||
 | 
						// Format:
 | 
				
			||||||
 | 
						// 	{
 | 
				
			||||||
 | 
						// 		path: <path>
 | 
				
			||||||
 | 
						// 		args: {
 | 
				
			||||||
 | 
						// 			<name>:<value>,
 | 
				
			||||||
 | 
						// 			...
 | 
				
			||||||
 | 
						// 		}
 | 
				
			||||||
 | 
						// 		action: <action>
 | 
				
			||||||
 | 
						// 	}
 | 
				
			||||||
 | 
						//
 | 
				
			||||||
 | 
						// Syntax:
 | 
				
			||||||
 | 
						// 		<path>/<name>:<value>/<name>:<value>/../action
 | 
				
			||||||
 | 
						//
 | 
				
			||||||
 | 
						// XXX the problem here is that we could legitimately create path 
 | 
				
			||||||
 | 
						// 		items containing ":" -- it either needs to be a reserved char
 | 
				
			||||||
 | 
						// 		or this scheme will not work...
 | 
				
			||||||
 | 
						splitArgs: function(path){
 | 
				
			||||||
 | 
							path = this.normalize(path, 'array')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							var res = {
 | 
				
			||||||
 | 
								path: '',
 | 
				
			||||||
 | 
								args: {},
 | 
				
			||||||
 | 
								actions: path.pop(),
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							var state = 'path'
 | 
				
			||||||
 | 
							var cur, value
 | 
				
			||||||
 | 
							for(var elem of path){
 | 
				
			||||||
 | 
								if(elem.includes(':')){
 | 
				
			||||||
 | 
									state = 'arg' }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								if(state == 'path'){
 | 
				
			||||||
 | 
									res.path += '/'+ elem
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								} else if(state == 'arg'){
 | 
				
			||||||
 | 
									;[cur, value] = elem.split(':')
 | 
				
			||||||
 | 
									res[cur] = value
 | 
				
			||||||
 | 
									state = value
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								} else if(state == 'value'){
 | 
				
			||||||
 | 
									res[cur] += '/'+ value } }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							return res },
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user