From 7ca80e57f06922e464626c7a6a1d7965e716b53f Mon Sep 17 00:00:00 2001 From: chai Date: Fri, 13 Jul 2018 21:53:49 +0800 Subject: update --- cgi-bin/.whisper.py.un~ | Bin 13233 -> 0 bytes cgi-bin/__pycache__/path.cpython-36.pyc | Bin 793 -> 951 bytes cgi-bin/add.py | 63 --------------------------- cgi-bin/config.ini | 13 ------ cgi-bin/config.py | 10 ----- cgi-bin/connect.py | 13 ------ cgi-bin/delete.py | 36 --------------- cgi-bin/edit.py | 46 -------------------- cgi-bin/html/ckeditor/config.js | 3 +- cgi-bin/html/imgs/1531471283.png | Bin 0 -> 442 bytes cgi-bin/html/imgs/1531471337.png | Bin 0 -> 442 bytes cgi-bin/html/imgs/1531471469.jpg | Bin 0 -> 876735 bytes cgi-bin/html/imgs/1531471899.jpg | Bin 0 -> 876735 bytes cgi-bin/html/imgs/1531471931.png | Bin 0 -> 442 bytes cgi-bin/html/style.css | 5 +++ cgi-bin/page.py | 75 -------------------------------- cgi-bin/path.py | 20 --------- cgi-bin/template/.whisper.html.un~ | Bin 523 -> 0 bytes cgi-bin/template/edit.html | 20 --------- cgi-bin/template/page.html | 37 ---------------- cgi-bin/template/whisper.html | 10 ----- cgi-bin/whisper.py | 19 -------- 22 files changed, 7 insertions(+), 363 deletions(-) delete mode 100644 cgi-bin/.whisper.py.un~ delete mode 100644 cgi-bin/add.py delete mode 100644 cgi-bin/config.ini delete mode 100644 cgi-bin/config.py delete mode 100644 cgi-bin/connect.py delete mode 100644 cgi-bin/delete.py delete mode 100644 cgi-bin/edit.py create mode 100644 cgi-bin/html/imgs/1531471283.png create mode 100644 cgi-bin/html/imgs/1531471337.png create mode 100644 cgi-bin/html/imgs/1531471469.jpg create mode 100644 cgi-bin/html/imgs/1531471899.jpg create mode 100644 cgi-bin/html/imgs/1531471931.png delete mode 100644 cgi-bin/page.py delete mode 100644 cgi-bin/path.py delete mode 100644 cgi-bin/template/.whisper.html.un~ delete mode 100644 cgi-bin/template/edit.html delete mode 100644 cgi-bin/template/page.html delete mode 100644 cgi-bin/template/whisper.html delete mode 100644 cgi-bin/whisper.py (limited to 'cgi-bin') diff --git a/cgi-bin/.whisper.py.un~ b/cgi-bin/.whisper.py.un~ deleted file mode 100644 index 4f409c2..0000000 Binary files a/cgi-bin/.whisper.py.un~ and /dev/null differ diff --git a/cgi-bin/__pycache__/path.cpython-36.pyc b/cgi-bin/__pycache__/path.cpython-36.pyc index c1e0d7b..11d1331 100644 Binary files a/cgi-bin/__pycache__/path.cpython-36.pyc and b/cgi-bin/__pycache__/path.cpython-36.pyc differ diff --git a/cgi-bin/add.py b/cgi-bin/add.py deleted file mode 100644 index e3a7d4e..0000000 --- a/cgi-bin/add.py +++ /dev/null @@ -1,63 +0,0 @@ -#!D:/Programs/Python3/python.exe -# -*- coding: utf-8 -*- -import cgi, cgitb -import pymysql -import sys, codecs -import configparser, codecs -import connect -from connect import Connect -import config -from config import Config -import path -from path import Path -import time - -sys.stdout = codecs.getwriter('utf8')(sys.stdout.buffer) -print("Content-type:text/html\n") - -form = cgi.FieldStorage() -action = form.getvalue('action') -if action == "modify": - whisper_content = form.getvalue('whisper_content') - if whisper_content == None: - whisper_content = "" - whisper_id = form.getvalue('whisper_id') - db = Connect.produce() - cursor = db.cursor() - query = "update whisper set content = '{0}' where id = {1}".format(pymysql.escape_string(whisper_content), whisper_id) - cursor.execute(query) - db.commit() - cursor.close() - db.close() - _url = Config.get("route", "url") - redirect = """ - - - - - - """.format(_url) - print(redirect) -elif action == "new": - whisper_content = form.getvalue('whisper_content') - if whisper_content == None: - whisper_content = "" - t = time.time() - db = Connect.produce() - cursor = db.cursor() - query = "insert into whisper (content, date) values ('{0}', '{1}')".format(pymysql.escape_string(whisper_content), t) - cursor.execute(query) - db.commit() - cursor.close() - db.close() - _url = Config.get("route", "url") - redirect = """ - - - - - - """.format(_url) - print(redirect) -else: - print("Invalid action") \ No newline at end of file diff --git a/cgi-bin/config.ini b/cgi-bin/config.ini deleted file mode 100644 index 7dfc0e1..0000000 --- a/cgi-bin/config.ini +++ /dev/null @@ -1,13 +0,0 @@ -[route] -url=/cgi-bin -static=/html -images=/html/imgs -templates=./template -[database] -user=root -passwd=root -host=localhost -port=3306 -db=whisper -[config] -whisper_count=15 diff --git a/cgi-bin/config.py b/cgi-bin/config.py deleted file mode 100644 index 539ed6c..0000000 --- a/cgi-bin/config.py +++ /dev/null @@ -1,10 +0,0 @@ -# -*- coding: utf-8 -*- -import configparser, codecs, sys - -conf = configparser.ConfigParser() -conf.read("config.ini") - -class Config(object): - @classmethod - def get(cls, section, option): - return conf.get(section, option) diff --git a/cgi-bin/connect.py b/cgi-bin/connect.py deleted file mode 100644 index 09c1942..0000000 --- a/cgi-bin/connect.py +++ /dev/null @@ -1,13 +0,0 @@ -import pymysql -import config -from config import Config - -host = Config.get("database", "host") -port = Config.get("database", "port") -user = Config.get("database", "user") -passwd = Config.get("database", "passwd") -db = Config.get("database", "db") -class Connect(object): - def produce(): - return pymysql.connect(host, user, passwd, db) - diff --git a/cgi-bin/delete.py b/cgi-bin/delete.py deleted file mode 100644 index 7c728a4..0000000 --- a/cgi-bin/delete.py +++ /dev/null @@ -1,36 +0,0 @@ -#!D:/Programs/Python3/python.exe -# -*- coding: utf-8 -*- -import cgi, cgitb -import pymysql -import sys, codecs -import configparser, codecs -import connect -from connect import Connect -import config -from config import Config -import path -from path import Path - -sys.stdout = codecs.getwriter('utf8')(sys.stdout.buffer) -print("Content-type:text/html\n") -form = cgi.FieldStorage() -w = form.getvalue('w') -if w == None: - print("Invalid whisper") -else: - db = Connect.produce() - cursor = db.cursor() - query = "delete from whisper where id={0}".format(int(w)) - cursor.execute(query) - db.commit() - cursor.close() - db.close() - _url = Config.get("route", "url") - redirect = """ - - - - - - """.format(_url) - print(redirect) \ No newline at end of file diff --git a/cgi-bin/edit.py b/cgi-bin/edit.py deleted file mode 100644 index b0a899d..0000000 --- a/cgi-bin/edit.py +++ /dev/null @@ -1,46 +0,0 @@ -#!D:/Programs/Python3/python.exe -# -*- coding: utf-8 -*- -import cgi, cgitb -import pymysql -import sys, codecs -import configparser, codecs -import connect -from connect import Connect -import config -from config import Config -import path -from path import Path - -sys.stdout = codecs.getwriter('utf8')(sys.stdout.buffer) -print("Content-type:text/html\n") -form = cgi.FieldStorage() -w = form.getvalue('w') -if w == None: - print("Invalid whisper") -else: - db = Connect.produce() - cursor = db.cursor() - - query_whisper = "select * from whisper where id={0}".format(w) - cursor.execute(query_whisper) - whisper = cursor.fetchone() - - edit_file = open(Path.template("edit.html"), 'r', encoding="utf8") - edit_templ = edit_file.read() - edit_file.close() - - _url = Config.get("route", "url") - _static = Config.get("route", "static") - - edit_html = edit_templ.format( \ - url = _url, - static = _static, - whisper_id = w, - whisper_content = whisper[1] - ) - - print(edit_html) - - db.commit() - cursor.close() - db.close() diff --git a/cgi-bin/html/ckeditor/config.js b/cgi-bin/html/ckeditor/config.js index 048198a..39a6e85 100644 --- a/cgi-bin/html/ckeditor/config.js +++ b/cgi-bin/html/ckeditor/config.js @@ -35,6 +35,7 @@ CKEDITOR.editorConfig = function( config ) { // Simplify the dialog windows. config.removeDialogTabs = 'image:advanced;link:advanced'; - config.filebrowserImageUploadUrl = "/cgi-bin/"; + config.filebrowserImageUploadUrl = "/chai/whisper/imguploader.py"; config.height = 100; + config.image_prefillDimensions = false; }; diff --git a/cgi-bin/html/imgs/1531471283.png b/cgi-bin/html/imgs/1531471283.png new file mode 100644 index 0000000..0d11f85 Binary files /dev/null and b/cgi-bin/html/imgs/1531471283.png differ diff --git a/cgi-bin/html/imgs/1531471337.png b/cgi-bin/html/imgs/1531471337.png new file mode 100644 index 0000000..0d11f85 Binary files /dev/null and b/cgi-bin/html/imgs/1531471337.png differ diff --git a/cgi-bin/html/imgs/1531471469.jpg b/cgi-bin/html/imgs/1531471469.jpg new file mode 100644 index 0000000..5932b51 Binary files /dev/null and b/cgi-bin/html/imgs/1531471469.jpg differ diff --git a/cgi-bin/html/imgs/1531471899.jpg b/cgi-bin/html/imgs/1531471899.jpg new file mode 100644 index 0000000..5932b51 Binary files /dev/null and b/cgi-bin/html/imgs/1531471899.jpg differ diff --git a/cgi-bin/html/imgs/1531471931.png b/cgi-bin/html/imgs/1531471931.png new file mode 100644 index 0000000..0d11f85 Binary files /dev/null and b/cgi-bin/html/imgs/1531471931.png differ diff --git a/cgi-bin/html/style.css b/cgi-bin/html/style.css index d3b9e3f..f9525f0 100644 --- a/cgi-bin/html/style.css +++ b/cgi-bin/html/style.css @@ -56,6 +56,11 @@ color : #3ea17c; } +.whisper_content img +{ + max-width: 100%; +} + #pagejump_next { float:right; diff --git a/cgi-bin/page.py b/cgi-bin/page.py deleted file mode 100644 index b776d8e..0000000 --- a/cgi-bin/page.py +++ /dev/null @@ -1,75 +0,0 @@ -#!D:/Programs/Python3/python.exe -# -*- coding: utf-8 -*- -import cgi, cgitb -import pymysql -import sys, codecs -import configparser, codecs -import connect -from connect import Connect -import whisper -from whisper import Whisper -import config -from config import Config -import path -from path import Path - -sys.stdout = codecs.getwriter('utf8')(sys.stdout.buffer) - -_url = Config.get("route", "url") -_static = Config.get("route", "static") -_whiperperpage = int(Config.get("config", "whisper_count")) - -page_file = open(Path.template("page.html"), 'r', encoding="utf8") -page_templ = page_file.read() -page_file.close() - -pagen = cgi.FieldStorage().getvalue('p') -if pagen == None: - pagen = 0 -else: - pagen = int(pagen) -pageprev = pagen - 1 -if pageprev < 0: - pageprev = 0 -pagenext = pagen + 1 - -# class PageBuilder(object): -# def build(pagen): -print("Content-type:text/html\n") - -db = Connect.produce() -cursor = db.cursor() - -query_count = "select COUNT(*) from whisper" -cursor.execute(query_count) -whispercount = cursor.fetchone() -whispercount = whispercount[0] - -query_allwhisper = "select * from whisper ORDER BY id DESC LIMIT {0}, {1}".format(pagen * _whiperperpage, _whiperperpage) -cursor.execute(query_allwhisper) - -_whispers = "" -whispersdata = cursor.fetchall() -odd = True -count = 0 -for whisper in whispersdata: - count = count + 1 - _whispers += Whisper.build(whisper[0], whisper[1], whisper[2], odd, _url) - odd = not odd - -if pagen * _whiperperpage + count >= whispercount: - pagenext = pagen - -page = page_templ.format(\ - url = _url, - static = _static, - whispers = _whispers, - page_prev = pageprev, - page_next = pagenext -) - -print(page) - -db.commit() -cursor.close() -db.close() diff --git a/cgi-bin/path.py b/cgi-bin/path.py deleted file mode 100644 index e4ad756..0000000 --- a/cgi-bin/path.py +++ /dev/null @@ -1,20 +0,0 @@ -# -*- coding: utf-8 -*- -import config -from config import Config - -root = Config.get("route", "url") -imgsDir = Config.get("route", "images") -templDir = Config.get("route", "templates") - -class Path(object): - # 拼接url - def url(path): - return root + '/' + path - - # 保存的图片路径 - def img(imgFile): - return root + imgsDir + '/' + imgFile - - # html模板路径 - def template(templ): - return templDir + '/' + templ diff --git a/cgi-bin/template/.whisper.html.un~ b/cgi-bin/template/.whisper.html.un~ deleted file mode 100644 index 70eaf48..0000000 Binary files a/cgi-bin/template/.whisper.html.un~ and /dev/null differ diff --git a/cgi-bin/template/edit.html b/cgi-bin/template/edit.html deleted file mode 100644 index bc8cea0..0000000 --- a/cgi-bin/template/edit.html +++ /dev/null @@ -1,20 +0,0 @@ - - -whisper - - - -
- -
-
- - - - 删除 -
-
- - \ No newline at end of file diff --git a/cgi-bin/template/page.html b/cgi-bin/template/page.html deleted file mode 100644 index 672be2c..0000000 --- a/cgi-bin/template/page.html +++ /dev/null @@ -1,37 +0,0 @@ - - -whisper - - - - -
- -
-
- - -
- - {whispers} - -
- <上一页 - 下一页> -
- - diff --git a/cgi-bin/template/whisper.html b/cgi-bin/template/whisper.html deleted file mode 100644 index ae7ede4..0000000 --- a/cgi-bin/template/whisper.html +++ /dev/null @@ -1,10 +0,0 @@ -
-
- {content} -
-
-
- [编辑] -
-
-
diff --git a/cgi-bin/whisper.py b/cgi-bin/whisper.py deleted file mode 100644 index aec20b6..0000000 --- a/cgi-bin/whisper.py +++ /dev/null @@ -1,19 +0,0 @@ -import path -from path import Path -import connect -from connect import Connect - -whisper_file = open(Path.template("whisper.html"), 'r', encoding="utf8") -whisper_templ = whisper_file.read() -whisper_file.close() - -class Whisper(object): - def build(_id, _content, _date, _odd, _url): - whisper = whisper_templ.format(\ - oddoreven=((_odd == True) and "odd" or "even"),\ - content=_content,\ - date=_date,\ - url=_url,\ - id=_id\ - ) - return whisper -- cgit v1.1-26-g67d0