relative time filter, show negative times (future)
This commit is contained in:
parent
a9bb8e4835
commit
ed0a9b8bbc
4 changed files with 9 additions and 36 deletions
|
@ -1,32 +0,0 @@
|
|||
|
||||
var WebSocketServer = require('ws').Server;
|
||||
var Redis = require('redis');
|
||||
|
||||
var port = 8077;
|
||||
|
||||
var wss = new WebSocketServer({port: port});
|
||||
|
||||
wss.on('connection', function(ws) {
|
||||
// console.log("New websockets connection");
|
||||
ws.on('message', function(channel) {
|
||||
var redis = Redis.createClient(6379, 'localhost');
|
||||
redis.subscribe(channel);
|
||||
// console.log('Listening for comments on channel ' + channel);
|
||||
redis.on('message', function (channel, message) {
|
||||
console.log('Sent comment to channel ' + channel);
|
||||
ws.send(message);
|
||||
});
|
||||
ws.on('close', function(){
|
||||
// console.log('Killing listener for channel ' + channel);
|
||||
redis.unsubscribe();
|
||||
redis.end();
|
||||
});
|
||||
ws.on('error', function(){
|
||||
// console.log('Killing listener for channel ' + channel);
|
||||
redis.unsubscribe();
|
||||
redis.end();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
console.log("WebSocket Server Listening on port "+port);
|
|
@ -133,7 +133,7 @@ def check_push_subscription(session, feed, response):
|
|||
'hub.mode': mode,
|
||||
'hub.topic': topic,
|
||||
'hub.callback': build_callback_url(),
|
||||
'hub.verify': 'async', # backcompat with 0.3
|
||||
'hub.verify': 'sync', # backcompat with 0.3
|
||||
# TODO secret should only be used over HTTPS
|
||||
# 'hub.secret': secret,
|
||||
})
|
||||
|
@ -145,6 +145,7 @@ def check_push_subscription(session, feed, response):
|
|||
hub = response.links.get('hub', {}).get('url')
|
||||
topic = response.links.get('self', {}).get('url')
|
||||
|
||||
logger.debug('link headers. links=%s, hub=%s, topic=%s', response.links, hub, topic)
|
||||
if not hub or not topic:
|
||||
# try to find link rel elements
|
||||
if feed.type == 'html':
|
||||
|
|
|
@ -372,13 +372,14 @@ def relative_time(dt):
|
|||
if dt:
|
||||
now = datetime.datetime.utcnow()
|
||||
diff = now - dt
|
||||
zero = datetime.timedelta(0)
|
||||
years = diff.days // 365
|
||||
hours = diff.seconds // 60 // 60
|
||||
minutes = diff.seconds // 60
|
||||
|
||||
if diff == 0:
|
||||
if diff == zero:
|
||||
pretty = 'Right now'
|
||||
if diff > 0:
|
||||
if diff > zero:
|
||||
if years > 1:
|
||||
pretty = str(years) + ' years ago'
|
||||
elif diff.days == 1:
|
||||
|
|
|
@ -31,7 +31,10 @@ class WSHandler(tornado.websocket.WebSocketHandler):
|
|||
return True
|
||||
|
||||
def forward_message(self, message):
|
||||
self.write_message(message)
|
||||
try:
|
||||
self.write_message(message)
|
||||
except tornado.websocket.WebSocketClosedError:
|
||||
self.on_close()
|
||||
|
||||
def on_message(self, topic):
|
||||
self.topic = topic
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue