Strip comments

Insert link to comment when it's referenced with #comment_number
This commit is contained in:
Gregory Soutade 2014-03-16 18:55:50 +01:00
parent 22b8c96fe3
commit 726d247632
14 changed files with 15 additions and 11 deletions

View File

@ -1,4 +1,4 @@
v0.2 (04/01/2014)
v0.2 (16/03/2014)
** User **
Add dyn:post_url and dyn:post_full_url for replace directive (doesn't prepend http://)
@ -6,12 +6,14 @@ v0.2 (04/01/2014)
Add Mardown support
Add all posts generators
Set default font size to 14 for TinyMCE
Allow to reference comments with #comment_number
** Dev **
Add coding information in all py files
Add HTML5 markup for blog.soutade.fr
Add ChangeLog
Simplify archive generation code
Trim comment before saving
** Bugs **
Escape double quotes in metas tag

3
README
View File

@ -7,7 +7,8 @@ Django >= 1.4, libapache2-mod-wsgi if you want to use Dynastie with Apache. PyGm
Installation :
* Download Dynastie
* Update wsgy.py (with $PWD/../) don't forget the final slash !
* Update dynastie/wsgy.py (with $PWD/../) don't forget the final slash !
* Update dynastie/settings.py (SECRET_KEY...)
* Run ./manage.sh syncdb and create a superuser
* Run ./manage.sh runserver
or

0
dynastie/sites/blog.soutade.fr/_all_posts.html Executable file → Normal file
View File

View File

@ -6,7 +6,7 @@
<div class="post_header">
<dyn:title link="1"/>
<div class="post_sub_header">
<dyn:date/> | <div class="author_icon"> Écrit par <dyn:author/> </div>
<dyn:date format="%A, %d %B %Y"/> | <div class="author_icon"> Écrit par <dyn:author/> </div>
</div>
<dyn:tags link="1"/>
</div>

0
dynastie/sites/blog.soutade.fr/_base_post.html Executable file → Normal file
View File

View File

@ -6,7 +6,7 @@
<div class="post_header">
<dyn:title link="1"/>
<div class="post_sub_header">
<dyn:date/> | <div class="author_icon"> Écrit par <dyn:author/> </div>
<dyn:date format="%A, %d %B %Y"/> | <div class="author_icon"> Écrit par <dyn:author/> </div>
</div>
<dyn:tags link="1"/>
</div>

View File

@ -5,7 +5,7 @@
<div class="post_header">
<dyn:title link="1"/>
<div class="post_sub_header">
<dyn:date/> | <div class="author_icon"> Écrit par <dyn:author/> </div>
<dyn:date format="%A, %d %B %Y"/> | <div class="author_icon"> Écrit par <dyn:author/> </div>
</div>
<dyn:tags link="1"/>
</div>

View File

@ -6,7 +6,7 @@
<div class="post_header">
<dyn:title link="0"/>
<div class="post_sub_header">
<dyn:date/> | <div class="author_icon"> Écrit par <dyn:author/> </div>
<dyn:date format="%A, %d %B %Y"/> | <div class="author_icon"> Écrit par <dyn:author/> </div>
</div>
<dyn:tags link="1"/>
</div>

View File

@ -5,7 +5,7 @@
<div class="post_header">
<dyn:title link="1"/>
<div class="post_sub_header">
<dyn:date/> | <div class="author_icon"> Écrit par <dyn:author/> </div>
<dyn:date format="%A, %d %B %Y"/> | <div class="author_icon"> Écrit par <dyn:author/> </div>
</div>
<dyn:tags link="1"/>
</div>

2
dynastie/sites/blog.soutade.fr/_tag.html Executable file → Normal file
View File

@ -6,7 +6,7 @@
<div class="post_header">
<dyn:title link="1"/>
<div class="post_sub_header">
<dyn:date/> | <div class="author_icon"> Écrit par <dyn:author/> </div>
<dyn:date format="%A, %d %B %Y"/> | <div class="author_icon"> Écrit par <dyn:author/> </div>
</div>
<dyn:tags link="1"/>
</div>

View File

@ -406,7 +406,6 @@ ul li
.comment_author, .comment_date
{
margin-left:5px;
margin-right:5px;
}
.comment_author

0
dynastie/sites/blog.soutade.fr/js/blog.js Executable file → Normal file
View File

View File

@ -22,7 +22,7 @@
</head>
<body>
<div class="logo">
<a href="http://indefero.soutade.fr/p/dynastie>"><img src="{{ STATIC_URL }}images/logo.png"/></a>
<a href="http://indefero.soutade.fr/p/dynastie"><img src="{{ STATIC_URL }}images/logo.png"/></a>
</div>
<div class="form">
<form method="post" action="/index">

View File

@ -18,6 +18,7 @@
along with Dynastie. If not, see <http://www.gnu.org/licenses/>.
"""
import os
import re
from datetime import datetime, date, time
from django.shortcuts import render
from django.contrib.auth import authenticate, login, logout
@ -710,10 +711,11 @@ def add_comment(request, post_id, parent_id):
ip = request.META['REMOTE_ADDR']
# Avoid script injection
the_comment = request.POST['the_comment']
the_comment = request.POST['the_comment'].strip()
the_comment = the_comment.replace('<', '&lt;')
the_comment = the_comment.replace('>', '&gt;')
the_comment = the_comment.replace('\n', '<br />')
the_comment = re.sub('#([0-9]+)', '<a href=\"#comment_\\1\">#\\1</a>', the_comment)
if 'mel' in request.POST:
mel = request.POST['mel'].strip()