From 9333c4d5cc0c810c3d15ae5494c4f46b4f083cf3 Mon Sep 17 00:00:00 2001 From: Robin Krahl Date: Sun, 28 Jun 2015 01:16:56 +0200 Subject: Add custom keyword when exporting. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit After a successful export, a configurable keyword is added to the picture. - add ‘export keyword’ setting to MediaWikiUtils and MediaWikiPluginInfoProvider - write keyword in MediaWikiExportServiceProvider.processRenderedPhotos Fix #34. --- .../MediaWikiExportServiceProvider.lua | 8 +++++ .../MediaWikiPluginInfoProvider.lua | 34 +++++++++------------- mediawiki.lrdevplugin/MediaWikiUtils.lua | 8 +++++ mediawiki.lrdevplugin/TranslatedStrings_de.txt | 1 + 4 files changed, 31 insertions(+), 20 deletions(-) diff --git a/mediawiki.lrdevplugin/MediaWikiExportServiceProvider.lua b/mediawiki.lrdevplugin/MediaWikiExportServiceProvider.lua index b88e1b0..b940cc8 100755 --- a/mediawiki.lrdevplugin/MediaWikiExportServiceProvider.lua +++ b/mediawiki.lrdevplugin/MediaWikiExportServiceProvider.lua @@ -131,6 +131,14 @@ MediaWikiExportServiceProvider.processRenderedPhotos = function(functionContext, end) end + -- add configured export keyword + local keyword = MediaWikiUtils.getExportKeyword() + if not MediaWikiUtils.isStringEmpty(keyword) then + catalog:withWriteAccessDo('AddExportKeyword', function(context) + photo:addKeyword(catalog:createKeyword(keyword, {}, false, nil, true)) + end) + end + -- file name for gallery creation fileNames[#fileNames + 1] = fileName end diff --git a/mediawiki.lrdevplugin/MediaWikiPluginInfoProvider.lua b/mediawiki.lrdevplugin/MediaWikiPluginInfoProvider.lua index 1f2f66a..b9e2201 100644 --- a/mediawiki.lrdevplugin/MediaWikiPluginInfoProvider.lua +++ b/mediawiki.lrdevplugin/MediaWikiPluginInfoProvider.lua @@ -25,16 +25,19 @@ MediaWikiPluginInfoProvider.startDialog = function(propertyTable) propertyTable.logging = MediaWikiUtils.getLogging() propertyTable.create_snapshots = MediaWikiUtils.getCreateSnapshots() propertyTable.check_version = MediaWikiUtils.getCheckVersion() + propertyTable.export_keyword = MediaWikiUtils.getExportKeyword() end MediaWikiPluginInfoProvider.endDialog = function(propertyTable) MediaWikiUtils.setLogging(propertyTable.logging) MediaWikiUtils.setCreateSnapshots(propertyTable.create_snapshots) MediaWikiUtils.setCheckVersion(propertyTable.check_version) + MediaWikiUtils.setExportKeyword(propertyTable.export_keyword) end MediaWikiPluginInfoProvider.sectionsForBottomOfDialog = function(viewFactory, propertyTable) local labelAlignment = 'right'; + local widthLong = 50; return { { @@ -47,11 +50,6 @@ MediaWikiPluginInfoProvider.sectionsForBottomOfDialog = function(viewFactory, pr viewFactory:row { spacing = viewFactory:label_spacing(), - viewFactory:static_text { - alignment = labelAlignment, - width = LrView.share "label_width", - }, - viewFactory:checkbox { value = bind 'create_snapshots', title = LOC '$$$/LrMediaWiki/Section/Config/Snapshots=Create snapshots on export', @@ -64,8 +62,19 @@ MediaWikiPluginInfoProvider.sectionsForBottomOfDialog = function(viewFactory, pr viewFactory:static_text { alignment = labelAlignment, width = LrView.share "label_width", + title = LOC '$$$/LrMediaWiki/Section/Config/ExportKeyword=Export keyword', }, + viewFactory:edit_field { + value = bind 'export_keyword', + immediate = true, + width_in_chars = widthLong, + }, + }, + + viewFactory:row { + spacing = viewFactory:label_spacing(), + viewFactory:checkbox { value = bind 'check_version', title = LOC '$$$/LrMediaWiki/Section/Config/Version=Check for new plugin versions after Lightroom starts', @@ -75,11 +84,6 @@ MediaWikiPluginInfoProvider.sectionsForBottomOfDialog = function(viewFactory, pr viewFactory:row { spacing = viewFactory:label_spacing(), - viewFactory:static_text { - alignment = labelAlignment, - width = LrView.share "label_width", - }, - viewFactory:checkbox { value = bind 'logging', title = LOC '$$$/LrMediaWiki/Section/Config/Logging=Enable logging', @@ -89,11 +93,6 @@ MediaWikiPluginInfoProvider.sectionsForBottomOfDialog = function(viewFactory, pr viewFactory:row { spacing = viewFactory:label_spacing(), - viewFactory:static_text { - alignment = labelAlignment, - width = LrView.share "label_width", - }, - viewFactory:static_text { title = LOC '$$$/LrMediaWiki/Section/Config/Logging/Description=If you enable logging, all API requests are logged. The log file is located in your "My Documents" directory.', wrap = true, @@ -103,11 +102,6 @@ MediaWikiPluginInfoProvider.sectionsForBottomOfDialog = function(viewFactory, pr viewFactory:row { spacing = viewFactory:label_spacing(), - viewFactory:static_text { - alignment = labelAlignment, - width = LrView.share "label_width", - }, - viewFactory:static_text { title = LOC '$$$/LrMediaWiki/Section/Config/Logging/Warning=Warning:', font = '', diff --git a/mediawiki.lrdevplugin/MediaWikiUtils.lua b/mediawiki.lrdevplugin/MediaWikiUtils.lua index 588121d..92539d6 100644 --- a/mediawiki.lrdevplugin/MediaWikiUtils.lua +++ b/mediawiki.lrdevplugin/MediaWikiUtils.lua @@ -80,6 +80,14 @@ MediaWikiUtils.setLogging = function(logging) end end +MediaWikiUtils.getExportKeyword = function() + return prefs.export_keyword or nil +end + +MediaWikiUtils.setExportKeyword = function(tag) + prefs.export_keyword = tag +end + MediaWikiUtils.trace = function(message) myLogger:trace(message) end diff --git a/mediawiki.lrdevplugin/TranslatedStrings_de.txt b/mediawiki.lrdevplugin/TranslatedStrings_de.txt index 61d2c8b..3df8302 100755 --- a/mediawiki.lrdevplugin/TranslatedStrings_de.txt +++ b/mediawiki.lrdevplugin/TranslatedStrings_de.txt @@ -35,6 +35,7 @@ "$$$/LrMediaWiki/Metadata/DescriptionEn=Beschreibung (en)" "$$$/LrMediaWiki/Metadata/Templates=Vorlagen" "$$$/LrMediaWiki/PluginName=MediaWiki für Lightroom" +"$$$/LrMediaWiki/Section/Config/ExportKeyword=Export-Schlüsselwort" "$$$/LrMediaWiki/Section/Config/Logging=Logging aktivieren" "$$$/LrMediaWiki/Section/Config/Logging/Description=Wenn du das Logging aktivierst, werden die API-Abfragen geloggt. Die Logdatei wird in deinem Eigene-Dokumente-Ordner abgelegt." "$$$/LrMediaWiki/Section/Config/Logging/Password=Die Logdatei enthält auch dein Passwort im Klartext!" -- cgit v1.2.3