David Chambers avatar David Chambers committed a6a6068

Added `Excerpt` and `Update` class definitions.

Comments (0)

Files changed (1)

             self._contents = contents
 
         contents = u'%s\n' % re.sub(RE['\r\n?'], '\n', contents)
-        if self._parent:
+        if isinstance(self, Update):
             contents = re.sub(RE['update_pipes'], u'', contents)
 
         self.body = contents
 
         # updates
         split = re.split(RE['update'], contents)
-        md.reset()
         chunks = md.convert(u'\n<mango/>\n'.join(split[0::2])).split('<mango/>')
         self.meta = getattr(md, 'Meta', {})
-        updates = [update_template.render(Context({'update': Document(parent=self).convert(item)})) for item in split[1::2]]
+        updates = [update_template.render(Context({'update': Update(parent=self).convert(item)})) for item in split[1::2]]
         combined = [None] * (len(chunks) + len(updates))
         combined[0::2] = chunks
         combined[1::2] = updates
             self.html += fragment
         self.body = re.sub(RE['skip'], '', self.body)
         self.html = mark_safe(re.sub(RE['skip'], '', self.html))
-        # excerpts inherit link definitions
-        self.excerpt = mark_safe(md.convert('\n\n'.join(snippets))) or self.html
+        self.excerpt = (Excerpt(parent=self).convert('\n\n'.join(snippets)) if snippets else self).html
         self.type = self.meta.get('type', 'post' if self.datetime else 'page')
 
         # attach comments thread
                     cache.set(cache_key, self._thread, 24*60*60)
                     logger.debug('Disqus thread for "%s" cached' % self._thread.title)
 
+        if type(self) is Document:
+            md.reset() # clear cached link definitions
+
         return self
 
     def comments(self):
 
     def __unicode__(self):
         return u''.join((getattr(self.master(), 'title', 'Untitled Document'), self.apt(' (update)')))
+
+
+class Excerpt(Document):
+    def __init__(self, parent):
+        super(Excerpt, self).__init__(parent=parent)
+
+
+class Update(Document):
+    def __init__(self, parent):
+        super(Update, self).__init__(parent=parent)
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.