experementing...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2016-01-03 04:49:00 +03:00
parent c978cdd0a4
commit 0932a2ca8e
6 changed files with 113 additions and 56 deletions

View File

@ -33,6 +33,15 @@ var base = require('features/base')
// - make index
// - merge
// - clone
//
// XXX a different approach to this would be an "external" cli controller
// script that would contain only cli code and load the ImageGrid
// only in the handler...
// + would be allot faster to load.
// + more flexible as we can load more than one instance...
// This could still be done via features, just load the cli feature
// alone at first and then either create new instances or setup
// additional features as needed...
var CLI =
module.CLI = core.ImageGridFeatures.Feature({
@ -40,7 +49,7 @@ module.CLI = core.ImageGridFeatures.Feature({
doc: '',
tag: 'commandline',
depends: ['base'],
depends: ['lifecycle'],
isApplicable: function(){
return this.runtime == 'node' || this.runtime == 'nw' },
@ -48,6 +57,7 @@ module.CLI = core.ImageGridFeatures.Feature({
handlers: [
['start',
function(){
var that = this
// get the arguments...
if(this.runtime == 'nw'){
var argv = requirejs('nw.gui').App.argv
@ -70,31 +80,59 @@ module.CLI = core.ImageGridFeatures.Feature({
// list features...
// XXX make this a core action... (???)
.option('--list-features', 'list loaded features', function(){
.option('lf, --list-features', 'list loaded features', function(){
// excluded...
this.features.excluded.length > 0
that.features.excluded.length > 0
&& console.warn('Features excluded (%d):\n ',
this.features.excluded.length,
this.features.excluded.join('\n '))
that.features.excluded.length,
that.features.excluded.join('\n '))
// not applicable...
console.log('Features not applicable (%d):\n ',
this.features.unapplicable.length,
this.features.unapplicable.join('\n '))
that.features.unapplicable.length > 0
&& console.log('Features not applicable (%d):\n ',
that.features.unapplicable.length,
that.features.unapplicable.join('\n '))
// loaded...
console.log('Features loaded (%d):\n ',
this.features.features.length,
this.features.features.join('\n '))
that.features.features.length,
that.features.features.join('\n '))
})
.option('laf, --list-available-features', 'list available features', function(){
var f = core.ImageGridFeatures.features
console.log('Features available (%d):\n ',
f.length,
f.join('\n '))
})
// list actions...
// XXX this is a bit pointless as single actions are
// meaningless when no state is stored...
.option('--list-actions', 'list loaded actions', function(){
.option('la, --list-actions', 'list loaded actions', function(){
console.log('Actions loaded (%d):\n ',
this.length,
Object.keys(this.getDoc()).join('\n '))
that.length,
Object.keys(that.getDoc()).join('\n '))
})
// XXX experimental....
// to see this in action use:
// ig lf sm lf
// ...this will print the list of features before
// and after setup...
.option('sm, --setup-minimal', 'setup minimap features', function(){
// load features we might need...
// XXX require js loads these at the root...
var location = require('features/location')
var history = require('features/history')
var app = require('features/app')
var marks = require('features/ui-marks')
var filesystem = require('features/filesystem')
var experimental = require('features/experimental')
// extend the current instance to a minimal non-ui
// state...
core.ImageGridFeatures
.setup(that, ['viewer-minimal'])
})
// XXX the problem with this is that it still tires

View File

@ -158,6 +158,7 @@ module.LifeCycle = ImageGridFeatures.Feature({
doc: '',
tag: 'lifecycle',
priority: 'high',
actions: LifeCycleActions,
})

View File

@ -27,8 +27,13 @@ var core = require('features/core')
core.ImageGridFeatures.Feature('viewer-commandline', [
'lifecycle',
'base-full',
'commandline',
])
core.ImageGridFeatures.Feature('viewer-minimal', [
'lifecycle',
'base-full',
'image-marks',
'image-bookmarks',
@ -38,10 +43,9 @@ core.ImageGridFeatures.Feature('viewer-commandline', [
])
core.ImageGridFeatures.Feature('viewer-testing', [
'viewer-commandline',
'viewer-minimal',
'ui',
@ -113,6 +117,7 @@ core.ImageGridFeatures.Feature('viewer-testing', [
'system-journal',
])
/*
core.ImageGridFeatures.Feature('viewer-minimal', [
'base',
'ui',
@ -124,6 +129,7 @@ core.ImageGridFeatures.Feature('viewer-minimal', [
//'ui-current-image-indicator-hide-on-screen-nav',
'ui-action-tree',
])
*/

View File

@ -25,13 +25,7 @@ require = requirejs
// XXX need to automate this...
var core = require('features/core')
var base = require('features/base')
var location = require('features/location')
var history = require('features/history')
var app = require('features/app')
var marks = require('features/ui-marks')
var filesystem = require('features/filesystem')
var cli = require('features/cli')
var experimental = require('features/experimental')
var meta = require('features/meta')

View File

@ -235,6 +235,16 @@ module.FeatureSet = {
// if true, .setup(..) will report things it's doing...
__verbose__: null,
// List of registered features...
get features(){
var that = this
return Object.keys(this)
.filter(function(e){
return e != 'features'
&& that[e] instanceof Feature })
},
// Build feature list...
//
// Build a list of all registered features
@ -297,13 +307,17 @@ module.FeatureSet = {
// careful.
//
// XXX make suggested feature expansion recursive...
// XXX this appears to be very slow if lst not passed...
buildFeatureList: function(obj, lst, auto_include, depth){
lst = lst == null ? Object.keys(this) : lst
var that = this
obj = obj || {}
lst = lst == null ? this.features : lst
lst = lst.constructor !== Array ? [lst] : lst
auto_include = auto_include == null ? true : false
depth = depth || 8
var that = this
var missing = {}

View File

@ -1,34 +1,38 @@
{
"name": "ImageGrid.Viewer.g4",
"main": "index.html",
"version": "0.0.1",
"window": {
"title": "ImageGrid.Viewer (gen4)",
"position": "center",
"width": 900,
"height": 700,
"min_width": 400,
"min_height": 400,
"frame": true,
"toolbar": false,
"show": false
},
"webkit": {
"page-cache": true
},
"dependencies": {
"commander": "^2.9.0",
"flickrapi": "^0.3.28",
"fs-extra": "*",
"fs-walk": "0.0.1",
"glob": "^4.0.6",
"guarantee-events": "^1.0.0",
"promise": "^6.0.1",
"requirejs": "*",
"sharp": "^0.12.0"
},
"preferGlobal": true,
"bin": {
"ig": "ig.js"
}
"name": "ImageGrid.Viewer.g4",
"main": "index.html",
"version": "0.0.1",
"window": {
"title": "ImageGrid.Viewer (gen4)",
"position": "center",
"width": 900,
"height": 700,
"min_width": 400,
"min_height": 400,
"frame": true,
"toolbar": false,
"show": false
},
"webkit": {
"page-cache": true
},
"dependencies": {
"commander": "^2.9.0",
"flickrapi": "^0.3.28",
"fs-extra": "*",
"fs-walk": "0.0.1",
"glob": "^4.0.6",
"guarantee-events": "^1.0.0",
"promise": "^6.0.1",
"requirejs": "*",
"sharp": "^0.12.0"
},
"preferGlobal": true,
"bin": {
"ig": "ig.js"
},
"devDependencies": {
"nw-builder": "^2.2.0",
"less": "*"
}
}