From 8581af29d2baae17108d6ef5305eebd6f3bbedbc Mon Sep 17 00:00:00 2001 From: Bill Ferguson Date: Wed, 13 Nov 2024 19:05:16 -0500 Subject: [PATCH 1/6] lib/dtutils - added a gen_uuid() function to generate a UUID string for use as a unique identifier. --- lib/dtutils.lua | 37 ++++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/lib/dtutils.lua b/lib/dtutils.lua index c8331cb..6721eac 100644 --- a/lib/dtutils.lua +++ b/lib/dtutils.lua @@ -374,7 +374,7 @@ dtutils.libdoc.functions["deprecated"] = { du.deprecated(script_name, removal_string) script_name - name of the script being deprecated - removal_strubg - a string explaining when the script will be removed]], + removal_string - a string explaining when the script will be removed]], Description = [[deprecated prints an error message saying the script is deprecated and when it will be removed]], Return_Value = [[]], Limitations = [[]], @@ -391,5 +391,40 @@ function dtutils.deprecated(script_name, removal_string) dt.print_error("WARNING: " .. script_name .. " is deprecated and will be removed in " .. removal_string) end +dtutils.libdoc.functions["gen_uuid"] = { + Name = [[gen_uuid]], + Synopsis = [[generate a UUID string]], + Usage = [[local du = require "lib/dtutils" + + uuid = du.gen_uuid(case) + case - "upper" or "lower" to specify the case of the UUID string]], + Description = [[gen_uuid prints an error message saying the script is gen_uuid and when it will be removed]], + Return_Value = [[uuid - string - a hexidecimal string representing the UUID in the requested case]], + Limitations = [[]], + Example = [[]], + See_Also = [[]], + Reference = [[https://gist.github.com/jrus/3197011]], + License = [[]], + Copyright = [[]], +} + +function dtutils.gen_uuid(case) + local template = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx' + + -- seed with os.time in seconds and add an extra degree of random for multiple calls in the same second + math.randomseed(os.time(), math.random(0, 65536)) + + local uuid = string.gsub(template, '[xy]', function (c) + local v = (c == 'x') and math.random(0, 0xf) or math.random(8, 0xb) + return string.format('%x', v) + end + ) + + if case and case == "upper" then + uuid = string.upper(uuid) + end + + return uuid +end return dtutils From 96b7ba24bc8c84c6ac4cda3da9b14182418148db Mon Sep 17 00:00:00 2001 From: Bill Ferguson Date: Wed, 13 Nov 2024 23:09:14 -0500 Subject: [PATCH 2/6] official/apply_camera_style - make the translatable strings contrib/hif_group_leader translation safe contrib/jpg_group_leader --- contrib/hif_group_leader.lua | 4 ++-- contrib/jpg_group_leader.lua | 4 ++-- official/apply_camera_style.lua | 6 ++---- 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/contrib/hif_group_leader.lua b/contrib/hif_group_leader.lua index f39d3ff..412eea0 100644 --- a/contrib/hif_group_leader.lua +++ b/contrib/hif_group_leader.lua @@ -186,7 +186,7 @@ dt.register_event(MODULE .. "_collect", "shortcut", local images = dt.collection make_existing_hif_group_leader(images) end, - string.format(_("make hif group leader for %s", _("collection"))) + _("make hif group leader for collection") ) dt.register_event(MODULE .. "_select", "shortcut", @@ -194,7 +194,7 @@ dt.register_event(MODULE .. "_select", "shortcut", local images = dt.gui.selection() make_existing_hif_group_leader(images) end, - string.format(_("make hif group leader for %s", _("selection"))) + _("make hif group leader for selection") ) return script_data \ No newline at end of file diff --git a/contrib/jpg_group_leader.lua b/contrib/jpg_group_leader.lua index 8391a67..733071e 100644 --- a/contrib/jpg_group_leader.lua +++ b/contrib/jpg_group_leader.lua @@ -186,7 +186,7 @@ dt.register_event(MODULE .. "_collect", "shortcut", local images = dt.collection make_existing_jpg_group_leader(images) end, - string.format(_("make jpg group leader for %s", _("collection"))) + _("make jpg group leader for collection") ) dt.register_event(MODULE .. "_select", "shortcut", @@ -194,7 +194,7 @@ dt.register_event(MODULE .. "_select", "shortcut", local images = dt.gui.selection() make_existing_jpg_group_leader(images) end, - string.format(_("make jpg group leader for %s", _("selection"))) + _("make jpg group leader for selection") ) return script_data \ No newline at end of file diff --git a/official/apply_camera_style.lua b/official/apply_camera_style.lua index 8c8aeae..c75974b 100644 --- a/official/apply_camera_style.lua +++ b/official/apply_camera_style.lua @@ -463,18 +463,16 @@ script_data.destroy = destroy -- E V E N T S -- - - - - - - - - - - - - - - - - - - - - - - - -local shortcut_string = _("apply darktable camera styles to %s") - dt.register_event(MODULE, "shortcut", function(event, shortcut) apply_camera_style(true) - end, string.format(shortcut_string, _("collection")) + end, _("apply darktable camera styles to collection") ) dt.register_event(MODULE, "shortcut", function(event, shortcut) apply_camera_style(false) - end, string.format(shortcut_string, _("selection")) + end, _("apply darktable camera styles to selection") ) dt.register_event(MODULE, "post-import-image", From 7e3c6471ff0ed65a3b2a8d516eda0879747d1325 Mon Sep 17 00:00:00 2001 From: Bill Ferguson Date: Sun, 1 Dec 2024 12:27:16 -0500 Subject: [PATCH 3/6] official/apply_camera_sytle - ensure style is only applied to raw images. Fixed comment. --- official/apply_camera_style.lua | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/official/apply_camera_style.lua b/official/apply_camera_style.lua index c75974b..aac49d1 100644 --- a/official/apply_camera_style.lua +++ b/official/apply_camera_style.lua @@ -64,7 +64,7 @@ local CS = dt.configuration.running_os == "windows" and "&" or ";" -- A P I C H E C K -- - - - - - - - - - - - - - - - - - - - - - - - -du.check_min_api_version("9.4.0", MODULE) -- styles use filmic V7 which appeared in darktable 4.4 +du.check_min_api_version("9.4.0", MODULE) -- camera styles added to darktable 5.0 -- - - - - - - - - - - - - - - - - - - - - - - - - - @@ -477,7 +477,9 @@ dt.register_event(MODULE, "shortcut", dt.register_event(MODULE, "post-import-image", function(event, image) - table.insert(acs.imported_images, image) + if image.is_raw then + table.insert(acs.imported_images, image) + end end ) From e4e194b0ec250991348d472f7531e724cb429250 Mon Sep 17 00:00:00 2001 From: Krzysztof Kotowicz Date: Mon, 2 Dec 2024 09:01:48 +0100 Subject: [PATCH 4/6] Fixed $(FILE.NAME) variable substitution According to comments and https://docs.darktable.org/usermanual/4.6/en/special-topics/variables/ it should be a basename. --- lib/dtutils/string.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/dtutils/string.lua b/lib/dtutils/string.lua index c8a1ce9..a710201 100644 --- a/lib/dtutils/string.lua +++ b/lib/dtutils/string.lua @@ -748,7 +748,7 @@ function dtutils_string.build_substitute_list(image, sequence, variable_string, local replacements = {image.film.path, -- ROLL.NAME image.path, -- FILE.FOLDER - image.filename, -- FILE.NAME + dtutils_string.get_basename(image.filename),-- FILE.NAME dtutils_string.get_filetype(image.filename),-- FILE.EXTENSION image.id, -- ID image.duplicate_index, -- VERSION From 3fa913d68ad75ea3ce49d706c670a0bd557a4872 Mon Sep 17 00:00:00 2001 From: Krzysztof Kotowicz Date: Mon, 2 Dec 2024 09:56:45 +0100 Subject: [PATCH 5/6] Fixed $ROLL.NAME substitution Accd to https://github.com/darktable-org/darktable/blob/57d3ad4bd30372b1f7ae7368f6887d3292269b2a/src/common/variables.c#L660 it should be a basename of the file path. --- lib/dtutils/string.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/dtutils/string.lua b/lib/dtutils/string.lua index a710201..2be4ef6 100644 --- a/lib/dtutils/string.lua +++ b/lib/dtutils/string.lua @@ -746,7 +746,7 @@ function dtutils_string.build_substitute_list(image, sequence, variable_string, local version_multi = #image:get_group_members() > 1 and image.version or "" - local replacements = {image.film.path, -- ROLL.NAME + local replacements = {dtutils_string.get_basename(image.film.path),-- ROLL.NAME image.path, -- FILE.FOLDER dtutils_string.get_basename(image.filename),-- FILE.NAME dtutils_string.get_filetype(image.filename),-- FILE.EXTENSION From da275c2a662466ded7170c3aa6c4fb98bcc81673 Mon Sep 17 00:00:00 2001 From: Krzysztof Kotowicz Date: Mon, 2 Dec 2024 10:11:23 +0100 Subject: [PATCH 6/6] Fixed $(VERSION.IF_MULTI) Variable substitution actually errored out when duplicates were present. --- lib/dtutils/string.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/dtutils/string.lua b/lib/dtutils/string.lua index 2be4ef6..7648f6f 100644 --- a/lib/dtutils/string.lua +++ b/lib/dtutils/string.lua @@ -744,7 +744,7 @@ function dtutils_string.build_substitute_list(image, sequence, variable_string, string.match(image.exif_datetime_taken, "(%d+):(%d+):(%d+) (%d+):(%d+):(%d+)$") end - local version_multi = #image:get_group_members() > 1 and image.version or "" + local version_multi = #image:get_group_members() > 1 and image.duplicate_index or "" local replacements = {dtutils_string.get_basename(image.film.path),-- ROLL.NAME image.path, -- FILE.FOLDER