added exportTo(..) still not final but working, also lacks a real UI...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2013-06-21 16:58:33 +04:00
parent d2717089b5
commit 01e8e39fc9
3 changed files with 105 additions and 1 deletions

View File

@ -40,6 +40,34 @@ if(window.CEF_dumpJSON != null){
} }
return fs.readdirSync(path) return fs.readdirSync(path)
} }
// XXX make this work across fs...
// XXX this will not overwrite...
window.copyFile = function(src, dst){
if(fp.test(src)){
// XXX will this work on Mac???
src = src.replace(fp, '')
}
if(fp.test(dst)){
// XXX will this work on Mac???
dst = dst.replace(fp, '')
}
var path = dst.split('/')
path.pop()
path = path.join('/')
// XXX make dirs...
if(!fs.existsSync(path)){
console.log('making:', path)
// XXX NOTE: this will not make more than one dir...
fs.mkdirSync(path)
}
if(!fs.existsSync(dst)){
fs.linkSync(src, dst)
}
}
window.dumpJSON = function(path, data){ window.dumpJSON = function(path, data){
if(fp.test(path)){ if(fp.test(path)){
// XXX will this work on Mac??? // XXX will this work on Mac???

View File

@ -555,6 +555,59 @@ function updateRibbonsFromFavDirs(){
} }
// Export current state to directory...
//
// NOTE: if size is null, the original image will be copied...
function exportTo(path, im_name, dir_name, size){
path = path == null ? BASE_URL : path
im_name = im_name == null ? '%f' : im_name
dir_name = dir_name == null ? 'fav' : dir_name
var base_path = path
path = normalizePath(path)
var order = DATA.order
var z = (('10e' + (order.length + '').length) * 1 + '').slice(2)
// go through ribbons...
for(var i=DATA.ribbons.length-1; i >= 0; i--){
var ribbon = DATA.ribbons[i]
// go through images...
for(var j=0; j < ribbon.length; j++){
var gid = ribbon[j]
// get correct preview...
var src = getBestPreview(gid, size).url
var orig = IMAGES[gid].path.split('/').pop()
// form image name...
var dest = im_name
// full filename...
dest = dest.replace('%f', orig)
// file name w.o. ext...
dest = dest.replace('%n', orig.split('.')[0])
// ext...
dest = dest.replace('%e', src.split('.').pop())
// gid...
dest = dest.replace('%gid', gid)
dest = dest.replace('%g', gid.slice(34))
// order...
var o = order.indexOf(gid) + ''
dest = dest.replace('%i', (z + o).slice(o.length))
// XXX Metadata...
// XXX
dest = path +'/'+ dest
// XXX link...
//console.log('>>>', dest)
copyFile(src, dest)
}
path = normalizePath(path +'/'+ dir_name)
}
}
/********************************************************************** /**********************************************************************
* vim:set ts=4 sw=4 : */ * vim:set ts=4 sw=4 : */

View File

@ -481,7 +481,30 @@ var KEYBOARD_CONFIG = {
saveFileState() saveFileState()
showStatusQ('Saving: Done.') showStatusQ('Saving: Done.')
}) }),
'ctrl+shift': doc('Export',
function(){
// XXX a dialog with alternatives...
// Export modes:
// - source:
// - all (default)
// - current ribbon only
// - marked only (can be combined with current ribbon)
// - structure
// - flat
// - fav dirs
// - naming
// - fav dir name (default: fav)
// - image file name (default: %f)
// (add several presets like %f for filename,
// %(tag) for metadata tag values, etc.)
// - common metadata
// - comment
// - ...
// - destination
// - ndir with current path as default
// - dir to create (default: "")
}),
}, },
Z: { Z: {
ctrl: doc('Restore to last saved state', ctrl: doc('Restore to last saved state',