mirror of
				https://github.com/flynx/ImageGrid.git
				synced 2025-10-31 03:10:07 +00:00 
			
		
		
		
	minor tweaking and docs...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
		
							parent
							
								
									afb97ab46e
								
							
						
					
					
						commit
						3f80f20e57
					
				| @ -61,34 +61,35 @@ var guaranteeGlobEvents = | |||||||
| module.guaranteeGlobEvents = | module.guaranteeGlobEvents = | ||||||
| function(glob){ return guaranteeEvents('match end', glob) } | function(glob){ return guaranteeEvents('match end', glob) } | ||||||
| 
 | 
 | ||||||
|  | var gGlob =  | ||||||
|  | module.gGlob = function(){ | ||||||
|  | 	return guaranteeGlobEvents(glob.apply(null, arguments)) | ||||||
|  | } | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| /*********************************************************************/ | /*********************************************************************/ | ||||||
| // Reader...
 | // Reader...
 | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| // XXX return a promise rather than an event emitter (???)
 | // XXX if path +'/'+ INDEX_DIR exists it will not be returned...
 | ||||||
| // XXX glob has a problem: if a match happens fast enough and we are slow
 |  | ||||||
| // 		enough to register a 'match' handler, then that match(s) will get
 |  | ||||||
| // 		missed...
 |  | ||||||
| var listIndexes = | var listIndexes = | ||||||
| module.listIndexes =  | module.listIndexes =  | ||||||
| function(base){ | function(base){ | ||||||
| 	return guaranteeGlobEvents(glob(base +'/**/'+ INDEX_DIR)) | 	return gGlob(base +'/**/'+ INDEX_DIR) | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| var listPreviews = | var listPreviews = | ||||||
| module.listPreviews =  | module.listPreviews =  | ||||||
| function(base){ | function(base){ | ||||||
| 	return guaranteeGlobEvents(glob(base +'/*px/*jpg')) | 	return gGlob(base +'/*px/*jpg') | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| // XXX return a promise rather than an event emitter (???)
 | // XXX return a promise rather than an event emitter (???)
 | ||||||
| function listJSON(path, pattern){ | function listJSON(path, pattern){ | ||||||
| 	pattern = pattern || '*' | 	pattern = pattern || '*' | ||||||
| 	return guaranteeGlobEvents(glob(path +'/'+ pattern +'.json')) | 	return gGlob(path +'/'+ pattern +'.json') | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| @ -157,9 +158,21 @@ function loadJSON(path){ | |||||||
| // 				f = m.loadIndex("L:/mnt/hdd15 (photo)/NTFS1/media/img/others") })
 | // 				f = m.loadIndex("L:/mnt/hdd15 (photo)/NTFS1/media/img/others") })
 | ||||||
| // 			.done(function(d){ console.log(d) })
 | // 			.done(function(d){ console.log(d) })
 | ||||||
| // XXX need to do better error handling -- stop when an error is not recoverable...
 | // XXX need to do better error handling -- stop when an error is not recoverable...
 | ||||||
| // XXX a bit overcomplicated (???), see if this can be split into more generic 
 | // XXX really overcomplicated, mostly due to promises...
 | ||||||
|  | // 		...see if this can be split into more generic 
 | ||||||
| // 		sections...
 | // 		sections...
 | ||||||
| // XXX problem with diff merging...
 | // XXX change path handling:
 | ||||||
|  | // 		1) explicit index -- ends with INDEX_DIR
 | ||||||
|  | // 			-> load directly...
 | ||||||
|  | // 		2) implicit index -- path contains INDEX_DIR
 | ||||||
|  | // 			-> append INDEX_DIR and (1)...
 | ||||||
|  | // 		3) path is a pattern (contains glob wildcards)
 | ||||||
|  | // 			-> search + load
 | ||||||
|  | // 		4) non of the above...
 | ||||||
|  | // 			a) error
 | ||||||
|  | // 			b) append '**' (current behavior)
 | ||||||
|  | // 			...(a) seems more logical...
 | ||||||
|  | //
 | ||||||
| var loadIndex = | var loadIndex = | ||||||
| module.loadIndex =  | module.loadIndex =  | ||||||
| function(path, logger){ | function(path, logger){ | ||||||
| @ -168,6 +181,7 @@ function(path, logger){ | |||||||
| 
 | 
 | ||||||
| 	return new Promise(function(resolve, reject){ | 	return new Promise(function(resolve, reject){ | ||||||
| 		// we've got an index...
 | 		// we've got an index...
 | ||||||
|  | 		// XXX rewrite this check...
 | ||||||
| 		if(p.length > 1 && /^\/*$/.test(last)){ | 		if(p.length > 1 && /^\/*$/.test(last)){ | ||||||
| 			listJSON(path) | 			listJSON(path) | ||||||
| 				// XXX handle errors...
 | 				// XXX handle errors...
 | ||||||
|  | |||||||
| @ -19,6 +19,9 @@ if(nodejs){ | |||||||
| 	requirejs.config({ | 	requirejs.config({ | ||||||
| 		nodeRequire: require, | 		nodeRequire: require, | ||||||
| 		//baseUrl: __dirname,
 | 		//baseUrl: __dirname,
 | ||||||
|  | 
 | ||||||
|  | 		// XXX this does not work on direct filesystem access...
 | ||||||
|  | 		//urlArgs: 'bust='+Date.now(),
 | ||||||
| 	}) | 	}) | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user