Add feed reading functionality
font-size: 14pt;
}
+.feed-button.new {
+ background-color: #E4C010;
+}
+
.spew-button {
color: #333;
background-color: #0D0;
});
enyo.setCookie('username', '', {"Max-Age": 0});
},
- requestFeedStatus: function() {
- if (!blerg.API.loggedIn)
- throw new Error('Cannot request feed status when not logged in');
- // TODO
- },
loadUserRecords: function(username, from ,to) {
var url;
if (from != undefined && to != undefined) {
}.bind(this));
req.go();
},
+ getFeedInfo: function() {
+ if (!blerg.API.loggedIn)
+ throw new Error('Cannot request feed status when not logged in');
+
+ var req = new enyo.Ajax({
+ url: baseURL + '/feedinfo',
+ method: 'POST'
+ });
+ req.response(function(inSender, inResponse) {
+ this.bubble('onFeedInfo', inResponse);
+ }.bind(this));
+ req.go({
+ username: blerg.API.username
+ });
+ },
+ loadFeed: function() {
+ if (!blerg.API.loggedIn)
+ throw new Error('Cannot request feed status when not logged in');
+
+ var req = new enyo.Ajax({
+ url: baseURL + '/feed',
+ method: 'POST'
+ });
+ req.response(function(inSender, inResponse) {
+ this.bubble('onItemsLoaded', {
+ type: "feed",
+ entries: inResponse
+ });
+ }.bind(this));
+ req.go({
+ username: blerg.API.username
+ });
+ },
getSubscriptionStatus: function(username) {
var req = new enyo.Ajax({
url: baseURL + '/feedinfo/' + username,
['hash', /^#\/feed(?:\/p(\d+))?$/, "blerg.Feed"],
['hash', /^#([A-Za-z0-9_-]+)(?:\/(p)?(\d+))?$/, "blerg.User"]
],
- pathHandlers: [ blerg.User, blerg.Tag, blerg.Welcome ],
+ pathHandlers: [ blerg.User, blerg.Tag, blerg.Feed, blerg.Welcome ],
rendered: function() {
this.inherited(arguments);
this.$.api.logout();
},
loginSuccessful: function(inSender, inEvent) {
- this.$.api.requestFeedStatus();
- this.feedStatusUpdateInterval = setInterval(function() {
- this.$.api.requestFeedStatus();
- }.bind(this), 900000);
this.waterfall('onLogin', inEvent);
},
loginFailed: function(inSender, inEvent) {
]},
{classes: "blerg-controls-toolbar", components: [
{kind: "onyx.Button", content: "Feed Your Vanity", onclick: "chatterClicked"},
- {kind: "onyx.Button", content: "Stalk Your Victims", onclick: "feedClicked"},
+ {name: "feedButton", kind: "onyx.Button", classes: "feed-button", content: "Stalk Your Victims", onclick: "feedClicked"},
{name: "spewButton", kind: "onyx.Button", classes: "spew-button", content: "Spew It!", onclick: "spewToggle"}
]},
- ]}
+ ]},
+ {name: "api", kind: "blerg.API",
+ onFeedInfo: "gotFeedInfo"}
],
showRSS: function(url) {
this.$.rssButton.show();
this.$.userlink.setAttribute('href', '/#' + inEvent.username);
this.$.userlink.setContent('@' + inEvent.username);
this.username = inEvent.username;
+
+ this.$.api.getFeedInfo();
+ this.feedStatusUpdateInterval = setInterval(function() {
+ this.$.api.getFeedInfo();
+ }.bind(this), 900000);
},
logout: function(inSender, inEvent) {
this.setLoggedIn(false);
+ clearInterval(this.feedStatusUpdateInterval);
},
spewToggle: function(inSender, inEvent) {
this.postShowing = !this.postShowing;
this.postShowing = inEvent.showing;
this.$.spewButton.addRemoveClass('active', inEvent.showing);
},
+ gotFeedInfo: function(inSender, inEvent) {
+ this.$.feedButton.addRemoveClass('new', inEvent.new > 0);
+ if (inEvent.new > 0) {
+ this.$.feedButton.setContent('Stalk Your Victims (' + inEvent.new + ')');
+ } else {
+ this.$.feedButton.setContent('Stalk Your Victims');
+ }
+ },
chatterClicked: function() {
window.location.href = '/#/ref/' + this.username;
this.bubble('onNavigate');
+enyo.kind({
+ name: "blerg.Feed",
+ kind: "blerg.Pager",
+ listKind: "blerg.TagRecord",
+ published: {
+ },
+ components: [
+ {name: "records"},
+ {name: "api", kind: "blerg.API",
+ onItemsLoaded: "itemsLoaded"}
+ ],
+ statics: {
+ locationDetect: function(l) {
+ var m = l.hash.match(/^#\/feed$/);
+ if (m) {
+ return {kind: "blerg.Feed"};
+ }
+ }
+ },
+ create: function() {
+ this.inherited(arguments);
+ this.loadMore();
+ },
+ loadItems: function(from, to) {
+ this.inherited(arguments);
+ this.$.api.loadFeed();
+ },
+ itemsLoaded: function(inSender, inEvent) {
+ this.addItems(inEvent.entries);
+ }
+});
'Pager.js',
'User.js',
'Tag.js',
+ 'Feed.js',
'Blerg.js'
);