author | Alberto Bertogli
<albertito@gmail.com> 2008-01-06 00:46:48 UTC |
committer | Alberto Bertogli
<albertito@gmail.com> 2008-01-06 00:46:48 UTC |
parent | a06c2713401f3771cb10bc70bfc8b284caea6136 |
wikiri.cgi | +16 | -12 |
diff --git a/wikiri.cgi b/wikiri.cgi index 4e8dd3c..a929a74 100755 --- a/wikiri.cgi +++ b/wikiri.cgi @@ -552,7 +552,8 @@ class Templates (object): # class Article (object): - def __init__(self, name, title = None, content = None): + def __init__(self, name, title = None, content = None, + has_header = True): self.name = name self.qname = urllib.quote_plus(name, safe = "") self.updated = None @@ -561,6 +562,7 @@ class Article (object): self.preloaded_title = title self.preloaded_content = content + self.has_header = has_header # loaded on demand self.attrs = {} @@ -597,16 +599,17 @@ class Article (object): self.updated = datetime.datetime.now() hdr_lines = 0 - for l in raw: - if ':' in l: - name, value = l.split(':', 1) - name = name.lower().strip() - self.attrs[name] = value.strip() - hdr_lines += 1 - - elif l == '\n': - # end of header - break + if self.has_header: + for l in raw: + if ':' in l: + name, value = l.split(':', 1) + name = name.lower().strip() + self.attrs[name] = value.strip() + hdr_lines += 1 + + elif l == '\n': + # end of header + break self._raw_content = ''.join(raw[hdr_lines:]) self.loaded = True @@ -938,7 +941,8 @@ def handle_cgi(): if preview: art = Article(artname, title = newtitle, - content = newcontent) + content = newcontent, + has_header = False) render_edit(art, preview = True) else: render_edit(Article(artname))