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/MediaWikiUtils.lua | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'mediawiki.lrdevplugin/MediaWikiUtils.lua') diff --git a/mediawiki.lrdevplugin/MediaWikiUtils.lua b/mediawiki.lrdevplugin/MediaWikiUtils.lua index abde828..588121d 100644 --- a/mediawiki.lrdevplugin/MediaWikiUtils.lua +++ b/mediawiki.lrdevplugin/MediaWikiUtils.lua @@ -34,6 +34,13 @@ MediaWikiUtils.isStringEmpty = function(str) return str == nil or string.match(str, '^%s*$') ~= nil end +MediaWikiUtils.getFirstKey = function(table) + for key, value in pairs(table) do + return key + end + return nil +end + MediaWikiUtils.getVersionString = function() local str = Info.VERSION.major .. '.' .. Info.VERSION.minor if Info.VERSION.revision > 0 then @@ -52,6 +59,14 @@ MediaWikiUtils.setCreateSnapshots = function(create_snapshot) prefs.create_snapshot = create_snapshot end +MediaWikiUtils.getCheckVersion = function() + return prefs.check_version or false +end + +MediaWikiUtils.setCheckVersion = function(check_version) + prefs.check_version = check_version +end + MediaWikiUtils.getLogging = function() return prefs.logging or false end -- cgit v1.2.1