added persistent aliases...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2017-08-04 04:28:29 +03:00
parent 3d81db1bc2
commit 00ec10a335
7 changed files with 77 additions and 4 deletions

57
ui (gen4)/features/alias.js Executable file
View File

@ -0,0 +1,57 @@
/**********************************************************************
*
*
*
**********************************************************************/
((typeof define)[0]=='u'?function(f){module.exports=f(require)}:define)
(function(require){ var module={} // make module AMD/node compatible...
/*********************************************************************/
var actions = require('lib/actions')
var features = require('lib/features')
var core = require('features/core')
/*********************************************************************/
var Alias =
module.Alias = core.ImageGridFeatures.Feature({
title: '',
doc: '',
tag: 'alias',
config: {
//aliases: {
//},
},
handlers: [
['alias',
function(_, alias, target){
console.log(alias, target)
// remove alias...
if(target === null || target === false){
var aliases = this.config.aliases || {}
delete aliases[alias]
if(Object.keys(alias).length == 0){
delete this.config.aliases
}
// save alias...
} else {
var aliases = this.config.aliases = this.config.aliases || {}
aliases[alias] = target
}
}]],
})
/**********************************************************************
* vim:set ts=4 sw=4 : */ return module })

View File

@ -19,6 +19,7 @@ require('features/recover')
require('features/history') require('features/history')
require('features/app') require('features/app')
require('features/peer') require('features/peer')
require('features/alias')
require('features/ui') require('features/ui')
// XXX // XXX
require('features/ui-blank-render') require('features/ui-blank-render')

View File

@ -802,6 +802,9 @@ module.Keyboard = core.ImageGridFeatures.Feature({
var that = this var that = this
this.__keyboard_config = this.keybindings || GLOBAL_KEYBOARD this.__keyboard_config = this.keybindings || GLOBAL_KEYBOARD
// string action call parser...
this.parseStringHandler = this.parseStringAction
this.toggleKeyboardHandling('on') this.toggleKeyboardHandling('on')
}], }],

View File

@ -50,6 +50,8 @@ core.ImageGridFeatures.Feature('viewer-testing', [
'viewer-commandline', 'viewer-commandline',
'viewer-minimal', 'viewer-minimal',
'alias',
// read-only mode... // read-only mode...
// XXX at this point this needs some more tuneup, the following // XXX at this point this needs some more tuneup, the following
// features are completely disabled when 'edit' is not present // features are completely disabled when 'edit' is not present

View File

@ -2295,6 +2295,10 @@ var WidgetTestActions = actions.Actions({
.attr(attrs)) .attr(attrs))
}], }],
// XXX does not work -- see actions.Actions(..) for details...
testAlias: ['Test/Action alias',
'focusImage: "prev"'],
// action constructor for testing... // action constructor for testing...
makeAction: ['- Test/', makeAction: ['- Test/',
function(name){ function(name){

View File

@ -159,6 +159,7 @@ function doc(text, func){
// XXX add support for suffix to return false / stop_propagation... // XXX add support for suffix to return false / stop_propagation...
// XXX should this handle calls??? // XXX should this handle calls???
// i.e. have .call(..) / .apply(..) methods??? // i.e. have .call(..) / .apply(..) methods???
// XXX this is the same as actions.parseStringAction(..), reuse in a logical manner...
var parseActionCall = var parseActionCall =
module.parseActionCall = module.parseActionCall =
function parseActionCall(txt){ function parseActionCall(txt){
@ -503,6 +504,8 @@ var KeyboardPrototype = {
// stop_propagation: <bool>, // stop_propagation: <bool>,
// } // }
// //
// XXX should this be a Keyboard thing or a context thing???
// XXX revise name...
parseStringHandler: parseActionCall, parseStringHandler: parseActionCall,
@ -1097,8 +1100,11 @@ function makeKeyboardHandler(keyboard, unhandled, actions){
res = handler.call(actions) res = handler.call(actions)
// action call syntax... // action call syntax...
} else if(kb.parseStringHandler){ // XXX should this be a Keyboard thing or a context thing???
var h = kb.parseStringHandler(handler) } else if(actions.parseStringHandler || kb.parseStringHandler){
//} else if(kb.parseStringHandler){
var h = (actions.parseStringHandler || kb.parseStringHandler)(handler)
//var h = kb.parseStringHandler(handler)
if(h && h.action in actions){ if(h && h.action in actions){
did_handling = true did_handling = true

View File

@ -18,11 +18,11 @@
"app-module-path": "^1.0.6", "app-module-path": "^1.0.6",
"commander": "^2.11.0", "commander": "^2.11.0",
"exiftool": "^0.0.3", "exiftool": "^0.0.3",
"fs-extra": "^4.0.0", "fs-extra": "^4.0.1",
"fs-walk": "^0.0.1", "fs-walk": "^0.0.1",
"glob": "^4.0.6", "glob": "^4.0.6",
"guarantee-events": "^1.0.0", "guarantee-events": "^1.0.0",
"ig-actions": "^3.2.5", "ig-actions": "^3.5.1",
"ig-features": "^3.2.6", "ig-features": "^3.2.6",
"ig-object": "^1.0.1", "ig-object": "^1.0.1",
"openseadragon": "^2.3.0", "openseadragon": "^2.3.0",