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