diff --git a/airtime_mvc/application/configs/constants.php b/airtime_mvc/application/configs/constants.php index e321f5a9c..e9b278230 100644 --- a/airtime_mvc/application/configs/constants.php +++ b/airtime_mvc/application/configs/constants.php @@ -25,6 +25,7 @@ define('AIRTIME_TRANSIFEX_URL' , 'http://libretime.org/translating/'); define('SUPPORT_TICKET_URL' , 'https://github.com/LibreTime/libretime/issues'); define('UI_REVAMP_EMBED_URL' , 'https://www.youtube.com/embed/nqpNnCKGluY'); define('LIBRETIME_WHATS_NEW_URL' , 'https://github.com/LibreTime/libretime/releases'); +define('LIBRETIME_UPDATE_FEED' , 'https://github.com/LibreTime/libretime/releases.atom'); define('LIBRETIME_EMAIL_FROM' , 'noreply@libretime.org'); define('LICENSE_VERSION' , 'GNU AGPL v.3'); diff --git a/airtime_mvc/application/controllers/LocaleController.php b/airtime_mvc/application/controllers/LocaleController.php index 99ac81f9b..482e3ec35 100644 --- a/airtime_mvc/application/controllers/LocaleController.php +++ b/airtime_mvc/application/controllers/LocaleController.php @@ -39,9 +39,11 @@ class LocaleController extends Zend_Controller_Action //dashboard/versiontooltip.js "You are running the latest version" => _("You are running the latest version"), "New version available: " => _("New version available: "), - "This version will soon be obsolete." => _("This version will soon be obsolete."), - "This version is no longer supported." => _("This version is no longer supported."), - "Please upgrade to " => _("Please upgrade to "), + "You have a pre-release version of LibreTime intalled." => _("You have a pre-release version of LibreTime intalled."), + "A patch update for your LibreTime installation is available." => _("A patch update for your LibreTime installation is available."), + "A feature update for your LibreTime installation is available." => _("A feature update for your LibreTime installation is available."), + "A major update for your LibreTime installation is available." => _("A major update for your LibreTime installation is available."), + "Multiple major updates for LibreTime installation are available. Please upgrade as soon as possible." => _("Multiple major updates for LibreTime installation are available. Please upgrade as soon as possible."), //library/events/library_playlistbuilder.js "Add to current playlist" => _("Add to current playlist"), "Add to current smart block" => _("Add to current smart block"), diff --git a/airtime_mvc/application/models/Preference.php b/airtime_mvc/application/models/Preference.php index 00b78ddcd..296915956 100644 --- a/airtime_mvc/application/models/Preference.php +++ b/airtime_mvc/application/models/Preference.php @@ -879,8 +879,27 @@ class Application_Model_Preference public static function GetLatestVersion() { $config = Config::getConfig(); - $latest = self::getValue("latest_version"); - if ($latest == null || strlen($latest) == 0) { + + $latest = json_decode(self::getValue('latest_version')); + $nextCheck = self::getValue('latest_version_nextcheck'); + if ($latest && $nextCheck > time()) { + return $latest; + } + + $rss = new SimplePie(); + $rss->set_feed_url(array(LIBRETIME_UPDATE_FEED)); + $rss->enable_cache(false); + $rss->init(); + $rss->handle_content_type(); + // get all available versions ut to default github api limit + $versions = array(); + foreach ($rss->get_items() as $item) { + $versions[] = $item->get_title(); + } + $latest = $versions; + self::setValue('latest_version', json_encode($latest)); + self::setValue('latest_version_nextcheck', strtotime('+1 week')); + if (empty($latest)) { return $config['airtime_version']; } else { return $latest; @@ -899,7 +918,7 @@ class Application_Model_Preference { $link = self::getValue("latest_link"); if ($link == null || strlen($link) == 0) { - return 'http://airtime.sourcefabric.org'; + return LIBRETIME_WHATS_NEW_URL; } else { return $link; } diff --git a/airtime_mvc/application/views/helpers/VersionNotify.php b/airtime_mvc/application/views/helpers/VersionNotify.php index bc940b31a..7e6c873c2 100644 --- a/airtime_mvc/application/views/helpers/VersionNotify.php +++ b/airtime_mvc/application/views/helpers/VersionNotify.php @@ -1,5 +1,8 @@ =%1$s', $currentParts[0] + 1)); + $minorCandidates = SemVer::satisfiedBy($latest, sprintf('~%1$s.%2$s', $currentParts[0], $currentParts[1] + 1)); + $patchCandidates = SemVer::satisfiedBy($latest, sprintf('>=%1$s.%2$s.%3$s <%1$s.%3$s', $currentParts[0], $currentParts[1], $currentParts[2] + 1, $currentParts[1] + 1)); + $hasMajor = !empty($majorCandidates); + $hasMinor = !empty($minorCandidates); + $hasPatch = !empty($patchCandidates); + $isPreRelease = $isGitRelease || array_key_exists(4, $currentParts); + $hasMultiMajor = count($majorCandidates) > 1; + + if ($isPreRelease) { + // orange "warning" if you are on unreleased code + $class = 'update2'; + } else if ($hasPatch || $hasMultiMajor) { + // current patch or more than 1 major behind + $class = 'outdated'; + } else if ($hasMinor) { + // green warning for feature update + $class = 'update'; + } else if ($hasMajor) { + // orange warning for 1 major beind + $class = 'update2'; + } else { + $class = 'uptodate'; + } + $latest = SemVer::rsort($latest); + $highestVersion = $latest[0]; + + $data = (object) array( + 'link' => $link, + 'latest' => $highestVersion, + 'current' => $current, + 'hasPatch' => $hasPatch, + 'hasMinor' => $hasMinor, + 'hasMajor' => $hasMajor, + 'isPreRelease' => $isPreRelease, + 'hasMultiMajor' => $hasMultiMajor, + ); + + $result = sprintf('', json_encode($data)) + . "
"; + return $result; } } diff --git a/airtime_mvc/public/css/styles.css b/airtime_mvc/public/css/styles.css index 6a587a2d9..ead2b90cf 100644 --- a/airtime_mvc/public/css/styles.css +++ b/airtime_mvc/public/css/styles.css @@ -101,8 +101,8 @@ select { /* Version Notification Starts*/ #version-icon { position:absolute; - right:96px; - top:104px; + top:68px; + right: 196px; height:35px; width:35px; z-index:1000; diff --git a/airtime_mvc/public/js/airtime/dashboard/versiontooltip.js b/airtime_mvc/public/js/airtime/dashboard/versiontooltip.js index 4b6675591..a5e75a37c 100644 --- a/airtime_mvc/public/js/airtime/dashboard/versiontooltip.js +++ b/airtime_mvc/public/js/airtime/dashboard/versiontooltip.js @@ -2,43 +2,91 @@ * Get the tooltip message to be displayed */ function getContent() { - var diff = getVersionDiff(); var link = getLatestLink(); - + var hasPatch = getHasPatch(); + var hasMinor = getHasMinor(); + var hasMajor = getHasMajor(); + var hasMultiMajor = getHasMultiMajor(); + var isPreRelease = getIsPreRelease(); + var msg = ""; // See file airtime_mvc/application/views/helpers/VersionNotify.php for more info if(isUpToDate()) { msg = $.i18n._("You are running the latest version"); - } else if (diff < 20) { - msg = $.i18n._("New version available: ") + link; - } else if (diff < 30) { - msg = $.i18n._("This version will soon be obsolete.")+"