Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Sitemap plugin update #1

Closed
wants to merge 1 commit into from

2 participants

Helen-Mobify John Boxall
Helen-Mobify
Collaborator

This plugin is modified to ignore any url that matches the following:

  • starts with "_"
  • contains "customer-only"
  • contains "customer-exclusive"
  • contains "krypton"
  • contains "thank-you"
John Boxall
Owner

@Helen-Mobify thanks - we'll override this inside our settings file.

John Boxall johnboxall closed this March 26, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 1 unique commit by 1 author.

Mar 22, 2013
Helen-Mobify Sitemap plugin update 9e360ac
This page is out of date. Refresh to see the latest.

Showing 1 changed file with 18 additions and 2 deletions. Show diff stats Hide diff stats

  1. 20  pelican/plugins/sitemap.py
20  pelican/plugins/sitemap.py
@@ -120,10 +120,26 @@ def __init__(self, context, settings, path, theme, output_path, *null):
120 120
 
121 121
     def write_url(self, page, fd):
122 122
 
  123
+        # ignore any url start with "/_" - these are internal files (ie. "/_/guide")
  124
+        if "/_" in page.url:
  125
+            return
  126
+        
  127
+        # ignore any url with customer-only, customer-exclusive, krypton, thank-you strings
  128
+        if "customer-only" in page.url or \
  129
+            "customer-exclusive" in page.url or \
  130
+            "krypton" in page.url or \
  131
+            "thank-you" in page.url:
  132
+            return
  133
+
123 134
         if getattr(page, 'status', 'published') != 'published':
124 135
             return
125 136
 
126  
-        page_path = os.path.join(self.output_path, page.url)
  137
+        # make sure the page url is not a absolute path so that os.path.join will work properly
  138
+        page_url = page.url
  139
+        if page.url[0] == '/':
  140
+            page_url = page.url[1:]
  141
+
  142
+        page_path = os.path.join(self.output_path, page_url)
127 143
         if not os.path.exists(page_path):
128 144
             return
129 145
 
@@ -141,7 +157,7 @@ def write_url(self, page, fd):
141 157
 
142 158
 
143 159
         if self.format == 'xml':
144  
-            fd.write(XML_URL.format(self.siteurl, page.url, lastmod, chfreq, pri))
  160
+            fd.write(XML_URL.format(self.siteurl, page_url, lastmod, chfreq, pri))
145 161
         else:
146 162
             fd.write(self.siteurl + '/' + loc + '\n')
147 163
 
Commit_comment_tip

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.