diff --git a/ui (gen4)/features/meta.js b/ui (gen4)/features/meta.js index 0afb397b..b90ebd73 100755 --- a/ui (gen4)/features/meta.js +++ b/ui (gen4)/features/meta.js @@ -40,6 +40,9 @@ core.ImageGridFeatures.Feature('viewer-minimal', [ 'fs-loader', 'fs-writer', + + 'metadata', + 'fs-metadata', ]) diff --git a/ui (gen4)/features/metadata.js b/ui (gen4)/features/metadata.js index cd620daf..b70003e4 100755 --- a/ui (gen4)/features/metadata.js +++ b/ui (gen4)/features/metadata.js @@ -18,6 +18,8 @@ define(function(require){ var module = {} //var DEBUG = DEBUG != null ? DEBUG : true +var tasks = require('lib/tasks') + var actions = require('lib/actions') var core = require('features/core') @@ -79,7 +81,8 @@ module.Metadata = core.ImageGridFeatures.Feature({ // XXX add Metadata writer... -// XXX need a way to trigger read-metadata... +// XXX store metadata in a JSON format -- currently exiftool returns an +// Array with attributes, make it an object... var MetadataReaderActions = actions.Actions({ // XXX should this be sync??? // XXX should this process multiple images??? @@ -120,7 +123,15 @@ var MetadataReaderActions = actions.Actions({ } else { // store metadata... // XXX - that.images[gid].metadata = data + + // convert to a real dict... + // NOTE: exiftool appears to return an array + // object rather than an actual dict/object + // and that is not JSON compatible.... + var m = {} + Object.keys(data).forEach(function(k){ m[k] = data[k] }) + + that.images[gid].metadata = m that.markChanged && that.markChanged(gid) resolve(data) @@ -132,6 +143,26 @@ var MetadataReaderActions = actions.Actions({ }) }], + // XXX STUB: add support for this to .readMetadata(..) + _readAllMetadata: ['- Image/Read all metadata', + function(){ + var that = this + // XXX make this a global API... + var q = this.__reader_queue = this.__reader_queue || tasks.Queue() + + var read = function(gid){ + return function(){ return that.readMetadata(gid) } } + + q.start() + + this.images + && this.images.forEach(function(gid){ + q.enqueue('metadata', read(gid)) + }) + + return q + }], + // XXX take image Metadata and write it to target... writeMetadata: ['- Image/Set metadata data', function(image, target){ diff --git a/ui (gen4)/lib/tasks.js b/ui (gen4)/lib/tasks.js index db98c834..b726e328 100755 --- a/ui (gen4)/lib/tasks.js +++ b/ui (gen4)/lib/tasks.js @@ -239,6 +239,7 @@ module.QueueActions = actions.Actions({ that.__running.push(elem) // start the task... + // XXX should we run a task in some specific context??? res = task() that.taskStarted(elem[0], task)