export dialog now can export single images in single image view -- effectively WYSIWYG...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2013-11-07 02:20:20 +04:00
parent 3440ed6538
commit 8bc1076a03
3 changed files with 100 additions and 51 deletions

View File

@ -1657,6 +1657,9 @@ function readImagesDates(images){
return $.when.apply(null, $.map(images, function(_, gid){ return $.when.apply(null, $.map(images, function(_, gid){
return readImageDate(gid, images) return readImageDate(gid, images)
.done(function(){
IMAGES_UPDATED.push(gid)
})
})) }))
} }
function readImagesDatesQ(images){ function readImagesDatesQ(images){
@ -1666,13 +1669,17 @@ function readImagesDatesQ(images){
$.each(images, function(gid, img){ $.each(images, function(gid, img){
queue.enqueue(readImageDate, gid, images) queue.enqueue(readImageDate, gid, images)
.always(function(){ queue.notify(gid, 'done') }) .always(function(){
IMAGES_UPDATED.push(gid)
queue.notify(gid, 'done')
})
}) })
return queue return queue
} }
// XXX after running this we need to re-save the images...
function updateImageGID(gid, images, data){ function updateImageGID(gid, images, data){
images = images == null ? IMAGES : images images = images == null ? IMAGES : images
var img = images[gid] var img = images[gid]

View File

@ -607,12 +607,55 @@ function updateRibbonsFromFavDirs(){
} }
function exportImageTo(gid, path, im_name, size){
path = path == null ? BASE_URL : path
im_name = im_name == null ? '%f' : im_name
size = size == null ? 1000 : size
// get correct preview...
var src = getBestPreview(gid, size).url
var orig = getImageFileName(gid)
// XXX might be a good idea to combine this with docs as a
// single mechanism...
// 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())
// marked status...
dest = dest.replace(/%\(([^)]*)\)m/, MARKED.indexOf(gid) >= 0 ? '$1' : '')
// gid...
dest = dest.replace('%gid', gid)
dest = dest.replace('%g', gid.slice(34))
// XXX Metadata...
// XXX
dest = path +'/'+ dest
// copy...
// NOTE: the sad smily face here is here for JS compatibility ;)
;(function(src, dest){
copyFile(src, dest)
.done(function(){
console.log(src, 'done.')
})
.fail(function(err){
console.warn(src, 'err:', err)
})
})(src, dest)
}
// Export current state to directory... // Export current state to directory...
// //
// XXX this copies the files in parallel, make it sync and sequential... // XXX this copies the files in parallel, make it sync and sequential...
// ...reason is simple, if we stop the copy we need to end up with // ...reason is simple, if we stop the copy we need to end up with
// part of the files copied full rather than all partially... // part of the files copied full rather than all partially...
function exportTo(path, im_name, dir_name, size){ function exportImagesTo(path, im_name, dir_name, size){
path = path == null ? BASE_URL : path path = path == null ? BASE_URL : path
im_name = im_name == null ? '%f' : im_name im_name = im_name == null ? '%f' : im_name
dir_name = dir_name == null ? 'fav' : dir_name dir_name = dir_name == null ? 'fav' : dir_name
@ -642,47 +685,17 @@ function exportTo(path, im_name, dir_name, size){
// go through images... // go through images...
for(var j=0; j < ribbon.length; j++){ for(var j=0; j < ribbon.length; j++){
var gid = ribbon[j] var gid = ribbon[j]
// get correct preview...
var src = getBestPreview(gid, size).url
var orig = getImageFileName(gid)
// XXX might be a good idea to combine this with docs as a // do global naming...
// single mechanism...
// form image name...
var dest = im_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())
// marked status...
dest = dest.replace(/%\(([^)]*)\)m/, MARKED.indexOf(gid) >= 0 ? '$1' : '')
// gid...
dest = dest.replace('%gid', gid)
dest = dest.replace('%g', gid.slice(34))
// global order... // global order...
var o = order.indexOf(gid) + '' var o = order.indexOf(gid) + ''
dest = dest.replace('%I', (Z + o).slice(o.length)) dest = dest.replace('%I', (Z + o).slice(o.length))
// current order... // current order...
var o = selection.indexOf(gid) + '' var o = selection.indexOf(gid) + ''
dest = dest.replace('%i', (z + o).slice(o.length)) dest = dest.replace('%i', (z + o).slice(o.length))
// XXX Metadata...
// XXX
dest = path +'/'+ dest exportImageTo(gid, path, dest, size)
// copy...
// NOTE: the sad smily face here is here for JS compatibility ;)
;(function(src, dest){
copyFile(src, dest)
.done(function(){
console.log(src, 'done.')
})
.fail(function(err){
console.warn(src, 'err:', err)
})
})(src, dest)
} }
path = normalizePath(path +'/'+ dir_name) path = normalizePath(path +'/'+ dir_name)

View File

@ -867,6 +867,7 @@ function exportPreviewsDialog(state, dfl){
if(state == null){ if(state == null){
state = toggleMarkedOnlyView('?') == 'on' ? 'marked images' : state state = toggleMarkedOnlyView('?') == 'on' ? 'marked images' : state
state = toggleSingleRibbonMode('?') == 'on' ? 'current ribbon' : state state = toggleSingleRibbonMode('?') == 'on' ? 'current ribbon' : state
state = toggleSingleImageMode('?') == 'on' ? 'current image' : state
state = state == null ? 'all images' : state state = state == null ? 'all images' : state
} }
@ -878,16 +879,28 @@ function exportPreviewsDialog(state, dfl){
// keys become unreadable with JS syntax preventing us from // keys become unreadable with JS syntax preventing us from
// splitting the key into several lines... // splitting the key into several lines...
var cfg = {} var cfg = {}
cfg['Image name pattern | '+ // multiple images...
'%f - full filename\n'+ if(state != 'current image'){
'%n - filename\n'+ cfg['Image name pattern | '+
'%e - extension (with leading dot)\n'+ '%f - full filename\n'+
'%(abc)m - if marked insert "abc"\n'+ '%n - filename\n'+
'%gid - log gid\n'+ '%e - extension (with leading dot)\n'+
'%g - short gid\n'+ '%(abc)m - if marked insert "abc"\n'+
'%I - global order\n'+ '%gid - log gid\n'+
'%i - current selection order'] = '%f' '%g - short gid\n'+
cfg['Level directory name'] = 'fav' '%I - global order\n'+
'%i - current selection order'] = '%f'
cfg['Level directory name'] = 'fav'
// single image...
} else {
cfg['Image name pattern | '+
'%f - full filename\n'+
'%n - filename\n'+
'%e - extension (with leading dot)\n'+
'%(abc)m - if marked insert "abc"\n'+
'%gid - log gid\n'+
'%g - short gid'] = '%f'
}
cfg['Size | '+ cfg['Size | '+
'The selected size is aproximate, the actual\n'+ 'The selected size is aproximate, the actual\n'+
'preview will be copied from cache.\n\n'+ 'preview will be copied from cache.\n\n'+
@ -908,13 +921,27 @@ function exportPreviewsDialog(state, dfl){
formDialog(null, '<b>Export:</b> '+ state +'.', cfg, 'OK', 'exportPreviewsDialog') formDialog(null, '<b>Export:</b> '+ state +'.', cfg, 'OK', 'exportPreviewsDialog')
.done(function(data){ .done(function(data){
var s = data[keys[2]] // get the form data...
s = s == 'Original image' ? Math.max.apply(null, PREVIEW_SIZES)*2 : parseInt(s)-5 var name = data[keys[0]]
exportTo( if(state != 'current image'){
normalizePath(data[keys[3]]), var size = data[keys[2]]
data[keys[0]], var path = normalizePath(data[keys[3]])
data[keys[1]], var dir = data[keys[1]]
s)
} else {
var size = data[keys[1]]
var path = normalizePath(data[keys[2]])
}
size = size == 'Original image' ? Math.max.apply(null, PREVIEW_SIZES)*2 : parseInt(size)-5
// do the actual exporting...
if(state != 'current image'){
exportImagesTo(path, name, dir, size)
} else {
exportImageTo(getImageGID(), path, name, size)
}
// XXX do real reporting... // XXX do real reporting...
showStatusQ('Copying data...') showStatusQ('Copying data...')
res.resolve(data['']) res.resolve(data[''])
@ -1028,6 +1055,7 @@ function showImageInfo(){
flipped = flipped == null ? '' : ', flipped '+flipped+'ly' flipped = flipped == null ? '' : ', flipped '+flipped+'ly'
var order = DATA.order.indexOf(gid) var order = DATA.order.indexOf(gid)
var name = getImageFileName(gid) var name = getImageFileName(gid)
var date = new Date(data.ctime * 1000)
var comment = data.comment var comment = data.comment
comment = comment == null ? '' : comment comment = comment == null ? '' : comment
comment = comment.replace(/\n/g, '<br>') comment = comment.replace(/\n/g, '<br>')
@ -1040,6 +1068,7 @@ function showImageInfo(){
// basic info... // basic info...
'<tr><td colspan="2"><hr></td></tr>'+ '<tr><td colspan="2"><hr></td></tr>'+
'<tr><td>GID: </td><td>'+ gid +'</td></tr>'+ '<tr><td>GID: </td><td>'+ gid +'</td></tr>'+
'<tr><td>Date: </td><td>'+ date +'</td></tr>'+
'<tr><td>Path: </td><td>"'+ unescape(data.path) +'"</td></tr>'+ '<tr><td>Path: </td><td>"'+ unescape(data.path) +'"</td></tr>'+
'<tr><td>Orientation: </td><td>'+ orientation +'&deg;'+flipped+'</td></tr>'+ '<tr><td>Orientation: </td><td>'+ orientation +'&deg;'+flipped+'</td></tr>'+
'<tr><td>Order: </td><td>'+ order +'</td></tr>'+ '<tr><td>Order: </td><td>'+ order +'</td></tr>'+