mirror of
				https://github.com/flynx/ImageGrid.git
				synced 2025-10-31 03:10:07 +00:00 
			
		
		
		
	added rough git and date updating...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
		
							parent
							
								
									74dbcd8113
								
							
						
					
					
						commit
						7849f58ca5
					
				| @ -66,6 +66,7 @@ if(window.CEF_dumpJSON != null){ | ||||
| 	} | ||||
| 	// XXX make this work across fs...
 | ||||
| 	// XXX this will not overwrite...
 | ||||
| 	// XXX set ctime to the same value as the original...
 | ||||
| 	window.copyFile = function(src, dst){ | ||||
| 		var deferred = $.Deferred() | ||||
| 		src = osPath(src) | ||||
| @ -75,7 +76,6 @@ if(window.CEF_dumpJSON != null){ | ||||
| 		path.pop() | ||||
| 		path = path.join('/') | ||||
| 
 | ||||
| 
 | ||||
| 		// make dirs...
 | ||||
| 		if(!fs.existsSync(path)){ | ||||
| 			console.log('making:', path) | ||||
| @ -380,7 +380,22 @@ if(window.CEF_dumpJSON != null){ | ||||
| 		return queue | ||||
| 	} | ||||
| 
 | ||||
| 	window.makeImageGID = function(source, make_text_gid){ | ||||
| 	// format: "20130102-122315"
 | ||||
| 	window.getEXIFDate = function(source){ | ||||
| 		var getter = $.Deferred() | ||||
| 		getVipsField('exif-ifd0-Date and Time', source) | ||||
| 			.done(function(date){ | ||||
| 				getter.resolve(date | ||||
| 					// remove substrings in braces...
 | ||||
| 					.replace(/\([^)]*\)/, '') | ||||
| 					.trim() | ||||
| 					.replace(/:/g, '') | ||||
| 					.replace(/ /g, '-')) | ||||
| 			}) | ||||
| 		return getter | ||||
| 	} | ||||
| 
 | ||||
| 	window.getEXIFGID = function(source, make_text_gid){ | ||||
| 		if(source in IMAGES){ | ||||
| 			var img = IMAGES[source] | ||||
| 			var source = normalizePath(img.path) | ||||
| @ -389,21 +404,19 @@ if(window.CEF_dumpJSON != null){ | ||||
| 
 | ||||
| 		$.when( | ||||
| 				getVipsField('exif-ifd0-Artist', source), | ||||
| 				getVipsField('exif-ifd0-Date and Time', source)) | ||||
| 				getEXIFDate(source)) | ||||
| 			.done(function(artist, date){ | ||||
| 				// Artist...
 | ||||
| 				artist = artist | ||||
| 					// remove substrings in braces...
 | ||||
| 					.replace(/\([^)]*\)/, '') | ||||
| 					.trim() | ||||
| 				artist = artist == '' ? 'Unknown' : artist | ||||
| 
 | ||||
| 				// Date...
 | ||||
| 				// format: "20130102-122315"
 | ||||
| 				// XXX if not set, get ctime...
 | ||||
| 				date = date | ||||
| 					.replace(/\([^)]*\)/, '') | ||||
| 					.trim() | ||||
| 					.replace(/:/g, '') | ||||
| 					.replace(/ /g, '-') | ||||
| 				// XXX
 | ||||
| 
 | ||||
| 				// File name...
 | ||||
| 				var name = source.split(/[\\\/]/).pop().split('.')[0] | ||||
| 
 | ||||
|  | ||||
							
								
								
									
										88
									
								
								ui/data.js
									
									
									
									
									
								
							
							
						
						
									
										88
									
								
								ui/data.js
									
									
									
									
									
								
							| @ -715,7 +715,10 @@ function orientationExif2ImageGrid(orientation){ | ||||
| // NOTE: this depends on that the base dir contains ALL the images...
 | ||||
| // NOTE: if base is not given, this will not read image to get 
 | ||||
| // 		orientation data...
 | ||||
| function imagesFromUrls(lst){ | ||||
| function imagesFromUrls(lst, ctime_getter){ | ||||
| 	ctime_getter = (ctime_getter == null  | ||||
| 			? function(){ return Date.now()/1000 }  | ||||
| 			: ctime_getter) | ||||
| 	var res = {} | ||||
| 
 | ||||
| 	$.each(lst, function(i, e){ | ||||
| @ -739,7 +742,7 @@ function imagesFromUrls(lst){ | ||||
| 			type: 'image', | ||||
| 			state: 'single', | ||||
| 			path: e, | ||||
| 			ctime: Date.now(), | ||||
| 			ctime: ctime_getter(e), | ||||
| 			preview: {}, | ||||
| 			classes: '', | ||||
| 			orientation: 0, | ||||
| @ -1606,7 +1609,7 @@ function openImageWith(prog){ | ||||
| 
 | ||||
| 
 | ||||
| /********************************************************************** | ||||
| * Experimental  | ||||
| * Experimental & utility | ||||
| */ | ||||
| 
 | ||||
| // The idea here is to add markers as first-class image-like elements...
 | ||||
| @ -1641,6 +1644,85 @@ function loadRibbonsFromPath(path, cmp, reverse, dir_name){ | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
| function readImageDate(gid, images){ | ||||
| 	images = images == null ? IMAGES : images | ||||
| 	var img = images[gid] | ||||
| 	return getEXIFDate(normalizePath(img.path)) | ||||
| 		.done(function(date){ | ||||
| 			img.ctime = Date.fromTimeStamp(date).getTime()/1000 | ||||
| 		}) | ||||
| } | ||||
| function readImagesDates(images){ | ||||
| 	images = images == null ? IMAGES : images | ||||
| 
 | ||||
| 	return $.when.apply(null, $.map(images, function(_, gid){ | ||||
| 		return readImageDate(gid, images) | ||||
| 	})) | ||||
| } | ||||
| function readImagesDatesQ(images){ | ||||
| 	images = images == null ? IMAGES : images | ||||
| 
 | ||||
| 	var queue = getWorkerQueue('date_reader') | ||||
| 
 | ||||
| 	$.each(images, function(gid, img){ | ||||
| 		queue.enqueue(readImageDate, gid, images) | ||||
| 			.always(function(){ queue.notify(gid, 'done') }) | ||||
| 	}) | ||||
| 
 | ||||
| 	return queue | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
| function updateImageGID(gid, images, data){ | ||||
| 	images = images == null ? IMAGES : images | ||||
| 	var img = images[gid] | ||||
| 	return getEXIFGID(normalizePath(img.path)) | ||||
| 		.done(function(gid){ | ||||
| 			img.id = gid | ||||
| 			// images...
 | ||||
| 			images[gid] = images[key] | ||||
| 			delete images[key] | ||||
| 
 | ||||
| 			// data...
 | ||||
| 			if(data != null){ | ||||
| 				// replace current...
 | ||||
| 				if(data.current == key){ | ||||
| 					data.current = gid | ||||
| 				} | ||||
| 				// replace in order...
 | ||||
| 				data.order[data.order.indexOf(key)] = gid | ||||
| 				// replace in ribbons...
 | ||||
| 				for(var i=0; i < data.ribbons; i++){ | ||||
| 					var r = data.ribbons[i] | ||||
| 					var k = r.indexOf(key) | ||||
| 					if(k >= 0){ | ||||
| 						r[k] = gid | ||||
| 					} | ||||
| 				} | ||||
| 			} | ||||
| 		}) | ||||
| } | ||||
| function updateImagesGIDs(images, data){ | ||||
| 	images = images == null ? IMAGES : images | ||||
| 
 | ||||
| 	return $.when.apply(null, $.map(images, function(_, key){ | ||||
| 		return updateImageGID(key, images, data) | ||||
| 	})) | ||||
| } | ||||
| function updateImagesGIDsQ(images, data){ | ||||
| 	images = images == null ? IMAGES : images | ||||
| 
 | ||||
| 	var queue = getWorkerQueue('gid_updater') | ||||
| 
 | ||||
| 	$.each(images, function(_, key){ | ||||
| 		queue.enqueue(updateImageGID, key, images, data) | ||||
| 			.always(function(){ queue.notify(key, 'done') }) | ||||
| 	}) | ||||
| 
 | ||||
| 	return queue | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| /********************************************************************** | ||||
| * vim:set ts=4 sw=4 spell :                                          */ | ||||
|  | ||||
| @ -778,6 +778,7 @@ Date.prototype.getTimeStamp = function(no_seconds){ | ||||
| 	return ''+y+M+D+H+m+s | ||||
| } | ||||
| Date.prototype.setTimeStamp = function(ts){ | ||||
| 	ts = ts.replace(/[^0-9]*/g, '') | ||||
| 	this.setFullYear(ts.slice(0, 4)) | ||||
| 	this.setMonth(ts.slice(4, 6)*1-1) | ||||
| 	this.setDate(ts.slice(6, 8)) | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user