Пример #1
0
def ss_keywords(keywords, page=1):
    keyword = urllib2.unquote(str(keywords))
    # print keyword
    condition = {"Status": 4}
    condition.update(
        {"$or": [{"Title": {"$regex": keyword}}, {"Content": {"regex": keyword}}, {"Keywords": {"$in": [keyword]}}]})
    # condition = {"$text": {"$search": keyword}, "Status": 4}
    k_list = db.News.find(condition).sort('Published', pymongo.DESCENDING).skip(
        pre_page * (int(page) - 1)).limit(pre_page)
    c_list = []
    for i in k_list:
        c_list.append(get_mongodb_dict(i))
    # 新闻排行
    hours = search_indexnews_db("576b37b8a6d2e970226062d1", 8)
    zb = search_indexnews_db("576b37cda6d2e970226062d4", 8)
    yb = search_indexnews_db("576b37daa6d2e970226062d7", 8)
    # 侃八卦
    gbg = search_indexnews_db("579190303c7ee91e3478823e", 10)
    # 专题
    zt_images = get_head_image("5765057edcc88e31a7d2e4c6", 4)
    zt = search_indexnews_db("579584633c7e431eaf791a06", 3)
    # 热门图集
    rmtj = search_indexnews_db("57bba817f5e86117cb228908", 5)
    return render_template('search.html', zt_images=zt_images, zt=zt, gbg=gbg, rmtj=rmtj, menu=get_menu(), hours=hours,
                           zb=zb, yb=yb,
                           c_list=c_list, keyword=keyword)
Пример #2
0
def s_list(id, page=1):
    try:
        channel = db.Channel.find_one({"numid": int(id)})["_id"]
        # 轮换图
        lht = get_head_image(ObjectId(channel), 5)
        condition = {"Channel": {"$in": [ObjectId(channel)]}, "Status": 4}
        count = db.News.find(condition).sort('Published', pymongo.DESCENDING).count()
        news_list = db.News.find(condition).sort('Published', pymongo.DESCENDING).skip(
            pre_page * (int(page) - 1)).limit(
            pre_page)
        _news_list = []
        for i in news_list:
            _news_list.append(get_mongodb_dict(i))
        pagenums, pagebar_html = pager("/" + str(id), int(page), count, pre_page).show_page()
        # 频道
        detail = db.Channel.find_one({"numid": int(id)})
        # 新闻排行
        hours = search_indexnews_db("576b37b8a6d2e970226062d1", 8)
        zb = search_indexnews_db("576b37cda6d2e970226062d4", 8)
        yb = search_indexnews_db("576b37daa6d2e970226062d7", 8)
        # 侃八卦
        gbg = search_indexnews_db("579190303c7ee91e3478823e", 10)
        # 专题
        zt_images = get_head_image("5765057edcc88e31a7d2e4c6", 4)
        zt = search_indexnews_db("579584633c7e431eaf791a06", 3)
        # 今日热评图片1
        jrrp_2 = get_image_news("577c647559f0d8efacae7e68", 1)
        # 今日热评文字3
        jrrp_5 = get_image_news("577c647559f0d8efacae7e68", 4, jrrp_2)
        # 热门图集
        rmtj = search_indexnews_db("57bba817f5e86117cb228908", 5)
        biaoti = ""
        pic = 0
        menu_list = []
        if id in ["16", "17", "18", "19", "20"]:
            pic = 1
            menu_list = db.Channel.find({"Parent": ObjectId("576500c6dcc88e31a6f3500c")}).sort("OrderNumber")
            biaoti = "special"
        elif id in ["21", "22", "23", "55", "56"]:
            pic = 2
            menu_list = db.Channel.find({"Parent": ObjectId("576500cfdcc88e31a7d2e4b9")}).sort("OrderNumber")
            biaoti = "special"
        elif id in ["24", "25", "26", "27", "51"]:
            pic = 3
            menu_list = db.Channel.find({"Parent": ObjectId("576500e8dcc88e31a6f3500e")}).sort("OrderNumber")
            biaoti = "special"
        name_list = []
        for i in menu_list:
            name_list.append(i)
        channel_parent_id = db.Channel.find_one({"numid": int(id)})["Parent"]
        p_id = db.Channel.find_one({"_id": ObjectId(channel_parent_id)})["numid"]
        return render_template('list.html', zt_images=zt_images, zt=zt, gbg=gbg, rmtj=rmtj, lht=lht, channel=_news_list,
                               detail=detail, menu=get_menu(), hours=hours, zb=zb, yb=yb,
                               name_list=name_list, biaoti=biaoti, cid=ObjectId(channel), pic=pic, jrrp_5=jrrp_5,
                               jrrp_2=jrrp_2,
                               pagebar_html=pagebar_html, id=p_id)
    except:
        abort(404)
