started work on the fs loader...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2015-11-14 04:48:55 +03:00
parent 3eb788b02e
commit d727691977
4 changed files with 78 additions and 6 deletions

View File

@ -319,7 +319,15 @@ function(path, logger){
// collect the found indexes...
.on('match', function(path){
loadIndex(path, logger)
.done(function(obj){ res[path] = obj[path] })
.done(function(obj){
// NOTE: considering that all the paths within
// the index are relative to the preview
// dir (the parent dir to the index root)
// we do not need to include the index
// itself in the base path...
var p = path.split(INDEX_DIR)[0]
res[p] = obj[path]
})
})
// done...
.on('end', function(paths){

View File

@ -1115,6 +1115,12 @@ var RibbonsPrototype = {
// preview...
var p_url = that.images.getBestPreview(img_data.id, size, img_data).url
// XXX experimental...
if(img_data.base != null){
// XXX need to check if p_url is already absolute...
p_url = img_data.base +'/'+ p_url
}
// update the preview if it's a new image or...
// XXX this should be pushed as far back as possible...
if(old_gid != gid

View File

@ -282,7 +282,7 @@ $(function(){
// setup base keyboard for devel, in case something breaks...
// This branch does not drop keys...
if(module.MAX_KEY_REPEAT_RATE < 0 || module.MAX_KEY_REPEAT_RATE == null){
if(a.config['max-key-repeat-rate'] < 0 || a.config['max-key-repeat-rate'] == null){
$(document)
.keydown(
keyboard.makeKeyboardHandler(
@ -305,8 +305,7 @@ $(function(){
},
a),
function(){
// XXX get this from config...
return module.MAX_KEY_REPEAT_RATE
return a.config['max-key-repeat-rate']
}))
}
})

View File

@ -810,8 +810,9 @@ var ViewerActions =
module.ViewerActions =
actions.Actions({
/*
// Images...
// XXX this seems like a hack...
// ...should this be here???
get images(){
return this.ribbons != null ? this.ribbons.images : null
},
@ -821,7 +822,6 @@ actions.Actions({
this.ribbons.images = value
}
},
*/
get screenwidth(){
return this.ribbons != null ? this.ribbons.getScreenWidthImages() : null
@ -1329,6 +1329,14 @@ module.Viewer = ImageGridFeatures.Feature({
// ...this effectively sets the closest distance an image can be from
// the viewer edge...
'fit-overflow': 0.2,
// limit key repeat to one per N milliseconds.
//
// Set this to -1 or null to run keys without any limitations.
// XXX at this point the keyboard is setup in ui.js, need to
// move to a more logical spot...
'max-key-repeat-rate': 0,
},
actions: ViewerActions,
@ -2889,6 +2897,55 @@ module.AppControl = ImageGridFeatures.Feature({
//---------------------------------------------------------------------
// XXX at this point this is a stub...
if(window.nodejs != null){
var file = requirejs('./file')
}
var FileSystemLoaderActions = actions.Actions({
// XXX
loadPath: ['File/',
function(path){
var that = this
// XXX does not appear to load correctly...
file.loadIndex(path)
.done(function(res){
// XXX res may contain multiple indexes, need to
// combine them...
var k = Object.keys(res)[0]
// XXX use the logger...
console.log('LOADING:', k)
var d = data.Data.fromJSON(res[k].data)
// XXX need to load tags, marks, bookmarks, ...
// XXX
// XXX need to make this segment specific...
d.base = k
// XXX STUB remove ASAP...
// ...need a real way to handle base dir, possible
// approaches:
// 1) .base attr in image, set on load and
// do not save (or ignore on load)...
// if exists prepend to all paths...
// - more to do in view-time
// + more flexible
// 2) add/remove on load/save (approach below)
// + less to do in real time
// - more processing on load/save
var img = images.Images(res[k].images)
.forEach(function(_, img){ img.base = k })
that.load({
data: d,
images: img,
})
})
}],
})
var FileSystemLoader =
module.FileSystemLoader = ImageGridFeatures.Feature({
title: '',
@ -2896,6 +2953,8 @@ module.FileSystemLoader = ImageGridFeatures.Feature({
tag: 'fs-loader',
actions: FileSystemLoaderActions,
isApplicable: function(){
return window.nodejs != null
},