diff options
author | chai <chaifix@163.com> | 2018-01-25 20:07:15 +0800 |
---|---|---|
committer | chai <chaifix@163.com> | 2018-01-25 20:07:15 +0800 |
commit | a253c861daed44aad49ae9a195c9b0bc5d309134 (patch) | |
tree | a10782ea82b8d71a86ab2d8311ac630f0676786e | |
parent | 9b10aa27ce8aab1ba5a05369766136071f7f9957 (diff) |
修改
-rw-r--r-- | cgi-bin/.issue.html.un~ | bin | 1402 -> 14943 bytes | |||
-rw-r--r-- | cgi-bin/.issue.py.un~ | bin | 10920 -> 85310 bytes | |||
-rw-r--r-- | cgi-bin/.page.html.un~ | bin | 4339 -> 7876 bytes | |||
-rw-r--r-- | cgi-bin/.page.py.un~ | bin | 189770 -> 198461 bytes | |||
-rw-r--r-- | cgi-bin/.tag_unit.html.un~ | bin | 3497 -> 4962 bytes | |||
-rw-r--r-- | cgi-bin/.tags.py.un~ | bin | 0 -> 26004 bytes | |||
-rw-r--r-- | cgi-bin/add.py | 0 | ||||
-rw-r--r-- | cgi-bin/issue.html | 28 | ||||
-rw-r--r-- | cgi-bin/issue.py | 38 | ||||
-rw-r--r-- | cgi-bin/page.html | 1 | ||||
-rw-r--r-- | cgi-bin/page.py | 14 | ||||
-rw-r--r-- | cgi-bin/tag_unit.html | 2 | ||||
-rw-r--r-- | cgi-bin/tags.py | 41 | ||||
-rw-r--r-- | html/.style.css.un~ | bin | 42207 -> 42661 bytes | |||
-rw-r--r-- | html/style.css | 8 | ||||
-rw-r--r-- | sql/relation.sql | 0 |
16 files changed, 121 insertions, 11 deletions
diff --git a/cgi-bin/.issue.html.un~ b/cgi-bin/.issue.html.un~ Binary files differindex 7b7344e..69fa826 100644 --- a/cgi-bin/.issue.html.un~ +++ b/cgi-bin/.issue.html.un~ diff --git a/cgi-bin/.issue.py.un~ b/cgi-bin/.issue.py.un~ Binary files differindex 0ffc5cd..665ee64 100644 --- a/cgi-bin/.issue.py.un~ +++ b/cgi-bin/.issue.py.un~ diff --git a/cgi-bin/.page.html.un~ b/cgi-bin/.page.html.un~ Binary files differindex 0a10c4e..e3e37d6 100644 --- a/cgi-bin/.page.html.un~ +++ b/cgi-bin/.page.html.un~ diff --git a/cgi-bin/.page.py.un~ b/cgi-bin/.page.py.un~ Binary files differindex 8a6674f..8128fc8 100644 --- a/cgi-bin/.page.py.un~ +++ b/cgi-bin/.page.py.un~ diff --git a/cgi-bin/.tag_unit.html.un~ b/cgi-bin/.tag_unit.html.un~ Binary files differindex 5d4ea4a..ff82ead 100644 --- a/cgi-bin/.tag_unit.html.un~ +++ b/cgi-bin/.tag_unit.html.un~ diff --git a/cgi-bin/.tags.py.un~ b/cgi-bin/.tags.py.un~ Binary files differnew file mode 100644 index 0000000..9184da7 --- /dev/null +++ b/cgi-bin/.tags.py.un~ diff --git a/cgi-bin/add.py b/cgi-bin/add.py new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/cgi-bin/add.py diff --git a/cgi-bin/issue.html b/cgi-bin/issue.html index fd40910..129a531 100644 --- a/cgi-bin/issue.html +++ b/cgi-bin/issue.html @@ -1,4 +1,26 @@ - - - +<html> +<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> +<title>issues tags</title> +<body> +<link rel="stylesheet" href="style.css" type="text/css" /> +<div id="container"> + <img src="logo.png" id="logo"/> + <br/> + <div class="issue_container"> + <div class="issue_title"> + #{issueId} {issueTitle} + </div> + <div class="issue_tags"> + {tags} + </div> + <div class="issue_description"> + {issueDescription} + </div> + <div class="issue_solve"> + {issueSolve} + </div> + </div> +</div> +</body> +</html> diff --git a/cgi-bin/issue.py b/cgi-bin/issue.py index 84d84a7..83f6950 100644 --- a/cgi-bin/issue.py +++ b/cgi-bin/issue.py @@ -7,10 +7,46 @@ import issuedb from issuedb import IssueDBFactory sys.stdout = codecs.getwriter('utf8')(sys.stdout.buffer) +print("Content-type:text/html\n") + db = IssueDBFactory.produce() cursor = db.cursor() +tag_unit_html_file = open("tag_unit.html", 'r', encoding='utf8') issue_html_file = open("issue.html", 'r', encoding='utf8') +issue_html = issue_html_file.read() +tag_unit_html = tag_unit_html_file.read() + + +issue = "" + +#try: +issueId = cgi.FieldStorage().getvalue("id") +cursor.execute("select * from issue where issueId={0}".format(issueId)) +issue_content = cursor.fetchall() +issue_content = issue_content[0] + +if issue_content != None: + taglist = "" + cursor.execute("SELECT * FROM tag WHERE tagId IN (SELECT tagId FROM relation WHERE issueId = {0})".format(issueId)) + tags_rows = cursor.fetchall() + for tag_row in tags_rows: + tag = tag_unit_html.format(\ + tagid = tag_row[0], \ + tag_name = tag_row[1],\ + tag_count = '' \ + ) + taglist += tag + issue = issue_html.format( \ + issueId = issue_content[0], \ + issueTitle = issue_content[1],\ + issueDescription = issue_content[2],\ + issueSolve = issue_content[3],\ + tags = taglist\ + ) +print(issue) +#except Exception, e: +#print("Error: unable to fetch data \n" + e.message) + -print("Content-type:text/html\n") diff --git a/cgi-bin/page.html b/cgi-bin/page.html index 062171c..f5a5641 100644 --- a/cgi-bin/page.html +++ b/cgi-bin/page.html @@ -9,6 +9,7 @@ <input type="text" id="searchbar_input" name="content"/> <input type="submit" id="searchbar_submit" value="搜索"/> <a href="/tags">标签</a> + <a href="/add">添加</a> </form> <br/> <!--issues--> diff --git a/cgi-bin/page.py b/cgi-bin/page.py index 300069a..8bdbc0a 100644 --- a/cgi-bin/page.py +++ b/cgi-bin/page.py @@ -10,6 +10,8 @@ from config import Config sys.stdout = codecs.getwriter('utf8')(sys.stdout.buffer) +print("Content-type:text/html\n") + db = IssueDBFactory.produce() cursor = db.cursor() @@ -20,9 +22,13 @@ page_html = page_html_file.read() issue_unit_html = issue_unit_html_file.read() tag_unit_html = tag_unit_html_file.read() +issue_unit_html_file.close() +page_html_file.close() +tag_unit_html_file.close() + issues_list = "" issues_count = Config.get("config", "issues_count") -try: +try: cursor.execute("select * from issue limit 0, 10") issues_rows = cursor.fetchall() odd = True @@ -34,7 +40,8 @@ try: for tag_row in tags_rows: tag = tag_unit_html.format(\ tagid = tag_row[0], - tag_name = tag_row[1] + tag_name = tag_row[1], + tag_count = '' ) tagslist += tag issue = issue_unit_html.format(\ @@ -66,12 +73,9 @@ page = page_html.format(\ ) # HTTP header -print("Content-type:text/html\n") print(page) db.commit() cursor.close() db.close() -issue_unit_html_file.close() -page_html_file.close() diff --git a/cgi-bin/tag_unit.html b/cgi-bin/tag_unit.html index 0d173d6..2af9753 100644 --- a/cgi-bin/tag_unit.html +++ b/cgi-bin/tag_unit.html @@ -1 +1 @@ -<a class="tag_link" href="/search?tag={tagid}">{tag_name}</a> +<a class="tag_link" href="/search?tagid={tagid}">{tag_name}{tag_count}</a> diff --git a/cgi-bin/tags.py b/cgi-bin/tags.py index e69de29..4e018f6 100644 --- a/cgi-bin/tags.py +++ b/cgi-bin/tags.py @@ -0,0 +1,41 @@ +#!C:\Python364\python3.exe +# -*- coding: utf-8 -*- +import sys, codecs +import cgi, cgitb +import pymysql +import issuedb +import config +from issuedb import IssueDBFactory +from config import Config + +sys.stdout = codecs.getwriter('utf8')(sys.stdout.buffer) + +tag_unit_html_file = open("tag_unit.html", 'r', encoding='utf8') +tag_html_file = open("tags.html", 'r', encoding='utf8') +tag_unit_html = tag_unit_html_file.read() +tag_html = tag_html_file.read() + +db = IssueDBFactory.produce() +cursor = db.cursor() + +tagslist = "" +cursor.execute("SELECT tag.tagId, tagName, COUNT(*) FROM tag, relation WHERE \ + tag.tagId = relation.tagId GROUP BY tag.tagId;") +tags_rows = cursor.fetchall() +for tag_row in tags_rows: + tag = tag_unit_html.format(\ + tagid = tag_row[0], \ + tag_name = tag_row[1], \ + tag_count = '(' + str(tag_row[2]) + ')' \ + ) + tagslist += tag + +print("Content-type:text/html\n") +print(tag_html.format(tags = tagslist)) + +db.commit() +cursor.close() +db.close() +issue_unit_html_file.close() +page_html_file.close() + diff --git a/html/.style.css.un~ b/html/.style.css.un~ Binary files differindex fb56d1e..fcf7809 100644 --- a/html/.style.css.un~ +++ b/html/.style.css.un~ diff --git a/html/style.css b/html/style.css index 33c7f1c..8084580 100644 --- a/html/style.css +++ b/html/style.css @@ -18,7 +18,13 @@ } .tag_link{ - font-size: 80%; + font-size: 10px; + color: #ffffff; + background: #228B22; + text-decoration: none; + padding:0 3px; + border:0px solid; + border-radius:4px; } .issue_unit .tag_link{ diff --git a/sql/relation.sql b/sql/relation.sql new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/sql/relation.sql |