From 24875af9d53e3f1a90fa5e6bd4aaef36bb0c3591 Mon Sep 17 00:00:00 2001 From: Robin Krahl Date: Sat, 27 Jun 2015 23:05:52 +0200 Subject: Check for new versions after start. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit After LrMediaWiki is loaded, GitHub is checked for new versions if the user enabled that setting. To parse the response of the GitHub API, a third-party library is used for JSON parsing (JSON.lua). As the GitHub API query for the latest release only returns non-pre-release versions, all releases are queried and the first one is considered the latest. - create MediaWikiInit that queries the new version and shows a message (if necessary) - add MediaWikiInit to Info so that it is run after LrMediaWiki is loaded - add ‘Check version’ setting to the configuration - refactor MediaWikiApi and create performHttpRequest as a generic HTTP request method - add MediaWikiApi.getCurrentPluginVersion to query the GitHub API Fix #44. --- mediawiki.lrdevplugin/MediaWikiInit.lua | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 mediawiki.lrdevplugin/MediaWikiInit.lua (limited to 'mediawiki.lrdevplugin/MediaWikiInit.lua') diff --git a/mediawiki.lrdevplugin/MediaWikiInit.lua b/mediawiki.lrdevplugin/MediaWikiInit.lua new file mode 100644 index 0000000..d775930 --- /dev/null +++ b/mediawiki.lrdevplugin/MediaWikiInit.lua @@ -0,0 +1,33 @@ +-- 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) 2015 by the LrMediaWiki team (see CREDITS.txt file in the +-- project root directory or [2]) +-- +-- [0] +-- [1] +-- [2] + +-- Code status: +-- doc: missing +-- i18n: complete + +local LrDialogs = import 'LrDialogs' +local LrTasks = import 'LrTasks' + +local MediaWikiApi = require 'MediaWikiApi' +local MediaWikiUtils = require 'MediaWikiUtils' + +if MediaWikiUtils.getCheckVersion() then + LrTasks.startAsyncTask(function() + local currentVersion = MediaWikiApi.getCurrentPluginVersion() + if currentVersion ~= nil then + MediaWikiUtils.trace('Current version of LrMediaWiki is: ' .. currentVersion) + if currentVersion ~= 'v' .. MediaWikiUtils.getVersionString() then + -- new version available! + LrDialogs.message(LOC '$$$/LrMediaWiki/Init/Version/Message=New version available', LOC('$$$/LrMediaWiki/Init/Version/Info=Please update to LrMediaWiki ^1.', currentVersion), 'info') + end + end + end) +end -- cgit v1.2.1