Пример #3
0
def s_list(id, page=1):
    try:
        channel = db.Channel.find_one({"numid": int(id)})["_id"]
        # 轮换图
        lht = get_head_image(ObjectId(channel), 5)
        condition = {"Channel": {"$in": [ObjectId(channel)]}, "Status": 4}
        count = db.News.find(condition).sort('Published',
                                             pymongo.DESCENDING).count()
        news_list = db.News.find(condition).sort(
            'Published', pymongo.DESCENDING).skip(
                pre_page * (int(page) - 1)).limit(pre_page)
        _news_list = []
        for i in news_list:
            _news_list.append(get_mongodb_dict(i))
        pagenums, pagebar_html = pager("/klj/" + str(id), int(page), count,
                                       pre_page).show_page()
        # 频道
        detail = db.Channel.find_one({"numid": int(id)})
        # 新闻排行
        hours = search_indexnews_db("576b37b8a6d2e970226062d1", 8)
        zb = search_indexnews_db("576b37cda6d2e970226062d4", 8)
        yb = search_indexnews_db("576b37daa6d2e970226062d7", 8)
        # 侃八卦
        gbg = search_indexnews_db("579190303c7ee91e3478823e", 10)
        # 专题
        zt_images = get_head_image("5765057edcc88e31a7d2e4c6", 4)
        zt = search_indexnews_db("579584633c7e431eaf791a06", 3)
        # 热门图集
        rmtj = search_indexnews_db("57bba817f5e86117cb228908", 5)
        menu = db.Channel.find({
            "Parent": ObjectId("576500b1dcc88e31a7d2e4b8"),
            "Visible": 1
        }).sort("OrderNumber")
        # 今日热评图片1
        jrrp_2 = get_image_news("577c647559f0d8efacae7e68", 1)
        # 今日热评文字3
        jrrp_5 = get_image_news("577c647559f0d8efacae7e68", 4, jrrp_2)
        return render_template('klj/klj_list.html',
                               zt_images=zt_images,
                               zt=zt,
                               gbg=gbg,
                               rmtj=rmtj,
                               lht=lht,
                               channel=_news_list,
                               detail=detail,
                               menu=menu,
                               hours=hours,
                               zb=zb,
                               yb=yb,
                               cid=ObjectId(channel),
                               jrrp_2=jrrp_2,
                               jrrp_5=jrrp_5,
                               pagebar_html=pagebar_html)
    except:
        abort(404)
Пример #4
0
def klj_ld_list_detail(id, num, page=1):
    try:
        pre_page_1 = 20
        lingdao = db.Channel.find_one({"numid": int(id)})
        parent = lingdao["_id"]
        channel = db.Channel.find({"Parent": ObjectId(parent)}).sort("OrderNumber")
        news_list = []
        name = ''
        if num == "1":  # 路由中num=='1'得到讲话List
            condition = {"Channel": {"$in": [channel[0]["_id"]]}}
            count = db.News.find(condition).sort('Pulished', pymongo.DESCENDING).count()
            news_list = db.News.find(condition).sort('Published', pymongo.DESCENDING).skip(
                pre_page_1 * (int(page) - 1)).limit(
                pre_page_1)
            # news_list = search_news_db([channel[0]["_id"]], 20)
            name = "讲话"
        elif num == "2":  # 路由中num=='2'得到活动List
            condition = {"Channel": {"$in": [channel[1]["_id"]]}}
            count = db.News.find(condition).sort('Pulished', pymongo.DESCENDING).count()
            news_list = db.News.find(condition).sort('Published', pymongo.DESCENDING).skip(
                pre_page_1 * (int(page) - 1)).limit(
                pre_page_1)
            # news_list = search_news_db([channel[1]["_id"]], 20)
            name = "活动"
        # 翻页内容
        _news_list = []
        for i in news_list:
            _news_list.append(get_mongodb_dict(i))
        url_mid = str(id) + "_" + str(num)
        pagenums, pagebar_html = pager("/ld/" + url_mid, int(page), count, pre_page_1).show_page()
        return render_template("leaders_3rd.html", news_list=news_list, name=name, lingdao=lingdao, ld2nd='ld2nd',
                               _news_list=_news_list,
                               pagebar_html=pagebar_html

                               )
    except:
        abort(404)
