[go: nahoru, domu]

Skip to content

Commit

Permalink
git-svn-id: http://micolog.googlecode.com/svn/trunk@32 fd139d67-4554-…
Browse files Browse the repository at this point in the history
…0410-8437-97b8145f5b4d
  • Loading branch information
coolchyni committed Oct 8, 2008
1 parent 1ae4f51 commit 344c8ed
Show file tree
Hide file tree
Showing 8 changed files with 692 additions and 184 deletions.
548 changes: 548 additions & 0 deletions app/html_filter.py

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion blog.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from datetime import datetime ,timedelta
import base64,random
from django.utils import simplejson

import filter as myfilter

def doRequestHandle(old_handler,new_handler,**args):
new_handler.initialize(old_handler.request,old_handler.response)
Expand Down Expand Up @@ -207,6 +207,8 @@ def post(self,slug=None):
## url=urldecode(url)
## key=urldecode(key)
## content=urldecode(content)

content=myfilter.do_filter(content)
if not (name and email and content):
if useajax:
self.write(simplejson.dumps((False,-101,'Please input name, email and comment .')))
Expand Down
38 changes: 38 additions & 0 deletions filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,42 @@ def dict_value(v1,v2):
return v1[v2]


from app.html_filter import html_filter

plog_filter = html_filter()
plog_filter.allowed = {
'a': ('href', 'target', 'name'),
'b': (),
'blockquote': (),
'pre': (),
'em': (),
'i': (),
'img': ('src', 'width', 'height', 'alt', 'title'),
'strong': (),
'u': (),
'font': ('color', 'size'),
'p': (),
'h1': (),
'h2': (),
'h3': (),
'h4': (),
'h5': (),
'h6': (),
'table': (),
'tr': (),
'th': (),
'td': (),
'ul': (),
'ol': (),
'li': (),
'br': (),
'hr': (),
}

plog_filter.no_close += ('br',)
plog_filter.allowed_entities += ('nbsp','ldquo', 'rdquo', 'hellip',)
plog_filter.make_clickable_urls = False # enable this will get a bug about a and img

@register.filter
def do_filter(data):
return plog_filter.go(data)
8 changes: 4 additions & 4 deletions index.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ indexes:
- name: date
direction: desc

# Used 84 times in query history.
# Used 114 times in query history.
- kind: Comment
properties:
- name: date
direction: desc

# Used 120 times in query history.
# Used 1320 times in query history.
- kind: Comment
properties:
- name: entry
Expand All @@ -35,7 +35,7 @@ indexes:
- name: date
direction: desc

# Used 69 times in query history.
# Used 96 times in query history.
- kind: Entry
properties:
- name: entry_parent
Expand All @@ -50,7 +50,7 @@ indexes:
- name: date
direction: desc

# Used 37 times in query history.
# Used 45 times in query history.
- kind: Entry
properties:
- name: entrytype
Expand Down
10 changes: 10 additions & 0 deletions static/js/jquery.form.gb2312.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

86 changes: 85 additions & 1 deletion themes/xuming/templates/comments.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@



<h3 id="comments" {% if not entry.comments.count%} style="display:none"{%endif%}>&#8220;{{entry.title}}&#8221; 共有<span style='color:red;font-weight:bold;padding:0px 3px'>{{entry.comments.count}}</span>条留言 </h3>

Expand Down Expand Up @@ -65,4 +65,88 @@ <h3 id="respond">我要留言</h3>
</p>
</form>

<script>
loadjs=false;
function showinfo(msg)
{
alert(msg);
}
function add_comment(msg)
{
comment=$(msg)
if (!loadjs)
{
$("#commentlist").append(comment).show();
$.getScript("http://dev.jquery.com/view/trunk/plugins/color/jquery.color.js", function(){
comment.animate( { backgroundColor: '#fbc7c7' }, "slow")
.animate( { backgroundColor: 'white' }, "slow")
loadjs=true;
});
}else
{
$("#commentlist").append(comment);
comment.animate( { backgroundColor: '#fbc7c7' }, "slow")
.animate( { backgroundColor: 'white' }, "slow")

}
}

$('#commentform').ajaxForm({
type:'post',
dataType: 'json',
beforeSubmit:function(formData,jqForm,options){
var form = jqForm[0];
if (form.author)
{

if (!form.author.value)
{
showinfo('请输入你的名字!');
form.author.focus();
return false;
}
if (!form.email.value)
{
showinfo('请输入邮件地址');
form.email.focus();
return false;
}
}
if (form.checknum.value)
{
if(eval(form.checknum.value)!=form.checkret.value)
{
alert('计算错误,这个算术好像在幼儿园学过的吧?');
form.checkret.value='';
form.checkret.focus();
return false;
}

}

if (!form.comment.value)
{
showinfo('请输入留言内容');
form.comment.focus();
return false;
}

return true;

},
success:function(data){
if (data[0])
{
document.cookie=data[1];
add_comment(data[2]);
}
else
{ if (data[1]==-102)
showinfo('计算错误,回幼儿园进修一下再来过。');
$('#checkret').focus();
}
}
});

</script>

91 changes: 2 additions & 89 deletions themes/xuming/templates/page.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,98 +28,11 @@ <h2><a href="/{{ entry.link }}" rel="bookmark" title="Permanent Link to {{ entry


</div>
{# include "comments.html" #}
{% include "comments.html" %}
<div id="comment_area">

</div>
<script>
loadjs=false;
function showinfo(msg)
{
alert(msg);
/*
if (!loadjs)
{
$("#comment_info").text(msg).show();
$.getScript("http://dev.jquery.com/view/trunk/plugins/color/jquery.color.js", function(){
loadjs=true;
});
}else
{ $("#comment_info").text(msg).animate( { backgroundColor: '#fbc7c7' }, "fast")
.animate( { backgroundColor: '#F7F0EF' }, "slow")
.animate( { backgroundColor: '#fbc7c7' }, "fast");
}
*/
}
function add_comment(msg)
{
comment=$(msg)
if (!loadjs)
{
$("#commentlist").append(comment).show();
$.getScript("http://dev.jquery.com/view/trunk/plugins/color/jquery.color.js", function(){
comment.animate( { backgroundColor: '#fbc7c7' }, "slow")
.animate( { backgroundColor: 'white' }, "slow")
loadjs=true;
});
}else
{
$("#commentlist").append(comment);
comment.animate( { backgroundColor: '#fbc7c7' }, "slow")
.animate( { backgroundColor: 'white' }, "slow")

}
}
$.getJSON("{{self.blog.baseurl}}/do/getcomments?key={{entry.key}}", function(ret){

$('#comment_area').html(ret);

$('#commentform').ajaxForm({
type:'post',
dataType: 'json',
beforeSubmit:function(formData,jqForm,options){
var form = jqForm[0];
if (form.author)
{

if (!form.author.value)
{
showinfo('请输入你的名字!');
form.author.focus();
return false;
}
if (!form.email.value)
{
showinfo('请输入邮件地址');
form.email.focus();
return false;
}
}
if (!form.comment.value)
{
showinfo('请输入留言内容');
form.comment.focus();
return false;
}

return true;

},
success:function(data){
if (data[0])
{
document.cookie=data[1];
add_comment(data[2]);
}
else
{ if (data[1]==-102)
showinfo('计算错误,回幼儿园进修一下再来过。');
$('#checkret').focus();
}
}
});
});
</script>

{% else %}
<p>Sorry, no posts matched your criteria.</p>
{% endif %}
Expand Down
Loading

0 comments on commit 344c8ed

Please sign in to comment.