From e1257f32eec1503c1230c4f4642bf2e0bafb7aa4 Mon Sep 17 00:00:00 2001 From: Robin Krahl Date: Sat, 1 Nov 2014 16:24:36 +0100 Subject: Add permission field to export dialog Add the permission field to the export dialog and to the file description template. - add permission to the template in `description.txt` - add permission to the UI in `MediaWikiExportServiceProvider` - add permission to the data items in `MediaWikiInterface` Fix https://github.com/ireas/LrMediaWiki/issues/27 --- mediawiki.lrdevplugin/MediaWikiApi.lua | 4 ++-- .../MediaWikiExportServiceProvider.lua | 23 ++++++++++++++++++---- mediawiki.lrdevplugin/MediaWikiInterface.lua | 3 ++- .../MediaWikiMetadataProvider.lua | 4 ++-- mediawiki.lrdevplugin/TranslatedStrings_de.txt | 1 + mediawiki.lrdevplugin/description.txt | 2 +- 6 files changed, 27 insertions(+), 10 deletions(-) diff --git a/mediawiki.lrdevplugin/MediaWikiApi.lua b/mediawiki.lrdevplugin/MediaWikiApi.lua index cde8b48..33ae9a6 100755 --- a/mediawiki.lrdevplugin/MediaWikiApi.lua +++ b/mediawiki.lrdevplugin/MediaWikiApi.lua @@ -5,9 +5,9 @@ -- Copyright (C) 2014 by the LrMediaWiki team (see CREDITS.txt file in the -- project root directory or [2]) -- --- [0] +-- [0] -- [1] --- [2] +-- [2] -- Code status: -- doc: partly diff --git a/mediawiki.lrdevplugin/MediaWikiExportServiceProvider.lua b/mediawiki.lrdevplugin/MediaWikiExportServiceProvider.lua index 079225e..d91c971 100755 --- a/mediawiki.lrdevplugin/MediaWikiExportServiceProvider.lua +++ b/mediawiki.lrdevplugin/MediaWikiExportServiceProvider.lua @@ -5,9 +5,9 @@ -- Copyright (C) 2014 by the LrMediaWiki team (see CREDITS.txt file in the -- project root directory or [2]) -- --- [0] +-- [0] -- [1] --- [2] +-- [2] -- Code status: -- doc: missing @@ -91,6 +91,7 @@ MediaWikiExportServiceProvider.processRenderedPhotos = function(functionContext, end local author = exportSettings.info_author local license = exportSettings.info_license + local permission = exportSettings.info_permission local templates = exportSettings.info_templates local additionalTemplates = photo:getPropertyForPlugin(Info.LrToolkitIdentifier, 'templates') or '' if not MediaWikiUtils.isStringEmpty(additionalTemplates) then @@ -106,7 +107,7 @@ MediaWikiExportServiceProvider.processRenderedPhotos = function(functionContext, templates = location .. templates end - local fileDescription = MediaWikiInterface.buildFileDescription(description, source, timestamp, author, license, templates, other, categories, additionalCategories) + local fileDescription = MediaWikiInterface.buildFileDescription(description, source, timestamp, author, license, templates, other, categories, additionalCategories, permission) MediaWikiInterface.uploadFile(pathOrMessage, fileDescription) LrFileUtils.delete(pathOrMessage) @@ -215,6 +216,19 @@ MediaWikiExportServiceProvider.sectionsForTopOfDialog = function(viewFactory, pr }, }, + viewFactory:row { + spacing = viewFactory:control_spacing(), + + viewFactory:static_text { + title = LOC '$$$/LrMediaWiki/Section/Licensing/Permission=Permission', + }, + + viewFactory:edit_field { + value = bind 'info_permission', + immediate = true, + }, + }, + viewFactory:row { spacing = viewFactory:control_spacing(), @@ -268,7 +282,7 @@ MediaWikiExportServiceProvider.sectionsForTopOfDialog = function(viewFactory, pr action = function(button) result, message = MediaWikiInterface.loadFileDescriptionTemplate() if result then - local wikitext = MediaWikiInterface.buildFileDescription('', propertyTable.info_source, '', propertyTable.info_author, propertyTable.info_license, '\n' .. propertyTable.info_templates, propertyTable.info_other, propertyTable.info_categories, '') + local wikitext = MediaWikiInterface.buildFileDescription('', propertyTable.info_source, '', propertyTable.info_author, propertyTable.info_license, '\n' .. propertyTable.info_templates, propertyTable.info_other, propertyTable.info_categories, '', '') LrDialogs.message(LOC '$$$/LrMediaWiki/Section/Licensing/Preview=Preview generated wikitext', wikitext, 'info') else LrDialogs.message(LOC '$$$/LrMediaWiki/Export/DescriptionError=Error reading the file description', message, 'error') @@ -297,6 +311,7 @@ MediaWikiExportServiceProvider.exportPresetFields = { { key = 'info_source', default = '{{own}}' }, { key = 'info_author', default = '' }, { key = 'info_license', default = '{{Cc-by-sa-4.0}}' }, + { key = 'info_permission', default = '' }, { key = 'info_templates', default = '' }, { key = 'info_other', default = '' }, { key = 'info_categories', default = '' }, diff --git a/mediawiki.lrdevplugin/MediaWikiInterface.lua b/mediawiki.lrdevplugin/MediaWikiInterface.lua index be874f0..2473406 100755 --- a/mediawiki.lrdevplugin/MediaWikiInterface.lua +++ b/mediawiki.lrdevplugin/MediaWikiInterface.lua @@ -132,7 +132,7 @@ MediaWikiInterface.uploadFile = function(filePath, description, fileName) end end -MediaWikiInterface.buildFileDescription = function(description, source, timestamp, author, license, templates, other, categories, additionalCategories) +MediaWikiInterface.buildFileDescription = function(description, source, timestamp, author, license, templates, other, categories, additionalCategories, permission) local categoriesString = '' for category in string.gmatch(categories, '[^;]+') do if category then @@ -153,6 +153,7 @@ MediaWikiInterface.buildFileDescription = function(description, source, timestam templates = templates, license = license, categories = categoriesString, + permission = permission, } return MediaWikiUtils.formatString(MediaWikiInterface.fileDescriptionPattern, arguments) end diff --git a/mediawiki.lrdevplugin/MediaWikiMetadataProvider.lua b/mediawiki.lrdevplugin/MediaWikiMetadataProvider.lua index bab12af..a094652 100644 --- a/mediawiki.lrdevplugin/MediaWikiMetadataProvider.lua +++ b/mediawiki.lrdevplugin/MediaWikiMetadataProvider.lua @@ -5,9 +5,9 @@ -- Copyright (C) 2014 by the LrMediaWiki team (see CREDITS.txt file in the -- project root directory or [2]) -- --- [0] +-- [0] -- [1] --- [2] +-- [2] -- Code status: -- doc: missing diff --git a/mediawiki.lrdevplugin/TranslatedStrings_de.txt b/mediawiki.lrdevplugin/TranslatedStrings_de.txt index 2585861..a662099 100755 --- a/mediawiki.lrdevplugin/TranslatedStrings_de.txt +++ b/mediawiki.lrdevplugin/TranslatedStrings_de.txt @@ -37,6 +37,7 @@ "$$$/LrMediaWiki/Section/Licensing/License=Lizenz" "$$$/LrMediaWiki/Section/Licensing/Other=Andere Felder" "$$$/LrMediaWiki/Section/Licensing/OtherTemplates=Andere Vorlagen" +"$$$/LrMediaWiki/Section/Licensing/Permission=Genehmigung" "$$$/LrMediaWiki/Section/Licensing/Preview=Vorschau des generierten Wikitexts" "$$$/LrMediaWiki/Section/Licensing/Source=Quelle" "$$$/LrMediaWiki/Section/Licensing/Title=Upload-Informationen" diff --git a/mediawiki.lrdevplugin/description.txt b/mediawiki.lrdevplugin/description.txt index 69818f0..47bb91d 100644 --- a/mediawiki.lrdevplugin/description.txt +++ b/mediawiki.lrdevplugin/description.txt @@ -4,7 +4,7 @@ |Source=${source} |Date=${timestamp} |Author=${author} -|Permission= +|Permission=${permission} |other_versions= |other_fields=${other_fields} }} -- cgit v1.2.3