mirror of
				https://github.com/flynx/pWiki.git
				synced 2025-10-31 11:00:08 +00:00 
			
		
		
		
	added masic tag listing...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
		
							parent
							
								
									a0152c4192
								
							
						
					
					
						commit
						01e59af5a1
					
				| @ -76,8 +76,8 @@ object.Constructor('BasePage', { | |||||||
| 		type: true, | 		type: true, | ||||||
| 		ctime: true, | 		ctime: true, | ||||||
| 		mtime: true, | 		mtime: true, | ||||||
| 		// XXX TAGS HACK -- should this be a list???
 | 		// XXX
 | ||||||
| 		tags: 'tagstr', | 		//tags: true,
 | ||||||
| 	}, | 	}, | ||||||
| 	// These actions will be default get :$ARGS appended if no args are 
 | 	// These actions will be default get :$ARGS appended if no args are 
 | ||||||
| 	// explicitly given...
 | 	// explicitly given...
 | ||||||
| @ -358,9 +358,6 @@ object.Constructor('BasePage', { | |||||||
| 			...(await this.data), | 			...(await this.data), | ||||||
| 			tags: [...value], | 			tags: [...value], | ||||||
| 		} }.call(this) }, | 		} }.call(this) }, | ||||||
| 	// XXX TAGS HACK -- should this be a list???
 |  | ||||||
| 	get tagstr(){ return async function(){ |  | ||||||
| 		return JSON.stringify(await this.tags ?? []).slice(1,-1) }.call(this) }, |  | ||||||
| 	tag: async function(...tags){ | 	tag: async function(...tags){ | ||||||
| 		this.tags = [...new Set([ | 		this.tags = [...new Set([ | ||||||
| 			...(await this.tags),  | 			...(await this.tags),  | ||||||
| @ -2065,7 +2062,7 @@ module.System = { | |||||||
| 
 | 
 | ||||||
| 			type: @source(../type)<br> | 			type: @source(../type)<br> | ||||||
| 
 | 
 | ||||||
| 			tags: @source(../tags)<br> | 			tags: @source(../tags join=", ")<br> | ||||||
| 
 | 
 | ||||||
| 			ctime: @source(../ctime)<br> | 			ctime: @source(../ctime)<br> | ||||||
| 			mtime: @source(../mtime)<br> | 			mtime: @source(../mtime)<br> | ||||||
| @ -2077,8 +2074,19 @@ module.System = { | |||||||
| 	stores: function(){ | 	stores: function(){ | ||||||
| 		return Object.keys(this.store.substores ?? {}) }, | 		return Object.keys(this.store.substores ?? {}) }, | ||||||
| 
 | 
 | ||||||
| 	tagslist: function(){ | 	// tags...
 | ||||||
| 		return this.tags }, | 	//
 | ||||||
|  | 	// XXX should these be actions???
 | ||||||
|  | 	// 		...actions do not yet support lists/generators...
 | ||||||
|  | 	tags: async function*(){ | ||||||
|  | 		yield* this.get('..').tags }, | ||||||
|  | 	allTags: async function*(){ | ||||||
|  | 		yield* Object.keys((await this.store.tags).tags) }, | ||||||
|  | 	relatedTags: async function*(){ | ||||||
|  | 		yield* this.store.relatedTags( | ||||||
|  | 			...((await this.args.tags) | ||||||
|  | 				?? this.get('..').tags | ||||||
|  | 				?? [])) }, | ||||||
| 
 | 
 | ||||||
| 	// page parts...
 | 	// page parts...
 | ||||||
| 	//
 | 	//
 | ||||||
|  | |||||||
| @ -282,6 +282,18 @@ module.BaseStore = { | |||||||
| 	get tags(){ | 	get tags(){ | ||||||
| 		return this.__tags() }, | 		return this.__tags() }, | ||||||
| 
 | 
 | ||||||
|  | 	relatedTags: function*(...tags){ | ||||||
|  | 		var cur = tags | ||||||
|  | 		var {tags, paths} = this.tags  | ||||||
|  | 		var seen = new Set() | ||||||
|  | 		for(var tag of cur){ | ||||||
|  | 			for(var p of tags[tag] ?? []){ | ||||||
|  | 				for(var t of paths[p] ?? []){ | ||||||
|  | 					if(!seen.has(t)){ | ||||||
|  | 						seen.add(t) | ||||||
|  | 						yield t } } } } }, | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
| 	// XXX text search index (???)
 | 	// XXX text search index (???)
 | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -17,6 +17,12 @@ | |||||||
| * 		- CLI | * 		- CLI | ||||||
| * | * | ||||||
| * | * | ||||||
|  | * XXX BUG: | ||||||
|  | * 			await pwiki.parse('@source(/Test/list/static join=", ")') | ||||||
|  | *				-> 'abcdef, abcdef, abcdef, abcdef, abcdef, abcdef' | ||||||
|  | *		should be: | ||||||
|  | * 			await pwiki.parse('@source(/Test/list/static join=", ")') | ||||||
|  | *				-> 'a, b, c, d, e, f' | ||||||
| * XXX TAGS should ./tags (i.e. .tagstr) return a list of tags??? | * XXX TAGS should ./tags (i.e. .tagstr) return a list of tags??? | ||||||
| * XXX TAGS | * XXX TAGS | ||||||
| * 		- add tags to page -- macro/filter | * 		- add tags to page -- macro/filter | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user