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 readImageDate(gid, images)
.done(function(){
IMAGES_UPDATED.push(gid)
})
}))
}
function readImagesDatesQ(images){
@ -1666,13 +1669,17 @@ function readImagesDatesQ(images){
$.each(images, function(gid, img){
queue.enqueue(readImageDate, gid, images)
.always(function(){ queue.notify(gid, 'done') })
.always(function(){
IMAGES_UPDATED.push(gid)
queue.notify(gid, 'done')
})
})
return queue
}
// XXX after running this we need to re-save the images...
function updateImageGID(gid, images, data){
images = images == null ? IMAGES : images
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...
//
// 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
// 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
im_name = im_name == null ? '%f' : im_name
dir_name = dir_name == null ? 'fav' : dir_name
@ -642,47 +685,17 @@ function exportTo(path, im_name, dir_name, size){
// 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 = getImageFileName(gid)
// XXX might be a good idea to combine this with docs as a
// single mechanism...
// form image name...
// do global naming...
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...
var o = order.indexOf(gid) + ''
dest = dest.replace('%I', (Z + o).slice(o.length))
// current order...
var o = selection.indexOf(gid) + ''
dest = dest.replace('%i', (z + o).slice(o.length))
// 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)
exportImageTo(gid, path, dest, size)
}
path = normalizePath(path +'/'+ dir_name)

View File

@ -867,6 +867,7 @@ function exportPreviewsDialog(state, dfl){
if(state == null){
state = toggleMarkedOnlyView('?') == 'on' ? 'marked images' : state
state = toggleSingleRibbonMode('?') == 'on' ? 'current ribbon' : state
state = toggleSingleImageMode('?') == 'on' ? 'current image' : state
state = state == null ? 'all images' : state
}
@ -878,16 +879,28 @@ function exportPreviewsDialog(state, dfl){
// keys become unreadable with JS syntax preventing us from
// splitting the key into several lines...
var cfg = {}
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\n'+
'%I - global order\n'+
'%i - current selection order'] = '%f'
cfg['Level directory name'] = 'fav'
// multiple images...
if(state != 'current image'){
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\n'+
'%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 | '+
'The selected size is aproximate, the actual\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')
.done(function(data){
var s = data[keys[2]]
s = s == 'Original image' ? Math.max.apply(null, PREVIEW_SIZES)*2 : parseInt(s)-5
exportTo(
normalizePath(data[keys[3]]),
data[keys[0]],
data[keys[1]],
s)
// get the form data...
var name = data[keys[0]]
if(state != 'current image'){
var size = data[keys[2]]
var path = normalizePath(data[keys[3]])
var dir = data[keys[1]]
} 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...
showStatusQ('Copying data...')
res.resolve(data[''])
@ -1028,6 +1055,7 @@ function showImageInfo(){
flipped = flipped == null ? '' : ', flipped '+flipped+'ly'
var order = DATA.order.indexOf(gid)
var name = getImageFileName(gid)
var date = new Date(data.ctime * 1000)
var comment = data.comment
comment = comment == null ? '' : comment
comment = comment.replace(/\n/g, '<br>')
@ -1040,6 +1068,7 @@ function showImageInfo(){
// basic info...
'<tr><td colspan="2"><hr></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>Orientation: </td><td>'+ orientation +'&deg;'+flipped+'</td></tr>'+
'<tr><td>Order: </td><td>'+ order +'</td></tr>'+