mirror of
				https://github.com/flynx/ImageGrid.git
				synced 2025-10-30 02:40:08 +00:00 
			
		
		
		
	started work on support for relative paths in cache + added --images-only key to buildcache.py + work on align issue...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
		
							parent
							
								
									52442801a7
								
							
						
					
					
						commit
						cc1d88771e
					
				| @ -1,7 +1,7 @@ | ||||
| #======================================================================= | ||||
| 
 | ||||
| __version__ = '''0.0.01''' | ||||
| __sub_version__ = '''20130522224619''' | ||||
| __sub_version__ = '''20130525140732''' | ||||
| __copyright__ = '''(c) Alex A. Naanou 2011''' | ||||
| 
 | ||||
| 
 | ||||
| @ -345,7 +345,7 @@ def build_data(images, path, config=CONFIG): | ||||
| #---------------------------------------------------------build_cache--- | ||||
| ##!!! DO NOT OVERWRITE EXISTING DATA... | ||||
| def build_cache(path, config=CONFIG, gid_generator=hash_gid,  | ||||
| 		report_progress=report_progress, dry_run=False, verbosity=0): | ||||
| 		report_progress=report_progress, dry_run=False, images_only=False, verbosity=0): | ||||
| 	''' | ||||
| 	''' | ||||
| 	cache_dir = config['cache-dir'] | ||||
| @ -371,7 +371,17 @@ def build_cache(path, config=CONFIG, gid_generator=hash_gid, | ||||
| 	if verbosity >= 1: | ||||
| 		print | ||||
| 
 | ||||
| 	for n, d in {images_file: images, data_file: data, marked_file: marked}.items(): | ||||
| 	if images_only: | ||||
| 		files = { | ||||
| 			images_file: images, | ||||
| 		} | ||||
| 	else: | ||||
| 		files = { | ||||
| 			images_file: images,  | ||||
| 			data_file: data,  | ||||
| 			marked_file: marked, | ||||
| 		} | ||||
| 	for n, d in files.items(): | ||||
| 		n = os.path.join(path, n) | ||||
| 		if verbosity >= 1: | ||||
| 			print 'Writing: %s' % n | ||||
| @ -422,6 +432,10 @@ if __name__ == '__main__': | ||||
| 
 | ||||
| 
 | ||||
| 	output_configuration = OptionGroup(parser, 'Output configuration') | ||||
| 	output_configuration.add_option('--images-only',  | ||||
| 						action='store_true', | ||||
| 						default=False, | ||||
| 						help='Create only images.json file, skip the rest.')  | ||||
| 	output_configuration.add_option('--path-mode', | ||||
| 						default='absolute' if CONFIG['absolute-path'] else 'relative', | ||||
| 						help='Path generation mode (default: "%default").') | ||||
| @ -492,6 +506,7 @@ if __name__ == '__main__': | ||||
| 	verbosity = options.verbosity | ||||
| 	# bool... | ||||
| 	dry_run = options.dry_run | ||||
| 	images_only = options.images_only | ||||
| 
 | ||||
| 	# configuration stuff... | ||||
| 	# write a local configuration... | ||||
| @ -534,8 +549,9 @@ if __name__ == '__main__': | ||||
| 				config,  | ||||
| 				hash_gid,  | ||||
| 				report, | ||||
| 				dry_run, | ||||
| 				verbosity) | ||||
| 				dry_run=dry_run, | ||||
| 				images_only=images_only, | ||||
| 				verbosity=verbosity) | ||||
| 
 | ||||
