Exemplo n.º 1
0
    def get(self, name=None):
        if not name:
            tags = Tag.find()
            self.render("tag.html", tags=tags)
        else:
            tag = Tag.find_one({'name': name})
            shares = []
            share_ids = tag.share_ids.split(' ')
            share_ids = list(set(share_ids))
            cond = {}
            cond['_id'] = 0
            cond['id'] = 1
            cond['user_id'] = 1
            cond['published'] = 1
            cond['sharetype'] = 1
            cond['title'] = 1
            cond['commentnum'] = 1

            for share_id in share_ids:
                # share = Share.by_sid(share_id)
                share = Share.find_one({'id': int(share_id)}, cond)
                print(share)
                # <!-- <p class="info">{{ escape(share.markdown) }} ...</p> -->
                user = User.by_sid(share.user_id)
                share.user_name = user.user_name
                share.user_domain = user.user_domain
                share.published = time.strftime(
                    '%Y-%m-%d %H:%M:%S', time.localtime(share.published))
                # share.markdown = filter_tags(
                #     markdown2.markdown(share.markdown))[:100]
                shares.append(share)
            self.render("tage.html", tag=tag, name=name, shares=shares)
Exemplo n.º 2
0
Arquivo: index.py Projeto: anwen/anwen
 def get(self, name=None):
     if not name:
         tags = Tag.find()
         self.render("tag.html", tags=tags)
     else:
         tag = Tag.find_one({'name': name})
         shares = []
         for i in tag.share_ids.split(' '):
             share = Share.by_sid(i)
             user = User.by_sid(share.user_id)
             share.name = user.user_name
             share.published = time.strftime(
                 '%Y-%m-%d %H:%M:%S', time.localtime(share.published))
             share.domain = user.user_domain
             share.markdown = filter_tags(
                 markdown2.markdown(share.markdown))[:100]
             shares.append(share)
         self.render("tage.html", name=name, shares=shares)
Exemplo n.º 3
0
 def get(self, name=None):
     if not name:
         tags = Tag.find()
         self.render("tag.html", tags=tags)
     else:
         tag = Tag.find_one({'name': name})
         shares = []
         for i in tag.share_ids.split(' '):
             share = Share.by_sid(i)
             user = User.by_sid(share.user_id)
             share.name = user.user_name
             share.published = time.strftime(
                 '%Y-%m-%d %H:%M:%S', time.localtime(share.published))
             share.domain = user.user_domain
             share.markdown = filter_tags(markdown2.markdown(
                 share.markdown))[:100]
             shares.append(share)
         self.render("tage.html", name=name, shares=shares)