mirror of
https://github.com/flynx/ImageGrid.git
synced 2025-10-30 19:00:09 +00:00
added stat reading to loaders + docs and cleanup...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
2f32dda3ed
commit
2dca0a85fd
@ -599,6 +599,8 @@ module.SortActions = actions.Actions({
|
|||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// NOTE: the cmp function is called in the actions context.
|
// NOTE: the cmp function is called in the actions context.
|
||||||
|
//
|
||||||
|
// XXX sequence number with overflow...
|
||||||
__sort_methods__: {
|
__sort_methods__: {
|
||||||
'name-leading-sequence': function(a, b){
|
'name-leading-sequence': function(a, b){
|
||||||
a = this.images.getImageNameLeadingSeq(a)
|
a = this.images.getImageNameLeadingSeq(a)
|
||||||
@ -657,9 +659,14 @@ module.SortActions = actions.Actions({
|
|||||||
// will reverse the result's order while:
|
// will reverse the result's order while:
|
||||||
// 'metadata.createDate birthtime reverse' + ' reverese'
|
// 'metadata.createDate birthtime reverse' + ' reverese'
|
||||||
// will cancel reversal.
|
// will cancel reversal.
|
||||||
|
// NOTE: with empty images this will not do anything.
|
||||||
//
|
//
|
||||||
// XXX this also requires images...
|
|
||||||
// XXX cache order???
|
// XXX cache order???
|
||||||
|
// XXX would be nice to be able to sort a list of gids or a section
|
||||||
|
// of images...
|
||||||
|
// XXX sorting with partial images will throw the images that do not
|
||||||
|
// exist or the ones that do not have the right attrs all over
|
||||||
|
// the place...
|
||||||
sortImages: ['- Edit|Sort/Sort images',
|
sortImages: ['- Edit|Sort/Sort images',
|
||||||
function(method, reverse){
|
function(method, reverse){
|
||||||
var that = this
|
var that = this
|
||||||
@ -692,7 +699,6 @@ module.SortActions = actions.Actions({
|
|||||||
.join(' ')
|
.join(' ')
|
||||||
: method
|
: method
|
||||||
method = typeof(method) == typeof('str') ? method.split(/ +/g) : method
|
method = typeof(method) == typeof('str') ? method.split(/ +/g) : method
|
||||||
method = method instanceof Array ? method : [method]
|
|
||||||
|
|
||||||
// get the reverse arity...
|
// get the reverse arity...
|
||||||
var i = method.indexOf('reverse')
|
var i = method.indexOf('reverse')
|
||||||
@ -808,8 +814,8 @@ module.SortActions = actions.Actions({
|
|||||||
})],
|
})],
|
||||||
|
|
||||||
// Store/load sort data:
|
// Store/load sort data:
|
||||||
// .data.sort_method - current sort mode (optional)
|
// .data.sort_method - current sort mode (optional)
|
||||||
// .manual_order - manual sort order (optional)
|
// .data.manual_order - manual sort order (optional)
|
||||||
load: [function(data){
|
load: [function(data){
|
||||||
return function(){
|
return function(){
|
||||||
if(data.data && data.data.sort_method){
|
if(data.data && data.data.sort_method){
|
||||||
|
|||||||
@ -141,6 +141,9 @@ module.CLI = core.ImageGridFeatures.Feature({
|
|||||||
})
|
})
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
// XXX might be a good idea to make the action call
|
||||||
|
// syntax like this:
|
||||||
|
// --<action-name> [args]
|
||||||
.arguments('<action> [args]')
|
.arguments('<action> [args]')
|
||||||
.action(function(action, args){
|
.action(function(action, args){
|
||||||
// XXX
|
// XXX
|
||||||
|
|||||||
@ -270,6 +270,7 @@ var FileSystemLoaderActions = actions.Actions({
|
|||||||
|
|
||||||
// XXX auto-detect format or let the user chose...
|
// XXX auto-detect format or let the user chose...
|
||||||
// XXX should this return a promise??? ...a clean promise???
|
// XXX should this return a promise??? ...a clean promise???
|
||||||
|
// XXX should the added section be marked or sorted???
|
||||||
loadPath: ['- File/Load path (STUB)',
|
loadPath: ['- File/Load path (STUB)',
|
||||||
function(path, logger){
|
function(path, logger){
|
||||||
// XXX check if this.config['index-dir'] exists, if yes then
|
// XXX check if this.config['index-dir'] exists, if yes then
|
||||||
@ -278,8 +279,6 @@ var FileSystemLoaderActions = actions.Actions({
|
|||||||
//this.location.method = 'loadImages'
|
//this.location.method = 'loadImages'
|
||||||
}],
|
}],
|
||||||
|
|
||||||
// XXX merging does not work (something wrong with .data.join(..))
|
|
||||||
// ...fixed a bug in images.js hash generator, now might be fixed...
|
|
||||||
// XXX should this return a promise??? ...a clean promise???
|
// XXX should this return a promise??? ...a clean promise???
|
||||||
// XXX revise logger...
|
// XXX revise logger...
|
||||||
loadNewImages: ['File/Load new images',
|
loadNewImages: ['File/Load new images',
|
||||||
@ -298,8 +297,11 @@ var FileSystemLoaderActions = actions.Actions({
|
|||||||
var base_pattern = RegExp('^'+path)
|
var base_pattern = RegExp('^'+path)
|
||||||
|
|
||||||
// find images...
|
// find images...
|
||||||
glob(path + '/'+ this.config['image-file-pattern'])
|
glob(path + '/'+ this.config['image-file-pattern'],
|
||||||
|
{stat: !!this.config['image-file-read-stat']})
|
||||||
.on('end', function(lst){
|
.on('end', function(lst){
|
||||||
|
var stats = this.statCache
|
||||||
|
|
||||||
// create a new images chunk...
|
// create a new images chunk...
|
||||||
lst = lst
|
lst = lst
|
||||||
// filter out loaded images...
|
// filter out loaded images...
|
||||||
@ -327,6 +329,19 @@ var FileSystemLoaderActions = actions.Actions({
|
|||||||
var gids = new_images.keys()
|
var gids = new_images.keys()
|
||||||
var new_data = that.data.constructor.fromArray(gids)
|
var new_data = that.data.constructor.fromArray(gids)
|
||||||
|
|
||||||
|
new_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.size = stat.size
|
||||||
|
|
||||||
|
// XXX do we need anything else???
|
||||||
|
})
|
||||||
|
|
||||||
// merge with index...
|
// merge with index...
|
||||||
// NOTE: we are prepending new images to the start...
|
// NOTE: we are prepending new images to the start...
|
||||||
// NOTE: all ribbon gids will change here...
|
// NOTE: all ribbon gids will change here...
|
||||||
|
|||||||
@ -168,6 +168,8 @@ module.GLOBAL_KEYBOARD = {
|
|||||||
// XXX need to prevent default on mac + browser...
|
// XXX need to prevent default on mac + browser...
|
||||||
meta: 'nextScreen',
|
meta: 'nextScreen',
|
||||||
},
|
},
|
||||||
|
Space: 'Right',
|
||||||
|
Backspace: 'Left',
|
||||||
'(': 'prevImageInOrder',
|
'(': 'prevImageInOrder',
|
||||||
')': 'nextImageInOrder',
|
')': 'nextImageInOrder',
|
||||||
',': 'prevMarked',
|
',': 'prevMarked',
|
||||||
|
|||||||
@ -90,6 +90,8 @@ module.Metadata = core.ImageGridFeatures.Feature({
|
|||||||
|
|
||||||
// XXX add Metadata writer...
|
// XXX add Metadata writer...
|
||||||
var MetadataReaderActions = actions.Actions({
|
var MetadataReaderActions = actions.Actions({
|
||||||
|
// NOTE: this will read both stat and metadata...
|
||||||
|
//
|
||||||
// XXX add support to taskqueue...
|
// XXX add support to taskqueue...
|
||||||
// XXX should this process multiple images???
|
// XXX should this process multiple images???
|
||||||
// XXX also check the metadata/ folder (???)
|
// XXX also check the metadata/ folder (???)
|
||||||
@ -119,6 +121,20 @@ var MetadataReaderActions = actions.Actions({
|
|||||||
return reject(err)
|
return reject(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// read stat...
|
||||||
|
if(!that.images[gid].birthtime){
|
||||||
|
var img = that.images[gid]
|
||||||
|
var stat = fs.statSync(full_path)
|
||||||
|
|
||||||
|
img.atime = stat.atime
|
||||||
|
img.mtime = stat.mtime
|
||||||
|
img.ctime = stat.ctime
|
||||||
|
img.birthtime = stat.birthtime
|
||||||
|
|
||||||
|
img.size = stat.size
|
||||||
|
}
|
||||||
|
|
||||||
|
// read image metadata...
|
||||||
exiftool.metadata(file, function(err, data){
|
exiftool.metadata(file, function(err, data){
|
||||||
if(err){
|
if(err){
|
||||||
reject(err)
|
reject(err)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user