| 		# report results... | ||||
| 		if verbosity >= 1: | ||||
|  | ||||
| @ -2,6 +2,24 @@ | ||||
| 	[_] 48% High priority | ||||
| 		[_] BUG: aligning still sometimes gets off... | ||||
| 		| ...after rotating a number of images | ||||
| 		| | ||||
| 		| happens when: | ||||
| 		| 	- getScreenWidthInImages() < 2 | ||||
| 		| 	- looking through images in one direction and back, some get misaligned | ||||
| 		| 		...this is stable behaviour by centerRibbon(...),  | ||||
| 		| 		calling it again will not fix this. | ||||
| 		| 		moving next/prev will fix the issue until it comes back again | ||||
| 		| 	- affected by LOAD_SCREENS and number of images in ribbon | ||||
| 		| 		current figures: | ||||
| 		| 			Ribbon: 18 | ||||
| 		| 			Position going forward: 4 | ||||
| 		| 			Position going back: 1 | ||||
| 		| 			LOAD_SCREENS: 6 | ||||
| 		| 	NOTE: changing LOAD_SCREENS moves the affected positions. | ||||
| 		| 	NOTE: had a similar bug where some images still kept their  | ||||
| 		| 			prior sizing after recycling... | ||||
| 		| 			...check if centerRibbon(...) and correctImageProportionsForRotation(...) | ||||
| 		| 			are called in right sequence... | ||||
| 		[_] ASAP: support relative paths in cache... | ||||
| 		[_] ASAP: load/view un-cached directories... | ||||
| 		[_] import fav dirs (wo. index)... | ||||
|  | ||||
							
								
								
									
										41
									
								
								ui/base.js
									
									
									
									
									
								
							
							
						
						
									
										41
									
								
								ui/base.js
									
									
									
									
									
								
							| @ -592,7 +592,7 @@ function centerView(image, mode){ | ||||
| // XXX this needs the image to exist... should be GID compatible... (???)
 | ||||
| function centerRibbon(ribbon, image, mode){ | ||||
| 	mode = mode == null ? TRANSITION_MODE_DEFAULT : mode | ||||
| 	ribbon = $(ribbon) | ||||
| 	ribbon = ribbon == null ? getRibbon() : $(ribbon) | ||||
| 	image = image == null ? $('.current.image') : $(image) | ||||
| 
 | ||||
| 	$('.viewer').trigger('preCenteringRibbon', [ribbon, image]) | ||||
| @ -611,15 +611,15 @@ function centerRibbon(ribbon, image, mode){ | ||||
| 
 | ||||
| 	if(target.length > 0){ | ||||
| 		var dl = getRelativeVisualPosition(target, image).left/scale | ||||
| 		//var dl = getRelativeImagePosition(target, image).left/scale
 | ||||
| 		l = { | ||||
| 			left: l + dl - (w/2) + offset | ||||
| 		} | ||||
| 
 | ||||
| 	// we are at the start of a ribbon -- nothing before...
 | ||||
| 	} else { | ||||
| 		// get first image in ribbon...
 | ||||
| 		target = ribbon.find('.image').filter(NAV_DEFAULT).first()  | ||||
| 		var dl = getRelativeVisualPosition(target, image).left/scale | ||||
| 		//var dl = getRelativeImagePosition(target, image).left/scale
 | ||||
| 		l = { | ||||
| 			left: l + dl + (w/2) + offset | ||||
| 		} | ||||
| @ -790,22 +790,6 @@ function nextRibbon(mode){ | ||||
| 
 | ||||
| /******************************************************** Rotating ***/ | ||||
| 
 | ||||
| var cw = { | ||||
| 	null: 0, | ||||
| 	0: 90, | ||||
| 	90: 180, | ||||
| 	180: 270, | ||||
| 	270: 0, | ||||
| } | ||||
| 
 | ||||
| var ccw = { | ||||
| 	null: 0, | ||||
| 	0: 270, | ||||
| 	90: 0, | ||||
| 	180: 90, | ||||
| 	270: 180, | ||||
| } | ||||
| 
 | ||||
| function correctImageProportionsForRotation(images){ | ||||
| 	var viewer = $('.viewer') | ||||
| 	var W = viewer.innerWidth() | ||||
| @ -867,8 +851,25 @@ function correctImageProportionsForRotation(images){ | ||||
| 	}) | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
| var _cw = { | ||||
| 	null: 0, | ||||
| 	0: 90, | ||||
| 	90: 180, | ||||
| 	180: 270, | ||||
| 	270: 0, | ||||
| } | ||||
| 
 | ||||
| var _ccw = { | ||||
| 	null: 0, | ||||
| 	0: 270, | ||||
| 	90: 0, | ||||
| 	180: 90, | ||||
| 	270: 180, | ||||
| } | ||||
| 
 | ||||
| function rotateImage(direction, image){ | ||||
| 	var r_table = direction == 'left' ? cw : ccw | ||||
| 	var r_table = direction == 'left' ? _cw : _ccw | ||||
| 	image = image == null ? $('.current.image') : $(image) | ||||
| 	image.each(function(i, e){ | ||||
| 		var img = $(this) | ||||
|  | ||||
							
								
								
									
										61
									
								
								ui/data.js
									
									
									
									
									
								
							
							
						
						
									
										61
									
								
								ui/data.js
									
									
									
									
									
								
							| @ -8,7 +8,8 @@ | ||||
| //var DEBUG = DEBUG != null ? DEBUG : true
 | ||||
| 
 | ||||
| var LOAD_SCREENS = 6 | ||||
| var LOAD_THRESHOLD = 2 | ||||
| //var LOAD_THRESHOLD = 2
 | ||||
| 
 | ||||
| var DEFAULT_SCREEN_IMAGES = 4 | ||||
| var MAX_SCREEN_IMAGES = 12 | ||||
| 
 | ||||
| @ -72,6 +73,8 @@ var SETTINGS = { | ||||
| 	'single-image-mode-proportions': null, | ||||
| } | ||||
| 
 | ||||
| var BASE_URL = '.' | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| /********************************************************************** | ||||
| @ -287,6 +290,8 @@ function getImageGIDs(from, count, ribbon, inclusive){ | ||||
| // Select best preview by size...
 | ||||
| //
 | ||||
| // NOTE: this will use the original if everything else is smaller...
 | ||||
| //
 | ||||
| // XXX make this both relative and absolute URL compatible...
 | ||||
| function getBestPreview(gid, size){ | ||||
| 	size = size == null ? getVisibleImageSize('max') : size | ||||
| 	var s | ||||
| @ -304,12 +309,46 @@ function getBestPreview(gid, size){ | ||||
| 		} | ||||
| 	} | ||||
| 	return { | ||||
| 		url: url, | ||||
| 		//url: url,
 | ||||
| 		url: normalizePath(url), | ||||
| 		size: preview_size | ||||
| 	} | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
| // NOTE: mode can be either 'absolute' (default) or 'relative'...
 | ||||
| // XXX need to account for '.' base
 | ||||
| function normalizePath(url, base, mode){ | ||||
| 	mode = mode == null ? 'absolute' : mode | ||||
| 	base = base == null ? BASE_URL : base | ||||
| 
 | ||||
| 	// absolute path...
 | ||||
| 	if(/^(file|http|https):\/\/.*$/.test(url)){ | ||||
| 		// check if we start with base, and remove it if so...
 | ||||
| 		if(mode == 'relative' && url.substring(0, base.length) == base){ | ||||
| 			url = url.substring(base.length - 1) | ||||
| 			return url[0] == '/' ? url.substring(1) : url | ||||
| 
 | ||||
| 		// if it's a different path, return as-is
 | ||||
| 		} else if(mode == 'absolute'){ | ||||
| 			return url | ||||
| 		} | ||||
| 
 | ||||
| 	// make an absolute path...
 | ||||
| 	} else if(mode == 'absolute') { | ||||
| 		// if base ends and url starts with '.' avoid making it a '..'
 | ||||
| 		if(base[base.length-1] == '.' && url[0] == '.'){ | ||||
| 			return base + url.substring(1) | ||||
| 		// avoid creating '//'...
 | ||||
| 		} else if(base[base.length-1] != '/' && url[0] != '/'){ | ||||
| 			return base + '/' + url | ||||
| 		} else { | ||||
| 			return base + url | ||||
| 		} | ||||
| 	} | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| /********************************************************************** | ||||
| * Loaders | ||||
| @ -710,6 +749,7 @@ function loadFileImages(path, callback){ | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
| // XXX add relative path support (via. normalizePath(...))
 | ||||
| function loadFile(data_path, image_path, callback){ | ||||
| 	// CEF
 | ||||
| 	return $.getJSON(data_path) | ||||
| @ -873,6 +913,7 @@ function setupDataBindings(viewer){ | ||||
| 			var img_before = getImageBefore(image, ribbon) | ||||
| 			var gid_before = getGIDBefore(gid, r) | ||||
| 			var screen_size = getScreenWidthInImages() | ||||
| 			screen_size = screen_size < 1 ? 1 : screen_size | ||||
| 			var l = ribbon.find('.image').length | ||||
| 
 | ||||
| 			// load images if we do a long jump -- start, end or some mark 
 | ||||
| @ -892,12 +933,22 @@ function setupDataBindings(viewer){ | ||||
| 
 | ||||
| 			// NOTE: if this is greater than the number of images currently 
 | ||||
| 			//		loaded, it might lead to odd effects...
 | ||||
| 			var frame_size = (screen_size * LOAD_SCREENS) / 2 | ||||
| 			var threshold = Math.ceil(screen_size * LOAD_THRESHOLD) | ||||
| 			var frame_size = Math.ceil((screen_size * LOAD_SCREENS) / 2) | ||||
| 			//var threshold = Math.ceil(screen_size * LOAD_THRESHOLD)
 | ||||
| 			var threshold = Math.floor(frame_size / 2)  | ||||
| 			threshold = threshold < 1 ? 1 : threshold | ||||
| 
 | ||||
| 			// do the loading...
 | ||||
| 			// XXX need to expand/contract the ribbon depending on zoom and speed...
 | ||||
| 			// XXX need to expand/contract the ribbon depending on speed...
 | ||||
| 			// 		...might also be a good idea to load smaller images 
 | ||||
| 			// 		while scrolling really fast...
 | ||||
| 			// XXX use extendRibbon, to both roll and expand/contract...
 | ||||
| 			// XXX BUG: when rolling a ribbon, this will sometimes 
 | ||||
| 			// 		misalign an image...
 | ||||
| 			// 		...where exactly this happens in the ribbon depends on 
 | ||||
| 			// 		its size and LOAD_SCREENS...
 | ||||
| 			// 		NOTE: calling centerView() will fix this.
 | ||||
| 			// 		...the problem is in centerRibbon
 | ||||
| 			if(tail.length < threshold){ | ||||
| 				var rolled = rollImages(frame_size, ribbon) | ||||
| 			} | ||||
|  | ||||
| @ -24,13 +24,13 @@ function loadMarkedOnlyData(cmp, no_cleanout_marks){ | ||||
| 	// NOTE: if IMAGES contains only part of the data loadable this will 
 | ||||
| 	// 		be wrong...
 | ||||
| 	if(!no_cleanout_marks){ | ||||
| 		for(var i=0; i < marks.length;){ | ||||
| 			if(marks[i] in IMAGES){ | ||||
| 		for(var i=0; i < marked.length;){ | ||||
| 			if(marked[i] in IMAGES){ | ||||
| 				i++ | ||||
| 				continue | ||||
| 			} | ||||
| 			// NOTE: we do not need to advance i here...
 | ||||
| 			marks.splice(i, 1) | ||||
| 			marked.splice(i, 1) | ||||
| 		} | ||||
| 	} | ||||
| 	ALL_DATA = DATA | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user