コード例 #1
0
ファイル: po.py プロジェクト: xqk/42qu_github_mirror
 def htm(self):
     cid = self.cid
     id = self.id
     if cid != CID_WORD:
         s = self.txt
         if s:
             s = txt_withlink(s)
             user_id = self.user_id
             s = pic_htm(s, user_id, id)
     else:
         s = txt_withlink(self.name_)
     return s
コード例 #2
0
ファイル: po.py プロジェクト: xqk/42qu_github_mirror
    def name_htm(self):
        q = self.target
        cid = self.cid

        if cid in (CID_EVENT_NOTICE, CID_REVIEW):
            return txt_withlink(self.name_)

        if q:
            u = q.user
            link = '<a href="%s">%s</a>' % (q.link, escape(q.name))

            if cid == CID_EVENT_FEEDBACK:
                if q.user_id == self.user_id:
                    name = '总结 : %s'
                else:
                    name = '评价 : %s'
                return name%link
            elif cid == CID_REC:
                pre_po_zsite = Zsite.mc_get(q.user_id)
                if pre_po_zsite:
                    if q.cid != CID_WORD:
                        name = '推荐 <a href="%s" >%s</a> ~ <a href="%s">%s</a>' % (q.link, escape(q.name), pre_po_zsite.link, escape(pre_po_zsite.name), )
                    else:
                        name = '推荐 <a href="%s" class="fcmname c0 TPH" >%s</a> : %s <a class="zsite_reply" href="%s" target="_blank"></a>'%(
                            pre_po_zsite.link, escape(pre_po_zsite.name), escape(q.name), q.link
                        )
                else:
                    name = '推荐 <a href="%s" >%s</a>' % (q.link, escape(q.name))
                return name
            else:
                if q.user_id == self.user_id:
                    return '自问自答 : %s' % link
                else:
                    return '答 <a href="%s">%s</a> 问 : %s' % (
                        u.link, escape(u.name), link
                    )
        if cid == CID_WORD:
            return txt_withlink(self.name)

        return escape(self.name)
コード例 #3
0
ファイル: feed_render.py プロジェクト: xqk/42qu_github_mirror
def feed_tuple_by_db(id):
    m = Po.mc_get(id)
    if not m:
        feed_rm(id)
    cid = m.cid
    rid = m.rid
    has_question = cid in (CID_WORD, CID_ANSWER)

    if rid and has_question:
        question = m.target
        name = question.name
    elif cid == CID_REC:
        name = m.name_htm
    elif cid != CID_WORD:
        name = m.name
    else:
        name = None

    #if cid == CID_QUESTION:
    #    reply_count = answer_count(id)
    #else:
    reply_count = m.reply_count
    if cid == CID_PHOTO:
        rid = fs_url_jpg(721, rid)
    elif cid == CID_AUDIO:
        rid = fs_url_audio(id, '')
    elif cid == CID_VIDEO:
        rid = video_link_autoplay(rid, id)
    elif cid == CID_EVENT:
        event = Event.mc_get(id)
        feed_rm(id)
        rid = fs_url_jpg(162, event.pic_id)
    else:
        rid = rid

    result = [
        m.user_id,
        cid,
        rid,
        m.zsite_id,
        reply_count,
        m.create_time,
        name,
        #vote_count(id)
    ]

    txt = m.txt
    if cid != CID_WORD:
        txt, has_more = cnenoverflow(txt, 100)
        if not has_more:
            txt = m.htm
        result.extend((txt, has_more))
    else:
        txt = txt_withlink(txt)
        result.extend((txt, False))

    if cid == CID_EVENT:
        result.append(place_name(event.pid))
        result.append(event.address)
        result.extend(begin_end_by_minute(event.begin_time, event.end_time))
    elif rid and has_question:
        user = question.user
        result.extend((question.id, user.name, user.link))

    return result
コード例 #4
0
def feed_tuple_by_db(id):
    m = Po.mc_get(id)
    if not m:
        feed_rm(id)
    cid = m.cid
    rid = m.rid
    has_question = cid in (CID_WORD, CID_ANSWER)

    if rid and has_question:
        question = m.target
        name = question.name
    elif cid == CID_REC:
        name = m.name_htm
    elif cid != CID_WORD:
        name = m.name
    else:
        name = None

    #if cid == CID_QUESTION:
    #    reply_count = answer_count(id)
    #else:
    reply_count = m.reply_count
    if cid == CID_PHOTO:
        rid = fs_url_jpg(721, rid)
    elif cid == CID_AUDIO:
        rid = fs_url_audio(id, '')
    elif cid == CID_VIDEO:
        rid = video_link_autoplay(rid, id)
    elif cid == CID_EVENT:
        event = Event.mc_get(id)
        feed_rm(id)
        rid = fs_url_jpg(162, event.pic_id)
    else:
        rid = rid

    result = [
        m.user_id,
        cid,
        rid,
        m.zsite_id,
        reply_count,
        m.create_time,
        name,
        #vote_count(id)
    ]

    txt = m.txt
    if cid != CID_WORD:
        txt, has_more = cnenoverflow(txt, 100)
        if not has_more:
            txt = m.htm
        result.extend((txt, has_more))
    else:
        txt = txt_withlink(txt)
        result.extend((txt, False))

    if cid == CID_EVENT:
        result.append(place_name(event.pid))
        result.append(event.address)
        result.extend(
            begin_end_by_minute(event.begin_time, event.end_time)
        )
    elif rid and has_question:
        user = question.user
        result.extend(
            (question.id, user.name, user.link)
        )

    return result