diff options
author | chai <chaifix@163.com> | 2018-01-24 20:04:34 +0800 |
---|---|---|
committer | chai <chaifix@163.com> | 2018-01-24 20:04:34 +0800 |
commit | 6562ad5da1548247e50c2b592332c9f56afda072 (patch) | |
tree | 9b8adbf557d0d7126ca16aee29d1c603e1705e14 | |
parent | 131cf12827e64f527da69251b6a6221d130c1cc7 (diff) |
*修改
-rw-r--r-- | cgi-bin/.conf.ini.un~ | bin | 0 -> 4882 bytes | |||
-rw-r--r-- | cgi-bin/.conf.py.un~ | bin | 0 -> 2234 bytes | |||
-rw-r--r-- | cgi-bin/.config.py.un~ | bin | 0 -> 31412 bytes | |||
-rw-r--r-- | cgi-bin/.issue.html.swp | bin | 0 -> 12288 bytes | |||
-rw-r--r-- | cgi-bin/.issue.html.un~ (renamed from cgi-bin/.index.py.un~) | bin | 1371 -> 1402 bytes | |||
-rw-r--r-- | cgi-bin/.issue.py.swp | bin | 0 -> 12288 bytes | |||
-rw-r--r-- | cgi-bin/.issue.py.un~ (renamed from html/.issue.html.un~) | bin | 10654 -> 10920 bytes | |||
-rw-r--r-- | cgi-bin/.issue_unit.html.swp | bin | 0 -> 12288 bytes | |||
-rw-r--r-- | cgi-bin/.issue_unit.html.un~ | bin | 0 -> 20181 bytes | |||
-rw-r--r-- | cgi-bin/.page.html.swp | bin | 0 -> 12288 bytes | |||
-rw-r--r-- | cgi-bin/.page.html.un~ | bin | 0 -> 4339 bytes | |||
-rw-r--r-- | cgi-bin/.page.py.swp | bin | 0 -> 12288 bytes | |||
-rw-r--r-- | cgi-bin/.page.py.un~ | bin | 0 -> 189770 bytes | |||
-rw-r--r-- | cgi-bin/.tag_unit.html.un~ | bin | 0 -> 3497 bytes | |||
-rw-r--r-- | cgi-bin/__pycache__/config.cpython-36.pyc | bin | 0 -> 566 bytes | |||
-rw-r--r-- | cgi-bin/__pycache__/issuedb.cpython-36.pyc | bin | 0 -> 593 bytes | |||
-rw-r--r-- | cgi-bin/conf.ini | 4 | ||||
-rw-r--r-- | cgi-bin/config.py | 12 | ||||
-rw-r--r-- | cgi-bin/issue.html (renamed from cgi-bin/index.py) | 2 | ||||
-rw-r--r-- | cgi-bin/issue.py | 16 | ||||
-rw-r--r-- | cgi-bin/issue_unit.html | 8 | ||||
-rw-r--r-- | cgi-bin/issuedb.py | 14 | ||||
-rw-r--r-- | cgi-bin/page.html | 23 | ||||
-rw-r--r-- | cgi-bin/page.py | 77 | ||||
-rw-r--r-- | cgi-bin/tag_unit.html | 1 | ||||
-rw-r--r-- | cgi-bin/tags.html | 18 | ||||
-rw-r--r-- | cgi-bin/tags.py | 0 | ||||
-rw-r--r-- | doc/~$sql表格.docx | bin | 0 -> 162 bytes | |||
-rw-r--r-- | html/.style.css.swp | bin | 0 -> 12288 bytes | |||
-rw-r--r-- | html/.style.css.un~ | bin | 0 -> 42207 bytes | |||
-rw-r--r-- | html/issue.html | 7 | ||||
-rw-r--r-- | html/logo.png | bin | 0 -> 1919 bytes | |||
-rw-r--r-- | html/style.css | 46 | ||||
-rw-r--r-- | sql/issue.sql | 0 | ||||
-rw-r--r-- | sql/tag.sql | 1 |
35 files changed, 220 insertions, 9 deletions
diff --git a/cgi-bin/.conf.ini.un~ b/cgi-bin/.conf.ini.un~ Binary files differnew file mode 100644 index 0000000..3d1e5b5 --- /dev/null +++ b/cgi-bin/.conf.ini.un~ diff --git a/cgi-bin/.conf.py.un~ b/cgi-bin/.conf.py.un~ Binary files differnew file mode 100644 index 0000000..ea49443 --- /dev/null +++ b/cgi-bin/.conf.py.un~ diff --git a/cgi-bin/.config.py.un~ b/cgi-bin/.config.py.un~ Binary files differnew file mode 100644 index 0000000..9271503 --- /dev/null +++ b/cgi-bin/.config.py.un~ diff --git a/cgi-bin/.issue.html.swp b/cgi-bin/.issue.html.swp Binary files differnew file mode 100644 index 0000000..109533d --- /dev/null +++ b/cgi-bin/.issue.html.swp diff --git a/cgi-bin/.index.py.un~ b/cgi-bin/.issue.html.un~ Binary files differindex d403562..7b7344e 100644 --- a/cgi-bin/.index.py.un~ +++ b/cgi-bin/.issue.html.un~ diff --git a/cgi-bin/.issue.py.swp b/cgi-bin/.issue.py.swp Binary files differnew file mode 100644 index 0000000..7dde80a --- /dev/null +++ b/cgi-bin/.issue.py.swp diff --git a/html/.issue.html.un~ b/cgi-bin/.issue.py.un~ Binary files differindex e2b008e..0ffc5cd 100644 --- a/html/.issue.html.un~ +++ b/cgi-bin/.issue.py.un~ diff --git a/cgi-bin/.issue_unit.html.swp b/cgi-bin/.issue_unit.html.swp Binary files differnew file mode 100644 index 0000000..c1e2409 --- /dev/null +++ b/cgi-bin/.issue_unit.html.swp diff --git a/cgi-bin/.issue_unit.html.un~ b/cgi-bin/.issue_unit.html.un~ Binary files differnew file mode 100644 index 0000000..fa271bd --- /dev/null +++ b/cgi-bin/.issue_unit.html.un~ diff --git a/cgi-bin/.page.html.swp b/cgi-bin/.page.html.swp Binary files differnew file mode 100644 index 0000000..d7bb0e0 --- /dev/null +++ b/cgi-bin/.page.html.swp diff --git a/cgi-bin/.page.html.un~ b/cgi-bin/.page.html.un~ Binary files differnew file mode 100644 index 0000000..0a10c4e --- /dev/null +++ b/cgi-bin/.page.html.un~ diff --git a/cgi-bin/.page.py.swp b/cgi-bin/.page.py.swp Binary files differnew file mode 100644 index 0000000..d900e49 --- /dev/null +++ b/cgi-bin/.page.py.swp diff --git a/cgi-bin/.page.py.un~ b/cgi-bin/.page.py.un~ Binary files differnew file mode 100644 index 0000000..8a6674f --- /dev/null +++ b/cgi-bin/.page.py.un~ diff --git a/cgi-bin/.tag_unit.html.un~ b/cgi-bin/.tag_unit.html.un~ Binary files differnew file mode 100644 index 0000000..5d4ea4a --- /dev/null +++ b/cgi-bin/.tag_unit.html.un~ diff --git a/cgi-bin/__pycache__/config.cpython-36.pyc b/cgi-bin/__pycache__/config.cpython-36.pyc Binary files differnew file mode 100644 index 0000000..e280003 --- /dev/null +++ b/cgi-bin/__pycache__/config.cpython-36.pyc diff --git a/cgi-bin/__pycache__/issuedb.cpython-36.pyc b/cgi-bin/__pycache__/issuedb.cpython-36.pyc Binary files differnew file mode 100644 index 0000000..134c4de --- /dev/null +++ b/cgi-bin/__pycache__/issuedb.cpython-36.pyc diff --git a/cgi-bin/conf.ini b/cgi-bin/conf.ini new file mode 100644 index 0000000..c4f21cd --- /dev/null +++ b/cgi-bin/conf.ini @@ -0,0 +1,4 @@ +[config] +issues_count = 10 + + diff --git a/cgi-bin/config.py b/cgi-bin/config.py new file mode 100644 index 0000000..e856beb --- /dev/null +++ b/cgi-bin/config.py @@ -0,0 +1,12 @@ +# parse conf.ini +# -*- coding: utf-8 -*- +import configparser, codecs, sys + +conf = configparser.ConfigParser() +conf.read("conf.ini") + +class Config(object): + @classmethod + def get(cls, section, option): + return conf.get(section, option) + diff --git a/cgi-bin/index.py b/cgi-bin/issue.html index 6fb66a5..fd40910 100644 --- a/cgi-bin/index.py +++ b/cgi-bin/issue.html @@ -2,5 +2,3 @@ - - diff --git a/cgi-bin/issue.py b/cgi-bin/issue.py new file mode 100644 index 0000000..84d84a7 --- /dev/null +++ b/cgi-bin/issue.py @@ -0,0 +1,16 @@ +#!C:\Python364\python3.exe +# -*- coding: utf-8 -*- +import sys, codecs +import cgi, cgitb +import pymysql +import issuedb +from issuedb import IssueDBFactory +sys.stdout = codecs.getwriter('utf8')(sys.stdout.buffer) + +db = IssueDBFactory.produce() +cursor = db.cursor() + +issue_html_file = open("issue.html", 'r', encoding='utf8') + + +print("Content-type:text/html\n") diff --git a/cgi-bin/issue_unit.html b/cgi-bin/issue_unit.html new file mode 100644 index 0000000..b4d5fd6 --- /dev/null +++ b/cgi-bin/issue_unit.html @@ -0,0 +1,8 @@ +<div class="issue_unit issue_unit_{oddoreven}"> + <a href="/issue?id={issueid}">#{issueid} {title}</a> + <br/> + {tags} + <br/> + {description} + <br/> +</div> diff --git a/cgi-bin/issuedb.py b/cgi-bin/issuedb.py new file mode 100644 index 0000000..faa6bc6 --- /dev/null +++ b/cgi-bin/issuedb.py @@ -0,0 +1,14 @@ +import pymysql + +host = "localhost" +port = 3306 +user = "root" +passwd = "root" +db = "issues" + + +class IssueDBFactory(object): + def produce(): + issuedb = pymysql.connect(host, user, passwd, db) + return issuedb + diff --git a/cgi-bin/page.html b/cgi-bin/page.html new file mode 100644 index 0000000..062171c --- /dev/null +++ b/cgi-bin/page.html @@ -0,0 +1,23 @@ +<html> +<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> +<title>issues</title> +<body> +<link rel="stylesheet" href="style.css" type="text/css" /> +<div id="container"> + <img src="logo.png" id="logo"/> + <form action="/search" method="get" id="searchbar"> + <input type="text" id="searchbar_input" name="content"/> + <input type="submit" id="searchbar_submit" value="搜索"/> + <a href="/tags">标签</a> + </form> + <br/> + <!--issues--> + {issues} + <!--issues end--> + <br/> + <a href="/page?p={page_prev}" id="pagejump_prev" class="pagejump"><上一页</a> + <a href="/page?p={page_next}" id="pagejump_next" class="pagejump">下一页></a> +</div> +</body> +</html> + diff --git a/cgi-bin/page.py b/cgi-bin/page.py new file mode 100644 index 0000000..300069a --- /dev/null +++ b/cgi-bin/page.py @@ -0,0 +1,77 @@ +#!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) + +db = IssueDBFactory.produce() +cursor = db.cursor() + +tag_unit_html_file = open("tag_unit.html", 'r', encoding='utf8') +page_html_file = open("page.html", 'r', encoding= 'utf8') +issue_unit_html_file = open("issue_unit.html", 'r', encoding = 'utf8') +page_html = page_html_file.read() +issue_unit_html = issue_unit_html_file.read() +tag_unit_html = tag_unit_html_file.read() + +issues_list = "" +issues_count = Config.get("config", "issues_count") +try: + cursor.execute("select * from issue limit 0, 10") + issues_rows = cursor.fetchall() + odd = True + for row in issues_rows: + tagslist = "" + cursor.execute("select * from tag where tagId in (select tagId from \ + relation where issueId = {0})".format(row[0])) + tags_rows = cursor.fetchall() + for tag_row in tags_rows: + tag = tag_unit_html.format(\ + tagid = tag_row[0], + tag_name = tag_row[1] + ) + tagslist += tag + issue = issue_unit_html.format(\ + issueid = row[0], \ + title = row[1], \ + description = row[2], \ + tags = tagslist, \ + oddoreven = ((odd == True) and "odd" or "even") + ) + odd = not odd + issues_list += issue +except: + print("Error: unable to fetch data") + +#处理页号 +form = cgi.FieldStorage() +pagen = form.getvalue('p') +if pagen == None: + pagen = 0 +pageprev = pagen - 1 +if pageprev < 0: + pageprev = 0 +pagenext = pagen + 1 + +page = page_html.format(\ + issues = issues_list, \ + page_prev = pageprev, \ + page_next = pagenext,\ +) + +# 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 new file mode 100644 index 0000000..0d173d6 --- /dev/null +++ b/cgi-bin/tag_unit.html @@ -0,0 +1 @@ +<a class="tag_link" href="/search?tag={tagid}">{tag_name}</a> diff --git a/cgi-bin/tags.html b/cgi-bin/tags.html new file mode 100644 index 0000000..1714a78 --- /dev/null +++ b/cgi-bin/tags.html @@ -0,0 +1,18 @@ +<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 id="tags_container"> + <!--tags--> + <!--根据tag_unit.html生成的一些tag条目--> + {tags} + <!--tags end--> + </div> +</div> +</body> +</html> + diff --git a/cgi-bin/tags.py b/cgi-bin/tags.py new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/cgi-bin/tags.py diff --git a/doc/~$sql表格.docx b/doc/~$sql表格.docx Binary files differnew file mode 100644 index 0000000..6dbfe9b --- /dev/null +++ b/doc/~$sql表格.docx diff --git a/html/.style.css.swp b/html/.style.css.swp Binary files differnew file mode 100644 index 0000000..b244fc6 --- /dev/null +++ b/html/.style.css.swp diff --git a/html/.style.css.un~ b/html/.style.css.un~ Binary files differnew file mode 100644 index 0000000..fb56d1e --- /dev/null +++ b/html/.style.css.un~ diff --git a/html/issue.html b/html/issue.html deleted file mode 100644 index aaba09c..0000000 --- a/html/issue.html +++ /dev/null @@ -1,7 +0,0 @@ -<!--issue条目--> -<a href="" >{name}</a> - - - - - diff --git a/html/logo.png b/html/logo.png Binary files differnew file mode 100644 index 0000000..a640254 --- /dev/null +++ b/html/logo.png diff --git a/html/style.css b/html/style.css new file mode 100644 index 0000000..33c7f1c --- /dev/null +++ b/html/style.css @@ -0,0 +1,46 @@ +#container{ + width:640; +} + +#pagejump_next{ + float:right; +} + +#logo{ +} + +#searchbar{ + clear:both; +} + +#searchbar_input{ + width:40%; +} + +.tag_link{ + font-size: 80%; +} + +.issue_unit .tag_link{ + font-size: 10px; + color: #ffffff; + background: #228B22; + text-decoration: none; + padding:0 3px; + border:0px solid; + border-radius:4px; +} + +.issue_unit{ + /*margin-top: 10px;*/ + padding: 3px; +} + +.issue_unit_odd{ + background: #f7f7f7; +} + +.issue_unit_even{ + background: #ffffff; +} + diff --git a/sql/issue.sql b/sql/issue.sql new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/sql/issue.sql diff --git a/sql/tag.sql b/sql/tag.sql new file mode 100644 index 0000000..e82f07f --- /dev/null +++ b/sql/tag.sql @@ -0,0 +1 @@ +`relation`
\ No newline at end of file |