示例#1
0
def getTableAndPagingHtml(param_dic, dao_util):
	if not dao_util:
		return "", ""
	if not param_dic["sc_type"]:
		return "", ""

	if param_dic["page"]:
		page = int(param_dic["page"])
		param_dic["page"] = page+1
		next_page_get_params = html.getGetParamStr(param_dic)
		param_dic["page"] = page-1
		if (page-1) < 1:
			param_dic["page"] = 1
		prev_page_get_params = html.getGetParamStr(param_dic)
		param_dic["page"] = page
	else:
		param_dic["page"] = 2
		next_page_get_params = html.getGetParamStr(param_dic)
		param_dic["page"] = 1
		prev_page_get_params = html.getGetParamStr(param_dic)

	sc_type = param_dic["sc_type"]
	status_dic = getDataMappingDic(param_dic["_service_type"], param_dic["_data_type"], "status")
	data_list = dao_util.getDataList(param_dic, "web")

	col_name_list = ["도메인ID<br/>(클릭 시 수정)", "도메인", "사이트명<br/>(메모)", "상태", "서버", "PID",
					 "씨드URL수%s"%(html.getOrderingLinkHtml("/moon/crawl/domain_list.py", param_dic, "seed_url_count")),
					 "신규URL수%s<br/>(최근7일 현황)"%(html.getOrderingLinkHtml("/moon/crawl/domain_list.py", param_dic, "daily_count")),
					 "마지막 크롤일%s"%(html.getOrderingLinkHtml("/moon/crawl/domain_list.py", param_dic, "last_visit"))]

	if param_dic["sc_type"] == "user":  # TODO SC별 테이블 CUSTOMIZING
		col_name_list.append("새컬럼명")
	col_name_list.append("관리")

	html_title_row = html.getTableTR(col_name_list, "title")
	html_table = "<table style='table-layout:fixed; word-break:break-all;'>"+html_title_row
	row_count = 0

	# MAKE TABLE HTML
	for row_data in data_list:
		domain_id = row_data[0]
		domain = row_data[1]
		name = row_data[2]
		memo = row_data[3]
		if memo:
			name = "%s<br/>(%s)"%(name, memo)
		status = row_data[4]
		if status:
			status = status_dic[status]
		server = row_data[5]
		pid = row_data[6]
		seed_url_count = row_data[7]
		daily_count = row_data[8]
		crawl_count_history = row_data[9]
		last_visit = row_data[10]
		if last_visit:
			last_visit = getDateByStamp(last_visit)
		else:
			last_visit = ""

		added_td_tags = ""
		if sc_type == "user":  # TODO 표시 데이터 SC별 CUSTOMIZING
			added_td_tags += "<td>%s</td>"%row_data[11]

		if (row_count % 2) == 0:
			html_row = "<tr class='evenRow'>"
		else:
			html_row = "<tr>"

		document_view_link = "http://topicplus.zuminternet.com/recent_documents.py?sc=%s&channelId=%s"%(sc_type, domain_id)
		if sc_type == "bbs":
			document_view_link = "http://topicplus.zuminternet.com/recent_documents.py?sc=%s&siteId=%s"%(sc_type, domain_id)

		html_row += """
			<td><a href="/moon/domanager/domain_add.py?domainIdx=%s" target="_blank">%s</a></td>
			<td><a href="%s" target="_blank">%s</a><br/>
				<a href="/moon/domanager/urlpt_list.py?domainLike=%s" target='_blank'>URL패턴</a> |
				<a href="/moon/crawl/seedurl_list.py?sc_type=%s&domain_id=%s" target='_blank'>씨드URL</a><br/>
				<a href="/moon/domanager/sitemapurl_list.py?domain_id=%s" target='_blank'>사이트맵URL</a>
			</td>
			"""%(domain_id, domain_id, "http://"+domain, domain,  domain, sc_type, domain_id, domain_id)+"""
			<td>%s</td>
			<td>%s</td>
			<td>%s</td>
			<td>%s</td>
			<td>%s</td>
			<td>
				<a href="%s" target="_blank" >%s</a>
				<br/>%s
			</td>
			<td>%s</td>
			"""%(name, status, server, pid, seed_url_count, document_view_link, daily_count, crawl_count_history, last_visit)+ added_td_tags +"""
			<td>
				<a href="/moon/crawl/data_add.py?sc_type=%s&domain_id=%s" target="_blank" >수정</a> &nbsp;|&nbsp;
				<a href="#" onclick="confirmPopup('%s','/moon/action/sc_common.py?cmd=del&sc_type=%s&_data_type=domain&domain_id=%s')">삭제</a><br/>
				<a href="/moon/crawl/data_add.py?sc_type=%s&domain_id=%s#seedAddForm" target="_blank" >씨드등록</a> &nbsp;|&nbsp;
				<a href="#" onclick="confirmPopup2('%s','/moon/action/sc_common.py?cmd=del&sc_type=%s&_data_type=seed&domain_id=%s')">씨드삭제</a><br/>
				<a href="/moon/action/sc_common.py?cmd=resetNoNewCount&sc_type=%s&domain_id=%s" target="_blank" >씨드전체 신규문서<br/>미발견 횟수 초기화</a>
			</td>
		</tr>
		"""%(sc_type, domain_id, domain, sc_type, domain_id, sc_type, domain_id, domain, sc_type, domain_id, sc_type, domain_id)
		html_table += html_row
		row_count += 1

	# MAKE PAGING HTML
	total_count = dao_util.getDataList(param_dic, "count")
	total_page = total_count / 15
	if (total_count % 15) > 0:
		total_page += 1
	html_paging = """
	<p>
		<b>페이지 [%s/%s]</b> : <b style='color:red;'>%s</b> 개중 <b style='color:red;'>%s</b> 개 표시
		&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
		<a href='/moon/crawl/domain_list.py?%s#tableDiv'>&lt;&lt;이전</a> || <a href='/moon/crawl/domain_list.py?%s#tableDiv'>다음&gt;&gt;</a>
	</p>
	"""%( param_dic["page"], total_page, total_count, len(data_list), prev_page_get_params, next_page_get_params)

	return html_table+"</table>", html_paging
