mirror of
				https://github.com/flynx/pWiki.git
				synced 2025-11-04 04:50:09 +00:00 
			
		
		
		
	some tweaking and cleanup...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
		
							parent
							
								
									63539dde4b
								
							
						
					
					
						commit
						7255be8c35
					
				@ -577,15 +577,8 @@ object.Constructor('BasePage', {
 | 
				
			|||||||
			}) },
 | 
								}) },
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// XXX should this be an iterator???
 | 
						// XXX should this be an iterator???
 | 
				
			||||||
	// XXX EXPERIMENTAL...
 | 
					 | 
				
			||||||
	// 		to be sync this needs:
 | 
					 | 
				
			||||||
	// 			.energetic
 | 
					 | 
				
			||||||
	// 			.store.isEnergetic(..)
 | 
					 | 
				
			||||||
	// 			.resolve(..) -> .store.resolve(..)
 | 
					 | 
				
			||||||
	// XXX should this support strict mode???
 | 
					 | 
				
			||||||
	each: function(path, strict){
 | 
						each: function(path, strict){
 | 
				
			||||||
		var that = this
 | 
							var that = this
 | 
				
			||||||
		// XXX STRICT...
 | 
					 | 
				
			||||||
		if(path === true || path === false){
 | 
							if(path === true || path === false){
 | 
				
			||||||
			strict = path
 | 
								strict = path
 | 
				
			||||||
			path = null }
 | 
								path = null }
 | 
				
			||||||
@ -615,7 +608,6 @@ object.Constructor('BasePage', {
 | 
				
			|||||||
		return Promise.iter(
 | 
							return Promise.iter(
 | 
				
			||||||
			paths,
 | 
								paths,
 | 
				
			||||||
			function(path){
 | 
								function(path){
 | 
				
			||||||
				// XXX STRICT...
 | 
					 | 
				
			||||||
				return strict ?
 | 
									return strict ?
 | 
				
			||||||
					Promise.awaitOrRun(
 | 
										Promise.awaitOrRun(
 | 
				
			||||||
						that.exists('/'+path),
 | 
											that.exists('/'+path),
 | 
				
			||||||
@ -624,32 +616,7 @@ object.Constructor('BasePage', {
 | 
				
			|||||||
								that.get('/'+ path)
 | 
													that.get('/'+ path)
 | 
				
			||||||
								: [] })
 | 
													: [] })
 | 
				
			||||||
					: that.get('/'+ path) })
 | 
										: that.get('/'+ path) })
 | 
				
			||||||
				/*/ // XXX STRICT...
 | 
					 | 
				
			||||||
				return that.get('/'+ path) })
 | 
					 | 
				
			||||||
				//*/
 | 
					 | 
				
			||||||
			.sync() },
 | 
								.sync() },
 | 
				
			||||||
	/*/ // XXX ASYNC...
 | 
					 | 
				
			||||||
	each: async function*(path){
 | 
					 | 
				
			||||||
		// NOTE: we are trying to avoid resolving non-pattern paths unless 
 | 
					 | 
				
			||||||
		// 		we really have to...
 | 
					 | 
				
			||||||
		path = path ?
 | 
					 | 
				
			||||||
			pwpath.relative(this.path, path)
 | 
					 | 
				
			||||||
			: this.location
 | 
					 | 
				
			||||||
		var paths = path.includes('*') 
 | 
					 | 
				
			||||||
				// XXX ENERGETIC...
 | 
					 | 
				
			||||||
				&& !(await this.energetic
 | 
					 | 
				
			||||||
					// XXX test if energetic action...
 | 
					 | 
				
			||||||
					|| await this.store.isEnergetic(path)) ?
 | 
					 | 
				
			||||||
			this.resolve(path)
 | 
					 | 
				
			||||||
			: path
 | 
					 | 
				
			||||||
		paths = paths instanceof Array ? 
 | 
					 | 
				
			||||||
				paths 
 | 
					 | 
				
			||||||
			: paths instanceof Promise ?
 | 
					 | 
				
			||||||
				await paths
 | 
					 | 
				
			||||||
			: [paths]
 | 
					 | 
				
			||||||
		for(var path of paths){
 | 
					 | 
				
			||||||
			yield this.get('/'+ path) } },
 | 
					 | 
				
			||||||
	//*/
 | 
					 | 
				
			||||||
	// XXX is this correct here???
 | 
						// XXX is this correct here???
 | 
				
			||||||
	[Symbol.asyncIterator]: async function*(){
 | 
						[Symbol.asyncIterator]: async function*(){
 | 
				
			||||||
		yield* this.each() },
 | 
							yield* this.each() },
 | 
				
			||||||
@ -1979,52 +1946,6 @@ object.Constructor('Page', BasePage, {
 | 
				
			|||||||
	// 		actions...
 | 
						// 		actions...
 | 
				
			||||||
	//
 | 
						//
 | 
				
			||||||
	// XXX revise name...
 | 
						// XXX revise name...
 | 
				
			||||||
	/*/ XXX EXPERIMENTAL
 | 
					 | 
				
			||||||
	asPages: function(path='.:$ARGS', strict=false){
 | 
					 | 
				
			||||||
		// options...
 | 
					 | 
				
			||||||
		var args = [...arguments]
 | 
					 | 
				
			||||||
		var opts = typeof(args.at(-1)) == 'object' ?
 | 
					 | 
				
			||||||
			args.pop()
 | 
					 | 
				
			||||||
			: {}
 | 
					 | 
				
			||||||
		var {path, strict} = {
 | 
					 | 
				
			||||||
			...opts,
 | 
					 | 
				
			||||||
			path: typeof(args[0]) == 'string' ?
 | 
					 | 
				
			||||||
				args.shift()
 | 
					 | 
				
			||||||
				: '.:$ARGS',
 | 
					 | 
				
			||||||
			strict: args.shift() 
 | 
					 | 
				
			||||||
				?? false,
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		var page = this.get(path, strict)
 | 
					 | 
				
			||||||
		// each...
 | 
					 | 
				
			||||||
		if(page.isPattern){
 | 
					 | 
				
			||||||
			return page.each()
 | 
					 | 
				
			||||||
		// handle lists in pages (actions, ... etc.)...
 | 
					 | 
				
			||||||
		} else {
 | 
					 | 
				
			||||||
			return Promise.awaitOrRun(
 | 
					 | 
				
			||||||
				page.data,
 | 
					 | 
				
			||||||
				function(data){
 | 
					 | 
				
			||||||
					data = 
 | 
					 | 
				
			||||||
						data instanceof types.Generator ?
 | 
					 | 
				
			||||||
							// XXX
 | 
					 | 
				
			||||||
							//await data()
 | 
					 | 
				
			||||||
							data()
 | 
					 | 
				
			||||||
						: typeof(data) == 'function' ?
 | 
					 | 
				
			||||||
							data
 | 
					 | 
				
			||||||
						: data && 'text' in data ?
 | 
					 | 
				
			||||||
							data.text
 | 
					 | 
				
			||||||
						: null
 | 
					 | 
				
			||||||
					if(data instanceof Array
 | 
					 | 
				
			||||||
							|| data instanceof types.Generator){
 | 
					 | 
				
			||||||
						return data
 | 
					 | 
				
			||||||
							.map(function(p){
 | 
					 | 
				
			||||||
								return page.virtual({text: p}) }) }
 | 
					 | 
				
			||||||
					// do not iterate pages/actions that are undefined...
 | 
					 | 
				
			||||||
					if(data == null){
 | 
					 | 
				
			||||||
						return }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
					return page }) } },
 | 
					 | 
				
			||||||
	/*/ // XXX ASYNC...
 | 
					 | 
				
			||||||
	// XXX BUG: this does not respect strict of single pages if they do 
 | 
						// XXX BUG: this does not respect strict of single pages if they do 
 | 
				
			||||||
	// 		not exist...
 | 
						// 		not exist...
 | 
				
			||||||
	// 		...see: @macro(..) bug + .each(..)
 | 
						// 		...see: @macro(..) bug + .each(..)
 | 
				
			||||||
@ -2050,7 +1971,7 @@ object.Constructor('Page', BasePage, {
 | 
				
			|||||||
			yield* page
 | 
								yield* page
 | 
				
			||||||
		// handle lists in pages (actions, ... etc.)...
 | 
							// handle lists in pages (actions, ... etc.)...
 | 
				
			||||||
		} else {
 | 
							} else {
 | 
				
			||||||
			// page does not exist...
 | 
								// strict + page does not exist...
 | 
				
			||||||
			if(strict 
 | 
								if(strict 
 | 
				
			||||||
					&& !(await page.exists())){
 | 
										&& !(await page.exists())){
 | 
				
			||||||
				return }
 | 
									return }
 | 
				
			||||||
@ -2074,7 +1995,6 @@ object.Constructor('Page', BasePage, {
 | 
				
			|||||||
				return }
 | 
									return }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			yield page } },
 | 
								yield page } },
 | 
				
			||||||
	//*/
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// expanded page text...
 | 
						// expanded page text...
 | 
				
			||||||
	//
 | 
						//
 | 
				
			||||||
@ -2521,9 +2441,9 @@ module.System = {
 | 
				
			|||||||
							oninput="saveContent(\'@source(s ./path)/title\', this.innerText)">
 | 
												oninput="saveContent(\'@source(s ./path)/title\', this.innerText)">
 | 
				
			||||||
						@source(./title/quote)
 | 
											@source(./title/quote)
 | 
				
			||||||
					</span>
 | 
										</span>
 | 
				
			||||||
					@macro(src="." strict 
 | 
										@macro(src="." 
 | 
				
			||||||
						text=""
 | 
											strict 
 | 
				
			||||||
						else="<sup>*</sup>")
 | 
											else='<span class="new-page-indicator">new</sup>')
 | 
				
			||||||
				</h1>
 | 
									</h1>
 | 
				
			||||||
			</macro>
 | 
								</macro>
 | 
				
			||||||
			<macro texteditor>
 | 
								<macro texteditor>
 | 
				
			||||||
@ -2705,7 +2625,9 @@ module.System = {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
			Path: [@source(../path/quote)]
 | 
								Path: [@source(../path/quote)]
 | 
				
			||||||
				(<a href="#../edit">edit</a>)<br>
 | 
									(<a href="#../edit">edit</a>)<br>
 | 
				
			||||||
 | 
								<macro src=".." strict><else>
 | 
				
			||||||
				Resolved path: [/@source(../resolved/quote)]<br>
 | 
									Resolved path: [/@source(../resolved/quote)]<br>
 | 
				
			||||||
 | 
								</else></macro>
 | 
				
			||||||
			Referrer: [@source(../referrer/quote)]<br>
 | 
								Referrer: [@source(../referrer/quote)]<br>
 | 
				
			||||||
			Args: <args/><br>
 | 
								Args: <args/><br>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -2721,6 +2643,8 @@ module.System = {
 | 
				
			|||||||
			ctime: @source(../ctime)<br>
 | 
								ctime: @source(../ctime)<br>
 | 
				
			||||||
			mtime: @source(../mtime)<br>
 | 
								mtime: @source(../mtime)<br>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								<br>
 | 
				
			||||||
 | 
								Resolved text:
 | 
				
			||||||
			<hr>
 | 
								<hr>
 | 
				
			||||||
			<pre wikiwords="no"><quote filter="quote-tags" src=".."/></pre> ` },
 | 
								<pre wikiwords="no"><quote filter="quote-tags" src=".."/></pre> ` },
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -167,6 +167,12 @@ body.loading .page.spinner span {
 | 
				
			|||||||
	opacity: 0.4;
 | 
						opacity: 0.4;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					.new-page-indicator {
 | 
				
			||||||
 | 
						position: absolute;	
 | 
				
			||||||
 | 
						font-size: small;
 | 
				
			||||||
 | 
						font-style: italic;
 | 
				
			||||||
 | 
						opacity: 0.5;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* TOC */
 | 
					/* TOC */
 | 
				
			||||||
toc {
 | 
					toc {
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user