def get(self, gist_id): #sg = ShowGravatar(self) gist = self.find_gist(gist_id) comments = [] now = datetime.datetime.now() for comment in self.db.Comment.find({ 'gist.$id': gist._id }).sort('add_date', 1): #pprint(dict(comment.user)) comment_dict = dict(comment=markdown.markdown(comment.comment, safe_mode='escape'), ago=smartertimesince(comment.add_date, now), file=comment.file, id=str(comment._id), user=dict( name=comment.user.name, login=comment.user.login, )) if comment.user.gravatar_id: comment_dict['user']['gravatar_html'] = \ gravatar_html(self.is_secure(), comment.user.gravatar_id, width_and_height=20) #pprint(comment_dict) comments.append(comment_dict) self.write_json(dict(comments=comments))
def get(self, gist_id): #sg = ShowGravatar(self) gist = self.find_gist(gist_id) comments = [] now = datetime.datetime.now() for comment in self.db.Comment.find({'gist.$id': gist._id}).sort('add_date', 1): #pprint(dict(comment.user)) comment_dict = dict( comment=markdown.markdown(comment.comment, safe_mode='escape'), ago=smartertimesince(comment.add_date, now), file=comment.file, id=str(comment._id), user=dict(name=comment.user.name, login=comment.user.login, ) ) if comment.user.gravatar_id: comment_dict['user']['gravatar_html'] = \ gravatar_html(self.is_secure(), comment.user.gravatar_id, width_and_height=20) #pprint(comment_dict) comments.append(comment_dict) self.write_json(dict(comments=comments))
def render(self, gravatar_id, width_and_height=140): return gravatar_html(self.handler.is_secure(), gravatar_id, width_and_height)