Steve Schwarz avatar Steve Schwarz committed c03f449

Changes for optionally requesting link titles

Comments (0)

Files changed (3)

 * ``DISQUS_FORUM_SHORTNAME``: The name of your Disqus site.  This is what's
   used to link comments to your site.
 
+Less frequently changed settings:
+* ``ARTICLES_TEASER_LIMIT``: The number of words to display in the teaser. Defaults to ``75``.
+* ``ARTICLES_AUTO_TAG``: Whether or not to automatically tag articles. Defaults to ``True``.
+* ``ARTICLES_DEFAULT_DB``: Database in which to store articles. Defaults to ``default``.
+* ``ARTICLES_LOOKUP_LINK_TITLE``: Whether to fetch the title of remote links or use the local name of the link. Defaults to ``True``.
+
 Also, make sure that you have the following context processors in your
 ``TEMPLATE_CONTEXT_PROCESSORS`` tuple:
 

articles/forms.py

 
     class Media:
         css = {
-            'all': ('css/jquery.autocomplete.css',),
+            'all': ('/css/jquery.autocomplete.css',),
         }
         js = (
-            'js/jquery-1.4.1.min.js',
-            'js/jquery.bgiframe.min.js',
-            'js/jquery.autocomplete.pack.js',
-            'js/tag_autocomplete.js',
+            '/js/jquery-1.4.1.min.js',
+            '/js/jquery.bgiframe.min.js',
+            '/js/jquery.autocomplete.pack.js',
+            '/js/tag_autocomplete.js',
         )
 

articles/models.py

 WORD_LIMIT = getattr(settings, 'ARTICLES_TEASER_LIMIT', 75)
 AUTO_TAG = getattr(settings, 'ARTICLES_AUTO_TAG', True)
 DEFAULT_DB = getattr(settings, 'ARTICLES_DEFAULT_DB', 'default')
+LOOKUP_LINK_TITLE = getattr(settings, 'ARTICLES_LOOKUP_LINK_TITLE', True)
 
 MARKUP_HTML = 'h'
 MARKUP_MARKDOWN = 'm'
 
             # look in the cache for the link target's title
             if not cache.get(key):
-                try:
-                    # open the URL
-                    c = urllib.urlopen(url)
-                    html = c.read()
-                    c.close()
+                if LOOKUP_LINK_TITLE:
+                    try:
+                        # open the URL
+                        c = urllib.urlopen(url)
+                        html = c.read()
+                        c.close()
 
-                    # try to determine the title of the target
-                    title = TITLE_RE.search(html)
-                    if title: title = title.group(1)
-                    else: title = link.group(2)
-                except:
-                    # if anything goes wrong (ie IOError), use the link's text
+                        # try to determine the title of the target
+                        title = TITLE_RE.search(html)
+                        if title: title = title.group(1)
+                        else: title = link.group(2)
+                    except:
+                        # if anything goes wrong (ie IOError), use the link's text
+                        title = link.group(2)
+                else:
                     title = link.group(2)
 
                 # cache the page title for a week
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.