minor tweaks...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2020-12-10 06:44:47 +03:00
parent afef0a36d4
commit 7db2efd948
3 changed files with 56 additions and 36 deletions

View File

@ -7,6 +7,7 @@
(function(require){ var module={} // make module AMD/node compatible... (function(require){ var module={} // make module AMD/node compatible...
/*********************************************************************/ /*********************************************************************/
var object = require('lib/object')
var util = require('lib/util') var util = require('lib/util')
var actions = require('lib/actions') var actions = require('lib/actions')
var features = require('lib/features') var features = require('lib/features')
@ -294,10 +295,13 @@ var CLIActions = actions.Actions({
}], }],
//*/ //*/
// XXX test...
// XXX report that can't find an index...
cliExportImages: ['- System/Export images', cliExportImages: ['- System/Export images',
{cli: argv.Parser({ {cli: argv && argv.Parser({
key: '@export', key: '@export',
// help...
'-help-pattern': { '-help-pattern': {
doc: 'Show image filename pattern info and exit', doc: 'Show image filename pattern info and exit',
priority: 89, priority: 89,
@ -307,16 +311,18 @@ var CLIActions = actions.Actions({
'-version': undefined, '-version': undefined,
'-quiet': undefined, '-quiet': undefined,
// commands...
'@from': { '@from': {
doc: 'Source path', doc: 'Source path',
arg: 'FROM | from', arg: 'PATH | from',
default: '.', }, default: '.', },
'@to': { '@to': {
doc: 'Destination path', doc: 'Destination path',
arg: 'TO | path', arg: 'PATH | path',
required: true, required: true,
valueRequired: true, }, valueRequired: true, },
// options...
// XXX these should get defaults from .config // XXX these should get defaults from .config
'-include-virtual': { '-include-virtual': {
doc: 'Include virtual blocks', doc: 'Include virtual blocks',
@ -328,28 +334,26 @@ var CLIActions = actions.Actions({
arg: 'BOOL | clean-target', arg: 'BOOL | clean-target',
type: 'bool', type: 'bool',
default: true, }, default: true, },
// XXX add tip to get doc...
// .formatImageName(..) -- format docs...
'-image-name': { '-image-name': {
doc: 'Image name pattern', doc: 'Image name pattern',
arg: 'PATTERN | preview-name-pattern', arg: 'PATTERN | preview-name-pattern',
default: '%(fav)l%n%(-%c)c', }, default: '%(fav)l%n%(-%c)c', },
// XXX get values automatically...
'-mode': { '-mode': {
doc: 'Export mode', doc: 'Export mode, can be "resize" or "copy best match"',
arg: 'MODE | export-mode', arg: 'MODE | export-mode',
//default: 'copy best match', //default: 'copy best match',
default: 'resize', }, default: 'resize', },
// XXX add help on possible values...
'-image-size': { '-image-size': {
doc: 'Output image size', doc: 'Output image size',
arg: 'SIZE | preview-size', arg: 'SIZE | preview-size',
default: 1000, }, default: 1000, },
})}, })},
function(){ function(path, options={}){
console.log('EXPORT', ...arguments) var that = this
// XXX load from... return this.loadIndex(path || options.path || '.')
// XXX export to... .then(function(){
}], return that.exportImages(options) }) }],
// Utility... (EXPERIMENTAL) // Utility... (EXPERIMENTAL)
// //
@ -413,8 +417,8 @@ var CLIActions = actions.Actions({
.then(function(){ .then(function(){
if(index.makePreviews){ if(index.makePreviews){
return Promise.all([ return Promise.all([
// NOTE: this is already running after .loadImages(..) // NOTE: no need to call .cacheMetadata(..) as
//index.cacheMetadata('all'), // it is already running after .loadImages(..)
index.makePreviews('all') ])} }) index.makePreviews('all') ])} })
.then(function(){ .then(function(){
return index return index

View File

@ -1797,29 +1797,29 @@ var FileSystemWriterActions = actions.Actions({
core.doc` core.doc`
Filename patterns: Filename patterns:
%n - name without extension %n - name without extension
%gid - full image gid %gid - full image gid
%g - short gid %g - short gid
%i - image index in ribbon %i - image index in ribbon
%I - global image index %I - global image index
%r - ribbon number %r - ribbon number
%R - ribbon number counting from the bottom %R - ribbon number counting from the bottom
%t - total number of images in ribbon %t - total number of images in ribbon
%T - total number of images %T - total number of images
%(...)m - add text in braces if image marked %(...)m - add text in braces if image marked
%(...)b - add text in braces if image is bookmark %(...)b - add text in braces if image is bookmark
%(...)C - add text in braces if there are name conflicts. %(...)C - add text in braces if there are name conflicts.
NOTE: this will be added to all images. NOTE: this will be added to all images.
%(...)c - add text in braces if there are name conflicts %(...)c - add text in braces if there are name conflicts
present, but only if the current image has a present, but only if the current image has a
conflicting name. conflicting name.
%c - number in set of conflicting names (default: 0). %c - number in set of conflicting names (default: 0).
NOTE: this is not stable and can change depending NOTE: this is not stable and can change depending
on image order. on image order.
@ -2060,7 +2060,7 @@ var FileSystemWriterActions = actions.Actions({
return index }) }], return index }) }],
// XXX add name conflict resolution strategies (pattern)... // XXX add name conflict resolution strategies (pattern)...
// ...use the same strategy as for .exportDirs(..) // ...use the same strategy as for .exportImages(..)
// XXX ways to treat a collection: // XXX ways to treat a collection:
// - crop data // - crop data
// - independent index // - independent index
@ -2355,6 +2355,7 @@ var FileSystemWriterActions = actions.Actions({
return Promise.all(queue) }], return Promise.all(queue) }],
// XXX ASAP rename to exportImages(..)
// XXX ASAP test settings['export-mode'] = 'copy best match' // XXX ASAP test settings['export-mode'] = 'copy best match'
// XXX might also be good to save/load the export options to .ImageGrid-export.json // XXX might also be good to save/load the export options to .ImageGrid-export.json
// XXX resolve env variables in path... (???) // XXX resolve env variables in path... (???)
@ -2364,16 +2365,31 @@ var FileSystemWriterActions = actions.Actions({
// XXX use tasks... // XXX use tasks...
// XXX check global index ('%I') in crop... // XXX check global index ('%I') in crop...
// XXX make clean_target more error tolerant... // XXX make clean_target more error tolerant...
exportDirs: ['- File/Export/Export ribbons as directories', exportImages: ['- File/Export/Export ribbons as directories',
core.doc`Export ribbons as directories core.doc`Export ribbons as directories
.exportDirs(path) .exportImages(path)
.exportDirs(settings) .exportImages(settings)
settings format: settings format:
{ {
path: <path>,
'include-virtual': <bool>,
'clean-target': <bool>,
// NOTE: file extension is added automatically...
// NOTE: see .formatImageName(..) for format docs...
'preview-name-pattern': <str>,
'export-mode': 'copy best match' | 'resize',
'preview-size': <size>,
} }
NOTE: see .formatImageName(..) for pattern syntax details. NOTE: see .formatImageName(..) for pattern syntax details.
`, `,
function(path, pattern, level_dir, size, include_virtual, clean_target_dir, logger){ function(path, pattern, level_dir, size, include_virtual, clean_target_dir, logger){
@ -2610,7 +2626,7 @@ var FileSystemWriterUIActions = actions.Actions({
}, },
'Images only': { 'Images only': {
alias: 'images', alias: 'images',
action: 'exportDirs', action: 'exportImages',
data: [ data: [
//'name', //'name',
'pattern', 'pattern',
@ -3459,7 +3475,7 @@ module.FileSystemWriterUI = core.ImageGridFeatures.Feature({
// update export history... // update export history...
[[ [[
'exportIndex', 'exportIndex',
'exportDirs', 'exportImages',
], function(_, settings){ ], function(_, settings){
this.exportHistoryPush( this.exportHistoryPush(
(!settings || typeof(settings) == typeof('str')) ? (!settings || typeof(settings) == typeof('str')) ?

View File

@ -15,7 +15,7 @@
// - browser + requirejs + http* // - browser + requirejs + http*
var VERSION = '4.0.0a' var VERSION = '4.0.0a'
console.log(VERSION) //console.log(VERSION)
module.version = VERSION module.version = VERSION