aboutsummaryrefslogtreecommitdiff
path: root/mediawiki.lrdevplugin
diff options
context:
space:
mode:
Diffstat (limited to 'mediawiki.lrdevplugin')
-rwxr-xr-xmediawiki.lrdevplugin/Info.lua2
-rw-r--r--mediawiki.lrdevplugin/MediaWikiPluginInfoProvider.lua96
-rw-r--r--mediawiki.lrdevplugin/MediaWikiUtils.lua21
-rwxr-xr-xmediawiki.lrdevplugin/TranslatedStrings_de.txt5
4 files changed, 116 insertions, 8 deletions
diff --git a/mediawiki.lrdevplugin/Info.lua b/mediawiki.lrdevplugin/Info.lua
index 959923f..cbfa8c6 100755
--- a/mediawiki.lrdevplugin/Info.lua
+++ b/mediawiki.lrdevplugin/Info.lua
@@ -21,6 +21,8 @@ return {
LrMetadataProvider = 'MediaWikiMetadataProvider.lua',
+ LrPluginInfoProvider = 'MediaWikiPluginInfoProvider.lua',
+
VERSION = {
major = 0,
minor = 3,
diff --git a/mediawiki.lrdevplugin/MediaWikiPluginInfoProvider.lua b/mediawiki.lrdevplugin/MediaWikiPluginInfoProvider.lua
new file mode 100644
index 0000000..7bd76ab
--- /dev/null
+++ b/mediawiki.lrdevplugin/MediaWikiPluginInfoProvider.lua
@@ -0,0 +1,96 @@
+-- This file is part of the LrMediaWiki project and distributed under the terms
+-- of the MIT license (see LICENSE.txt file in the project root directory or
+-- [0]). See [1] for more information about LrMediaWiki.
+--
+-- Copyright (C) 2015 by the LrMediaWiki team (see CREDITS.txt file in the
+-- project root directory or [2])
+--
+-- [0] <https://raw.githubusercontent.com/robinkrahl/LrMediaWiki/master/LICENSE.txt>
+-- [1] <https://commons.wikimedia.org/wiki/Commons:LrMediaWiki>
+-- [2] <https://raw.githubusercontent.com/robinkrahl/LrMediaWiki/master/CREDITS.txt>
+
+-- Code status:
+-- doc: missing
+-- i18n: complete
+
+local LrView = import 'LrView'
+
+local MediaWikiUtils = require 'MediaWikiUtils'
+
+local bind = LrView.bind
+local prefs = import 'LrPrefs'.prefsForPlugin()
+
+local MediaWikiPluginInfoProvider = {}
+
+MediaWikiPluginInfoProvider.startDialog = function(propertyTable)
+ propertyTable.logging = prefs.logging or false
+end
+
+MediaWikiPluginInfoProvider.endDialog = function(propertyTable)
+ prefs.logging = propertyTable.logging
+ MediaWikiUtils.setLogging(prefs.logging)
+end
+
+MediaWikiPluginInfoProvider.sectionsForBottomOfDialog = function(viewFactory, propertyTable)
+ local labelAlignment = 'right';
+ local widthLong = 50;
+
+ return {
+ {
+ title = LOC '$$$/LrMediaWiki/Section/Config/Title=Configuration',
+ bind_to_object = propertyTable,
+
+ viewFactory:column {
+ spacing = viewFactory:control_spacing(),
+
+ 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',
+ },
+ },
+
+ 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,
+ },
+ },
+
+ 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 = '<system/bold>',
+ },
+
+ viewFactory:static_text {
+ title = LOC '$$$/LrMediaWiki/Section/Config/Logging/Password=The log file contains your password!:',
+ },
+ },
+ },
+ },
+ }
+end
+
+return MediaWikiPluginInfoProvider
diff --git a/mediawiki.lrdevplugin/MediaWikiUtils.lua b/mediawiki.lrdevplugin/MediaWikiUtils.lua
index 7d1dd8d..6727e3b 100644
--- a/mediawiki.lrdevplugin/MediaWikiUtils.lua
+++ b/mediawiki.lrdevplugin/MediaWikiUtils.lua
@@ -15,16 +15,13 @@
local LrLogger = import 'LrLogger'
local Info = require 'Info'
-local myLogger = LrLogger('LrMediaWikiLogger')
-
--- LOGGING
--- If enabled, the log file will appear in your "My Documents" folder. Warning:
--- LrMediaWiki will log all requests sent to MediaWiki, including your password!
--- If you share a log file, make sure you removed your password.
--- To enable logging, uncomment the following line:
--- myLogger:enable("logfile")
local MediaWikiUtils = {}
+local myLogger = LrLogger('LrMediaWikiLogger')
+local prefs = import 'LrPrefs'.prefsForPlugin()
+if prefs.logging then
+ myLogger:enable('logfile')
+end
-- Allows formatting of strings like "${test} eins zwei drei ${test2}"
-- Based on a solution by http://lua-users.org/wiki/RiciLake shown here:
@@ -45,6 +42,14 @@ MediaWikiUtils.getVersionString = function()
return str
end
+MediaWikiUtils.setLogging = function(logging)
+ if logging then
+ myLogger:enable('logfile')
+ else
+ myLogger:disable()
+ end
+end
+
MediaWikiUtils.trace = function(message)
myLogger:trace(message)
end
diff --git a/mediawiki.lrdevplugin/TranslatedStrings_de.txt b/mediawiki.lrdevplugin/TranslatedStrings_de.txt
index d989940..36566cc 100755
--- a/mediawiki.lrdevplugin/TranslatedStrings_de.txt
+++ b/mediawiki.lrdevplugin/TranslatedStrings_de.txt
@@ -33,6 +33,11 @@
"$$$/LrMediaWiki/Metadata/DescriptionEn=Beschreibung (en)"
"$$$/LrMediaWiki/Metadata/Templates=Vorlagen"
"$$$/LrMediaWiki/PluginName=MediaWiki für Lightroom"
+"$$$/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!"
+"$$$/LrMediaWiki/Section/Config/Logging/Warning=Achtung:"
+"$$$/LrMediaWiki/Section/Config/Title=Einstellungen"
"$$$/LrMediaWiki/Section/Licensing/Author=Urheber"
"$$$/LrMediaWiki/Section/Licensing/Categories/Details=mit ; trennen"
"$$$/LrMediaWiki/Section/Licensing/Categories=Kategorien"