mirror of
				https://github.com/flynx/ImageGrid.git
				synced 2025-10-30 19:00:09 +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 make this work across fs...
 | ||||||
| 	// XXX this will not overwrite...
 | 	// XXX this will not overwrite...
 | ||||||
|  | 	// XXX set ctime to the same value as the original...
 | ||||||
| 	window.copyFile = function(src, dst){ | 	window.copyFile = function(src, dst){ | ||||||
| 		var deferred = $.Deferred() | 		var deferred = $.Deferred() | ||||||
| 		src = osPath(src) | 		src = osPath(src) | ||||||
| @ -75,7 +76,6 @@ if(window.CEF_dumpJSON != null){ | |||||||
| 		path.pop() | 		path.pop() | ||||||
| 		path = path.join('/') | 		path = path.join('/') | ||||||
| 
 | 
 | ||||||
| 
 |  | ||||||
| 		// make dirs...
 | 		// make dirs...
 | ||||||
| 		if(!fs.existsSync(path)){ | 		if(!fs.existsSync(path)){ | ||||||
| 			console.log('making:', path) | 			console.log('making:', path) | ||||||
| @ -380,7 +380,22 @@ if(window.CEF_dumpJSON != null){ | |||||||
| 		return queue | 		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){ | 		if(source in IMAGES){ | ||||||
| 			var img = IMAGES[source] | 			var img = IMAGES[source] | ||||||
| 			var source = normalizePath(img.path) | 			var source = normalizePath(img.path) | ||||||
| @ -389,21 +404,19 @@ if(window.CEF_dumpJSON != null){ | |||||||
| 
 | 
 | ||||||
| 		$.when( | 		$.when( | ||||||
| 				getVipsField('exif-ifd0-Artist', source), | 				getVipsField('exif-ifd0-Artist', source), | ||||||
| 				getVipsField('exif-ifd0-Date and Time', source)) | 				getEXIFDate(source)) | ||||||
| 			.done(function(artist, date){ | 			.done(function(artist, date){ | ||||||
| 				// Artist...
 | 				// Artist...
 | ||||||
| 				artist = artist | 				artist = artist | ||||||
|  | 					// remove substrings in braces...
 | ||||||
| 					.replace(/\([^)]*\)/, '') | 					.replace(/\([^)]*\)/, '') | ||||||
| 					.trim() | 					.trim() | ||||||
| 				artist = artist == '' ? 'Unknown' : artist | 				artist = artist == '' ? 'Unknown' : artist | ||||||
|  | 
 | ||||||
| 				// Date...
 | 				// Date...
 | ||||||
| 				// format: "20130102-122315"
 |  | ||||||
| 				// XXX if not set, get ctime...
 | 				// XXX if not set, get ctime...
 | ||||||
| 				date = date | 				// XXX
 | ||||||
| 					.replace(/\([^)]*\)/, '') | 
 | ||||||
| 					.trim() |  | ||||||
| 					.replace(/:/g, '') |  | ||||||
| 					.replace(/ /g, '-') |  | ||||||
| 				// File name...
 | 				// File name...
 | ||||||
| 				var name = source.split(/[\\\/]/).pop().split('.')[0] | 				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: this depends on that the base dir contains ALL the images...
 | ||||||
| // NOTE: if base is not given, this will not read image to get 
 | // NOTE: if base is not given, this will not read image to get 
 | ||||||
| // 		orientation data...
 | // 		orientation data...
 | ||||||
| function imagesFromUrls(lst){ | function imagesFromUrls(lst, ctime_getter){ | ||||||
|  | 	ctime_getter = (ctime_getter == null  | ||||||
|  | 			? function(){ return Date.now()/1000 }  | ||||||
|  | 			: ctime_getter) | ||||||
| 	var res = {} | 	var res = {} | ||||||
| 
 | 
 | ||||||
| 	$.each(lst, function(i, e){ | 	$.each(lst, function(i, e){ | ||||||
| @ -739,7 +742,7 @@ function imagesFromUrls(lst){ | |||||||
| 			type: 'image', | 			type: 'image', | ||||||
| 			state: 'single', | 			state: 'single', | ||||||
| 			path: e, | 			path: e, | ||||||
| 			ctime: Date.now(), | 			ctime: ctime_getter(e), | ||||||
| 			preview: {}, | 			preview: {}, | ||||||
| 			classes: '', | 			classes: '', | ||||||
| 			orientation: 0, | 			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...
 | // 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 :                                          */ | * vim:set ts=4 sw=4 spell :                                          */ | ||||||
|  | |||||||
| @ -778,6 +778,7 @@ Date.prototype.getTimeStamp = function(no_seconds){ | |||||||
| 	return ''+y+M+D+H+m+s | 	return ''+y+M+D+H+m+s | ||||||
| } | } | ||||||
| Date.prototype.setTimeStamp = function(ts){ | Date.prototype.setTimeStamp = function(ts){ | ||||||
|  | 	ts = ts.replace(/[^0-9]*/g, '') | ||||||
| 	this.setFullYear(ts.slice(0, 4)) | 	this.setFullYear(ts.slice(0, 4)) | ||||||
| 	this.setMonth(ts.slice(4, 6)*1-1) | 	this.setMonth(ts.slice(4, 6)*1-1) | ||||||
| 	this.setDate(ts.slice(6, 8)) | 	this.setDate(ts.slice(6, 8)) | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user