Skip to content

Instantly share code, notes, and snippets.

@joelhooks
Created July 25, 2012 22:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joelhooks/3179101 to your computer and use it in GitHub Desktop.
Save joelhooks/3179101 to your computer and use it in GitHub Desktop.
Upgrading to Octopress
fill_pages(site, urlset)
fill_legacy(urlset)
sitemap.add_element(urlset)
# File I/O: create sitemap.xml file and write out pretty-printed XML
unless File.exists?(site.dest)
FileUtils.mkdir_p(site.dest)
end
file = File.new(File.join(site.dest, SITEMAP_FILE_NAME), "w")
formatter = REXML::Formatters::Pretty.new(4)
formatter.compact = true
formatter.write(sitemap, file)
file.close
# Keep the sitemap.xml file from being cleaned by Jekyll
site.static_files << Jekyll::SitemapFile.new(site, site.dest, "/", SITEMAP_FILE_NAME)
end
#this is a hack addition to push in my legacy content
def fill_legacy(urlset)
file = File.new("/Volumes/Gonzales/Users/joel/Code/octopress/plugins/sitemapx.xml")
doc = REXML::Document.new(file)
root = doc.root
root.elements.each do |post|
urlset.add_element(post)
end
end
# Create url elements for all the posts and find the date of the latest one
#
# Returns last_modified_date of latest post
def fill_posts(site, urlset)
last_modified_date = nil
site.posts.each do |post|
if !excluded?(post.name)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment