Exemplo n.º 1
0
def is_sift(page=1):
    condition = {"IsSift": 1, "Guideimage": {"$ne": ""}, "Status": 4, "_id": {"$nin": zd}}
    news_list = db.News.find(condition).sort('Published', pymongo.DESCENDING).skip((int(page) - 1) * 14).limit(14)
    string = ""
    for i in news_list:
        string += "<li><p><a href='/d/%s.html' target='_blank'>" % (i["numid"])
        string += "<img src='%s?w=261&h=171, width='261' height='171'/></a></p><h3 class='Txt_cu'><a href='/d/%s.html' target='_blank'>%s</a></h3>" % (
            image_server + i["Guideimage"], i["numid"], i["Title"])
        string += "<h4>%s</h4><span><h5>%s</h5>" % (i["Summary"], datetime_op(i["Published"]))
        c = db.Channel.find_one({"_id": ObjectId(i["Channel"][0])})
        string += "<h6><a href='%s' target='_blank' >%s</a></h6></span></li>" % (c["Href"], c["Name"])
    return json.dumps({"datalist": string})
Exemplo n.º 2
0
def m_index_page(page=1):
    condition = {"IsSift": 1, "Guideimage": {"$ne": ""}, "_id": {"$nin": zd}, "Status": 4}
    news_list = db.News.find(condition).sort('Published', pymongo.DESCENDING).skip((int(page) - 1) * pre_page).limit(
        pre_page)
    string = ""
    for i in news_list:
        string += "<li><a href='/d/%s.html'>" % (i["numid"])
        if i["Guideimage"] != "":
            string += "<img src='%s' class='news-img' />" % (image_server + i["Guideimage"])
        string += "<div class='m_article_desc_l'>%s</div>" % (datetime_op(i["Published"]))
        string += "<div class='news-text'><h3>%s</h3></div>" % (i["Title"])
        string += "</a></li>"
    return json.dumps(string)
Exemplo n.º 3
0
def s_list_page(id, page=1):
    channel = db.Channel.find_one({"numid": int(id)})["_id"]
    condition = {"Channel": {"$in": [ObjectId(channel)]}, "Status": 4}
    news_list = db.News.find(condition).sort('Published', pymongo.DESCENDING).skip(pre_page * (int(page) - 1)).limit(
        pre_page)
    value = ""
    for i in news_list:
        style = 'style="display: block"'
        if i["Guideimage"] == "":
            style = 'style="display: none"'
        value += "<li><p %s><img src='%s' width='261' height='171'/></p><h2><a href='/d/%s.html' target='_blank'>%s</a></h2> <h5>%s</h5> <h6>&nbsp;&nbsp;&nbsp;%s</h6></li>" % \
                 (style, image_server + i["Guideimage"], i["numid"], i["Title"], i["Summary"],
                  datetime_op((i["Published"])))
    return json.dumps(value)
Exemplo n.º 4
0
def ss_keys_page(keys, page=1):
    keyword = urllib2.unquote(str(keys))
    condition = {"Status": 4}
    condition.update(
        {"$or": [{"Title": {"$regex": keyword}}, {"Content": {"regex": keyword}}, {"Keywords": {"$in": [keyword]}}]})
    news_list = db.News.find(condition).sort('Published', pymongo.DESCENDING).skip((int(page) - 1) * pre_page).limit(
        pre_page)
    string = ""
    for i in news_list:
        string += "<li><a href='/d/%s.html'>" % (i["numid"])
        if i["Guideimage"] != "":
            string += "<img src='%s' class='news-img' />" % (image_server + i["Guideimage"])
        string += "<div class='m_article_desc_l'>%s</div>" % (datetime_op(i["Published"]))
        string += "<div class='news-text'><h3>%s</h3></div>" % (i["Title"])
        string += "</a></li>"
    return json.dumps(string)
Exemplo n.º 5
0
def ss_keywords_list(keywords, page=1):
    keyword = urllib2.unquote(str(keywords))
    condition = {"Status": 4}
    condition.update(
        {"$or": [{"Title": {"$regex": keyword}}, {"Content": {"regex": keyword}}, {"Keywords": {"$in": [keyword]}}]})
    k_list = db.News.find(condition).sort('Published', pymongo.DESCENDING).skip(
        pre_page * (int(page) - 1)).limit(pre_page)
    value = ""
    for i in k_list:
        style = 'style="display: block"'
        if i["Guideimage"] == "":
            style = 'style="display: none"'
        value += "<li><p %s><img src='%s' width='261' height='171'/></p><h2><a href='/d/%s.html' target='_blank'>%s</a></h2> <h5>%s</h5> <h6>&nbsp;&nbsp;&nbsp;%s</h6></li>" % \
                 (style, image_server + i["Guideimage"], i["numid"],
                  str(i["Title"]).replace(keyword, "<span style='color:red'>" + keyword + "</span>"),
                  str(i["Summary"]).replace(keyword, "<span style='color:red'>" + keyword + "</span>"),
                  datetime_op((i["Published"])))
    return json.dumps(value)
Exemplo n.º 6
0
def m_list_by_id(cid, page=1):
    channel_raw = db.Channel.find_one({"numid": int(cid)})
    child = db.Channel.find({"Parent": ObjectId(channel_raw["_id"]), "Visible": 1}).sort("OrderNumber")
    idlist = []
    for i in child:
        idlist.append(i["_id"])
    condition = {"Channel": {"$in": idlist}, "Status": 4}
    news_list = db.News.find(condition).sort('Published', pymongo.DESCENDING).skip((int(page) - 1) * pre_page).limit(
        pre_page)
    string = ""
    for i in news_list:
        string += "<li><a href='/d/%s.html'>" % (i["numid"])
        if i["Guideimage"] != "":
            string += "<img src='%s' class='news-img' />" % (image_server + i["Guideimage"])
        string += "<div class='m_article_desc_l'>%s</div>" % (datetime_op(i["Published"]))
        string += "<div class='news-text'><h3>%s</h3></div>" % (i["Title"])
        string += "</a></li>"
    return json.dumps(string)
Exemplo n.º 7
0
def news_list_page(channel, page=1):
    channel_list_raw = db.Channel.find({"Parent": ObjectId(channel)})
    channel_list = []
    for i in channel_list_raw:
        channel_list.append(i["_id"])
    condition = {"Channel": {"$in": channel_list}, "Status": 4}
    news_list = db.News.find(condition).sort('Published', pymongo.DESCENDING).skip(
        pre_page * (int(page) - 1)).limit(
        pre_page)
    news_dic_list = []
    for i in news_list:
        i["cname"] = db.Channel.find_one({"_id": ObjectId(i["Channel"][0])})["Name"]
        news_dic_list.append(i)
    value = ""
    for i in news_dic_list:
        style = 'style="display: block"'
        if i["Guideimage"] == "":
            style = 'style="display: none"'
        value += "<li %s><p %s><a href='/d/%s.html' target='_blank'><img src='%s?w=261&h=171' width='261' height='171'/></a></p><h2><a href='/d/%s.html' target='_blank'>%s</a></h2> <h5>%s</h5> <h6>&nbsp;&nbsp;&nbsp;%s<tt><a href='#'>%s</a></tt></h6></li>" % \
                 (style, style, i["numid"], image_server + i["Guideimage"], i["numid"], i["Title"], i["Summary"],
                  datetime_op((i["Published"])), i["cname"])
    return json.dumps(value)
Exemplo n.º 8
0
def index():
    detail = db.Channel.find_one({"_id": ObjectId("5764f5396aba261f94bf517a")})
    # 轮换图
    lht = get_head_image(ObjectId("57688f50dcc88e552361ba27"), 5)
    # 龙江头条
    yw = search_indexnews_db("576b36a9a6d2e970226062c3", 3)
    # 侃八卦
    gbg = search_indexnews_db("579190303c7ee91e3478823e", 5)
    # 专题
    zt_images = get_head_image("5765057edcc88e31a7d2e4c6", 4)
    zt = search_indexnews_db("579584633c7e431eaf791a06", 3)
    # 热门图集
    rmtj = search_indexnews_db("57bba817f5e86117cb228908", 5)
    # 龙江生活
    ljsh = search_indexnews_db("57beb8507fdf3f9496838594", 4)
    # 龙江看点
    ljkd = search_indexnews_db("579190303c7ee91e3478823d", 5)
    # 今日热评图片1
    jrrp_2 = get_image_news("577c647559f0d8efacae7e68", 1)
    # 今日热评文字3
    jrrp_5 = get_image_news("577c647559f0d8efacae7e68", 3, jrrp_2)
    # 城市联播图片1
    cslb_1 = get_image_news("583bcab159f02f781666d40d", 1)
    # 城市联播文字2
    cslb_2 = get_image_news("583bcab159f02f781666d40d", 3, cslb_1)
    # 新闻排行
    hours = search_indexnews_db("576b37b8a6d2e970226062d1", 6)
    zb = search_indexnews_db("576b37cda6d2e970226062d4", 6)
    yb = search_indexnews_db("576b37daa6d2e970226062d7", 6)
    # 首页推荐置顶
    _list = db.IndexNews.find({"ChannelId": "579190303c7ee91e3478823f", "guide_image": {"$ne": ""}}).sort("orderno",
                                                                                                          pymongo.ASCENDING)
    _zd = []
    for i in _list:
        try:
            zd.append(i["NewsID"])
            news = db.News.find_one({"_id": ObjectId(i["NewsID"])})
            new_dict = {}
            new_dict["_id"] = i["numid"]
            new_dict["title"] = i["Title"]
            new_dict["summary"] = i["Summary"]
            try:
                new_dict["guide_image"] = i["image"] if i["image"] == "" else image_server + i["image"]
            except:
                new_dict["guide_image"] = "/static/images/bg-hui.png"
            # new_dict["guide_image"] = i["image"] if i["image"] == "" else image_server + i["image"]
            new_dict["publish_time"] = datetime_op(news["Published"])
            new_dict["cid"] = news["channelnumid"][0]
            new_dict["cname"] = db.Channel.find_one({"_id": ObjectId(news["Channel"][0])})["Name"]
            new_dict["href"] = db.Channel.find_one({"_id": ObjectId(news["Channel"][0])})["Href"]
        except:
            pass
        _zd.append(new_dict)
    # 首页14条新闻
    condition = {"IsSift": 1, "Guideimage": {"$ne": ""}, "_id": {"$nin": zd}, "Status": 4}
    news_list = db.News.find(condition).sort('Published', pymongo.DESCENDING).limit(14)
    _news_list = []
    for news_detail in news_list:
        _news_list.append(get_mongodb_dict(news_detail))
    return render_template('index.html', zt_images=zt_images, zt=zt, gbg=gbg, yw=yw, ljkd=ljkd, lht=lht,
                           ljsh=ljsh,
                           rmtj=rmtj,
                           detail=detail,
                           menu=get_menu(),
                           news_list=_news_list,
                           hours=hours, zb=zb, yb=yb, zd=_zd,
                           jrrp_2=jrrp_2,
                           jrrp_5=jrrp_5,
                           cslb_1=cslb_1,
                           cslb_2=cslb_2
                           )