Sha256: 3fa534e87aaba6492f2976184dd87b9ce8b83ab588b753d54fe75fd95141fb4f

Contents?: true

Size: 1.07 KB

Versions: 3

Compression:

Stored size: 1.07 KB

Contents

module Gluttonberg
  # Wrapper class for sitemap generator gem
  class Sitemap
    @@sitemap = nil
    @@links = {}
    
    def self.add(link, lastmod , group="")
      unless @@links.has_key?(group)
        @@links[group] = [link]
      else
        @@links[group] << link
        @@links[group] = @@links[group].uniq
      end
      @@sitemap.add(link[:path] , :lastmod => Time.now)
      @@links
    end
  
    def self.links
      @@links
    end
    
    def self.sitemap=(sitemap)
      @@sitemap = sitemap
    end
    
    def self.add_custom_model(model_name,title_field_name,pages=[:index , :show])
      pl = model_name.to_s.underscore.pluralize
      last_updated_at = ""
      if pages.include?(:index)
        Gluttonberg::Sitemap.add({:path => "/#{pl}" , :title => model_name.to_s.humanize } , last_updated_at , pl)
      end
      
      if pages.include?(:show)
        model_name.published.each do |obj|
          Gluttonberg::Sitemap.add({:path => "/#{pl}/#{obj.id}" , :title => obj.send(title_field_name) } , obj.updated_at , pl)
        end
      end  
    end
  
  end
end  

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
gluttonberg-core-3.0.2 app/models/gluttonberg/sitemap.rb
gluttonberg-core-3.0.1 app/models/gluttonberg/sitemap.rb
gluttonberg-core-3.0.0 app/models/gluttonberg/sitemap.rb