Added OctoPi + Spotlight feeds, article link, better reader design
This commit is contained in:
parent
58fc67bd99
commit
3a570f8ab0
4 changed files with 72 additions and 23 deletions
|
|
@ -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",
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,8 +10,8 @@
|
|||
<ul class="nav nav-list" id="plugin_announcements_dialog_tabs">
|
||||
<!-- ko foreach: {data: channels.items, afterAdd: setupTabLink} -->
|
||||
<!-- ko if: $data.enabled || $data.forced -->
|
||||
<li data-bind="css: {active: $index() == 0}">
|
||||
<a data-toggle="tab" target="_blank" data-bind="text: $data.channel + ' (' + $data.unread + ')', attr: {href: '#plugin_announcements_dialog_channel_' + $data.key}, css: {unread: $data.unread}"></a>
|
||||
<li>
|
||||
<a data-toggle="tab" target="_blank" data-bind="text: $data.channel + ' (' + $data.unread + '/' + $data.count + ')', attr: {href: '#plugin_announcements_dialog_channel_' + $data.key}, css: {unread: $data.unread}"></a>
|
||||
</li>
|
||||
<!-- /ko -->
|
||||
<!-- /ko -->
|
||||
|
|
@ -20,14 +20,15 @@
|
|||
<div class="tab-content span9 scrollable" id="plugin_announcements_dialog_content">
|
||||
<!-- ko foreach: channels.items -->
|
||||
<!-- ko if: $data.enabled || $data.forced -->
|
||||
<div class="tab-pane" data-bind="css: {active: $index() == 0}, attr: {id: 'plugin_announcements_dialog_channel_' + $data.key}">
|
||||
<div class="tab-pane" data-bind="attr: {id: 'plugin_announcements_dialog_channel_' + $data.key}">
|
||||
<!-- ko foreach: $data.data -->
|
||||
<hr data-bind="visible: $index() > 0">
|
||||
<article data-bind="css: {muted: $data.read}">
|
||||
<h3><a data-bind="text: $data.title, attr: {href: $data.link}" target="_blank" rel="noreferrer noopener"></a> <small data-bind="text: formatTimeAgo($data.published)"></small></h3>
|
||||
<article data-bind="css: {read: $data.read}">
|
||||
<h3><a data-bind="text: $data.title, attr: {href: $data.link}" target="_blank" rel="noreferrer noopener"></a> <small data-bind="text: formatTimeAgo($data.published), attr: {title: formatDate($data.published)}"></small></h3>
|
||||
<div data-bind="html: $data.summary"></div>
|
||||
<div class="actions">
|
||||
<small><a data-bind="click: function() { $root.markRead($parent.key, $data.published) }"><i class="icon-eye-open"></i> {{ _('Last read') }}</a></small>
|
||||
<span class="articlelink"><small><a data-bind="text: $data.link, attr: {href: $data.link}" target="_blank" rel="noreferrer noopener"></a></small></span>
|
||||
<span class="markread"><small><a href="javascript:void(0)" data-bind="click: function() { $root.markRead($parent.key, $data.published) }"><i class="icon-eye-open"></i> {{ _('Mark as last read') }}</a></small></span>
|
||||
</div>
|
||||
</article>
|
||||
<!-- /ko -->
|
||||
|
|
@ -40,5 +41,5 @@
|
|||
</div>
|
||||
<div class="modal-footer">
|
||||
<button class="btn btn-block" data-dismiss="modal" aria-hidden="true">{{ _('Close') }}</button>
|
||||
</div>
|
||||
</div>k
|
||||
</div>
|
||||
|
|
|
|||
Loading…
Reference in a new issue