Beispiel #1
0
    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))
Beispiel #2
0
    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))
Beispiel #3
0
 def render(self, date, date2=None):
     return smartertimesince(date, date2)
Beispiel #4
0
 def render(self, date, date2=None):
     return smartertimesince(date, date2)