Пример #5
0
def kbg_list_index(id, page=1):
    try:
        channel = db.Channel.find_one({"numid": int(id)})["_id"]
        # 轮换图
        lht = get_head_image(ObjectId(channel), 4)
        condition = {"Channel": {"$in": [ObjectId(channel)]}, "Status": 4}
        count = db.News.find(condition).sort('Published', pymongo.DESCENDING).count()
        news_list = db.News.find(condition).sort('Published', pymongo.DESCENDING).skip(
            pre_page * (int(page) - 1)).limit(
            pre_page)
        _news_list = []
        for i in news_list:
            _news_list.append(get_mongodb_dict(i))
        pagenums, pagebar_html = pager("/kbg/" + str(id), int(page), count, pre_page).show_page()
        # 新闻排行
        hours = search_indexnews_db("576b37b8a6d2e970226062d1", 8)
        zb = search_indexnews_db("576b37cda6d2e970226062d4", 8)
        yb = search_indexnews_db("576b37daa6d2e970226062d7", 8)
        # 频道菜单
        menu1 = db.Channel.find({"Parent": ObjectId("576500f0dcc88e31a7d2e4ba"), "Visible": 1}).sort("OrderNumber")
        # 报料台 4条
        blt = search_news_db([ObjectId("5782f7a4dcc88e7769576fc5")], 12)
        # 热门图集
        rmtj = search_indexnews_db("57c3a1c2795266887b863b83", 5)
        # 今日热评图片1
        jrrp_2 = get_image_news("577c647559f0d8efacae7e68", 1)
        # 今日热评文字3
        jrrp_5 = get_image_news("577c647559f0d8efacae7e68", 4, jrrp_2)
        detail = db.Channel.find_one({"_id": ObjectId(channel)})
        return render_template('kbg/kbg_list.html', news_list=_news_list, lht=lht, hours=hours, zb=zb, yb=yb,
                               cid=ObjectId(channel),
                               menu=menu1, blt=blt, rmtj=rmtj, detail=detail,
                               jrrp_2=jrrp_2,
                               jrrp_5=jrrp_5, pagebar_html=pagebar_html
                               )
    except:
        abort(404)
Пример #6
0
def front_page(id, page=1):
    try:
        channel_raw = db.Channel.find_one({"numid": int(id)})
        channel = channel_raw["_id"]
        name = channel_raw["Name"]
        lht = get_head_image(channel, 5)
        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}
        count = db.News.find(condition).count()
        news_list = db.News.find(condition).sort('Published', pymongo.DESCENDING).skip(
            pre_page * (int(page) - 1)).limit(
            pre_page)
        _news_list = []
        for i in news_list:
            _news_list.append(get_mongodb_dict(i))
        pagenums, pagebar_html = pager("/index/" + str(id), int(page), count, pre_page).show_page()
        detail = db.Channel.find_one({"_id": ObjectId(channel)})
        # 今日热评图片1
        jrrp_2 = get_image_news("577c647559f0d8efacae7e68", 1)
        # 今日热评文字3
        jrrp_5 = get_image_news("577c647559f0d8efacae7e68", 4, jrrp_2)
        # 新闻排行
        hours = search_indexnews_db("576b37b8a6d2e970226062d1", 8)
        zb = search_indexnews_db("576b37cda6d2e970226062d4", 8)
        yb = search_indexnews_db("576b37daa6d2e970226062d7", 8)
        # 侃八卦
        gbg = search_indexnews_db("579190303c7ee91e3478823e", 8)
        # 专题
        zt_images = get_head_image("5765057edcc88e31a7d2e4c6", 4)
        zt = search_indexnews_db("579584633c7e431eaf791a06", 3)
        # 热门图集
        rmtj = search_indexnews_db("57bba817f5e86117cb228908", 5)
        menu_list = []
        ys = ""
        pic = 0
        if id == "5":
            menu_list = db.Channel.find({"Parent": ObjectId("576500c6dcc88e31a6f3500c")}).sort("OrderNumber")
            pic = 1
            ys = 'sy'
        elif id == "6":
            menu_list = db.Channel.find({"Parent": ObjectId("576500cfdcc88e31a7d2e4b9")}).sort("OrderNumber")
            pic = 2
            ys = 'sy'
        elif id == "8":
            menu_list = db.Channel.find({"Parent": ObjectId("576500e8dcc88e31a6f3500e")}).sort("OrderNumber")
            pic = 3
            ys = 'sy'
        name_list = []
        for i in menu_list:
            name_list.append(i)
        return render_template('front_list.html', news_list=_news_list,
                               detail=detail,
                               hours=hours,
                               zb=zb,
                               yb=yb,
                               gbg=gbg,
                               name=name,
                               zt_images=zt_images,
                               lht=lht,
                               jrrp_2=jrrp_2,
                               jrrp_5=jrrp_5,
                               zt=zt,
                               cid=ObjectId(channel),
                               rmtj=rmtj,
                               menu_list=menu_list,
                               name_list=name_list,
                               ys=ys,
                               pic=pic,
                               pagebar_html=pagebar_html,
                               id=id
                               )
    except:
        abort(404)
