aboutsummaryrefslogtreecommitdiff
path: root/mediawiki.lrdevplugin/MediaWikiInterface.lua
diff options
context:
space:
mode:
authorRobin Krahl <me@robin-krahl.de>2015-06-28 00:36:09 +0200
committerRobin Krahl <me@robin-krahl.de>2015-06-28 00:36:09 +0200
commit93c667f039ffc19ed47e3eb381a3771e96c24711 (patch)
tree98cf6b4a5f879db7046db69ed27fd46c7a1c022d /mediawiki.lrdevplugin/MediaWikiInterface.lua
parenta673ab08731494f4541f2c9a70ccd3695b747624 (diff)
downloadLrMediaWiki-93c667f039ffc19ed47e3eb381a3771e96c24711.tar.gz
LrMediaWiki-93c667f039ffc19ed47e3eb381a3771e96c24711.tar.bz2
Add option to populate a gallery.
If set, a new section of the given page is created with a gallery of the uploaded files. - add MediaWikiApi.appendToPage and MediaWikiInterface.addToGallery - require target file name to be set when calling MediaWikiInterface.uploadFile - calculate file name in MediaWikiExportServiceProvider.processRenderedPhotos insted of in ..., store it and pass it to MediaWikiInterface.addToGallery - add the gallery option to the export dialog in MediaWikiExportServiceProvider - update messages Fix #24.
Diffstat (limited to 'mediawiki.lrdevplugin/MediaWikiInterface.lua')
-rwxr-xr-xmediawiki.lrdevplugin/MediaWikiInterface.lua24
1 files changed, 16 insertions, 8 deletions
diff --git a/mediawiki.lrdevplugin/MediaWikiInterface.lua b/mediawiki.lrdevplugin/MediaWikiInterface.lua
index dbae6ed..34fc249 100755
--- a/mediawiki.lrdevplugin/MediaWikiInterface.lua
+++ b/mediawiki.lrdevplugin/MediaWikiInterface.lua
@@ -14,10 +14,10 @@
-- i18n: complete
local LrBinding = import 'LrBinding'
+local LrDate = import 'LrDate'
local LrDialogs = import 'LrDialogs'
local LrErrors = import 'LrErrors'
local LrFunctionContext = import 'LrFunctionContext'
-local LrPathUtils = import 'LrPathUtils'
local LrView = import 'LrView'
local MediaWikiApi = require 'MediaWikiApi'
@@ -101,17 +101,25 @@ MediaWikiInterface._prompt = function(functionContext, title, label, default)
return result
end
-MediaWikiInterface.uploadFile = function(filePath, description, hasDescription, fileName)
+MediaWikiInterface.addToGallery = function(fileNames, galleryName)
+ local currentTimeStamp = LrDate.currentTime()
+ local currentDate = LrDate.formatShortDate(currentTimeStamp)
+ local currentTime = LrDate.formatShortTime(currentTimeStamp)
+ local section = '== ' .. currentDate .. ' ' .. currentTime .. ' ==';
+ local text = '<gallery>\n';
+ for i, fileName in pairs(fileNames) do
+ text = text .. fileName .. '\n'
+ end
+ text = text .. '</gallery>'
+ local comment = 'Uploaded with LrMediaWiki ' .. MediaWikiUtils.getVersionString()
+ MediaWikiApi.appendToPage(galleryName, section, text, comment)
+end
+
+MediaWikiInterface.uploadFile = function(filePath, description, hasDescription, targetFileName)
if not MediaWikiInterface.loggedIn then
LrErrors.throwUserError(LOC '$$$/LrMediaWiki/Interface/Internal/NotLoggedIn=Internal error: not logged in before upload.')
end
local comment = 'Uploaded with LrMediaWiki ' .. MediaWikiUtils.getVersionString()
- local targetFileName = fileName or LrPathUtils.leafName(filePath)
-
- -- ensure that the target file name does not contain a series of spaces or
- -- underscores (as this would cause the upload to fail without a proper
- -- error message)
- targetFileName = string.gsub(targetFileName, '[ _]+', '_')
local ignorewarnings = false
if MediaWikiApi.existsFile(targetFileName) then