From c8b653567a30483ba4cab55a18894975443ad19a Mon Sep 17 00:00:00 2001 From: "Alex A. Naanou" Date: Sun, 15 Nov 2015 01:25:04 +0300 Subject: [PATCH] some fixes + more work on the loader... Signed-off-by: Alex A. Naanou --- ui (gen4)/css/layout.css | 1 + ui (gen4)/css/layout.less | 1 + ui (gen4)/file.js | 46 +++++++++++++++++++++++++++++++++++++++ ui (gen4)/formats.js | 2 ++ ui (gen4)/index.html | 2 +- ui (gen4)/object.js | 9 ++++++++ ui (gen4)/testing.js | 5 +++++ ui (gen4)/ui.js | 3 +++ ui (gen4)/viewer.js | 33 ++++++---------------------- 9 files changed, 75 insertions(+), 27 deletions(-) diff --git a/ui (gen4)/css/layout.css b/ui (gen4)/css/layout.css index 57f97ef4..ef26b629 100644 --- a/ui (gen4)/css/layout.css +++ b/ui (gen4)/css/layout.css @@ -759,6 +759,7 @@ stretching in width... */ background: blue; left: -25px; } +.marks-visible.single-image-mode.viewer .mark:before, .marks-visible.single-image-mode.viewer .mark:after { display: none; } diff --git a/ui (gen4)/css/layout.less b/ui (gen4)/css/layout.less index 6466842f..d3998541 100755 --- a/ui (gen4)/css/layout.less +++ b/ui (gen4)/css/layout.less @@ -777,6 +777,7 @@ stretching in width... */ background: blue; left: -25px; } +.marks-visible.single-image-mode.viewer .mark:before, .marks-visible.single-image-mode.viewer .mark:after { display: none; } diff --git a/ui (gen4)/file.js b/ui (gen4)/file.js index 3574bb9d..25e195ec 100755 --- a/ui (gen4)/file.js +++ b/ui (gen4)/file.js @@ -19,6 +19,9 @@ console.log('>>> file') //var DEBUG = DEBUG != null ? DEBUG : true +var data = require('data') +var images = require('images') + var tasks = require('lib/tasks') @@ -404,6 +407,49 @@ function(base, previews, absolute_path){ +// XXX move this to a better spot... +var buildIndex = +module.buildIndex = function(index, base){ + var d = data.Data.fromJSON(index.data) + + // buildup the data object... + d.tags = d.tags || {} + d.tags.bookmark = index.bookmarked ? index.bookmarked[0] : [] + d.tags.selected = index.marked || [] + d.sortTags() + + // current... + d.current = index.current || d.current + + + // images... + // XXX there seems to be a problem with updated images... + // - in the test set not all rotated manually images are loaded rotated... + var img = images.Images(index.images) + + if(base){ + d.base_path = base + // 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 + img.forEach(function(_, img){ img.base = base }) + } + + return { + data: d, + images: img, + } +} + + /*********************************************************************/ // Writer... diff --git a/ui (gen4)/formats.js b/ui (gen4)/formats.js index decf58ee..fb82ab1c 100755 --- a/ui (gen4)/formats.js +++ b/ui (gen4)/formats.js @@ -85,6 +85,7 @@ function(data){ res.order = data.order.slice() res.ribbon_order = data.ribbon_order == null ? [] : data.ribbon_order.slice() res.ribbons = {} + // generate gids... // NOTE: this will use the structures stored in data if available, // otherwise new structures will be generated... @@ -98,6 +99,7 @@ function(data){ res.ribbon_order.push(gid) res.ribbons[gid] = data.ribbons[k].slice() }) + // we set the base to the first ribbon... res.base = data.base == null ? res.ribbon_order[0] : res.base return res diff --git a/ui (gen4)/index.html b/ui (gen4)/index.html index 337d54c9..79a362f7 100755 --- a/ui (gen4)/index.html +++ b/ui (gen4)/index.html @@ -19,7 +19,7 @@ body { } /* show image gid... */ -.image:after { +.visible-gid .image:after { content: attr(gid); display: block; position: relative; diff --git a/ui (gen4)/object.js b/ui (gen4)/object.js index 4078dbd7..1f5b8985 100755 --- a/ui (gen4)/object.js +++ b/ui (gen4)/object.js @@ -65,6 +65,15 @@ function makeConstructor(name, a, b){ // super equivalent... +// +// Example: +// superMethod(, ).call(this, ...) +// -> +// +// This will return a next method in inheritance chain after by +// its name (). +// In the normal use-case is the current class and +// is the name of the current method. var superMethod = module.superMethod = function superMethod(cls, meth){ diff --git a/ui (gen4)/testing.js b/ui (gen4)/testing.js index 5c574e71..d3ded9fa 100755 --- a/ui (gen4)/testing.js +++ b/ui (gen4)/testing.js @@ -125,6 +125,11 @@ if(typeof(glob) != 'undefined'){ } + window.loadMBFWR1 = function(){ + a.loadPath('L:/mnt/hdd15 (photo)/NTFS2/media/img/my/work/20151022 - MBFWR (1),/*') + } + + /* window.loadSaved = function(){ a.data.loadJSON(require('fs').readFileSync('insta.json', 'utf-8')) diff --git a/ui (gen4)/ui.js b/ui (gen4)/ui.js index 666230e2..18fc078e 100755 --- a/ui (gen4)/ui.js +++ b/ui (gen4)/ui.js @@ -233,6 +233,9 @@ module.GLOBAL_KEYBOARD = { alt: 'browseActions: "/Bookmark/"', }, C: 'browseActions: "/Crop/"', + + // XXX for debug... + G: function(){ $('.viewer').toggleClass('visible-gid') }, }, } diff --git a/ui (gen4)/viewer.js b/ui (gen4)/viewer.js index dede795f..ac1d95e7 100755 --- a/ui (gen4)/viewer.js +++ b/ui (gen4)/viewer.js @@ -2901,12 +2901,15 @@ if(window.nodejs != null){ var file = requirejs('./file') } + var FileSystemLoaderActions = actions.Actions({ // XXX loadPath: ['File/', function(path){ var that = this + // XXX get a logger... + // XXX this will not work for explicit path (path to a dir // that contains the index) file.loadIndex(path) @@ -2915,36 +2918,14 @@ var FileSystemLoaderActions = actions.Actions({ // XXX res may contain multiple indexes, need to // combine them... + var k = Object.keys(res)[0] + var index = res[k] // 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, - }) + + that.load(file.buildIndex(index, k)) }) }], })