mirror of
				https://github.com/flynx/ImageGrid.git
				synced 2025-10-31 03:10:07 +00:00 
			
		
		
		
	added exportTo(..) still not final but working, also lacks a real UI...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
		
							parent
							
								
									d2717089b5
								
							
						
					
					
						commit
						01e8e39fc9
					
				| @ -40,6 +40,34 @@ if(window.CEF_dumpJSON != null){ | |||||||
| 		} | 		} | ||||||
| 		return fs.readdirSync(path) | 		return fs.readdirSync(path) | ||||||
| 	} | 	} | ||||||
|  | 	// XXX make this work across fs...
 | ||||||
|  | 	// XXX this will not overwrite...
 | ||||||
|  | 	window.copyFile = function(src, dst){ | ||||||
|  | 		if(fp.test(src)){ | ||||||
|  | 			// XXX will this work on Mac???
 | ||||||
|  | 			src = src.replace(fp, '') | ||||||
|  | 		} | ||||||
|  | 		if(fp.test(dst)){ | ||||||
|  | 			// XXX will this work on Mac???
 | ||||||
|  | 			dst = dst.replace(fp, '') | ||||||
|  | 		} | ||||||
|  | 
 | ||||||
|  | 		var path = dst.split('/') | ||||||
|  | 		path.pop() | ||||||
|  | 		path = path.join('/') | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 		// XXX make dirs...
 | ||||||
|  | 		if(!fs.existsSync(path)){ | ||||||
|  | 			console.log('making:', path) | ||||||
|  | 			// XXX NOTE: this will not make more than one dir...
 | ||||||
|  | 			fs.mkdirSync(path) | ||||||
|  | 		} | ||||||
|  | 
 | ||||||
|  | 		if(!fs.existsSync(dst)){ | ||||||
|  | 			fs.linkSync(src, dst) | ||||||
|  | 		} | ||||||
|  | 	} | ||||||
| 	window.dumpJSON = function(path, data){ | 	window.dumpJSON = function(path, data){ | ||||||
| 		if(fp.test(path)){ | 		if(fp.test(path)){ | ||||||
| 			// XXX will this work on Mac???
 | 			// XXX will this work on Mac???
 | ||||||
|  | |||||||
							
								
								
									
										53
									
								
								ui/files.js
									
									
									
									
									
								
							
							
						
						
									
										53
									
								
								ui/files.js
									
									
									
									
									
								
							| @ -555,6 +555,59 @@ function updateRibbonsFromFavDirs(){ | |||||||
| } | } | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|  | // Export current state to directory...
 | ||||||
|  | //
 | ||||||
|  | // NOTE: if size is null, the original image will be copied...
 | ||||||
|  | function exportTo(path, im_name, dir_name, size){ | ||||||
|  | 	path = path == null ? BASE_URL : path | ||||||
|  | 	im_name = im_name == null ? '%f' : im_name | ||||||
|  | 	dir_name = dir_name == null ? 'fav' : dir_name | ||||||
|  | 
 | ||||||
|  | 	var base_path = path | ||||||
|  | 	path = normalizePath(path) | ||||||
|  | 
 | ||||||
|  | 	var order = DATA.order | ||||||
|  | 	var z = (('10e' + (order.length + '').length) * 1 + '').slice(2) | ||||||
|  | 
 | ||||||
|  | 	// go through ribbons...
 | ||||||
|  | 	for(var i=DATA.ribbons.length-1; i >= 0; i--){ | ||||||
|  | 		var ribbon = DATA.ribbons[i] | ||||||
|  | 		// go through images...
 | ||||||
|  | 		for(var j=0; j < ribbon.length; j++){ | ||||||
|  | 			var gid = ribbon[j] | ||||||
|  | 			// get correct preview...
 | ||||||
|  | 			var src = getBestPreview(gid, size).url | ||||||
|  | 			var orig = IMAGES[gid].path.split('/').pop() | ||||||
|  | 
 | ||||||
|  | 			// form image name...
 | ||||||
|  | 			var dest = im_name | ||||||
|  | 			// full filename...
 | ||||||
|  | 			dest = dest.replace('%f', orig) | ||||||
|  | 			// file name w.o. ext...
 | ||||||
|  | 			dest = dest.replace('%n', orig.split('.')[0]) | ||||||
|  | 			// ext...
 | ||||||
|  | 			dest = dest.replace('%e', src.split('.').pop()) | ||||||
|  | 			// gid...
 | ||||||
|  | 			dest = dest.replace('%gid', gid) | ||||||
|  | 			dest = dest.replace('%g', gid.slice(34)) | ||||||
|  | 			// order...
 | ||||||
|  | 			var o = order.indexOf(gid) + '' | ||||||
|  | 			dest = dest.replace('%i', (z + o).slice(o.length)) | ||||||
|  | 			// XXX Metadata...
 | ||||||
|  | 			// XXX
 | ||||||
|  | 
 | ||||||
|  | 			dest = path +'/'+ dest | ||||||
|  | 
 | ||||||
|  | 			// XXX link...
 | ||||||
|  | 			//console.log('>>>', dest)
 | ||||||
|  | 			copyFile(src, dest) | ||||||
|  | 		} | ||||||
|  | 
 | ||||||
|  | 		path = normalizePath(path +'/'+ dir_name) | ||||||
|  | 	} | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
| 
 | 
 | ||||||
| /********************************************************************** | /********************************************************************** | ||||||
| * vim:set ts=4 sw=4 :                                                */ | * vim:set ts=4 sw=4 :                                                */ | ||||||
|  | |||||||
| @ -481,7 +481,30 @@ var KEYBOARD_CONFIG = { | |||||||
| 						saveFileState() | 						saveFileState() | ||||||
| 
 | 
 | ||||||
| 						showStatusQ('Saving: Done.') | 						showStatusQ('Saving: Done.') | ||||||
| 					}) | 					}), | ||||||
|  | 				'ctrl+shift': doc('Export', | ||||||
|  | 					function(){ | ||||||
|  | 						// XXX a dialog with alternatives...
 | ||||||
|  | 						// 		Export modes:
 | ||||||
|  | 						// 			- source:
 | ||||||
|  | 						// 				- all (default)
 | ||||||
|  | 						// 				- current ribbon only
 | ||||||
|  | 						// 				- marked only (can be combined with current ribbon)
 | ||||||
|  | 						// 			- structure
 | ||||||
|  | 						// 				- flat
 | ||||||
|  | 						// 				- fav dirs
 | ||||||
|  | 						// 			- naming
 | ||||||
|  | 						// 				- fav dir name (default: fav)
 | ||||||
|  | 						// 				- image file name (default: %f)
 | ||||||
|  | 						// 					(add several presets like %f for filename,
 | ||||||
|  | 						// 					%(tag) for metadata tag values, etc.)
 | ||||||
|  | 						// 			- common metadata
 | ||||||
|  | 						// 				- comment
 | ||||||
|  | 						// 				- ...
 | ||||||
|  | 						// 			- destination
 | ||||||
|  | 						// 				- ndir with current path as default
 | ||||||
|  | 						// 				- dir to create (default: "")
 | ||||||
|  | 					}),  | ||||||
| 			}, | 			}, | ||||||
| 		Z: { | 		Z: { | ||||||
| 				ctrl: doc('Restore to last saved state',  | 				ctrl: doc('Restore to last saved state',  | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user