diff options
author | chai <chaifix@163.com> | 2018-07-12 21:14:44 +0800 |
---|---|---|
committer | chai <chaifix@163.com> | 2018-07-12 21:14:44 +0800 |
commit | 181b206863d3765fe5343ceea8e1e00e52ffba9e (patch) | |
tree | c14fea74a41b7c1d789bf89a0e15238f3511dc8c | |
parent | d351e45604f192df6ef710d476a8e529fefa73bf (diff) |
update
-rw-r--r-- | cgi-bin/config.ini | 4 | ||||
-rw-r--r-- | cgi-bin/delete.py | 36 | ||||
-rw-r--r-- | cgi-bin/html/ckeditor/config.js | 2 | ||||
-rw-r--r-- | cgi-bin/template/edit.html | 1 | ||||
-rw-r--r-- | cgi-bin/template/page.html | 24 | ||||
-rw-r--r-- | cgi-bin/template/whisper.html | 6 |
6 files changed, 54 insertions, 19 deletions
diff --git a/cgi-bin/config.ini b/cgi-bin/config.ini index b6d3959..7dfc0e1 100644 --- a/cgi-bin/config.ini +++ b/cgi-bin/config.ini @@ -2,7 +2,7 @@ url=/cgi-bin static=/html images=/html/imgs -templates=template +templates=./template [database] user=root passwd=root @@ -10,4 +10,4 @@ host=localhost port=3306 db=whisper [config] -whisper_count=20 +whisper_count=15 diff --git a/cgi-bin/delete.py b/cgi-bin/delete.py new file mode 100644 index 0000000..7c728a4 --- /dev/null +++ b/cgi-bin/delete.py @@ -0,0 +1,36 @@ +#!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 = """ + <html> + <head> + <meta http-equiv="refresh" content="0;url={0}/page.py"> + </head> + </html> + """.format(_url) + print(redirect)
\ No newline at end of file diff --git a/cgi-bin/html/ckeditor/config.js b/cgi-bin/html/ckeditor/config.js index 34baeed..048198a 100644 --- a/cgi-bin/html/ckeditor/config.js +++ b/cgi-bin/html/ckeditor/config.js @@ -35,6 +35,6 @@ CKEDITOR.editorConfig = function( config ) { // Simplify the dialog windows. config.removeDialogTabs = 'image:advanced;link:advanced'; - config.filebrowserImageUploadUrl = "/cgi-bin/html/image"; + config.filebrowserImageUploadUrl = "/cgi-bin/"; config.height = 100; }; diff --git a/cgi-bin/template/edit.html b/cgi-bin/template/edit.html index 27a3dd0..bc8cea0 100644 --- a/cgi-bin/template/edit.html +++ b/cgi-bin/template/edit.html @@ -13,6 +13,7 @@ {whisper_content} </textarea> <input type="submit" value=" 推 " class="submit"/> + <a style="float:right; color:red" href="{url}/delete.py?w={whisper_id}">删除</a> </form> </div> </body> diff --git a/cgi-bin/template/page.html b/cgi-bin/template/page.html index b87a6b0..672be2c 100644 --- a/cgi-bin/template/page.html +++ b/cgi-bin/template/page.html @@ -5,18 +5,18 @@ <link rel="stylesheet" href="{url}{static}/style.css" type="text/css" /> <script src="{url}{static}/ckeditor/ckeditor.js"></script> <script> -// window.onload = function() -// { - // var dates = document.getElementsByClassName("whisper_date"); - // for(var i = 0; i < dates.length; i++) - // { - // var d = dates[i]; - // var tstamp = d.date; - // var day = new Date(tstamp); - // var timestr = day.toLocaleString(); - // d.innerHTML = timestr; - // } -//} +window.onload = function() +{{ + var dates = document.getElementsByClassName("whisper_date"); + for(var i = 0; i < dates.length; i++) + {{ + var d = dates[i]; + var tstamp = parseInt(d.getAttribute("date")); + var day = new Date(tstamp * 1000); + var timestr = day.toLocaleString(); + d.innerHTML = timestr; + }} +}} </script> <div id="container"> <img src="{url}{static}/logo.png" id="logo"/> diff --git a/cgi-bin/template/whisper.html b/cgi-bin/template/whisper.html index ca09bb7..ae7ede4 100644 --- a/cgi-bin/template/whisper.html +++ b/cgi-bin/template/whisper.html @@ -2,11 +2,9 @@ <div class="whisper_content"> {content} </div> - <div class="whisper_date" date="{date}"> - {date} - </div> + <div class="whisper_date" date="{date}"></div> <div class="whisper_edit"> <a href="{url}/edit.py?w={id}">[编辑]</a> </div> <div style="clear:both"></div> -</div>
\ No newline at end of file +</div> |