diff options
| author | Robin Krahl <me@robin-krahl.de> | 2015-06-27 21:28:27 +0200 | 
|---|---|---|
| committer | Robin Krahl <me@robin-krahl.de> | 2015-06-27 21:28:27 +0200 | 
| commit | ffc819355032db2547e9b03d07a1b800885d60b4 (patch) | |
| tree | c40a9fcc2763c2176508b78283bec1fdd4d9759c | |
| parent | d513bc565782965d66c6307bfefe21dc3fd36c1a (diff) | |
| download | LrMediaWiki-ffc819355032db2547e9b03d07a1b800885d60b4.tar.gz LrMediaWiki-ffc819355032db2547e9b03d07a1b800885d60b4.tar.bz2 | |
Add configuration for snapshot creation.
The creation of snapshots after the export now depends on a new setting.
The snapshots now are created after the successful export instead of before any
export.
 - move the preferences handling to MediaWikiUtils
 - add the ‘Snapshot creation’ setting to MediaWikiPluginInfoProvider and
   MediaWikiUtils
 - move the snapshot creation in
   MediaWikiExportServiceProvider.processRenderedPhotos after the successful
   upload
 - check the ‘Snapshot creation’ setting before creating the snapshot in
   MediaWikiExportServiceProvider.processRenderedPhotos
 - update the internationalization
| -rwxr-xr-x | mediawiki.lrdevplugin/MediaWikiExportServiceProvider.lua | 20 | ||||
| -rw-r--r-- | mediawiki.lrdevplugin/MediaWikiPluginInfoProvider.lua | 22 | ||||
| -rw-r--r-- | mediawiki.lrdevplugin/MediaWikiUtils.lua | 15 | ||||
| -rwxr-xr-x | mediawiki.lrdevplugin/TranslatedStrings_de.txt | 1 | 
4 files changed, 45 insertions, 13 deletions
| diff --git a/mediawiki.lrdevplugin/MediaWikiExportServiceProvider.lua b/mediawiki.lrdevplugin/MediaWikiExportServiceProvider.lua index accbf88..f2ddfc3 100755 --- a/mediawiki.lrdevplugin/MediaWikiExportServiceProvider.lua +++ b/mediawiki.lrdevplugin/MediaWikiExportServiceProvider.lua @@ -67,15 +67,6 @@ MediaWikiExportServiceProvider.processRenderedPhotos = function(functionContext,  			local photo = rendition.photo
  			local catalog = photo.catalog
 -			-- create new snapshot
 -			local currentTimeStamp = LrDate.currentTime()
 -			local currentDate = LrDate.formatShortDate(currentTimeStamp)
 -			local currentTime = LrDate.formatShortTime(currentTimeStamp)
 -			local snapshotTitle = LOC('$$$/LrMediaWiki/Export/Snapshot=MediaWiki export, ^1 ^2, ^3', currentDate, currentTime, exportSettings.api_path)
 -			catalog:withWriteAccessDo('CreateDevelopSnapshot', function(context)
 -				photo:createDevelopSnapshot(snapshotTitle, true)
 -			end)
 -
  			-- do upload to MediaWiki
  			local descriptionEn = photo:getPropertyForPlugin(Info.LrToolkitIdentifier, 'description_en')
  			local descriptionDe = photo:getPropertyForPlugin(Info.LrToolkitIdentifier, 'description_de')
 @@ -120,6 +111,17 @@ MediaWikiExportServiceProvider.processRenderedPhotos = function(functionContext,  			local message = MediaWikiInterface.uploadFile(pathOrMessage, fileDescription, hasDescription)
  			if message then
  				rendition:uploadFailed(message)
 +			else
 +				-- create new snapshot if the upload was successful
 +				if MediaWikiUtils.getCreateSnapshots() then
 +					local currentTimeStamp = LrDate.currentTime()
 +					local currentDate = LrDate.formatShortDate(currentTimeStamp)
 +					local currentTime = LrDate.formatShortTime(currentTimeStamp)
 +					local snapshotTitle = LOC('$$$/LrMediaWiki/Export/Snapshot=MediaWiki export, ^1 ^2, ^3', currentDate, currentTime, exportSettings.api_path)
 +					catalog:withWriteAccessDo('CreateDevelopSnapshot', function(context)
 +						photo:createDevelopSnapshot(snapshotTitle, true)
 +					end)
 +				end
  			end
  			LrFileUtils.delete(pathOrMessage)
  		else
 diff --git a/mediawiki.lrdevplugin/MediaWikiPluginInfoProvider.lua b/mediawiki.lrdevplugin/MediaWikiPluginInfoProvider.lua index 7bd76ab..d2ee2c6 100644 --- a/mediawiki.lrdevplugin/MediaWikiPluginInfoProvider.lua +++ b/mediawiki.lrdevplugin/MediaWikiPluginInfoProvider.lua @@ -18,17 +18,17 @@ 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
 +  propertyTable.logging = MediaWikiUtils.getLogging()
 +  propertyTable.create_snapshots = MediaWikiUtils.getCreateSnapshots()
  end
  MediaWikiPluginInfoProvider.endDialog = function(propertyTable)
 -  prefs.logging = propertyTable.logging
 -  MediaWikiUtils.setLogging(prefs.logging)
 +  MediaWikiUtils.setLogging(propertyTable.logging)
 +  MediaWikiUtils.setCreateSnapshots(propertyTable.create_snapshots)
  end
  MediaWikiPluginInfoProvider.sectionsForBottomOfDialog = function(viewFactory, propertyTable)
 @@ -52,6 +52,20 @@ MediaWikiPluginInfoProvider.sectionsForBottomOfDialog = function(viewFactory, pr  					},
  					viewFactory:checkbox {
 +						value = bind 'create_snapshots',
 +            title = LOC '$$$/LrMediaWiki/Section/Config/Snapshots=Create snapshots on export',
 +					},
 +				},
 +
 +				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',
  					},
 diff --git a/mediawiki.lrdevplugin/MediaWikiUtils.lua b/mediawiki.lrdevplugin/MediaWikiUtils.lua index 6727e3b..abde828 100644 --- a/mediawiki.lrdevplugin/MediaWikiUtils.lua +++ b/mediawiki.lrdevplugin/MediaWikiUtils.lua @@ -42,7 +42,22 @@ MediaWikiUtils.getVersionString = function()      return str
  end
 +-- configuration
 +
 +MediaWikiUtils.getCreateSnapshots = function()
 +	return prefs.create_snapshot or false
 +end
 +
 +MediaWikiUtils.setCreateSnapshots = function(create_snapshot)
 +	prefs.create_snapshot = create_snapshot
 +end
 +
 +MediaWikiUtils.getLogging = function()
 +	return prefs.logging or false
 +end
 +
  MediaWikiUtils.setLogging = function(logging)
 +	prefs.logging = logging
  	if logging then
  		myLogger:enable('logfile')
  	else
 diff --git a/mediawiki.lrdevplugin/TranslatedStrings_de.txt b/mediawiki.lrdevplugin/TranslatedStrings_de.txt index 36566cc..eee73b8 100755 --- a/mediawiki.lrdevplugin/TranslatedStrings_de.txt +++ b/mediawiki.lrdevplugin/TranslatedStrings_de.txt @@ -37,6 +37,7 @@  "$$$/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/Snapshots=Beim Export einen Schnappschuss anlegen"
  "$$$/LrMediaWiki/Section/Config/Title=Einstellungen"
  "$$$/LrMediaWiki/Section/Licensing/Author=Urheber"
  "$$$/LrMediaWiki/Section/Licensing/Categories/Details=mit ; trennen"
 | 
