diff --git a/ui (gen4)/features/tags.js b/ui (gen4)/features/tags.js index 3d8e9696..4cae40e3 100755 --- a/ui (gen4)/features/tags.js +++ b/ui (gen4)/features/tags.js @@ -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, { diff --git a/ui (gen4)/imagegrid/tags.js b/ui (gen4)/imagegrid/tags.js index b248af49..1fd05b53 100755 --- a/ui (gen4)/imagegrid/tags.js +++ b/ui (gen4)/imagegrid/tags.js @@ -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 }, }