From 6562ad5da1548247e50c2b592332c9f56afda072 Mon Sep 17 00:00:00 2001 From: chai Date: Wed, 24 Jan 2018 20:04:34 +0800 Subject: =?UTF-8?q?*=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cgi-bin/.conf.ini.un~ | Bin 0 -> 4882 bytes cgi-bin/.conf.py.un~ | Bin 0 -> 2234 bytes cgi-bin/.config.py.un~ | Bin 0 -> 31412 bytes cgi-bin/.index.py.un~ | Bin 1371 -> 0 bytes cgi-bin/.issue.html.swp | Bin 0 -> 12288 bytes cgi-bin/.issue.html.un~ | Bin 0 -> 1402 bytes cgi-bin/.issue.py.swp | Bin 0 -> 12288 bytes cgi-bin/.issue.py.un~ | Bin 0 -> 10920 bytes cgi-bin/.issue_unit.html.swp | Bin 0 -> 12288 bytes cgi-bin/.issue_unit.html.un~ | Bin 0 -> 20181 bytes cgi-bin/.page.html.swp | Bin 0 -> 12288 bytes cgi-bin/.page.html.un~ | Bin 0 -> 4339 bytes cgi-bin/.page.py.swp | Bin 0 -> 12288 bytes cgi-bin/.page.py.un~ | Bin 0 -> 189770 bytes cgi-bin/.tag_unit.html.un~ | Bin 0 -> 3497 bytes cgi-bin/__pycache__/config.cpython-36.pyc | Bin 0 -> 566 bytes cgi-bin/__pycache__/issuedb.cpython-36.pyc | Bin 0 -> 593 bytes cgi-bin/conf.ini | 4 ++ cgi-bin/config.py | 12 +++++ cgi-bin/index.py | 6 --- cgi-bin/issue.html | 4 ++ cgi-bin/issue.py | 16 ++++++ cgi-bin/issue_unit.html | 8 +++ cgi-bin/issuedb.py | 14 ++++++ cgi-bin/page.html | 23 +++++++++ cgi-bin/page.py | 77 +++++++++++++++++++++++++++++ cgi-bin/tag_unit.html | 1 + cgi-bin/tags.html | 18 +++++++ cgi-bin/tags.py | 0 "doc/~$sql\350\241\250\346\240\274.docx" | Bin 0 -> 162 bytes html/.issue.html.un~ | Bin 10654 -> 0 bytes html/.style.css.swp | Bin 0 -> 12288 bytes html/.style.css.un~ | Bin 0 -> 42207 bytes html/issue.html | 7 --- html/logo.png | Bin 0 -> 1919 bytes html/style.css | 46 +++++++++++++++++ sql/issue.sql | 0 sql/tag.sql | 1 + 38 files changed, 224 insertions(+), 13 deletions(-) create mode 100644 cgi-bin/.conf.ini.un~ create mode 100644 cgi-bin/.conf.py.un~ create mode 100644 cgi-bin/.config.py.un~ delete mode 100644 cgi-bin/.index.py.un~ create mode 100644 cgi-bin/.issue.html.swp create mode 100644 cgi-bin/.issue.html.un~ create mode 100644 cgi-bin/.issue.py.swp create mode 100644 cgi-bin/.issue.py.un~ create mode 100644 cgi-bin/.issue_unit.html.swp create mode 100644 cgi-bin/.issue_unit.html.un~ create mode 100644 cgi-bin/.page.html.swp create mode 100644 cgi-bin/.page.html.un~ create mode 100644 cgi-bin/.page.py.swp create mode 100644 cgi-bin/.page.py.un~ create mode 100644 cgi-bin/.tag_unit.html.un~ create mode 100644 cgi-bin/__pycache__/config.cpython-36.pyc create mode 100644 cgi-bin/__pycache__/issuedb.cpython-36.pyc create mode 100644 cgi-bin/conf.ini create mode 100644 cgi-bin/config.py delete mode 100644 cgi-bin/index.py create mode 100644 cgi-bin/issue.html create mode 100644 cgi-bin/issue.py create mode 100644 cgi-bin/issue_unit.html create mode 100644 cgi-bin/issuedb.py create mode 100644 cgi-bin/page.html create mode 100644 cgi-bin/page.py create mode 100644 cgi-bin/tag_unit.html create mode 100644 cgi-bin/tags.html create mode 100644 cgi-bin/tags.py create mode 100644 "doc/~$sql\350\241\250\346\240\274.docx" delete mode 100644 html/.issue.html.un~ create mode 100644 html/.style.css.swp create mode 100644 html/.style.css.un~ delete mode 100644 html/issue.html create mode 100644 html/logo.png create mode 100644 html/style.css create mode 100644 sql/issue.sql create mode 100644 sql/tag.sql diff --git a/cgi-bin/.conf.ini.un~ b/cgi-bin/.conf.ini.un~ new file mode 100644 index 0000000..3d1e5b5 Binary files /dev/null and b/cgi-bin/.conf.ini.un~ differ diff --git a/cgi-bin/.conf.py.un~ b/cgi-bin/.conf.py.un~ new file mode 100644 index 0000000..ea49443 Binary files /dev/null and b/cgi-bin/.conf.py.un~ differ diff --git a/cgi-bin/.config.py.un~ b/cgi-bin/.config.py.un~ new file mode 100644 index 0000000..9271503 Binary files /dev/null and b/cgi-bin/.config.py.un~ differ diff --git a/cgi-bin/.index.py.un~ b/cgi-bin/.index.py.un~ deleted file mode 100644 index d403562..0000000 Binary files a/cgi-bin/.index.py.un~ and /dev/null differ diff --git a/cgi-bin/.issue.html.swp b/cgi-bin/.issue.html.swp new file mode 100644 index 0000000..109533d Binary files /dev/null and b/cgi-bin/.issue.html.swp differ diff --git a/cgi-bin/.issue.html.un~ b/cgi-bin/.issue.html.un~ new file mode 100644 index 0000000..7b7344e Binary files /dev/null and b/cgi-bin/.issue.html.un~ differ diff --git a/cgi-bin/.issue.py.swp b/cgi-bin/.issue.py.swp new file mode 100644 index 0000000..7dde80a Binary files /dev/null and b/cgi-bin/.issue.py.swp differ diff --git a/cgi-bin/.issue.py.un~ b/cgi-bin/.issue.py.un~ new file mode 100644 index 0000000..0ffc5cd Binary files /dev/null and b/cgi-bin/.issue.py.un~ differ diff --git a/cgi-bin/.issue_unit.html.swp b/cgi-bin/.issue_unit.html.swp new file mode 100644 index 0000000..c1e2409 Binary files /dev/null and b/cgi-bin/.issue_unit.html.swp differ diff --git a/cgi-bin/.issue_unit.html.un~ b/cgi-bin/.issue_unit.html.un~ new file mode 100644 index 0000000..fa271bd Binary files /dev/null and b/cgi-bin/.issue_unit.html.un~ differ diff --git a/cgi-bin/.page.html.swp b/cgi-bin/.page.html.swp new file mode 100644 index 0000000..d7bb0e0 Binary files /dev/null and b/cgi-bin/.page.html.swp differ diff --git a/cgi-bin/.page.html.un~ b/cgi-bin/.page.html.un~ new file mode 100644 index 0000000..0a10c4e Binary files /dev/null and b/cgi-bin/.page.html.un~ differ diff --git a/cgi-bin/.page.py.swp b/cgi-bin/.page.py.swp new file mode 100644 index 0000000..d900e49 Binary files /dev/null and b/cgi-bin/.page.py.swp differ diff --git a/cgi-bin/.page.py.un~ b/cgi-bin/.page.py.un~ new file mode 100644 index 0000000..8a6674f Binary files /dev/null and b/cgi-bin/.page.py.un~ differ diff --git a/cgi-bin/.tag_unit.html.un~ b/cgi-bin/.tag_unit.html.un~ new file mode 100644 index 0000000..5d4ea4a Binary files /dev/null and b/cgi-bin/.tag_unit.html.un~ differ diff --git a/cgi-bin/__pycache__/config.cpython-36.pyc b/cgi-bin/__pycache__/config.cpython-36.pyc new file mode 100644 index 0000000..e280003 Binary files /dev/null and b/cgi-bin/__pycache__/config.cpython-36.pyc differ diff --git a/cgi-bin/__pycache__/issuedb.cpython-36.pyc b/cgi-bin/__pycache__/issuedb.cpython-36.pyc new file mode 100644 index 0000000..134c4de Binary files /dev/null and b/cgi-bin/__pycache__/issuedb.cpython-36.pyc differ 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/index.py deleted file mode 100644 index 6fb66a5..0000000 --- a/cgi-bin/index.py +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - diff --git a/cgi-bin/issue.html b/cgi-bin/issue.html new file mode 100644 index 0000000..fd40910 --- /dev/null +++ b/cgi-bin/issue.html @@ -0,0 +1,4 @@ + + + + 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 @@ +
+ #{issueid} {title} +
+ {tags} +
+ {description} +
+
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 @@ + + +issues + + +
+ + +
+ + {issues} + +
+ <上一页 + 下一页> +
+ + + 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 @@ +{tag_name} 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 @@ + + +issues tags + + +
+ +
+
+ + + {tags} + +
+
+ + + diff --git a/cgi-bin/tags.py b/cgi-bin/tags.py new file mode 100644 index 0000000..e69de29 diff --git "a/doc/~$sql\350\241\250\346\240\274.docx" "b/doc/~$sql\350\241\250\346\240\274.docx" new file mode 100644 index 0000000..6dbfe9b Binary files /dev/null and "b/doc/~$sql\350\241\250\346\240\274.docx" differ diff --git a/html/.issue.html.un~ b/html/.issue.html.un~ deleted file mode 100644 index e2b008e..0000000 Binary files a/html/.issue.html.un~ and /dev/null differ diff --git a/html/.style.css.swp b/html/.style.css.swp new file mode 100644 index 0000000..b244fc6 Binary files /dev/null and b/html/.style.css.swp differ diff --git a/html/.style.css.un~ b/html/.style.css.un~ new file mode 100644 index 0000000..fb56d1e Binary files /dev/null and b/html/.style.css.un~ differ 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 @@ - -{name} - - - - - diff --git a/html/logo.png b/html/logo.png new file mode 100644 index 0000000..a640254 Binary files /dev/null and b/html/logo.png differ 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 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 -- cgit v1.1-26-g67d0