diff --git a/src/octoprint/plugins/announcements/__init__.py b/src/octoprint/plugins/announcements/__init__.py index 4590a4fd..33cf6ae1 100644 --- a/src/octoprint/plugins/announcements/__init__.py +++ b/src/octoprint/plugins/announcements/__init__.py @@ -50,6 +50,16 @@ class AnnouncementPlugin(octoprint.plugin.AssetPlugin, type="rss", url="http://octoprint.org/feeds/releases.xml", read_until=1458117576), + _spotlight=dict(name="OctoPrint Community Spotlights", + priority=2, + type="rss", + url="http://octoprint.org/feeds/spotlight.xml", + read_until=1447950371), + _octopi=dict(name="OctoPi Announcements", + priority=2, + type="rss", + url="http://octoprint.org/feeds/octopi.xml", + read_until=1462197000), _plugins=dict(name="New Plugins in the Repository", priority=2, type="rss", diff --git a/src/octoprint/plugins/announcements/static/js/announcements.js b/src/octoprint/plugins/announcements/static/js/announcements.js index 361bc9e5..55e941b3 100644 --- a/src/octoprint/plugins/announcements/static/js/announcements.js +++ b/src/octoprint/plugins/announcements/static/js/announcements.js @@ -116,11 +116,14 @@ $(function() { }; self.fromResponse = function(data) { + var currentTab = $("li.active a", self.announcementDialogTabs).attr("href"); + var unread = 0; var channels = []; _.each(data, function(value, key) { value.key = key; value.last = value.data.length ? value.data[0].published : undefined; + value.count = value.data.length; unread += value.unread; channels.push(value); }); @@ -128,22 +131,40 @@ $(function() { self.unread(unread); self.displayAnnouncements(channels); + + self.selectTab(currentTab); }; - self.showAnnouncementDialog = function() { - //self.aboutContent.scrollTop(0); - self.announcementDialog.modal({ - minHeight: function() { return Math.max($.fn.modal.defaults.maxHeight() - 80, 250); } - }).css({ - width: 'auto', - 'margin-left': function() { return -($(this).width() /2); } - }); + self.showAnnouncementDialog = function(channel) { + self.announcementDialogContent.scrollTop(0); + + if (!self.announcementDialog.hasClass("in")) { + self.announcementDialog.modal({ + minHeight: function() { return Math.max($.fn.modal.defaults.maxHeight() - 80, 250); } + }).css({ + width: 'auto', + 'margin-left': function() { return -($(this).width() /2); } + }); + } + + var tab = undefined; + if (channel) { + tab = "#plugin_announcements_dialog_channel_" + channel; + } + self.selectTab(tab); + return false; }; - self.showChannel = function(channel) { - self.showAnnouncementDialog(); - $("a[href=#plugin_announcements_dialog_channel_" + channel + "]", self.announcementDialogTabs).tab("show"); + self.selectTab = function(tab) { + if (tab != undefined) { + if (!_.startsWith(tab, "#")) { + tab = "#" + tab; + } + $('a[href="' + tab + '"]', self.announcementDialogTabs).tab("show"); + } else { + $('a:first', self.announcementDialogTabs).tab("show"); + } }; self.displayAnnouncements = function(channels) { @@ -225,7 +246,7 @@ $(function() { text: gettext("Read..."), addClass: "btn-primary", click: function(notice) { - self.showChannel(key); + self.showAnnouncementDialog(key); self.markRead(key, value.last); notice.remove(); } diff --git a/src/octoprint/plugins/announcements/static/less/announcements.less b/src/octoprint/plugins/announcements/static/less/announcements.less index 067a969a..35f0f667 100644 --- a/src/octoprint/plugins/announcements/static/less/announcements.less +++ b/src/octoprint/plugins/announcements/static/less/announcements.less @@ -27,11 +27,28 @@ table { font-weight: bold; } - .actions { - text-align: right; + article { + &.read { + opacity: 0.5; + } - a { - color: black; + &.read:hover { + opacity: 1; + } + + .actions { + background-color: #f5f5f5; + border-radius: 2px; + padding: 2px 5px; + margin-top: 5px; + + .markread { + float: right; + } + + a { + color: black; + } } } } diff --git a/src/octoprint/plugins/announcements/templates/announcements.jinja2 b/src/octoprint/plugins/announcements/templates/announcements.jinja2 index 5cb2653b..cbea05ff 100644 --- a/src/octoprint/plugins/announcements/templates/announcements.jinja2 +++ b/src/octoprint/plugins/announcements/templates/announcements.jinja2 @@ -10,8 +10,8 @@