Commits

Anonymous committed f28f6cd

Adds ARTICLES_TEASER_MARKER, used to specify the end of the article
teaser text, like the Wordpress <!--more--> tag.

Comments (0)

Files changed (2)

 Auto-Tagging **does not** attempt to produce any keywords that magically
 represent the content of your articles.  Only **existing** tags are used!!
 
+
+Teaser-Marker
+==============
+Explicitly specify the end of the article 'teaser' with a site defined 
+``ARTICLES_TEASER_MARKER``.  If an article contains this teaser tag, it will be 
+used to populate the article.description field directly from article.content up to
+the tag.
+
+For example, you can emulate WordPress More tag behavior by adding
+this line to your settings file:
+
+    ARTICLES_TEASER_MARKER = "<!--more-->"
+ 
+
 Help & Contributing
 ===================
 

articles/models.py

 import urllib
 
 WORD_LIMIT = getattr(settings, 'ARTICLES_TEASER_LIMIT', 75)
+TEASER_MARKER = getattr(settings, 'ARTICLES_TEASER_MARKER', None)
 AUTO_TAG = getattr(settings, 'ARTICLES_AUTO_TAG', True)
 DEFAULT_DB = getattr(settings, 'ARTICLES_DEFAULT_DB', 'default')
 
         Retrieve some part of the article or the article's description.
         """
         if not self._teaser:
-            if len(self.description.strip()):
-                text = self.description
-            else:
-                text = self.rendered_content
-
-            words = text.split(' ')
-            if len(words) > WORD_LIMIT:
-                text = '%s...' % ' '.join(words[:WORD_LIMIT])
-            self._teaser = text
+            marker_pos = -1
+            if TEASER_MARKER:
+                marker_pos = self.rendered_content.find(TEASER_MARKER)
+                if marker_pos > 0:
+                    self._teaser = self.rendered_content[0:marker_pos]
+            # If we aren't using the marker or didn't find one
+            if not TEASER_MARKER or marker_pos < 0:
+                if len(self.description.strip()):
+                    text = self.description
+                else:
+                    text = self.rendered_content
+                    
+                words = text.split(' ')
+                if len(words) > WORD_LIMIT:
+                    text = '%s...' % ' '.join(words[:WORD_LIMIT])
+                self._teaser = text
 
         return self._teaser
     teaser = property(_get_teaser)