Example #1
0
    def get(self, id):
        current_user_id = self.current_user_id
        result = None
        if not id.isdigit():
            id = id_by_url(id)
        if id:
            id = int(id)
        if not id or current_user_id == id:
            return self.finish('null')

        zsite = Zsite.mc_get(id)
        if zsite:
            career = career_current(id)
            career = filter(bool, career)
            current_user_id = self.current_user_id
            if current_user_id != id:
                if follow_get(current_user_id, id):
                    word = '淡忘'
                else:
                    word = '关注'
                result = [
                    zsite.name, ' , '.join(career),
                    ico_url_with_default(id), zsite.link, zsite.id, word,
                    motto_get(zsite.id)
                ]
        return self.finish(dumps(result))
def zsite2keyword(z):
    r = []
    t = defaultdict(int)
    id = z.id

    name = z.name
    if name:
        for word in seg_title_search(name):
            t[word] += 2

    url = url_by_id(id)
    if url:
        t[url] += 2

    if z.cid == CID_SITE:
        for word in seg_title_search(motto_get(id)):
            t[word] += 1

    elif z.cid == CID_USER:

        mail = mail_by_user_id(id)
        if mail:
            t[mail] += 2
            t[mail.split('@', 1)[0]] += 2


        txt = txt_get(id)

        if txt:
            man_txt_len = len(txt)

            for word in seg_txt_search(txt):
                t[word] += 1

        for seq, career in enumerate(career_list_all(id)):
            if seq:
                add = 1
            else:
                add = 2

            unit = career.unit
            title = career.title
            txt = career.txt

            if unit:
                for word in seg_title_search(unit):
                    t[word] += add

            if title:
                for word in seg_title_search(title):
                    t[word] += add
            if txt:
                for word in seg_txt_search(txt):
                    t[word] += add

    return t
Example #3
0
def zsite2keyword(z):
    r = []
    t = defaultdict(int)
    id = z.id

    name = z.name
    if name:
        for word in seg_title_search(name):
            t[word] += 2

    url = url_by_id(id)
    if url:
        t[url] += 2

    if z.cid == CID_SITE:
        for word in seg_title_search(motto_get(id)):
            t[word] += 1

    elif z.cid == CID_USER:

        mail = mail_by_user_id(id)
        if mail:
            t[mail] += 2
            t[mail.split('@', 1)[0]] += 2

        txt = txt_get(id)

        if txt:
            man_txt_len = len(txt)

            for word in seg_txt_search(txt):
                t[word] += 1

        for seq, career in enumerate(career_list_all(id)):
            if seq:
                add = 1
            else:
                add = 2

            unit = career.unit
            title = career.title
            txt = career.txt

            if unit:
                for word in seg_title_search(unit):
                    t[word] += add

            if title:
                for word in seg_title_search(title):
                    t[word] += add
            if txt:
                for word in seg_txt_search(txt):
                    t[word] += add

    return t
Example #4
0
 def get(self):
     zsite = self.zsite
     zsite_id = self.zsite_id
     link_list, link_cid = link_list_cid_by_zsite_id(
         zsite_id, SITE_LINK_ZSITE_DICT)
     self.render(errtip=JsDict(),
                 link_cid=link_cid,
                 link_list=link_list,
                 name=zsite.name,
                 motto=motto_get(zsite_id),
                 txt=txt_get(zsite_id),
                 pic_id=ico96.get(zsite_id))
Example #5
0
 def get(self):
     zsite = self.zsite
     zsite_id = self.zsite_id
     link_list , link_cid = link_list_cid_by_zsite_id(zsite_id, SITE_LINK_ZSITE_DICT)
     self.render(
         errtip=JsDict(),
         link_cid=link_cid,
         link_list=link_list,
         name=zsite.name,
         motto=motto_get(zsite_id),
         txt=txt_get(zsite_id),
         pic_id=ico96.get(zsite_id)
     )
def man_show_api(man_id):
    man = Zsite.mc_get(man_id)
    if man:
        comp, title = career_current(man_id)
        txt = txt_get(man_id)
        link = man.link
        li = [
            ('id', man_id),
            ('name', man.name),
            ('uid', url_by_id(man_id)),
            ('company', comp),
            ('title', title),
            ('signature', motto_get(man_id)),
            ('about_me', txt),
            ('ico', pic_url(man_id, 219)),
            ('link', name_link_by_zsite_id(man_id, 'http:')),
            ('appearance_fee', 42),
        ]
        return dict(filter(lambda x:bool(x[1]), li))
    return {}
Example #7
0
def man_show_api(man_id):
    man = Zsite.mc_get(man_id)
    if man:
        comp, title = career_current(man_id)
        txt = txt_get(man_id)
        link = man.link
        li = [
            ('id', man_id),
            ('name', man.name),
            ('uid', url_by_id(man_id)),
            ('company', comp),
            ('title', title),
            ('signature', motto_get(man_id)),
            ('about_me', txt),
            ('ico', pic_url(man_id, 219)),
            ('link', name_link_by_zsite_id(man_id, 'http:')),
            ('appearance_fee', 42),
        ]
        return dict(filter(lambda x: bool(x[1]), li))
    return {}
Example #8
0
    def get(self, id):
        current_user_id = self.current_user_id
        result = None
        if not id.isdigit():
            id = id_by_url(id)
        if id:
            id = int(id)
        if not id or current_user_id == id:
            return self.finish('null')

        zsite = Zsite.mc_get(id)
        if zsite:
            career = career_current(id)
            career = filter(bool, career)
            current_user_id = self.current_user_id
            if current_user_id != id:
                if follow_get(current_user_id, id):
                    word = '淡忘'
                else:
                    word = '关注'
                result = [zsite.name, ' , '.join(career), ico_url_with_default(id), zsite.link, zsite.id, word, motto_get(zsite.id)]
        return self.finish(dumps(result))
Example #9
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,
        )
Example #10
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,
        )