mirror of
				https://github.com/flynx/ImageGrid.git
				synced 2025-10-31 11:20:09 +00:00 
			
		
		
		
	minor cleanup...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
		
							parent
							
								
									b6e2847fda
								
							
						
					
					
						commit
						74f83dd637
					
				| @ -1985,6 +1985,8 @@ module.CollectionTags = core.ImageGridFeatures.Feature({ | |||||||
| 				var local_tags = (this.collections[title] || {}).local_tags || {} | 				var local_tags = (this.collections[title] || {}).local_tags || {} | ||||||
| 
 | 
 | ||||||
| 				return function(){ | 				return function(){ | ||||||
|  | 					tags.__index = tags.__index || {} | ||||||
|  | 
 | ||||||
| 					// load local_tags...
 | 					// load local_tags...
 | ||||||
| 					local_tag_names | 					local_tag_names | ||||||
| 						.forEach(function(tag){  | 						.forEach(function(tag){  | ||||||
|  | |||||||
| @ -50,6 +50,8 @@ var util = require('lib/util') | |||||||
| /*********************************************************************/ | /*********************************************************************/ | ||||||
| // Helpers...
 | // Helpers...
 | ||||||
| 
 | 
 | ||||||
|  | // Method input/output normalization...
 | ||||||
|  | //
 | ||||||
| // Normalize a split that contains either multiple values or a list to 
 | // Normalize a split that contains either multiple values or a list to 
 | ||||||
| // a list enabling the following method signature:
 | // a list enabling the following method signature:
 | ||||||
| //
 | //
 | ||||||
| @ -72,10 +74,10 @@ var util = require('lib/util') | |||||||
| // 	func([1], [2], 3)	// -> [[1], [2], 3]
 | // 	func([1], [2], 3)	// -> [[1], [2], 3]
 | ||||||
| //
 | //
 | ||||||
| var normalizeSplit = function(args){ | var normalizeSplit = function(args){ | ||||||
| 	return (args.length == 1 && args[0] instanceof Array) ?  | 	return ((args.length == 1 && args[0] instanceof Array) ?  | ||||||
| 		args.pop().slice() | 			args.pop() | ||||||
| 		: args.slice() } | 			: args) | ||||||
| 
 | 		.slice() } | ||||||
| // Normalize return value from Object.processor.run(..)...
 | // Normalize return value from Object.processor.run(..)...
 | ||||||
| //
 | //
 | ||||||
| // 	Create processor...
 | // 	Create processor...
 | ||||||
| @ -118,7 +120,6 @@ var normalizeRes = function(args){ | |||||||
| 		return (args.length == 1 && !(args[0] instanceof Array)) ?  | 		return (args.length == 1 && !(args[0] instanceof Array)) ?  | ||||||
| 			value[0] | 			value[0] | ||||||
| 			: value } } | 			: value } } | ||||||
| 
 |  | ||||||
| // Normalize return value...
 | // Normalize return value...
 | ||||||
| //
 | //
 | ||||||
| // 	normalizeResValue(value, args)
 | // 	normalizeResValue(value, args)
 | ||||||
| @ -134,6 +135,7 @@ var normalizeResValue = function(value, args){ | |||||||
| /*********************************************************************/ | /*********************************************************************/ | ||||||
| 
 | 
 | ||||||
| // meta stuff...
 | // meta stuff...
 | ||||||
|  | //
 | ||||||
| var makeSplitter = function(separator, unique){ | var makeSplitter = function(separator, unique){ | ||||||
| 	return function(...tags){ | 	return function(...tags){ | ||||||
| 		var SP = this[separator] | 		var SP = this[separator] | ||||||
| @ -188,12 +190,15 @@ var BaseTagsClassPrototype = { | |||||||
| 
 | 
 | ||||||
| 	// Utils...
 | 	// Utils...
 | ||||||
| 	//
 | 	//
 | ||||||
| 	isQuoted: function(tag){ | 	// check if str is in single or double quotes (ex: '"abc"' or "'abc'")...
 | ||||||
| 		return /^\s*(['"]).*\1\s*$/.test(tag) }, | 	isQuoted: function(str){ | ||||||
| 	isStarred: function(tag){ | 		return /^\s*(['"]).*\1\s*$/.test(str) }, | ||||||
| 		return /^\s*(\*).*\1\s*$/.test(tag) }, | 	// check if string surrounded with '*' (ex: '*abc*')...
 | ||||||
| 	isPattern: function(tag){ | 	isStarred: function(str){ | ||||||
| 		return /\*/.test(tag) }, | 		return /^\s*(\*).*\1\s*$/.test(str) }, | ||||||
|  | 	// check if string contains at least one '*'...
 | ||||||
|  | 	isPattern: function(str){ | ||||||
|  | 		return /\*/.test(str) }, | ||||||
| 	//
 | 	//
 | ||||||
| 	// 	.splitSet(tag)
 | 	// 	.splitSet(tag)
 | ||||||
| 	// 	.splitSet(tag, ..)
 | 	// 	.splitSet(tag, ..)
 | ||||||
| @ -283,7 +288,7 @@ var BaseTagsClassPrototype = { | |||||||
| 							set.join(SS) | 							set.join(SS) | ||||||
| 							: set }) | 							: set }) | ||||||
| 					.join(PS) }) }, | 					.join(PS) }) }, | ||||||
| 
 | 	// get all the single tags that make up a compound tag...
 | ||||||
| 	subTags: function(...tags){ | 	subTags: function(...tags){ | ||||||
| 		return this.splitTag(...tags).flat(Infinity) }, | 		return this.splitTag(...tags).flat(Infinity) }, | ||||||
| 
 | 
 | ||||||
| @ -305,15 +310,22 @@ var BaseTagsClassPrototype = { | |||||||
| 								.unique() | 								.unique() | ||||||
| 								.sort() | 								.sort() | ||||||
| 							: set }) }) }, | 							: set }) }) }, | ||||||
| 
 |  | ||||||
