Added precompiled regexp for commentfile parsing
This commit is contained in:
parent
c4b4c138c2
commit
59b3fe4272
12
blogthon.cgi
12
blogthon.cgi
@ -23,6 +23,8 @@ import ConfigParser
|
|||||||
|
|
||||||
# A wonderful place for doing some regexp ;)
|
# A wonderful place for doing some regexp ;)
|
||||||
no_break = re.compile('^\s*(<ul|</ul>|<li|</li>|<ol|</ol>|<table|</table>|<tr|</tr>|<td|</td>|<th|</th>|<p|</p>).*$')
|
no_break = re.compile('^\s*(<ul|</ul>|<li|</li>|<ol|</ol>|<table|</table>|<tr|</tr>|<td|</td>|<th|</th>|<p|</p>).*$')
|
||||||
|
line_start_hyphen = re.compile('^-.*$')
|
||||||
|
line_start_plus = re.compile('^\+.*$')
|
||||||
|
|
||||||
def generate_uuid(string):
|
def generate_uuid(string):
|
||||||
string_md5sum = md5.new(string).hexdigest()
|
string_md5sum = md5.new(string).hexdigest()
|
||||||
@ -409,6 +411,7 @@ else:
|
|||||||
|
|
||||||
print ' <div class="entries">'
|
print ' <div class="entries">'
|
||||||
print ''
|
print ''
|
||||||
|
|
||||||
# Staticpage
|
# Staticpage
|
||||||
if static_display != "":
|
if static_display != "":
|
||||||
content = open(staticpages_dir + static_display, "r")
|
content = open(staticpages_dir + static_display, "r")
|
||||||
@ -417,7 +420,7 @@ else:
|
|||||||
print ' <div class="entry_content">'
|
print ' <div class="entry_content">'
|
||||||
print ' <p>'
|
print ' <p>'
|
||||||
for line in content:
|
for line in content:
|
||||||
if re.match(no_break, line):
|
if no_break.match(line):
|
||||||
print ' ' + line.strip()
|
print ' ' + line.strip()
|
||||||
else:
|
else:
|
||||||
print ' ' + line.strip() + '<br />'
|
print ' ' + line.strip() + '<br />'
|
||||||
@ -431,6 +434,7 @@ else:
|
|||||||
print ' </div>'
|
print ' </div>'
|
||||||
print ''
|
print ''
|
||||||
content.close()
|
content.close()
|
||||||
|
|
||||||
# Entry
|
# Entry
|
||||||
else:
|
else:
|
||||||
entry_counter = 0
|
entry_counter = 0
|
||||||
@ -453,7 +457,7 @@ else:
|
|||||||
print ' <div class="entry_date">' + date + '</div>'
|
print ' <div class="entry_date">' + date + '</div>'
|
||||||
print ' <div class="entry_content">'
|
print ' <div class="entry_content">'
|
||||||
for line in content:
|
for line in content:
|
||||||
if re.match(no_break, line):
|
if no_break.match(line):
|
||||||
print ' ' + line.strip()
|
print ' ' + line.strip()
|
||||||
else:
|
else:
|
||||||
print ' ' + line.strip() + '<br />'
|
print ' ' + line.strip() + '<br />'
|
||||||
@ -480,7 +484,7 @@ else:
|
|||||||
label_count = 0
|
label_count = 0
|
||||||
|
|
||||||
for line in comments_content:
|
for line in comments_content:
|
||||||
if re.search("^-", line):
|
if line_start_hyphen.match(line):
|
||||||
if notfirstline == 1:
|
if notfirstline == 1:
|
||||||
print ' </div>'
|
print ' </div>'
|
||||||
print ' </div>'
|
print ' </div>'
|
||||||
@ -492,7 +496,7 @@ else:
|
|||||||
print ' <a name="' + str(label_count) + '"></a>'
|
print ' <a name="' + str(label_count) + '"></a>'
|
||||||
|
|
||||||
print ' <div class="comment_author">' + line.split(".", 1)[1].strip() + '</div>'
|
print ' <div class="comment_author">' + line.split(".", 1)[1].strip() + '</div>'
|
||||||
elif re.search("^\+", line):
|
elif line_start_plus.match(line):
|
||||||
print ' <div class="comment_date">' + line.split(".", 1)[1].strip() + '</div>'
|
print ' <div class="comment_date">' + line.split(".", 1)[1].strip() + '</div>'
|
||||||
print ' <div class="comment_content">'
|
print ' <div class="comment_content">'
|
||||||
else:
|
else:
|
||||||
|
Loading…
Reference in New Issue
Block a user