started work on partial index...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2016-06-06 18:46:23 +03:00
parent 82e10ff27e
commit 2c954da342
3 changed files with 54 additions and 34 deletions

View File

@ -1443,9 +1443,11 @@ var FileSystemWriterActions = actions.Actions({
index.date, index.date,
this.config['index-filename-template'], this.config['index-filename-template'],
logger) logger)
// set hidden file attribute on Windows...
.then(function(){ .then(function(){
typeof(process) != 'undefined' typeof(process) != 'undefined'
&& process.platform == 'win32' && (process.platform == 'win32'
|| process.platform == 'win64')
&& child_process && child_process
.spawn('attrib', ['+h', full_path]) .spawn('attrib', ['+h', full_path])
}) })
@ -1473,20 +1475,25 @@ var FileSystemWriterActions = actions.Actions({
// Export current state as a full loadable index // Export current state as a full loadable index
// //
// XXX resolve env variables in path... // XXX resolve env variables in path...
// XXX what sould happen if no path is given??? // XXX what should happen if no path is given???
// XXX should this return a promise??? ...a clean promise??? // XXX should this return a promise??? ...a clean promise???
// XXX add preview selection... // XXX add preview selection...
// XXX handle .image.path and other stack files... // XXX handle .image.path and other stack files...
// XXX local collections??? // XXX local collections???
exportIndex: ['- File/Export/Export index', exportIndex: ['- File/Export/Export index',
function(path, logger){ function(path, max_size, include_orig, logger){
logger = logger || this.logger logger = logger || this.logger
// XXX if size is not given save all sizes...
//max_size = max_size || this.config['export-preview-size']
include_orig = include_orig || true
// XXX is this correct??? // XXX is this correct???
path = path || './exported' path = path || './exported'
path = util.normalizePath(path) path = util.normalizePath(path)
// XXX resolve env variables in path... // XXX resolve env variables in path...
// ...also add ImageGrid specifics: $IG_INDEX, ...
// XXX // XXX
// resolve relative paths... // resolve relative paths...
@ -1507,15 +1514,11 @@ var FileSystemWriterActions = actions.Actions({
gids = gids.compact() gids = gids.compact()
// build .images with loaded images... // build .images with loaded images...
// XXX list of previews should be configurable (max size)
var images = {} var images = {}
gids.forEach(function(gid){ gids.forEach(function(gid){
var img = json.images[gid] var img = json.images[gid]
if(img){ if(img){
images[gid] = json.images[gid] images[gid] = json.images[gid]
// remove un-needed previews...
// XXX
} }
}) })
@ -1529,7 +1532,9 @@ var FileSystemWriterActions = actions.Actions({
// XXX should also optionally populate the base dir and nested favs... // XXX should also optionally populate the base dir and nested favs...
var base_dir = this.location.path var base_dir = this.location.path
gids.forEach(function(gid){ var queue = []
gids.map(function(gid){
var img = json.images[gid] var img = json.images[gid]
var img_base = img.base_path var img_base = img.base_path
var previews = img.preview var previews = img.preview
@ -1538,16 +1543,16 @@ var FileSystemWriterActions = actions.Actions({
// need for a base path... // need for a base path...
delete img.base_path delete img.base_path
var queue = []
// XXX copy img.path -- the main image, especially when no previews present....
// XXX
if(previews || img.path){ if(previews || img.path){
Object.keys(previews || {}) Object.keys(previews || {})
// limit preview size...
.filter(function(res){
return !max_size || parseInt(res) <= max_size})
// get paths...
.map(function(res){ return decodeURI(previews[res]) }) .map(function(res){ return decodeURI(previews[res]) })
// XXX should we copy this, especially if it's a hi-res??? // XXX might be a good idea to include include
.concat([img.path || null]) // the max preview if hires is too large...
.concat(include_orig ? [img.path || null] : [])
.forEach(function(preview_path){ .forEach(function(preview_path){
if(preview_path == null){ if(preview_path == null){
return return
@ -1561,6 +1566,7 @@ var FileSystemWriterActions = actions.Actions({
// internally then we do not need to bother... // internally then we do not need to bother...
// XXX // XXX
queue.push(ensureDir(pathlib.dirname(to)) queue.push(ensureDir(pathlib.dirname(to))
// XXX do we need error handling here???
.catch(function(err){ .catch(function(err){
logger && logger.emit('error', err) }) logger && logger.emit('error', err) })
.then(function(){ .then(function(){
@ -1571,6 +1577,7 @@ var FileSystemWriterActions = actions.Actions({
// .then(..)) // .then(..))
.then(function(){ .then(function(){
logger && logger.emit('done', to) }) logger && logger.emit('done', to) })
// XXX do we need error handling here???
.catch(function(err){ .catch(function(err){
logger && logger.emit('error', err) }) logger && logger.emit('error', err) })
})) }))
@ -1585,9 +1592,11 @@ var FileSystemWriterActions = actions.Actions({
index_path, index_path,
this.config['index-filename-template'], this.config['index-filename-template'],
logger || this.logger) logger || this.logger)
// set hidden file attribute on Windows...
.then(function(){ .then(function(){
typeof(process) != 'undefined' typeof(process) != 'undefined'
&& process.platform == 'win32' && (process.platform == 'win32'
|| process.platform == 'win64')
// XXX do we need to quote path??? // XXX do we need to quote path???
&& child_process && child_process
.spawn('attrib', ['+h', index_path]) .spawn('attrib', ['+h', index_path])
@ -1630,17 +1639,17 @@ var FileSystemWriterActions = actions.Actions({
size = size || this.config['export-preview-size'] || 1000 size = size || this.config['export-preview-size'] || 1000
pattern = pattern || this.config['export-preview-name-pattern'] || '%f' pattern = pattern || this.config['export-preview-name-pattern'] || '%f'
// XXX need to abort on fatal errors... // XXX need to abort on fatal errors...
this.data.ribbon_order return Promise.all(this.data.ribbon_order
.slice() .slice()
.reverse() .reverse()
.forEach(function(ribbon){ .map(function(ribbon){
// NOTE: this is here to keep the specific path local to // NOTE: this is here to keep the specific path local to
// this scope... // this scope...
var img_dir = to_dir var img_dir = to_dir
ensureDir(pathlib.dirname(img_dir)) var res = ensureDir(pathlib.dirname(img_dir))
// XXX do we need error handling here???
.catch(function(err){ .catch(function(err){
logger && logger.emit('error', err) }) logger && logger.emit('error', err) })
.then(function(){ .then(function(){
@ -1699,7 +1708,9 @@ var FileSystemWriterActions = actions.Actions({
}) })
to_dir += '/'+level_dir to_dir += '/'+level_dir
})
return res
}))
}] }]
}) })
@ -1855,11 +1866,16 @@ var FileSystemWriterUIActions = actions.Actions({
'comment' 'comment'
], ],
}, },
'Full index': { 'Current state as index': {
action: 'exportIndex', action: 'exportIndex',
data: [ data: [
//'size',
'target_dir', 'target_dir',
// XXX need to add options to size: 'none',
// XXX use closest preview instead of hi-res when
// this is set...
//'size_limit',
// XXX might be a good idea to include source data links
//'include_source_url', // bool
'comment', 'comment',
], ],
}, },
@ -1909,10 +1925,10 @@ var FileSystemWriterUIActions = actions.Actions({
// Export <mode> is set by: // Export <mode> is set by:
// .config['export-mode'] // .config['export-mode']
// //
// The fields used and their order is determined by: // The fields used and their order is set by:
// .config['export-modes'][<mode>].data (list) // .config['export-modes'][<mode>].data (list)
// //
// The action used to export is determined by: // The action used to export is set by:
// .config['export-modes'][<mode>].action // .config['export-modes'][<mode>].action
// //
// //
@ -1931,6 +1947,8 @@ var FileSystemWriterUIActions = actions.Actions({
// //
// NOTE: .__export_dialog_fields__ can be defined both in the feature // NOTE: .__export_dialog_fields__ can be defined both in the feature
// as well as in the instance. // as well as in the instance.
// NOTE: the export action should get all of its arguments from config
// except for the export path...
__export_dialog_fields__: { __export_dialog_fields__: {
'pattern': function(actions, make, parent){ 'pattern': function(actions, make, parent){
return make(['Filename pattern: ', return make(['Filename pattern: ',
@ -2082,7 +2100,7 @@ var FileSystemWriterUIActions = actions.Actions({
&& base_fields[k].call(that, that, make, dialog)) && base_fields[k].call(that, that, make, dialog))
}) })
// Start/stop action... // Start action...
make([function(){ make([function(){
// XXX indicate export state: index, crop, image... // XXX indicate export state: index, crop, image...
return 'Export'}]) return 'Export'}])

View File

@ -159,7 +159,9 @@ function(actions, list_key, options){
var to_remove = [] var to_remove = []
var lst = actions.config[list_key] var lst = list_key instanceof Function ? list_key()
: list_key instanceof Array ? list_key
: actions.config[list_key]
lst = lst instanceof Array ? lst : Object.keys(lst) lst = lst instanceof Array ? lst : Object.keys(lst)
var list = browse.makeList(null, var list = browse.makeList(null,
@ -266,22 +268,22 @@ function(actions, list, list_key, value_key, options){
var o = makeConfigListEditor(actions, list_key, options) var o = makeConfigListEditor(actions, list_key, options)
// update slideshow menu... // update menu...
o.open(function(){ o.open(function(){
list.update() list.update()
list.select(txt) list.select(txt)
}) })
// select default...
actions.Overlay(o) o.on('update', function(){
setTimeout(function(){
if(typeof(value_key) == typeof(function(){})){ if(typeof(value_key) == typeof(function(){})){
o.select(value_key()) o.select(value_key())
} else { } else {
o.select(actions.config[value_key]) o.select(actions.config[value_key])
} }
}, 0) })
actions.Overlay(o)
} }
} }

View File

@ -28,7 +28,7 @@
"sharp": "^0.12.0" "sharp": "^0.12.0"
}, },
"optionalDependencies": { "optionalDependencies": {
"flickrapi": "^0.3.28", "flickrapi": "^0.3.28"
}, },
"devDependencies": { "devDependencies": {
"less": "*", "less": "*",