| 	// Normalize tags...
 | 	// Normalize tags...
 | ||||||
| 	//
 | 	//
 | ||||||
| 	// 	.normalize(tag)
 | 	// 	.normalize(tag)
 | ||||||
| 	// 		-> ntag
 | 	// 		-> tag
 | ||||||
| 	//
 | 	//
 | ||||||
| 	// 	.normalize(tag, ...)
 | 	// 	.normalize(tag, ...)
 | ||||||
| 	// 	.normalize([tag, ...])
 | 	// 	.normalize([tag, ...])
 | ||||||
| 	// 		-> [ntag, ...]
 | 	// 		-> [tag, ...]
 | ||||||
|  | 	//
 | ||||||
|  | 	//
 | ||||||
|  | 	// This will:
 | ||||||
|  | 	// 	- remove ILLEGAL_CHARS
 | ||||||
|  | 	// 	- convert string to lower case
 | ||||||
|  | 	// 	- convert '\' or '/'
 | ||||||
|  | 	// 	- collapse repeating ':' or '/' to a single char
 | ||||||
|  | 	// 	- sort tag sets in alphabetical order
 | ||||||
| 	//
 | 	//
 | ||||||
| 	//
 | 	//
 | ||||||
| 	// NOTE: path sections take priority over set sections, i.e. a set is
 | 	// NOTE: path sections take priority over set sections, i.e. a set is
 | ||||||
| @ -491,7 +503,7 @@ var BaseTagsPrototype = { | |||||||
| 	get length(){ | 	get length(){ | ||||||
| 		return this.values().length }, | 		return this.values().length }, | ||||||
| 
 | 
 | ||||||
| 	// All persistent tags...
 | 	// All persistent tags (set)...
 | ||||||
| 	//
 | 	//
 | ||||||
| 	// This will combine .persistent and .definitionPaths()
 | 	// This will combine .persistent and .definitionPaths()
 | ||||||
| 	get persistentAll(){ | 	get persistentAll(){ | ||||||
| @ -521,7 +533,6 @@ var BaseTagsPrototype = { | |||||||
| 	subTags: BaseTagsClassPrototype.subTags,  | 	subTags: BaseTagsClassPrototype.subTags,  | ||||||
| 	 | 	 | ||||||
| 
 | 
 | ||||||
| 
 |  | ||||||
| 	// Tag matching and filtering...
 | 	// Tag matching and filtering...
 | ||||||
| 	//
 | 	//
 | ||||||
| 	// Match tags directly...
 | 	// Match tags directly...
 | ||||||
| @ -1490,7 +1501,6 @@ var BaseTagsPrototype = { | |||||||
| 	removeTag: function(tag, ...tags){ | 	removeTag: function(tag, ...tags){ | ||||||
| 		return this.rename(tag, '', ...tags) }, | 		return this.rename(tag, '', ...tags) }, | ||||||
| 
 | 
 | ||||||
| 
 |  | ||||||
| 	// Replace values...
 | 	// Replace values...
 | ||||||
| 	//
 | 	//
 | ||||||
| 	// 	.replaceValue(from, to)
 | 	// 	.replaceValue(from, to)
 | ||||||
| @ -1701,7 +1711,6 @@ var BaseTagsPrototype = { | |||||||
| 	// 			ts.optimizeTags()	// will remove 'a/c' form x as it is 
 | 	// 			ts.optimizeTags()	// will remove 'a/c' form x as it is 
 | ||||||
| 	// 								// fully contained within 'a/b/c'...
 | 	// 								// fully contained within 'a/b/c'...
 | ||||||
| 	//
 | 	//
 | ||||||
| 	//
 |  | ||||||
| 	optimizeTags: function(...values){ | 	optimizeTags: function(...values){ | ||||||
| 		var that = this | 		var that = this | ||||||
| 		return (normalizeSplit(values) || this.values()) | 		return (normalizeSplit(values) || this.values()) | ||||||
| @ -2395,6 +2404,7 @@ var TagsWithDictPrototype = { | |||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| 	// Save/clean dict on prototype methods...
 | 	// Save/clean dict on prototype methods...
 | ||||||
|  | 	//
 | ||||||
| 	tag: function(tags, value){ | 	tag: function(tags, value){ | ||||||
| 		this.normalizeSave(tags) | 		this.normalizeSave(tags) | ||||||
| 		return object.parent(TagsWithDictPrototype.tag, this).call(this, ...arguments) }, | 		return object.parent(TagsWithDictPrototype.tag, this).call(this, ...arguments) }, | ||||||
| @ -2452,6 +2462,7 @@ var TagsWithDictPrototype = { | |||||||
| 			&& this.removeOrphansFromDict(tag) | 			&& this.removeOrphansFromDict(tag) | ||||||
| 		return res | 		return res | ||||||
| 	}, | 	}, | ||||||
|  | 
 | ||||||
| 	// Serialization...
 | 	// Serialization...
 | ||||||
| 	//
 | 	//
 | ||||||
| 	// Format:
 | 	// Format:
 | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user