started work on windws attributes (does not work in nw yet) and some refactoring...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2016-06-05 17:39:19 +03:00
parent 5a4525f86e
commit 9618ffeab5
3 changed files with 43 additions and 13 deletions

View File

@ -15,6 +15,13 @@ if(typeof(process) != 'undefined'){
var pathlib = requirejs('path') var pathlib = requirejs('path')
var glob = requirejs('glob') var glob = requirejs('glob')
// Windows specific stuff...
try{
var fswin = requirejs('fswin')
}catch(err){
var fswin = null
}
var file = require('imagegrid/file') var file = require('imagegrid/file')
} }
@ -1432,14 +1439,21 @@ var FileSystemWriterActions = actions.Actions({
var location = this.location var location = this.location
var index = this.prepareIndexForWrite() var index = this.prepareIndexForWrite()
var full_path = path +'/'+ this.config['index-dir']
return file.writeIndex( return file.writeIndex(
index.prepared, index.prepared,
// XXX should we check if index dir is present in path??? // XXX should we check if index dir is present in path???
//path, //path,
path +'/'+ this.config['index-dir'], full_path,
index.date, index.date,
this.config['index-filename-template'], this.config['index-filename-template'],
logger) logger)
.then(function(){
fswin && fswin.setAttributeSync(full_path, {
IS_HIDDEN: true,
})
})
.then(function(){ .then(function(){
location.method = 'loadIndex' location.method = 'loadIndex'
location.from = index.date location.from = index.date
@ -1529,6 +1543,8 @@ 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 copy img.path -- the main image, especially when no previews present....
// XXX // XXX
@ -1549,7 +1565,7 @@ var FileSystemWriterActions = actions.Actions({
// ...needs testing, if node's fs queues the io // ...needs testing, if node's fs queues the io
// internally then we do not need to bother... // internally then we do not need to bother...
// XXX // XXX
ensureDir(pathlib.dirname(to)) queue.push(ensureDir(pathlib.dirname(to))
.catch(function(err){ .catch(function(err){
logger && logger.emit('error', err) }) logger && logger.emit('error', err) })
.then(function(){ .then(function(){
@ -1562,19 +1578,29 @@ var FileSystemWriterActions = actions.Actions({
logger && logger.emit('done', to) }) logger && logger.emit('done', to) })
.catch(function(err){ .catch(function(err){
logger && logger.emit('error', err) }) logger && logger.emit('error', err) })
}) }))
}) })
} }
}) })
// NOTE: if we are to use .saveIndex(..) here, do not forget // NOTE: if we are to use .saveIndex(..) here, do not forget
// to reset .changes // to reset .changes
file.writeIndex( queue.push(file.writeIndex(
this.prepareIndexForWrite(json, true).prepared, this.prepareIndexForWrite(json, true).prepared,
index_path, index_path,
this.config['index-filename-template'], this.config['index-filename-template'],
logger || this.logger) logger || this.logger)
.then(function(){
fswin && fswin.setAttributeSync(index_path, {
IS_HIDDEN: true,
})
}))
return Promise.all(queue)
.then(function(){
return that.location
})
}], }],
// 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

View File

@ -18,6 +18,7 @@ if(typeof(process) != 'undefined'){
var guaranteeEvents = requirejs('guarantee-events') var guaranteeEvents = requirejs('guarantee-events')
} else { } else {
return module return module
} }

View File

@ -2,6 +2,8 @@
"name": "ImageGrid.Viewer.g4", "name": "ImageGrid.Viewer.g4",
"main": "index.html", "main": "index.html",
"version": "4.0.0a", "version": "4.0.0a",
"preferGlobal": true,
"chromium-args": "--disable-gpu-compositing",
"window": { "window": {
"title": "ImageGrid.Viewer (gen4)", "title": "ImageGrid.Viewer (gen4)",
"position": "center", "position": "center",
@ -13,7 +15,6 @@
"toolbar": false, "toolbar": false,
"show": false "show": false
}, },
"chromium-args": "--disable-gpu-compositing",
"dependencies": { "dependencies": {
"app-module-path": "^1.0.6", "app-module-path": "^1.0.6",
"commander": "^2.9.0", "commander": "^2.9.0",
@ -27,15 +28,17 @@
"requirejs": "^2.1.23", "requirejs": "^2.1.23",
"sharp": "^0.12.0" "sharp": "^0.12.0"
}, },
"preferGlobal": true, "optionalDependencies": {
"bin": { "fswin": "*"
"ig": "ig.js"
}, },
"devDependencies": { "devDependencies": {
"less": "*", "less": "*",
"webdriverio": "^4.0.4", "webdriverio": "^4.0.4",
"nwjs": "*" "nwjs": "*"
}, },
"bin": {
"ig": "ig.js"
},
"scripts": { "scripts": {
"build-css": "lessc css/layout.less css/layout.css", "build-css": "lessc css/layout.less css/layout.css",
"start": "nw ." "start": "nw ."