From 30e38761b392bc388f4e54bcfbf99e1f8f06ca2a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maxime=20B=C3=A9guin?= Date: Thu, 21 Jan 2021 11:33:33 +0100 Subject: [PATCH] server: add tag "category" fallback for tar files Tags names were described in tar files with data.tagname and was named "TagN" if data.tagname wasn't defined, with "N" an incremental number. It is now possible to have tags with property data.category as a fallback to data.tagname. In order of priority: 1. data.tagname 2. data.category 3. "TagN" If tar file contains both tags with data.tagname or data.category, and tags without it, tags without a name will be named incrementally without counting tags with a name. --- CHANGELOG.md | 6 ++++++ app/server/packages/TarPackage.js | 5 +++-- docs/watcher.md | 3 ++- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 352617b5..138c7fe7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +# 11.1.0 / YYYY-MM-DD + +## NEW FEATURES + +- Add support for "category" property of tag indexes in tar archives. Actually the property data.tagname was used as the tag name with a fallback to "Tag N". An intermediate fallback has been added with the property "category" as the first fallback if data.tagname is not set. + # 11.0.3 / 2020-11-30 ## BUG FIXES diff --git a/app/server/packages/TarPackage.js b/app/server/packages/TarPackage.js index 89d6973f..d853959d 100644 --- a/app/server/packages/TarPackage.js +++ b/app/server/packages/TarPackage.js @@ -558,6 +558,7 @@ TarPackage.prototype.saveTimecodes = function() { // Format points of interest function(pointsOfInterest, spriteReferences, callback) { + var countTagsWithoutName = 0; var tags = []; var timecodes = []; @@ -602,8 +603,8 @@ TarPackage.prototype.saveTimecodes = function() { case 'tag': tags.push({ value: pointOfInterest.timecode, - name: pointOfInterest.data && pointOfInterest.data.tagname ? - pointOfInterest.data.tagname : 'Tag' + (tags.length + 1) + name: (pointOfInterest.data && (pointOfInterest.data.tagname || pointOfInterest.data.category)) || + 'Tag' + (++countTagsWithoutName) }); break; default: diff --git a/docs/watcher.md b/docs/watcher.md index 787733da..43a40e9a 100644 --- a/docs/watcher.md +++ b/docs/watcher.md @@ -57,7 +57,8 @@ It can contain some optional properties: "timecode": 9500, // timecode in ms "type": "tag", // timecode type (must be "image" or "tag") "data": { // Optional - related information for tag timecode - "tagname": "Very important moment" // tagname to display, if not defined, will be replaced by 'Tag N' where N is the number of the tag + "category": "Tag category", // Optional - The name of the category the tag belongs to used as a fallback when no tag name is specified + "tagname": "Very important moment" // Optional - Tag name, if not defined the category will be used as the tag name and if neither category nor tag name are defined it will be replaced by 'TagN' where N is an incremental number } }, ...