This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#controllers部分: | |
class media_describe: | |
@session.login_required | |
def POST(self): | |
f = web.input(image_title=[],image_describe=[],path={}) | |
imageTitle = f.image_title | |
imageDescribe = f.image_describe | |
imagePath = f.path.split(',') | |
image.saveTitleDescribe(imagePath, imageTitle, imageDescribe) #更新数据库 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import web | |
import mimetypes | |
class public: | |
def GET(self): | |
public_dir = 'public' | |
try: | |
file_name = web.ctx.path.split('/')[-1] | |
web.header('Content-type', mime_type(file_name)) | |
return open(public_dir + web.ctx.path, 'rb').read() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
server { | |
listen 80; | |
server_name 9y1p.com www.9y1p.com *.9y1p.com; | |
index index.html index.htm; | |
root /home/www/jiuyuyipin; | |
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)?$ | |
{ | |
expires 30d; | |
access_log off; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def render_account(show='all',login_form=login_form()): | |
return view.base(view.account(show, login_form), user, site_name) | |
class login: | |
def GET(self): | |
return render_account(show='login_only') | |
def POST(self): | |
f = self.form() | |
if not f.validates(web.input(_unicode=False)): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function capture(option) { | |
var window = mediator.getMostRecentWindow("navigator:browser") | |
//为了在v2ex显示方便,这里加了个回车 | |
.gBrowser.contentWindow; | |
var document = window.document; | |
var html = document.documentElement; | |
var w, h, x, y; | |
switch(option) { | |
case 'visible': | |
x = 0; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class post_image_delete: | |
@session.login_required | |
def POST(self, arg): | |
data = web.input() | |
path = data.path # 类似 '/static/upload/post_img/2012/11/9' | |
part_name = data.part_name # 类似 '201211981222_7a214d288112fe8ef99944aa7ce4d228' | |
homedir = os.getcwd() | |
imgPath = homedir + path | |
#上面组装的结果类似这样 : "/home/www/rhinocero" + "/static/upload/post_img/2012/11/9" | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
homedir = os.getcwd() | |
part_name = '201211981222_7a214d288112fe8ef99944aa7ce4d228' | |
path = '/static/upload/post_img/2012/11/9' | |
imgPath = homedir + path | |
if os.path.isfile(imgPath + '/.DS_Store'): | |
os.remove(imgPath + '/.DS_Store') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class post_image_delete: | |
@session.login_required | |
def POST(self, arg): | |
data = web.input() | |
path = data.path | |
part_name = data.part_name | |
homedir = os.getcwd() | |
imgPath = homedir + path | |
if os.path.isfile(imgPath + '/.DS_Store'): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import web | |
import app.controllers | |
from config import view | |
def notfound(): | |
return web.notfound(view.error()) | |
urls = ( | |
'/post/(\+?[1-9][0-9]*)', 'app.controllers.post.post_show', #正则匹配url 验证非零的正整数 | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#添加评论 | |
class new_post_comment: | |
@session.login_required | |
def POST(self, pid): | |
data = web.input() | |
reg_regchar = '@([a-zA-Z0-9][\w\-\.\_]+)' #正则匹配username | |
comment = data.postComment | |
comment = htmlquote(comment).strip().replace("\r\n", "<br/>") #内容过滤 | |
usernames = re.findall(reg_regchar, comment) #得到username数组 | |
nicknames = [] |
OlderNewer