aboutsummaryrefslogtreecommitdiff
path: root/mediawiki.lrdevplugin
diff options
context:
space:
mode:
Diffstat (limited to 'mediawiki.lrdevplugin')
-rwxr-xr-xmediawiki.lrdevplugin/MediaWikiApi.lua12
-rwxr-xr-xmediawiki.lrdevplugin/MediaWikiExportServiceProvider.lua3
-rw-r--r--mediawiki.lrdevplugin/MediaWikiUtils.lua13
3 files changed, 25 insertions, 3 deletions
diff --git a/mediawiki.lrdevplugin/MediaWikiApi.lua b/mediawiki.lrdevplugin/MediaWikiApi.lua
index ea9c396..de432a7 100755
--- a/mediawiki.lrdevplugin/MediaWikiApi.lua
+++ b/mediawiki.lrdevplugin/MediaWikiApi.lua
@@ -19,6 +19,7 @@ local LrPathUtils = import 'LrPathUtils'
local LrXml = import 'LrXml'
local Info = require 'Info'
+local MediaWikiUtils = require 'MediaWikiUtils'
local MediaWikiApi = {
userAgent = string.format('LrMediaWiki %d.%d', Info.VERSION.major, Info.VERSION.minor),
@@ -64,7 +65,7 @@ function MediaWikiApi.parseXmlDom(xmlDomInstance)
end
for i = 1, xmlDomInstance:childCount() do
local child = xmlDomInstance:childAtIndex(i)
- local childName = child:name()[0]
+ local childName = child:name()
if childName then
value[childName] = MediaWikiApi.parseXmlDom(child)
end
@@ -88,15 +89,24 @@ function MediaWikiApi.performRequest(arguments)
value = 'application/x-www-form-urlencoded',
},
}
+ MediaWikiUtils.trace('Performing API request');
+ MediaWikiUtils.trace('Request body:');
+ MediaWikiUtils.trace(requestBody);
local resultBody, resultHeaders = LrHttp.post(MediaWikiApi.apiPath, requestBody, requestHeaders)
+ MediaWikiUtils.trace('Result status:');
+ MediaWikiUtils.trace(resultHeaders.status);
+
if not resultHeaders.status then
LrErrors.throwUserError(LOC('$$$/LrMediaWiki/Api/NoConnection=Cannot connect to the MediaWiki API.'))
elseif resultHeaders.status ~= 200 then
LrErrors.throwUserError(LOC('$$$/LrMediaWiki/Api/HttpError=Received HTTP status ^1.', resultHeaders.status))
end
+ MediaWikiUtils.trace('Result body:');
+ MediaWikiUtils.trace(resultBody);
+
local resultXml = MediaWikiApi.parseXmlDom(LrXml.parseXml(resultBody))
if resultXml.error then
LrErrors.throwUserError(LOC('$$$/LrMediaWiki/Api/MediaWikiError=The MediaWiki error ^1 occured: ^2', resultXml.error.code, resultXml.error.info))
diff --git a/mediawiki.lrdevplugin/MediaWikiExportServiceProvider.lua b/mediawiki.lrdevplugin/MediaWikiExportServiceProvider.lua
index 8405cea..accbf88 100755
--- a/mediawiki.lrdevplugin/MediaWikiExportServiceProvider.lua
+++ b/mediawiki.lrdevplugin/MediaWikiExportServiceProvider.lua
@@ -60,8 +60,7 @@ MediaWikiExportServiceProvider.processRenderedPhotos = function(functionContext,
MediaWikiInterface.prepareUpload(exportSettings.username, exportSettings.password, exportSettings.api_path)
-- iterate over photos
- for item in exportContext:renditions() do
- local rendition = item[1]
+ for i, rendition in exportContext:renditions() do
-- render photo
local success, pathOrMessage = rendition:waitForRender()
if success then
diff --git a/mediawiki.lrdevplugin/MediaWikiUtils.lua b/mediawiki.lrdevplugin/MediaWikiUtils.lua
index 0eeb7a9..7d1dd8d 100644
--- a/mediawiki.lrdevplugin/MediaWikiUtils.lua
+++ b/mediawiki.lrdevplugin/MediaWikiUtils.lua
@@ -13,7 +13,16 @@
-- doc: missing
-- i18n: complete
+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 = {}
@@ -36,4 +45,8 @@ MediaWikiUtils.getVersionString = function()
return str
end
+MediaWikiUtils.trace = function(message)
+ myLogger:trace(message)
+end
+
return MediaWikiUtils