diff options
author | Robin Krahl <me@robin-krahl.de> | 2014-08-24 03:28:15 +0200 |
---|---|---|
committer | Robin Krahl <me@robin-krahl.de> | 2014-08-24 03:28:15 +0200 |
commit | 53cb610bdcbd32a417a58890061b36b2f2f9ea6a (patch) | |
tree | 0d17d40a11cda22677a5d8c7b8c1833350a83acc /mediawiki.lrdevplugin | |
parent | 8b917ece9ecf993e3ed34e556c48b2c31292159c (diff) | |
download | LrMediaWiki-53cb610bdcbd32a417a58890061b36b2f2f9ea6a.tar.gz LrMediaWiki-53cb610bdcbd32a417a58890061b36b2f2f9ea6a.tar.bz2 |
Add categories field to the file metadata (see #7).
Diffstat (limited to 'mediawiki.lrdevplugin')
-rwxr-xr-x | mediawiki.lrdevplugin/Info.lua | 2 | ||||
-rwxr-xr-x | mediawiki.lrdevplugin/MediaWikiExportServiceProvider.lua | 4 | ||||
-rwxr-xr-x | mediawiki.lrdevplugin/MediaWikiInterface.lua | 11 | ||||
-rw-r--r-- | mediawiki.lrdevplugin/MediaWikiMetadataProvider.lua | 26 | ||||
-rwxr-xr-x | mediawiki.lrdevplugin/TranslatedStrings_de.txt | 3 |
5 files changed, 42 insertions, 4 deletions
diff --git a/mediawiki.lrdevplugin/Info.lua b/mediawiki.lrdevplugin/Info.lua index 5636a42..1559fe7 100755 --- a/mediawiki.lrdevplugin/Info.lua +++ b/mediawiki.lrdevplugin/Info.lua @@ -19,6 +19,8 @@ return { file = 'MediaWikiExportServiceProvider.lua',
},
+ LrMetadataProvider = 'MediaWikiMetadataProvider.lua',
+
VERSION = {
major = 0,
minor = 1,
diff --git a/mediawiki.lrdevplugin/MediaWikiExportServiceProvider.lua b/mediawiki.lrdevplugin/MediaWikiExportServiceProvider.lua index 3a6eedd..9b4fa96 100755 --- a/mediawiki.lrdevplugin/MediaWikiExportServiceProvider.lua +++ b/mediawiki.lrdevplugin/MediaWikiExportServiceProvider.lua @@ -20,6 +20,7 @@ local LrView = import 'LrView' local bind = LrView.bind
+local Info = require 'Info'
local MediaWikiInterface = require 'MediaWikiInterface'
local MediaWikiExportServiceProvider = {}
@@ -87,8 +88,9 @@ MediaWikiExportServiceProvider.processRenderedPhotos = function(functionContext, local license = exportSettings.info_license
local other = exportSettings.info_other
local categories = exportSettings.info_categories
+ local additionalCategories = photo:getPropertyForPlugin(Info.LrToolkitIdentifier, 'categories')
- local fileDescription = MediaWikiInterface.buildFileDescription(description, source, timestamp, author, license, other, categories)
+ local fileDescription = MediaWikiInterface.buildFileDescription(description, source, timestamp, author, license, other, categories, additionalCategories)
MediaWikiInterface.uploadFile(pathOrMessage, fileDescription)
LrFileUtils.delete(pathOrMessage)
diff --git a/mediawiki.lrdevplugin/MediaWikiInterface.lua b/mediawiki.lrdevplugin/MediaWikiInterface.lua index 14ef24e..709129d 100755 --- a/mediawiki.lrdevplugin/MediaWikiInterface.lua +++ b/mediawiki.lrdevplugin/MediaWikiInterface.lua @@ -74,10 +74,17 @@ MediaWikiInterface.uploadFile = function(filePath, description) end
end
-MediaWikiInterface.buildFileDescription = function(description, source, timestamp, author, license, other, categories)
+MediaWikiInterface.buildFileDescription = function(description, source, timestamp, author, license, other, categories, additionalCategories)
local categoriesString = ''
for category in string.gmatch(categories, '[^;]+') do
- categoriesString = categoriesString .. string.format('[[Category:%s]]\n', category)
+ if category then
+ categoriesString = categoriesString .. string.format('[[Category:%s]]\n', category)
+ end
+ end
+ for category in string.gmatch(additionalCategories, '[^;]+') do
+ if category then
+ categoriesString = categoriesString .. string.format('[[Category:%s]]\n', category)
+ end
end
return string.format(MediaWikiInterface.fileDescriptionPattern, description, source, timestamp, author, other, license, categoriesString)
end
diff --git a/mediawiki.lrdevplugin/MediaWikiMetadataProvider.lua b/mediawiki.lrdevplugin/MediaWikiMetadataProvider.lua new file mode 100644 index 0000000..72cdda2 --- /dev/null +++ b/mediawiki.lrdevplugin/MediaWikiMetadataProvider.lua @@ -0,0 +1,26 @@ +-- This file is part of the LrMediaWiki project and distributed under the terms
+-- of the MIT license (see LICENSE.txt file in the project root directory or
+-- [0]). See [1] for more information about LrMediaWiki.
+--
+-- Copyright (C) 2014 by the LrMediaWiki team (see CREDITS.txt file in the
+-- project root directory or [2])
+--
+-- [0] <https://raw.githubusercontent.com/LrMediaWiki/LrMediaWiki/master/LICENSE.txt>
+-- [1] <https://commons.wikimedia.org/wiki/Commons:LrMediaWiki>
+-- [2] <https://raw.githubusercontent.com/LrMediaWiki/LrMediaWiki/master/CREDITS.txt>
+
+-- Code status:
+-- doc: missing
+-- i18n: complete
+
+return {
+ metadataFieldsForPhotos = {
+ {
+ id = 'categories',
+ title = LOC '$$$/LrMediaWiki/Metadata/Categories=Categories',
+ dataType = 'string',
+ },
+ },
+
+ schemaVersion = 1,
+}
\ No newline at end of file diff --git a/mediawiki.lrdevplugin/TranslatedStrings_de.txt b/mediawiki.lrdevplugin/TranslatedStrings_de.txt index e5ffbb8..62661ff 100755 --- a/mediawiki.lrdevplugin/TranslatedStrings_de.txt +++ b/mediawiki.lrdevplugin/TranslatedStrings_de.txt @@ -29,4 +29,5 @@ "$$$/LrMediaWiki/Interface/Internal/NotLoggedIn=Interner Fehler: vor dem Upload nicht angemeldet."
"$$$/LrMediaWiki/Interface/InUse=Dateiname schon verwendet"
"$$$/LrMediaWiki/Interface/InUse/Details=Es gibt bereits eine Datei mit dem Namen ^1. Überschreiben? (Die Dateibeschreibung wird nicht verändert.)"
-"$$$/LrMediaWiki/Interface/UploadFailed=Upload fehlgeschlagen: ^1"
\ No newline at end of file +"$$$/LrMediaWiki/Interface/UploadFailed=Upload fehlgeschlagen: ^1"
+"$$$/LrMediaWiki/Metadata/Categories=Kategorien"
\ No newline at end of file |