|
|
@@ -14,11 +14,11 @@ script_data.metadata = {
|
|
|
name = "lightgallery_export_module",
|
|
|
purpose = _("Export selected files into a directory and call a python script to create a lightGallery"),
|
|
|
author = "Markus Spring",
|
|
|
- help = "https://example.com/help"
|
|
|
+ help = "https://gogs.hermes.markus-spring.info/springm/darktable_to_lightgallery"
|
|
|
}
|
|
|
|
|
|
-- local variables
|
|
|
-local help_url = "https://example.com/help"
|
|
|
+local help_url = "https://gogs.hermes.markus-spring.info/springm/darktable_to_lightgallery"
|
|
|
local du = require "lib/dtutils"
|
|
|
local df = require "lib/dtutils.file"
|
|
|
local dtsys = require "lib/dtutils.system"
|
|
|
@@ -33,10 +33,15 @@ script_data.destroy_method = nil -- set to hide for libs since we can't destroy
|
|
|
script_data.restart = nil -- how to restart the (lib) script after it's been hidden - i.e. make it visible again
|
|
|
|
|
|
-- Register preferences
|
|
|
-dt.preferences.register("lightgallery_export", "export_path", "string", "LightGallery Export Path", "Path to export lightGallery", "")
|
|
|
-dt.preferences.register("lightgallery_export", "gallery_title", "string", "LightGallery Title", "Title for the lightGallery", "--..--")
|
|
|
-dt.preferences.register("lightgallery_export", "gallery_uplink", "string", "LightGallery Uplink", "Uplink for lightGallery index.html", "..")
|
|
|
-dt.preferences.register("lightgallery_export", "gallery_family_tags", "bool", "LightGallery attach published..family tag", "attach published..family tag", false)
|
|
|
+dt.preferences.register("lightgallery_export", "export_path", "string",
|
|
|
+ "LightGallery Export Path", "Path to export lightGallery", "")
|
|
|
+dt.preferences.register("lightgallery_export", "gallery_title", "string",
|
|
|
+ "LightGallery Title", "Title for the lightGallery", "--..--")
|
|
|
+dt.preferences.register("lightgallery_export", "gallery_uplink", "string",
|
|
|
+ "LightGallery Uplink", "Uplink for lightGallery index.html", "..")
|
|
|
+-- dt.preferences.register("lightgallery_export", "gallery_family_tags", "bool", "LightGallery attach published..family tag", "attach published..family tag", false)
|
|
|
+dt.preferences.register("lightgallery_export", "gallery_tag", "string",
|
|
|
+ "LightGallery attach published|gallery|<name> tag", "attach published|gallery|<name> tag", "family")
|
|
|
dt.preferences.register("lightgallery_export", "exiftoolbinary", "file",
|
|
|
_("lightGallery: executable for exiftool"),
|
|
|
_("select executable for exiftool command line version") , "")
|
|
|
@@ -69,48 +74,56 @@ function isDir(name)
|
|
|
return (exists(name) and not isFile(name))
|
|
|
end
|
|
|
|
|
|
-local export_path_widget = dt.new_widget("box") {
|
|
|
+local export_path_widget = dt.new_widget("file_chooser_button") {
|
|
|
+ title = "Select export path",
|
|
|
+ is_directory = true,
|
|
|
+ tooltip = "Choose the directory where to export the images for the lightGallery",
|
|
|
+ value = dt.preferences.read("lightgallery_export", "export_path", "string")
|
|
|
+}
|
|
|
+local export_path_widget_box = dt.new_widget("box") {
|
|
|
orientation = "horizontal",
|
|
|
dt.new_widget("label") {
|
|
|
label = "Verzeichnis: "
|
|
|
},
|
|
|
- dt.new_widget("file_chooser_button") {
|
|
|
- title = "Select export path",
|
|
|
- is_directory = true,
|
|
|
- tooltip = "Choose the directory where to export the images for the lightGallery",
|
|
|
- value = dt.preferences.read("lightgallery_export", "export_path", "string")
|
|
|
- }
|
|
|
+ export_path_widget
|
|
|
+}
|
|
|
+
|
|
|
+local gallery_title_widget = dt.new_widget("entry") {
|
|
|
+ text = dt.preferences.read("lightgallery_export", "gallery_title", "string"),
|
|
|
+ tooltip = "Enter the title for the lightGallery"
|
|
|
}
|
|
|
|
|
|
-local gallery_title_widget = dt.new_widget("box") {
|
|
|
+local gallery_title_widget_box = dt.new_widget("box") {
|
|
|
orientation = "horizontal",
|
|
|
dt.new_widget("label") {
|
|
|
label = "Titel: "
|
|
|
},
|
|
|
- dt.new_widget("entry") {
|
|
|
- text = dt.preferences.read("lightgallery_export", "gallery_title", "string"),
|
|
|
- tooltip = "Enter the title for the lightGallery"
|
|
|
- }
|
|
|
+ gallery_title_widget
|
|
|
+}
|
|
|
+
|
|
|
+local gallery_uplink_widget = dt.new_widget("entry") {
|
|
|
+ text = dt.preferences.read("lightgallery_uplink", "gallery_uplink", "string"),
|
|
|
+ tooltip = "Uplink for the lightGallery index.html"
|
|
|
}
|
|
|
|
|
|
-local gallery_uplink_widget = dt.new_widget("box") {
|
|
|
+local gallery_uplink_widget_box = dt.new_widget("box") {
|
|
|
orientation = "horizontal",
|
|
|
dt.new_widget("label") {
|
|
|
label = "Uplink: "
|
|
|
},
|
|
|
- dt.new_widget("entry") {
|
|
|
- text = dt.preferences.read("lightgallery_uplink", "gallery_uplink", "string"),
|
|
|
- tooltip = "Uplink for the lightGallery index.html"
|
|
|
- }
|
|
|
+ gallery_uplink_widget
|
|
|
}
|
|
|
|
|
|
-local gallery_family_tags_widget = dt.new_widget("check_button"){
|
|
|
- label = "Attach photography|...|family Tag",
|
|
|
- value = dt.preferences.read("lightgallery_export", "gallery_family_tags", "bool"),
|
|
|
- tooltip = "Click to toggle the checkbox",
|
|
|
- clicked_callback = function(self)
|
|
|
- dt.preferences.write("lightgallery_export", "gallery_family_tags", "bool", self.value)
|
|
|
- end
|
|
|
+local gallery_tag_widget = dt.new_widget("entry") {
|
|
|
+ text = dt.preferences.read("lightgallery_export", "gallery_tag", "string")
|
|
|
+}
|
|
|
+
|
|
|
+local gallery_tag_widget_box = dt.new_widget("box") {
|
|
|
+ orientation = "horizontal",
|
|
|
+ dt.new_widget("label") {
|
|
|
+ label = "photography|published|gallery Tag: "
|
|
|
+ },
|
|
|
+ gallery_tag_widget
|
|
|
}
|
|
|
|
|
|
-- Function to save preferences
|
|
|
@@ -118,6 +131,21 @@ local function save_preferences()
|
|
|
dt.preferences.write("lightgallery_export", "export_path", "string", export_path_widget.value)
|
|
|
dt.preferences.write("lightgallery_export", "gallery_title", "string", gallery_title_widget.text)
|
|
|
dt.preferences.write("lightgallery_export", "lightgallery_uplink", "string", gallery_uplink_widget.text)
|
|
|
+ dt.preferences.write("lightgallery_export", "gallery_tag", "string", gallery_tag_widget.text)
|
|
|
+end
|
|
|
+
|
|
|
+local function run_post_export_script(exp_path)
|
|
|
+ title = dt.preferences.read("lightgallery_export", "gallery_title", "string")
|
|
|
+ if title == "" then
|
|
|
+ title = "n.n"
|
|
|
+ end
|
|
|
+ uplink = dt.preferences.read("lightgallery_export", "lightgallery_uplink", "string")
|
|
|
+ if uplink == "" then
|
|
|
+ uplink = ".."
|
|
|
+ end
|
|
|
+ local post_export_script = dt.preferences.read("lightgallery_export", "post_export_script", "file")
|
|
|
+ dt.print_log( "post_export_script: ".. post_export_script.." -t '"..title.."' -u '"..uplink.."' "..exp_path )
|
|
|
+ os.execute( post_export_script.." -t '"..title.."' -u '"..uplink.."' "..exp_path )
|
|
|
end
|
|
|
|
|
|
-- Function to export images to Light Gallery
|
|
|
@@ -156,16 +184,18 @@ local function export_to_lightgallery()
|
|
|
targetfile = df.sanitize_filename(string.gsub(exp_path, "'", "")..PS..mws_basename(i.filename)..'.jpg')
|
|
|
dt.print('mv ' .. tmp_exported .. ' ' .. targetfile)
|
|
|
os.execute('mv ' .. tmp_exported .. ' ' .. targetfile)
|
|
|
- if dt.preferences.read("lightgallery_export", "gallery_family_tags", "bool") then
|
|
|
- local tagnr = dt.tags.find('photography|published|gallery|family') --- tag must exist!
|
|
|
- dt.tags.attach(tagnr,i)
|
|
|
+ tag = dt.preferences.read("lightgallery_export", "gallery_tags", "string")
|
|
|
+ if not tag == "" then
|
|
|
+ tag = 'photography|published|gallery|'..tag
|
|
|
+ tnr = dt.tags.find(tag)
|
|
|
+ if not tnr then
|
|
|
+ tnr = dt.create(tag)
|
|
|
+ end
|
|
|
+ dt.tags.attach(tnr,i)
|
|
|
end
|
|
|
os.execute( "rm -f " .. tmpname )
|
|
|
end
|
|
|
- local post_export_script = dt.preferences.read("lightgallery_export", "post_export_script", "file")
|
|
|
- dt.print("post_export_script: ".. post_export_script.." "..exp_path)
|
|
|
- os.execute( post_export_script.." "..exp_path )
|
|
|
- -- tell the user that everything worked
|
|
|
+ run_post_export_script(exp_path)
|
|
|
dt.print("Exported " .. #images .. " images to lightGallery")
|
|
|
end
|
|
|
|
|
|
@@ -177,7 +207,7 @@ local gallery_export_button = dt.new_widget("button"){
|
|
|
|
|
|
-- Create a button widget with a help link
|
|
|
local help_button = dt.new_widget("button"){
|
|
|
- label = "Help: "..help_url,
|
|
|
+ label = "Help/Documentation",
|
|
|
clicked_callback = function()
|
|
|
-- Open the help URL in the default web browser
|
|
|
dt.control.execute("xdg-open "..help_url)
|
|
|
@@ -187,10 +217,10 @@ local help_button = dt.new_widget("button"){
|
|
|
-- Create the module widget
|
|
|
local module_widget = dt.new_widget("box"){
|
|
|
orientation = "vertical",
|
|
|
- gallery_title_widget,
|
|
|
- export_path_widget,
|
|
|
- gallery_uplink_widget,
|
|
|
- gallery_family_tags_widget,
|
|
|
+ gallery_title_widget_box,
|
|
|
+ export_path_widget_box,
|
|
|
+ gallery_uplink_widget_box,
|
|
|
+ gallery_tag_widget_box,
|
|
|
gallery_export_button,
|
|
|
help_button
|
|
|
}
|