mirror of
https://github.com/flynx/ImageGrid.git
synced 2025-10-29 02:10:08 +00:00
added tag dict translation...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
bd97721bbc
commit
baec933d89
@ -541,7 +541,6 @@ var TagUIActions = actions.Actions({
|
|||||||
return browse.makeLister(null, function(path, make){
|
return browse.makeLister(null, function(path, make){
|
||||||
var tags = that.data.getTags(gids)
|
var tags = that.data.getTags(gids)
|
||||||
var tagset = that.data.tags
|
var tagset = that.data.tags
|
||||||
var dict = tagset.dict
|
|
||||||
|
|
||||||
// tags...
|
// tags...
|
||||||
// XXX make this a group...
|
// XXX make this a group...
|
||||||
@ -592,14 +591,8 @@ var TagUIActions = actions.Actions({
|
|||||||
var tagged = tag[3]
|
var tagged = tag[3]
|
||||||
tag = tag[0]
|
tag = tag[0]
|
||||||
|
|
||||||
var text = dict ?
|
var text = tagset.translateTag ?
|
||||||
tag.split(tagset.PATH_SEPARATOR)
|
tagset.translateTag(tag)
|
||||||
.map(function(s){
|
|
||||||
return s.split(tagset.SET_SEPARATOR)
|
|
||||||
.map(function(t){
|
|
||||||
return (dict[t] || [t])[0] })
|
|
||||||
.join(':') })
|
|
||||||
.join('/')
|
|
||||||
: tag
|
: tag
|
||||||
|
|
||||||
return make(text, {
|
return make(text, {
|
||||||
|
|||||||
@ -83,6 +83,7 @@ var BaseTagsClassPrototype = {
|
|||||||
// NOTE: do not include 'g' flag here, it will make the RE objects
|
// NOTE: do not include 'g' flag here, it will make the RE objects
|
||||||
// stateful which will yield very unpredictable results from
|
// stateful which will yield very unpredictable results from
|
||||||
// general system.
|
// general system.
|
||||||
|
// XXX need separators as attrs too...
|
||||||
PATH_SEPARATOR: /[\\\/]+/,
|
PATH_SEPARATOR: /[\\\/]+/,
|
||||||
SET_SEPARATOR: /:+/,
|
SET_SEPARATOR: /:+/,
|
||||||
COMBINED_SEPARATOR: /[:\\\/]+/,
|
COMBINED_SEPARATOR: /[:\\\/]+/,
|
||||||
@ -1682,6 +1683,7 @@ object.makeConstructor('BaseTags',
|
|||||||
// XXX EXPERIMENTAL...
|
// XXX EXPERIMENTAL...
|
||||||
// ...this is a bit too generic, we need to save dict values only
|
// ...this is a bit too generic, we need to save dict values only
|
||||||
// when tagging or adding tags...
|
// when tagging or adding tags...
|
||||||
|
// ...also need to clear the dict when untagging...
|
||||||
var TagsWithDictPrototype = {
|
var TagsWithDictPrototype = {
|
||||||
__proto__: BaseTags,
|
__proto__: BaseTags,
|
||||||
|
|
||||||
@ -1721,6 +1723,28 @@ var TagsWithDictPrototype = {
|
|||||||
|
|
||||||
return res
|
return res
|
||||||
},
|
},
|
||||||
|
translateTag: function(...tags){
|
||||||
|
var that = this
|
||||||
|
var dict = this.dict
|
||||||
|
tags = normalizeSplit(tags)
|
||||||
|
|
||||||
|
var res = dict != null ?
|
||||||
|
tags
|
||||||
|
.map(function(path){
|
||||||
|
return path
|
||||||
|
.split(that.PATH_SEPARATOR)
|
||||||
|
.map(function(set){
|
||||||
|
return set
|
||||||
|
.split(that.SET_SEPARATOR)
|
||||||
|
.map(function(tag){
|
||||||
|
return (dict[tag] || [tag])[0] })
|
||||||
|
.join(':') })
|
||||||
|
.join('/') })
|
||||||
|
: tags
|
||||||
|
|
||||||
|
return arguments.length == 1 && typeof(arguments[0]) == typeof('str') ?
|
||||||
|
res[0]
|
||||||
|
: res },
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user