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 --- .../MediaWikiExportServiceProvider.lua | 23 ++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) (limited to 'mediawiki.lrdevplugin/MediaWikiExportServiceProvider.lua') 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 = '' }, -- cgit v1.2.1