mirror of
				https://github.com/flynx/ImageGrid.git
				synced 2025-10-30 02:40:08 +00:00 
			
		
		
		
	tweaks and fixes...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
		
							parent
							
								
									5603acbd3b
								
							
						
					
					
						commit
						dc07d95cd1
					
				| @ -43,17 +43,37 @@ var base = require('features/base') | |||||||
| // 		alone at first and then either create new instances or setup 
 | // 		alone at first and then either create new instances or setup 
 | ||||||
| // 		additional features as needed...
 | // 		additional features as needed...
 | ||||||
| 
 | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | var CLIActions = actions.Actions({ | ||||||
|  | 	makeIndex: ['- System/', | ||||||
|  | 		function(path){ | ||||||
|  | 			var that = this | ||||||
|  | 
 | ||||||
|  | 			return this.loadImages(path) | ||||||
|  | 				.then(function(){ return that.makePreviews('all') }) | ||||||
|  | 				.then(function(){ return that.sortImages() }) | ||||||
|  | 				//.then(function(){ return that.readAllMetadata() })
 | ||||||
|  | 				.then(function(){ return that.saveIndex() }) | ||||||
|  | 		}], | ||||||
|  | }) | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
| var CLI =  | var CLI =  | ||||||
| module.CLI = core.ImageGridFeatures.Feature({ | module.CLI = core.ImageGridFeatures.Feature({ | ||||||
| 	title: '', | 	title: '', | ||||||
| 	doc: '', | 	doc: '', | ||||||
| 
 | 
 | ||||||
| 	tag: 'commandline', | 	tag: 'commandline', | ||||||
| 	depends: ['lifecycle'], | 	depends: [ | ||||||
|  | 		'lifecycle' | ||||||
|  | 	], | ||||||
| 
 | 
 | ||||||
| 	isApplicable: function(){  | 	isApplicable: function(){  | ||||||
| 		return this.runtime == 'node' || this.runtime == 'nw' }, | 		return this.runtime == 'node' || this.runtime == 'nw' }, | ||||||
| 
 | 
 | ||||||
|  | 	actions: CLIActions, | ||||||
|  | 
 | ||||||
| 	handlers: [ | 	handlers: [ | ||||||
| 		['start', | 		['start', | ||||||
| 			function(){ | 			function(){ | ||||||
| @ -133,6 +153,45 @@ module.CLI = core.ImageGridFeatures.Feature({ | |||||||
| 							.setup(that, ['viewer-minimal']) | 							.setup(that, ['viewer-minimal']) | ||||||
| 					}) | 					}) | ||||||
| 
 | 
 | ||||||
|  | 					.option('repl, --repl', 'start an ImageGrin REPL', function(){ | ||||||
|  | 						//var repl = require('repl')
 | ||||||
|  | 
 | ||||||
|  | 						//var ig = core.ImageGridFeatures
 | ||||||
|  | 
 | ||||||
|  | 						repl.start({ | ||||||
|  | 							prompt: 'ig> ', | ||||||
|  | 
 | ||||||
|  | 							input: process.stdin, | ||||||
|  | 							output: process.stdout, | ||||||
|  | 
 | ||||||
|  | 							ignoreUndefined: true, | ||||||
|  | 
 | ||||||
|  | 							/* | ||||||
|  | 							eval: function(str, context, filename, callback){ | ||||||
|  | 								var res | ||||||
|  | 
 | ||||||
|  | 								var lst = str.split(/\s+/) | ||||||
|  | 								var cmd = lst.shift() | ||||||
|  | 
 | ||||||
|  | 								// we got an action...
 | ||||||
|  | 								if(cmd == 'var'){ | ||||||
|  | 									eval(str, context, filename, callback) | ||||||
|  | 
 | ||||||
|  | 								// action...
 | ||||||
|  | 								} else if(cmd in ig){ | ||||||
|  | 									ig[cmd].apply(ig, lst.map(eval)) | ||||||
|  | 
 | ||||||
|  | 								// err
 | ||||||
|  | 								} else { | ||||||
|  | 									// XXX
 | ||||||
|  | 								} | ||||||
|  | 
 | ||||||
|  | 								callback(null, res) | ||||||
|  | 							}, | ||||||
|  | 							*/ | ||||||
|  | 						}) | ||||||
|  | 					}) | ||||||
|  | 
 | ||||||
| 					// XXX the problem with this is that it still tires 
 | 					// XXX the problem with this is that it still tires 
 | ||||||
| 					// 		to find and run 'ig-index'...
 | 					// 		to find and run 'ig-index'...
 | ||||||
| 					/* | 					/* | ||||||
| @ -147,7 +206,9 @@ module.CLI = core.ImageGridFeatures.Feature({ | |||||||
| 					.arguments('<action> [args]') | 					.arguments('<action> [args]') | ||||||
| 					.action(function(action, args){ | 					.action(function(action, args){ | ||||||
| 						// XXX
 | 						// XXX
 | ||||||
| 						console.log('>>>>', action, args) | 						//console.log('>>>>', action, args, !!that[action])
 | ||||||
|  | 
 | ||||||
|  | 						that[action](args) | ||||||
| 					}) | 					}) | ||||||
| 
 | 
 | ||||||
| 					.parse(argv) | 					.parse(argv) | ||||||
|  | |||||||
| @ -279,10 +279,12 @@ var FileSystemLoaderActions = actions.Actions({ | |||||||
| 				method: 'loadImages', | 				method: 'loadImages', | ||||||
| 			} | 			} | ||||||
| 
 | 
 | ||||||
| 			glob(path + '/'+ this.config['image-file-pattern'],  | 			return new Promise(function(resolve, reject){ | ||||||
| 					{stat: !!this.config['image-file-read-stat']}) | 				glob(path + '/'+ that.config['image-file-pattern'],  | ||||||
|  | 						{stat: !!that.config['image-file-read-stat']}) | ||||||
| 					.on('error', function(err){ | 					.on('error', function(err){ | ||||||
| 						console.log('!!!!', err) | 						console.log('!!!!', err) | ||||||
|  | 						reject(err) | ||||||
| 					}) | 					}) | ||||||
| 					/* | 					/* | ||||||
| 					.on('match', function(img){ | 					.on('match', function(img){ | ||||||
| @ -322,6 +324,9 @@ var FileSystemLoaderActions = actions.Actions({ | |||||||
| 							path: path, | 							path: path, | ||||||
| 							method: 'loadImages', | 							method: 'loadImages', | ||||||
| 						} | 						} | ||||||
|  | 
 | ||||||
|  | 						resolve(that) | ||||||
|  | 					}) | ||||||
| 			}) | 			}) | ||||||
| 		}], | 		}], | ||||||
| 
 | 
 | ||||||
| @ -1087,6 +1092,7 @@ var FileSystemWriterActions = actions.Actions({ | |||||||
| 		// 		- vertical
 | 		// 		- vertical
 | ||||||
| 		// 		- horizontal
 | 		// 		- horizontal
 | ||||||
| 		// 		- ...
 | 		// 		- ...
 | ||||||
|  | 		// XXX this repeats sharp.SharpActions.config['preview-sizes']
 | ||||||
| 		'export-preview-sizes': [ | 		'export-preview-sizes': [ | ||||||
| 			'500', | 			'500', | ||||||
| 			'900', | 			'900', | ||||||
|  | |||||||
| @ -39,6 +39,7 @@ core.ImageGridFeatures.Feature('viewer-minimal', [ | |||||||
| 	'image-bookmarks', | 	'image-bookmarks', | ||||||
| 
 | 
 | ||||||
| 	'fs', | 	'fs', | ||||||
|  | 	'sharp', | ||||||
| 
 | 
 | ||||||
| 	'metadata', | 	'metadata', | ||||||
| ]) | ]) | ||||||
| @ -52,8 +53,6 @@ core.ImageGridFeatures.Feature('viewer-testing', [ | |||||||
| 	'ui', | 	'ui', | ||||||
| 	'keyboard', | 	'keyboard', | ||||||
| 
 | 
 | ||||||
| 	'sharp', |  | ||||||
| 
 |  | ||||||
| 	'ui-ribbons-placement', | 	'ui-ribbons-placement', | ||||||
| 
 | 
 | ||||||
| 	'ui-fullscreen-controls', | 	'ui-fullscreen-controls', | ||||||
|  | |||||||
| @ -45,6 +45,7 @@ var SharpActions = actions.Actions({ | |||||||
| 
 | 
 | ||||||
| 		'preview-normalized': true, | 		'preview-normalized': true, | ||||||
| 
 | 
 | ||||||
|  | 		// XXX this repeats filesystem.FileSystemWriterActions.config['export-preview-sizes']
 | ||||||
| 		'preview-sizes': [ | 		'preview-sizes': [ | ||||||
| 			1920, | 			1920, | ||||||
| 			1280, | 			1280, | ||||||
| @ -100,9 +101,8 @@ var SharpActions = actions.Actions({ | |||||||
| 				.sort() | 				.sort() | ||||||
| 				.reverse() | 				.reverse() | ||||||
| 
 | 
 | ||||||
| 			sizes = sizes || cfg_sizes | 			if(sizes){ | ||||||
| 				sizes = sizes instanceof Array ? sizes : [sizes] | 				sizes = sizes instanceof Array ? sizes : [sizes] | ||||||
| 
 |  | ||||||
| 				// normalize to preview size...
 | 				// normalize to preview size...
 | ||||||
| 				sizes = (this.config['preview-normalized'] ?  | 				sizes = (this.config['preview-normalized'] ?  | ||||||
| 					sizes | 					sizes | ||||||
| @ -111,19 +111,22 @@ var SharpActions = actions.Actions({ | |||||||
| 					: sizes) | 					: sizes) | ||||||
| 						.unique() | 						.unique() | ||||||
| 
 | 
 | ||||||
|  | 			} else { | ||||||
|  | 				sizes = cfg_sizes | ||||||
|  | 			} | ||||||
|  | 
 | ||||||
| 			var that = this | 			var that = this | ||||||
| 			return Promise.all(images.map(function(gid){ | 			return Promise.all(images.map(function(gid){ | ||||||
| 				var data = that.images[gid] | 				var data = that.images[gid] | ||||||
| 				var preview = data.preview = data.preview || {} |  | ||||||
| 				var path = that.getImagePath(gid) | 				var path = that.getImagePath(gid) | ||||||
| 
 | 
 | ||||||
| 				var img = sharp(path) | 				var preview = data.preview = data.preview || {} | ||||||
| 
 | 
 | ||||||
|  | 				var img = sharp(path) | ||||||
| 				return img.metadata().then(function(metadata){ | 				return img.metadata().then(function(metadata){ | ||||||
| 					var orig_res = Math.max(metadata.width, metadata.height) | 					var orig_res = Math.max(metadata.width, metadata.height) | ||||||
| 
 | 
 | ||||||
| 					return Promise.all(sizes.map(function(res){ | 					return Promise.all(sizes.map(function(res){ | ||||||
| 
 |  | ||||||
| 						// skip if image is smaller than res...
 | 						// skip if image is smaller than res...
 | ||||||
| 						if(res >= orig_res){ | 						if(res >= orig_res){ | ||||||
| 							return  | 							return  | ||||||
| @ -193,6 +196,7 @@ module.Sharp = core.ImageGridFeatures.Feature({ | |||||||
| 		// 		- if image too large to set the preview to "loading..."
 | 		// 		- if image too large to set the preview to "loading..."
 | ||||||
| 		// 		- create previews...
 | 		// 		- create previews...
 | ||||||
| 		// 		- update image...
 | 		// 		- update image...
 | ||||||
|  | 		/* | ||||||
| 		['updateImage.pre', | 		['updateImage.pre', | ||||||
| 			function(gid){ | 			function(gid){ | ||||||
| 				var that = this | 				var that = this | ||||||
| @ -216,6 +220,7 @@ module.Sharp = core.ImageGridFeatures.Feature({ | |||||||
| 						}) | 						}) | ||||||
| 				} | 				} | ||||||
| 			}] | 			}] | ||||||
|  | 		//*/
 | ||||||
| 	], | 	], | ||||||
| }) | }) | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -1035,11 +1035,14 @@ var WidgetTestActions = actions.Actions({ | |||||||
| 
 | 
 | ||||||
| 				make('---') | 				make('---') | ||||||
| 
 | 
 | ||||||
|  | 
 | ||||||
| 				make('close parent') | 				make('close parent') | ||||||
| 					.on('open', function(){ | 					.on('open', function(){ | ||||||
| 						that.parent.close() | 						that.parent.close() | ||||||
| 					}) | 					}) | ||||||
| 
 | 
 | ||||||
|  | 				make('...') | ||||||
|  | 
 | ||||||
| 				// NOTE: the dialog's .parent is not yet set at this point...
 | 				// NOTE: the dialog's .parent is not yet set at this point...
 | ||||||
| 
 | 
 | ||||||
| 				// This will finalize the dialog...
 | 				// This will finalize the dialog...
 | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user