示例#1
0
    def get(self, n=1):
        zsite_id = self.zsite_id
        user_id = self.current_user_id
        zsite = self.zsite
        zsite_cid = zsite.cid

        if zsite_cid == CID_SITE:
            self.template = '/ctrl/zsite/po_view/site_po_page.htm'
        else:
            self.template = '/ctrl/zsite/po_view/po_page.htm'


        cid = self.cid
        page_template = self.page_template
        n = int(n)

        if zsite_cid == CID_SITE:
            total = po_cid_count_by_zsite_id(zsite_id, cid)
        else:
            is_self = zsite_id == user_id
            total = po_list_count(zsite_id, cid, is_self)

        page, limit, offset = page_limit_offset(
            page_template,
            total,
            n,
            PAGE_LIMIT
        )

        if n != 1 and offset >= total:
            return self.redirect(page_template[:-3])

        if zsite_cid == CID_SITE:
            po_list = feed_po_list_by_zsite_id(user_id, zsite_id, cid, limit, offset)
            back_a = None
            total = 0
        else:
            po_list = po_view_list(zsite_id, cid, is_self, limit, offset)

            if cid == CID_WORD:
                rid_po_list = [i for i in po_list if i.rid]
                Po.mc_bind(rid_po_list, 'question', 'rid')
                Zsite.mc_bind([i.target for i in rid_po_list], 'user', 'user_id')

            if is_self:
                back_a = '/feed'
            else:
                back_a = '/'


        self.render(
            cid=cid,
            total=total,
            li=po_list,
            page=page,
            back_a=back_a,
        )
示例#2
0
    def get(self):
        self.set_header('Content-Type', 'text/xml; charset=utf-8')

        items = []
        zsite = self.zsite
        id = zsite.id
        rss_title = '%s %s' % (zsite.name, host(id))
        rss_link = 'http:%s/rss' % zsite.link
        pubdate = time()
        rss_desc = motto_get(id)

        limit = 25
        offset = 0
        if zsite.cid == CID_SITE:
            site_po_list = feed_po_list_by_zsite_id(self.current_user_id, id, CID_NOTE, limit, offset)[0]
            po_id_list = []
            for i in site_po_list:
                po_id_list.append(i[1])
            po_list = Po.mc_get_list(po_id_list)
        else:
            po_list = po_view_list(id, CID_NOTE, False, limit, offset)

        for po in po_list:
            d = {}
            author = Zsite.get(po.user_id)
            po_title = po.name
            po_link = 'http:%s/%s' % (zsite.link, po.id)
            tag = tag_by_po_id(id, po.id)[2]
            title = [po_title]
            if tag:
                title.append('#%s#'%tag)
            d['title'] = ' '.join(title)
            d['author'] = author.name
            d['link'] = po_link
            htm = po.htm

            htm = htm.replace('class="PICR"', 'style="float:right;margin-left:14px"')\
                     .replace('class="PICL"', 'style="float:left;margin-right:14px"')\
                     .replace('class="PIC"', 'style="margin:14px auto"')

            desc = [
            """<font face="Verdana,sans-serif" size="3">
<pre style="font-family:Verdana;font-size:14px;white-space:pre-wrap;word-wrap:break-word;line-height:27px;">%s</pre>
""" % htm
            ]
            unit, title = career_current(id)
            desc.append(
                """ <div style="padding:27px 0;text-align:left;font-size:14px;float:left"><a target="_blank" href="%s">"""%author.link
            )

            ico = ico_url(id)
            if ico:
                desc.append(
                    """<img style="float:left;margin-right:28px" src="%s">"""%ico
                )

            desc.append("""<div style="line-height:32px;float:left"><div>%s</div><div style="color:#000">"""%escape(author.name))

            if unit:
                desc.append("""<div>%s</div>"""%escape(unit))

            if title:
                desc.append("""<div>%s</div>"""%escape(title))

            desc.append("""</div></div></a></div>""")
            desc.append('</font>')
            d['desc'] = ''.join(desc)
            d['pubdate'] = format_rfc822_data(po.create_time)
            items.append(d)

        self.render(
            rss_title=rss_title,
            rss_link=rss_link,
            rss_desc=rss_desc,
            pubdate=format_rfc822_data(pubdate),
            items=items,
        )
示例#3
0
    def get(self):
        self.set_header('Content-Type', 'text/xml; charset=utf-8')

        items = []
        zsite = self.zsite
        id = zsite.id
        rss_title = '%s %s' % (zsite.name, host(id))
        rss_link = 'http:%s/rss' % zsite.link
        pubdate = time()
        rss_desc = motto_get(id)

        limit = 25
        offset = 0
        if zsite.cid == CID_SITE:
            site_po_list = feed_po_list_by_zsite_id(self.current_user_id, id,
                                                    CID_NOTE, limit, offset)[0]
            po_id_list = []
            for i in site_po_list:
                po_id_list.append(i[1])
            po_list = Po.mc_get_list(po_id_list)
        else:
            po_list = po_view_list(id, CID_NOTE, False, limit, offset)

        for po in po_list:
            d = {}
            author = Zsite.get(po.user_id)
            po_title = po.name
            po_link = 'http:%s/%s' % (zsite.link, po.id)
            tag = tag_by_po_id(id, po.id)[2]
            title = [po_title]
            if tag:
                title.append('#%s#' % tag)
            d['title'] = ' '.join(title)
            d['author'] = author.name
            d['link'] = po_link
            htm = po.htm

            htm = htm.replace('class="PICR"', 'style="float:right;margin-left:14px"')\
                     .replace('class="PICL"', 'style="float:left;margin-right:14px"')\
                     .replace('class="PIC"', 'style="margin:14px auto"')

            desc = [
                """<font face="Verdana,sans-serif" size="3">
<pre style="font-family:Verdana;font-size:14px;white-space:pre-wrap;word-wrap:break-word;line-height:27px;">%s</pre>
""" % htm
            ]
            unit, title = career_current(id)
            desc.append(
                """ <div style="padding:27px 0;text-align:left;font-size:14px;float:left"><a target="_blank" href="%s">"""
                % author.link)

            ico = ico_url(id)
            if ico:
                desc.append(
                    """<img style="float:left;margin-right:28px" src="%s">""" %
                    ico)

            desc.append(
                """<div style="line-height:32px;float:left"><div>%s</div><div style="color:#000">"""
                % escape(author.name))

            if unit:
                desc.append("""<div>%s</div>""" % escape(unit))

            if title:
                desc.append("""<div>%s</div>""" % escape(title))

            desc.append("""</div></div></a></div>""")
            desc.append('</font>')
            d['desc'] = ''.join(desc)
            d['pubdate'] = format_rfc822_data(po.create_time)
            items.append(d)

        self.render(
            rss_title=rss_title,
            rss_link=rss_link,
            rss_desc=rss_desc,
            pubdate=format_rfc822_data(pubdate),
            items=items,
        )