mirror of
https://github.com/flynx/ImageGrid.git
synced 2025-10-28 18:00:09 +00:00
tweaks and fixes...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
5603acbd3b
commit
dc07d95cd1
@ -43,17 +43,37 @@ var base = require('features/base')
|
||||
// alone at first and then either create new instances or setup
|
||||
// additional features as needed...
|
||||
|
||||
|
||||
|
||||
var CLIActions = actions.Actions({
|
||||
makeIndex: ['- System/',
|
||||
function(path){
|
||||
var that = this
|
||||
|
||||
return this.loadImages(path)
|
||||
.then(function(){ return that.makePreviews('all') })
|
||||
.then(function(){ return that.sortImages() })
|
||||
//.then(function(){ return that.readAllMetadata() })
|
||||
.then(function(){ return that.saveIndex() })
|
||||
}],
|
||||
})
|
||||
|
||||
|
||||
var CLI =
|
||||
module.CLI = core.ImageGridFeatures.Feature({
|
||||
title: '',
|
||||
doc: '',
|
||||
|
||||
tag: 'commandline',
|
||||
depends: ['lifecycle'],
|
||||
depends: [
|
||||
'lifecycle'
|
||||
],
|
||||
|
||||
isApplicable: function(){
|
||||
return this.runtime == 'node' || this.runtime == 'nw' },
|
||||
|
||||
actions: CLIActions,
|
||||
|
||||
handlers: [
|
||||
['start',
|
||||
function(){
|
||||
@ -133,6 +153,45 @@ module.CLI = core.ImageGridFeatures.Feature({
|
||||
.setup(that, ['viewer-minimal'])
|
||||
})
|
||||
|
||||
.option('repl, --repl', 'start an ImageGrin REPL', function(){
|
||||
//var repl = require('repl')
|
||||
|
||||
//var ig = core.ImageGridFeatures
|
||||
|
||||
repl.start({
|
||||
prompt: 'ig> ',
|
||||
|
||||
input: process.stdin,
|
||||
output: process.stdout,
|
||||
|
||||
ignoreUndefined: true,
|
||||
|
||||
/*
|
||||
eval: function(str, context, filename, callback){
|
||||
var res
|
||||
|
||||
var lst = str.split(/\s+/)
|
||||
var cmd = lst.shift()
|
||||
|
||||
// we got an action...
|
||||
if(cmd == 'var'){
|
||||
eval(str, context, filename, callback)
|
||||
|
||||
// action...
|
||||
} else if(cmd in ig){
|
||||
ig[cmd].apply(ig, lst.map(eval))
|
||||
|
||||
// err
|
||||
} else {
|
||||
// XXX
|
||||
}
|
||||
|
||||
callback(null, res)
|
||||
},
|
||||
*/
|
||||
})
|
||||
})
|
||||
|
||||
// XXX the problem with this is that it still tires
|
||||
// to find and run 'ig-index'...
|
||||
/*
|
||||
@ -147,7 +206,9 @@ module.CLI = core.ImageGridFeatures.Feature({
|
||||
.arguments('<action> [args]')
|
||||
.action(function(action, args){
|
||||
// XXX
|
||||
console.log('>>>>', action, args)
|
||||
//console.log('>>>>', action, args, !!that[action])
|
||||
|
||||
that[action](args)
|
||||
})
|
||||
|
||||
.parse(argv)
|
||||
|
||||
@ -279,50 +279,55 @@ var FileSystemLoaderActions = actions.Actions({
|
||||
method: 'loadImages',
|
||||
}
|
||||
|
||||
glob(path + '/'+ this.config['image-file-pattern'],
|
||||
{stat: !!this.config['image-file-read-stat']})
|
||||
.on('error', function(err){
|
||||
console.log('!!!!', err)
|
||||
})
|
||||
/*
|
||||
.on('match', function(img){
|
||||
// XXX stat stuff...
|
||||
fse.statSync(img)
|
||||
})
|
||||
*/
|
||||
.on('end', function(lst){
|
||||
that.loadURLs(lst, path)
|
||||
// XXX do we need to normalize paths after we get them from glob??
|
||||
//that.loadURLs(lst.map(pathlib.posix.normalize), path)
|
||||
//that.loadURLs(lst
|
||||
// .map(function(p){ return util.normalizePath(p) }), path)
|
||||
return new Promise(function(resolve, reject){
|
||||
glob(path + '/'+ that.config['image-file-pattern'],
|
||||
{stat: !!that.config['image-file-read-stat']})
|
||||
.on('error', function(err){
|
||||
console.log('!!!!', err)
|
||||
reject(err)
|
||||
})
|
||||
/*
|
||||
.on('match', function(img){
|
||||
// XXX stat stuff...
|
||||
fse.statSync(img)
|
||||
})
|
||||
*/
|
||||
.on('end', function(lst){
|
||||
that.loadURLs(lst, path)
|
||||
// XXX do we need to normalize paths after we get them from glob??
|
||||
//that.loadURLs(lst.map(pathlib.posix.normalize), path)
|
||||
//that.loadURLs(lst
|
||||
// .map(function(p){ return util.normalizePath(p) }), path)
|
||||
|
||||
if(!!that.config['image-file-read-stat']){
|
||||
var stats = this.statCache
|
||||
var p = pathlib.posix
|
||||
if(!!that.config['image-file-read-stat']){
|
||||
var stats = this.statCache
|
||||
var p = pathlib.posix
|
||||
|
||||
that.images.forEach(function(gid, img){
|
||||
var stat = stats[p.join(img.base_path, img.path)]
|
||||
that.images.forEach(function(gid, img){
|
||||
var stat = stats[p.join(img.base_path, img.path)]
|
||||
|
||||
img.atime = stat.atime
|
||||
img.mtime = stat.mtime
|
||||
img.ctime = stat.ctime
|
||||
img.birthtime = stat.birthtime
|
||||
img.atime = stat.atime
|
||||
img.mtime = stat.mtime
|
||||
img.ctime = stat.ctime
|
||||
img.birthtime = stat.birthtime
|
||||
|
||||
img.size = stat.size
|
||||
img.size = stat.size
|
||||
|
||||
// XXX do we need anything else???
|
||||
})
|
||||
}
|
||||
// XXX do we need anything else???
|
||||
})
|
||||
}
|
||||
|
||||
// NOTE: we set it again because .loadURLs() does a clear
|
||||
// before it starts loading...
|
||||
// XXX is this a bug???
|
||||
that.__location = {
|
||||
path: path,
|
||||
method: 'loadImages',
|
||||
}
|
||||
})
|
||||
// NOTE: we set it again because .loadURLs() does a clear
|
||||
// before it starts loading...
|
||||
// XXX is this a bug???
|
||||
that.__location = {
|
||||
path: path,
|
||||
method: 'loadImages',
|
||||
}
|
||||
|
||||
resolve(that)
|
||||
})
|
||||
})
|
||||
}],
|
||||
|
||||
// XXX auto-detect format or let the user chose...
|
||||
@ -1087,6 +1092,7 @@ var FileSystemWriterActions = actions.Actions({
|
||||
// - vertical
|
||||
// - horizontal
|
||||
// - ...
|
||||
// XXX this repeats sharp.SharpActions.config['preview-sizes']
|
||||
'export-preview-sizes': [
|
||||
'500',
|
||||
'900',
|
||||
|
||||
@ -39,6 +39,7 @@ core.ImageGridFeatures.Feature('viewer-minimal', [
|
||||
'image-bookmarks',
|
||||
|
||||
'fs',
|
||||
'sharp',
|
||||
|
||||
'metadata',
|
||||
])
|
||||
@ -52,8 +53,6 @@ core.ImageGridFeatures.Feature('viewer-testing', [
|
||||
'ui',
|
||||
'keyboard',
|
||||
|
||||
'sharp',
|
||||
|
||||
'ui-ribbons-placement',
|
||||
|
||||
'ui-fullscreen-controls',
|
||||
|
||||
@ -45,6 +45,7 @@ var SharpActions = actions.Actions({
|
||||
|
||||
'preview-normalized': true,
|
||||
|
||||
// XXX this repeats filesystem.FileSystemWriterActions.config['export-preview-sizes']
|
||||
'preview-sizes': [
|
||||
1920,
|
||||
1280,
|
||||
@ -100,30 +101,32 @@ var SharpActions = actions.Actions({
|
||||
.sort()
|
||||
.reverse()
|
||||
|
||||
sizes = sizes || cfg_sizes
|
||||
sizes = sizes instanceof Array ? sizes : [sizes]
|
||||
if(sizes){
|
||||
sizes = sizes instanceof Array ? sizes : [sizes]
|
||||
// normalize to preview size...
|
||||
sizes = (this.config['preview-normalized'] ?
|
||||
sizes
|
||||
.map(function(s){
|
||||
return cfg_sizes.filter(function(c){ return c >= s }).pop() || s })
|
||||
: sizes)
|
||||
.unique()
|
||||
|
||||
// normalize to preview size...
|
||||
sizes = (this.config['preview-normalized'] ?
|
||||
sizes
|
||||
.map(function(s){
|
||||
return cfg_sizes.filter(function(c){ return c >= s }).pop() || s })
|
||||
: sizes)
|
||||
.unique()
|
||||
} else {
|
||||
sizes = cfg_sizes
|
||||
}
|
||||
|
||||
var that = this
|
||||
return Promise.all(images.map(function(gid){
|
||||
var data = that.images[gid]
|
||||
var preview = data.preview = data.preview || {}
|
||||
var path = that.getImagePath(gid)
|
||||
|
||||
var img = sharp(path)
|
||||
var preview = data.preview = data.preview || {}
|
||||
|
||||
var img = sharp(path)
|
||||
return img.metadata().then(function(metadata){
|
||||
var orig_res = Math.max(metadata.width, metadata.height)
|
||||
|
||||
return Promise.all(sizes.map(function(res){
|
||||
|
||||
// skip if image is smaller than res...
|
||||
if(res >= orig_res){
|
||||
return
|
||||
@ -193,6 +196,7 @@ module.Sharp = core.ImageGridFeatures.Feature({
|
||||
// - if image too large to set the preview to "loading..."
|
||||
// - create previews...
|
||||
// - update image...
|
||||
/*
|
||||
['updateImage.pre',
|
||||
function(gid){
|
||||
var that = this
|
||||
@ -216,6 +220,7 @@ module.Sharp = core.ImageGridFeatures.Feature({
|
||||
})
|
||||
}
|
||||
}]
|
||||
//*/
|
||||
],
|
||||
})
|
||||
|
||||
|
||||
@ -1035,11 +1035,14 @@ var WidgetTestActions = actions.Actions({
|
||||
|
||||
make('---')
|
||||
|
||||
|
||||
make('close parent')
|
||||
.on('open', function(){
|
||||
that.parent.close()
|
||||
})
|
||||
|
||||
make('...')
|
||||
|
||||
// NOTE: the dialog's .parent is not yet set at this point...
|
||||
|
||||
// This will finalize the dialog...
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user