mirror of
https://github.com/flynx/ImageGrid.git
synced 2025-10-28 18:00:09 +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){
|
||||
var tags = that.data.getTags(gids)
|
||||
var tagset = that.data.tags
|
||||
var dict = tagset.dict
|
||||
|
||||
// tags...
|
||||
// XXX make this a group...
|
||||
@ -592,14 +591,8 @@ var TagUIActions = actions.Actions({
|
||||
var tagged = tag[3]
|
||||
tag = tag[0]
|
||||
|
||||
var text = dict ?
|
||||
tag.split(tagset.PATH_SEPARATOR)
|
||||
.map(function(s){
|
||||
return s.split(tagset.SET_SEPARATOR)
|
||||
.map(function(t){
|
||||
return (dict[t] || [t])[0] })
|
||||
.join(':') })
|
||||
.join('/')
|
||||
var text = tagset.translateTag ?
|
||||
tagset.translateTag(tag)
|
||||
: tag
|
||||
|
||||
return make(text, {
|
||||
|
||||
@ -83,6 +83,7 @@ var BaseTagsClassPrototype = {
|
||||
// NOTE: do not include 'g' flag here, it will make the RE objects
|
||||
// stateful which will yield very unpredictable results from
|
||||
// general system.
|
||||
// XXX need separators as attrs too...
|
||||
PATH_SEPARATOR: /[\\\/]+/,
|
||||
SET_SEPARATOR: /:+/,
|
||||
COMBINED_SEPARATOR: /[:\\\/]+/,
|
||||
@ -1682,6 +1683,7 @@ object.makeConstructor('BaseTags',
|
||||
// XXX EXPERIMENTAL...
|
||||
// ...this is a bit too generic, we need to save dict values only
|
||||
// when tagging or adding tags...
|
||||
// ...also need to clear the dict when untagging...
|
||||
var TagsWithDictPrototype = {
|
||||
__proto__: BaseTags,
|
||||
|
||||
@ -1721,6 +1723,28 @@ var TagsWithDictPrototype = {
|
||||
|
||||
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