Пример #7
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
                           )
Пример #8
0
def psd_list(id, page=1):
    try:
        channel = db.Channel.find_one({"numid": int(id)})["_id"]
        # 轮换头图
        lht = get_head_image(ObjectId(channel), 5)
        # 新闻列表
        condition = {"Channel": {"$in": [ObjectId(channel)]}, "Status": 4}
        count = db.News.find(condition).sort('Published',
                                             pymongo.DESCENDING).count()
        news_list = db.News.find(condition).sort(
            'Published', pymongo.DESCENDING).skip(
                pre_page * (int(page) - 1)).limit(pre_page)
        _news_list = []
        for i in news_list:
            _news_list.append(get_mongodb_dict(i))
        pagenums, pagebar_html = pager("/psd/" + str(id), int(page), count,
                                       pre_page).show_page()
        # 今日热评文字1
        # jrrp_1 = get_image_news("577c647559f0d8efacae7e68", 1)
        # 今日热评图片1
        jrrp_2 = get_image_news("577c647559f0d8efacae7e68", 1)
        # 今日热评文字3
        jrrp_5 = get_image_news("577c647559f0d8efacae7e68", 3, jrrp_2)
        # 独家视界
        djsj = get_image_news("577c648559f0d8efacae7e6b", 10)
        # 当事者说
        dszs = get_image_news("577c649059f0d8efacae7e6e", 3)
        # 排行24
        ph_24 = get_image_news("576b37b8a6d2e970226062d1", 8)
        # 排行周
        ph_week = get_image_news("576b37cda6d2e970226062d4", 8)
        # 排行月
        ph_month = get_image_news("576b37daa6d2e970226062d7", 8)
        # 专题
        zt_images = get_head_image("5765057edcc88e31a7d2e4c6", 4)
        zt = search_indexnews_db("579584633c7e431eaf791a06", 3)
        # # 合作媒体
        # hzmt = db.Media.find({"ChannelID": ObjectId("576500f0dcc88e31a7d2e4ba")})
        # 频道
        menu1 = db.Channel.find({
            "Parent": ObjectId("576500d7dcc88e31a6f3500d"),
            "Visible": 1
        }).sort("OrderNumber")
        detail = db.Channel.find_one({"_id": ObjectId(channel)})
        # name = get_name(channel)
        return render_template('psd/psd_list.html',
                               lht=lht,
                               c_list=_news_list,
                               jrrp_2=jrrp_2,
                               jrrp_5=jrrp_5,
                               djsj=djsj,
                               dszs=dszs,
                               ph_24=ph_24,
                               ph_month=ph_month,
                               ph_week=ph_week,
                               zt=zt,
                               zt_images=zt_images,
                               detail=detail,
                               menu=menu1,
                               cid=ObjectId(channel),
                               pagebar_html=pagebar_html)
    except:
        abort(404)