Skip to content

Commit

Permalink
修改排序方式,新回复排前面
Browse files Browse the repository at this point in the history
  • Loading branch information
时雨 committed May 9, 2015
1 parent 5a5a838 commit 98dc32d
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 9 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ location / {
3. 编写测试脚本,在py2/3环境下进行测试。
4. 增加多语言支持。
5. 增加网站底部自定义,使之可以填写:备案信息、统计代码等。
6. 增加CSS白名单过滤,防止出乱子。

### LICENSE
开源协议:MPL
Expand Down
2 changes: 1 addition & 1 deletion controller/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def get(self, *args, **kwargs):
page = intval(args[1])
if not page or page <= 0 : page = 1
cursor = self.db.article.find()
cursor.sort([('top', pymongo.DESCENDING), ('time', pymongo.DESCENDING)]).limit(limit).skip((page - 1) * limit)
cursor.sort([('top', pymongo.DESCENDING), ("lastcomment", pymongo.DESCENDING), ('time', pymongo.DESCENDING)]).limit(limit).skip((page - 1) * limit)
count = yield cursor.count()
posts = yield cursor.to_list(length = limit)
sorts = yield self.get_sort()
Expand Down
2 changes: 1 addition & 1 deletion controller/open.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ def get(self, *args, **kwargs):
cursor = self.db.article.find({
"open": True
})
cursor.sort([("top", pymongo.DESCENDING), ('time', pymongo.DESCENDING)]).limit(limit).skip((page - 1) * limit)
cursor.sort([("top", pymongo.DESCENDING), ("lastcomment", pymongo.DESCENDING), ('time', pymongo.DESCENDING)]).limit(limit).skip((page - 1) * limit)
count = yield cursor.count()
posts = yield cursor.to_list(length = limit)
self.render("open_list.htm", posts = posts, page = page,
Expand Down
5 changes: 4 additions & 1 deletion controller/post.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,10 @@ def post(self, *args, **kwargs):
},
"time": time.time()
}
}
},
"$set": {
"lastcomment": time.time()
}
})
if post:
if self.current_user["username"] != post["user"]:
Expand Down
3 changes: 2 additions & 1 deletion controller/publish.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@ def post(self, *args, **kwargs):
"rank": 0,
"comment": [],
"open": False,
"top": False
"top": False,
"lastcomment": time.time()
}
model = ArticleModel()
if not model(article):
Expand Down
6 changes: 1 addition & 5 deletions util/pxfilter.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,10 +194,6 @@ def __htmlspecialchars(self, html, strict=False):

if "__main__" == __name__:
parser = XssHtml()
parser.feed("""<p><img src=1 onerror=alert(/xss/)></p><div class="left">
<a href='javascript:prompt(1)'><br />hehe</a></div>
<p id="test" onmouseover="alert(1)">&gt;M<svg>
<a href="https://www.baidu.com" target="self">MM</a></p>
<embed src='javascript:alert(/hehe/)' allowscriptaccess=always />""")
parser.feed("""<div onmouseover=alert(1) >""")
parser.close()
print(parser.getHtml())

0 comments on commit 98dc32d

Please sign in to comment.