aboutsummaryrefslogtreecommitdiffstats
path: root/blogthon.cgi
diff options
context:
space:
mode:
authorStefan Ritter <xeno@thehappy.de>2009-12-10 15:19:31 +0100
committerStefan Ritter <xeno@thehappy.de>2009-12-10 15:19:31 +0100
commit59b3fe427237302e94de3e16192b8a258b1fc4be (patch)
treeab38954df853c8ae1234d8fd86cc15e3aa46f35a /blogthon.cgi
parentc4b4c138c27656817d795d101b4dccdcb26a35e3 (diff)
Added precompiled regexp for commentfile parsing
Diffstat (limited to 'blogthon.cgi')
-rwxr-xr-xblogthon.cgi16
1 files changed, 10 insertions, 6 deletions
diff --git a/blogthon.cgi b/blogthon.cgi
index e257612..16e6e5d 100755
--- a/blogthon.cgi
+++ b/blogthon.cgi
@@ -22,7 +22,9 @@ import cgi, os, time, glob, re, md5, sys, random, smtplib
import ConfigParser
# 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):
string_md5sum = md5.new(string).hexdigest()
@@ -374,7 +376,7 @@ else:
print ' <div class="months_list">'
print ' <ul class="months_list">'
for entry in entries:
- date = time.strftime("%m%Y", entry[0])
+ date = time.strftime("%m%Y", entry[0])
date_display = time.strftime("%h %Y", entry[0])
if not olddate == date:
print ' <li class="months_list_entry"><a href="?m=' + date + '" class="months_list_entry">' + date_display + '</a></li>'
@@ -409,6 +411,7 @@ else:
print ' <div class="entries">'
print ''
+
# Staticpage
if static_display != "":
content = open(staticpages_dir + static_display, "r")
@@ -417,7 +420,7 @@ else:
print ' <div class="entry_content">'
print ' <p>'
for line in content:
- if re.match(no_break, line):
+ if no_break.match(line):
print ' ' + line.strip()
else:
print ' ' + line.strip() + '<br />'
@@ -431,6 +434,7 @@ else:
print ' </div>'
print ''
content.close()
+
# Entry
else:
entry_counter = 0
@@ -453,7 +457,7 @@ else:
print ' <div class="entry_date">' + date + '</div>'
print ' <div class="entry_content">'
for line in content:
- if re.match(no_break, line):
+ if no_break.match(line):
print ' ' + line.strip()
else:
print ' ' + line.strip() + '<br />'
@@ -480,7 +484,7 @@ else:
label_count = 0
for line in comments_content:
- if re.search("^-", line):
+ if line_start_hyphen.match(line):
if notfirstline == 1:
print ' </div>'
print ' </div>'
@@ -492,7 +496,7 @@ else:
print ' <a name="' + str(label_count) + '"></a>'
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_content">'
else: