diff --git a/ui (gen4)/features/base.js b/ui (gen4)/features/base.js index b145db84..08892390 100755 --- a/ui (gen4)/features/base.js +++ b/ui (gen4)/features/base.js @@ -270,6 +270,16 @@ actions.Actions({ return res }], + getImagePath: ['- System/', + function(gid, type){ + gid = this.data.getImage(gid) + + var img = this.images[gid] + + return img == null ? + null + : this.images.getImagePath(gid, this.location.path) + }], replaceGid: ['- System/Replace image gid', {journal: true}, function(from, to){ diff --git a/ui (gen4)/features/filesystem.js b/ui (gen4)/features/filesystem.js index 44446c9d..5e6c0172 100755 --- a/ui (gen4)/features/filesystem.js +++ b/ui (gen4)/features/filesystem.js @@ -196,14 +196,6 @@ module.IndexFormat = core.ImageGridFeatures.Feature({ /*********************************************************************/ var FileSystemInfoActions = actions.Actions({ - getImagePath: ['- System/', - function(gid, type){ - gid = this.data.getImage(gid) - - var img = this.images[gid] - - return pathlib.join(img.base_path || this.location.path, img.path) - }], }) diff --git a/ui (gen4)/features/metadata.js b/ui (gen4)/features/metadata.js index 93770d4c..c4f4fcc3 100755 --- a/ui (gen4)/features/metadata.js +++ b/ui (gen4)/features/metadata.js @@ -110,7 +110,8 @@ var MetadataReaderActions = actions.Actions({ return false } - var full_path = path.normalize(img.base_path +'/'+ img.path) + //var full_path = path.normalize(img.base_path +'/'+ img.path) + var full_path = this.getImagePath(gid) return new Promise(function(resolve, reject){ if(!force && img.metadata){ @@ -207,6 +208,7 @@ module.MetadataReader = core.ImageGridFeatures.Feature({ tag: 'fs-metadata', depends: [ + 'fs-info', 'metadata', ], diff --git a/ui (gen4)/imagegrid/images.js b/ui (gen4)/imagegrid/images.js index bd29f8d0..3eb8c765 100755 --- a/ui (gen4)/imagegrid/images.js +++ b/ui (gen4)/imagegrid/images.js @@ -10,6 +10,7 @@ var sha1 = require('ext-lib/sha1') var object = require('lib/object') +var util = require('lib/util') @@ -456,8 +457,16 @@ module.ImagesPrototype = { // Image data helpers... + + getImagePath: function(gid, path){ + var img = this[gid] || IMAGE_DATA + return (img.base_path || path) ? + [img.base_path || path, img.path].join('/') + : util.path2url(img.path) + }, // XXX see: ribbons.js for details... + // XXX this is the same (in part) as .getImagePath(..) getBestPreview: function(gid, size, img_data, full_path){ if(img_data === true){ full_path = true @@ -476,7 +485,7 @@ module.ImagesPrototype = { var s // XXX not sure about encodeURI(..) here... - var url = encodeURI(img_data.path) + var url = encodeURI(util.path2url(img_data.path)) var preview_size = 'Original' var p = Infinity var previews = img_data.preview || {} @@ -492,7 +501,7 @@ module.ImagesPrototype = { return { //url: normalizePath(url), url: (full_path && img_data.base_path ? - img_data.base_path + '/' + util.path2url(img_data.base_path) + '/' : '') + url, size: preview_size diff --git a/ui (gen4)/lib/util.js b/ui (gen4)/lib/util.js index e7208993..0ccdd77e 100755 --- a/ui (gen4)/lib/util.js +++ b/ui (gen4)/lib/util.js @@ -179,11 +179,12 @@ function(path){ return path } // skip encoding windows drives... - var drive = path.split(/^([a-z]:[\\\/])/i) - path = drive.pop() - drive = drive.pop() || '' - return drive + (path + path = path .split(/[\\\/]/g) + drive = path[0].endsWith(':') ? + path.shift() + '/' + : '' + return drive + (path // XXX these are too aggressive... //.map(encodeURI) //.map(encodeURIComponent) diff --git a/ui (gen4)/ui.js b/ui (gen4)/ui.js index 4be92ec0..4db4582f 100755 --- a/ui (gen4)/ui.js +++ b/ui (gen4)/ui.js @@ -105,6 +105,7 @@ function handleDrop(evt){ var files = event.dataTransfer.files var lst = {} + var paths = [] // files is a FileList of File objects. List some properties. var output = [] @@ -114,31 +115,40 @@ function handleDrop(evt){ continue } - lst[f.name] = { + if(f.path){ + paths.push(f.path) + + } else { // XXX get the metadata... + lst[f.name] = {} + + var reader = new FileReader() + + reader.onload = (function(f){ + return function(e){ + // update the data and reload... + var gid = lst[f.name].gid + ig.images[gid].path = e.target.result + ig.ribbons.updateImage(gid) + } })(f) + + reader.readAsDataURL(f) } - - var reader = new FileReader() - - reader.onload = (function(f){ - return function(e){ - // update the data and reload... - var gid = lst[f.name].gid - ig.images[gid].path = e.target.result - ig.ribbons.updateImage(gid) - } })(f) - - reader.readAsDataURL(f) } - ig.loadURLs(Object.keys(lst)) + if(paths.length > 0){ + ig.loadURLs(paths) - // add the generated stuff to the list -- this will help us id the - // images when they are loaded later... - ig.images.forEach(function(gid, img){ - lst[img.path].gid = gid - img.name = img.path - }) + } else { + ig.loadURLs(Object.keys(lst)) + + // add the generated stuff to the list -- this will help us id the + // images when they are loaded later... + ig.images.forEach(function(gid, img){ + lst[img.path].gid = gid + img.name = img.path + }) + } } function handleDragOver(evt) { evt.stopPropagation()