示例#2
0
def getTableAndPagingHtml(param_dic, dao_util):
    if not dao_util:
        return "", ""
    if not param_dic["sc_type"]:
        return "", ""

    if param_dic["page"]:
        page = int(param_dic["page"])
        param_dic["page"] = page + 1
        next_page_get_params = html.getGetParamStr(param_dic)
        param_dic["page"] = page - 1
        if (page - 1) < 1:
            param_dic["page"] = 1
        prev_page_get_params = html.getGetParamStr(param_dic)
        param_dic["page"] = page
    else:
        param_dic["page"] = 2
        next_page_get_params = html.getGetParamStr(param_dic)
        param_dic["page"] = 1
        prev_page_get_params = html.getGetParamStr(param_dic)

    data_list = dao_util.getDataList(param_dic, "web")
    sc_type = param_dic["sc_type"]

    col_name_list = [
        "ID",
        "씨드 URL 정보",
        "씨드명<br/>(앵커값)",
        "Generator",
        "크롤상태<br/>(씨드타입)",
        "view URL수<br/><b style='color:#6495ed;'>신규URL미발견 횟수</b><br/>INT_ID최대값",
        "마지막 방문일",
    ]

    if sc_type == "blog":  # TODO : SC별 TITLE 행 표시 데이터 CUSTOMIZING
        col_name_list[2] = "채널명<br/>(작성자)"  # 씨드명 대신 표시
        col_name_list[3] = "Generator<br/>(블로그ID)"  # 앵커TEXT 대신 표시
        # col_name_list.append("새컬럼명")

    col_name_list.append("관리")
    html_title_row = html.getTableTR(col_name_list, "title")
    html_table = "<table style='table-layout:fixed; word-break:break-all;'>" + html_title_row

    # MAKE TABLE HTML
    type_dic = getDataMappingDic(param_dic["_service_type"], param_dic["_data_type"], "seed_type")
    status_dic = getDataMappingDic(param_dic["_service_type"], param_dic["_data_type"], "crawl_status")
    row_count = 0
    for row_data in data_list:
        seed_id = row_data[0]
        domain_id = row_data[1]
        seed_guid = row_data[2]
        down_url = row_data[3]
        seed_name = "<b>%s</b>" % row_data[4]
        seed_type = row_data[5]
        if seed_type:
            seed_type = type_dic[seed_type]
        anchor_name = row_data[6]
        if anchor_name:
            seed_name = "%s<br/>(%s)" % (seed_name, anchor_name)
        crawl_status = row_data[7]
        status = ""
        if crawl_status:
            status = "크롤:<b>%s</b>" % status_dic[crawl_status]
        status += "<br/>타입:<b>%s</b>" % seed_type
        view_url_count = "뷰수:<b>%s</b><br/>" % row_data[8]
        no_new_count = "<b style='color:blue;'>노뉴:%s</b><br/>" % row_data[9]
        max_no = "맥스:<b>%s</b>" % row_data[10]
        numbers = view_url_count + no_new_count + max_no
        last_visit = row_data[11]
        generator = row_data[12]

        if last_visit:
            last_visit = getDateByStamp(last_visit)
        else:
            last_visit = ""

            # TODO : SC별 데이터 행 표시 데이터 CUSTOMIZING
        added_url_info = ""
        added_td_tags = ""
        if sc_type == "blog":
            if row_data[13]:  # 블로그 ID
                generator += "<br/>(%s)" % row_data[13]

            if row_data[14]:  # 블로그 링크
                added_url_info = "<a href='%s' target='_blank'>해당 블로그 바로가기</a><br/>" % row_data[14]

            if row_data[15]:  # author
                seed_name += "<br/>작성자 : %s" % row_data[15]

                # ROW 데이터 표시 시작
        if (row_count % 2) == 0:
            html_row = "<tr class='evenRow'>"
        else:
            html_row = "<tr>"

        html_row += (
            """
			<td>%s</td>
			<td>
				<b style="color:red;">%s</b><br/>
				%s
				도메인ID:<a href="/moon/domanager/domain_add.py?domainIdx=%s">%s</a>&nbsp;&nbsp;
				<a href="%s" target="_blank" >다운로드URL</a>
			</td>
			"""
            % (seed_id, seed_guid.replace("&", "&amp;"), added_url_info, domain_id, domain_id, down_url)
            + """
			<td>%s</td>
			<td>%s</td>
			<td>%s</td>
			<td>%s</td>
			<td>%s</td>
			"""
            % (seed_name, generator, status, numbers, last_visit)
            + added_td_tags
            + """
			<td>
				<a href="/moon/crawl/data_add.py?sc_type=%s&seed_id=%s" target="_blank" >수정</a> &nbsp;|&nbsp;
				<a href="/moon/action/sc_common.py?sc_type=%s&cmd=blockSeed&seed_id=%s" target="_blank" >차단</a> &nbsp;|&nbsp;
				<a href="#" onclick="confirmPopup('%s','/moon/action/sc_common.py?cmd=del&sc_type=%s&_data_type=seed&seed_id=%s')">삭제</a>
				<br/><a href="/moon/action/sc_common.py?cmd=resetNoNewCount&sc_type=%s&seed_id=%s" target="_blank" >신규URL수 초기화</a>
				<br/><a href="/moon/domanager/pattern_add.py?urlTypeTestUrl=%s" target="_blank">URL추출 TEST</a>
			</td>
		</tr>
		"""
            % (
                sc_type,
                seed_id,
                sc_type,
                seed_id,
                seed_guid,
                sc_type,
                seed_id,
                sc_type,
                seed_id,
                urllib2.quote(down_url),
            )
        )
        html_table += html_row
        row_count += 1

        # MAKE PAGING HTML
    total_count = dao_util.getDataList(param_dic, "count")
    total_page = total_count / 15
    if (total_count % 15) > 0:
        total_page += 1
    html_paging = """
	<p>
		<b>페이지 [%s/%s]</b> : <b style='color:red;'>%s</b> 개중 <b style='color:red;'>%s</b> 개 표시
		&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
		<a href='/moon/crawl/seedurl_list.py?%s#tableDiv'>&lt;&lt;이전</a> || <a href='/moon/crawl/seedurl_list.py?%s#tableDiv'>다음&gt;&gt;</a>
	</p>
	""" % (
        param_dic["page"],
        total_page,
        total_count,
        len(data_list),
        prev_page_get_params,
        next_page_get_params,
    )

    return html_table + "</table>", html_paging