public
Description: Rails Sitemap Plugin / Site Map Plugin for Rails. A beautiful rails sitemap plugin that talks to Google, Yahoo and MSN when updated. Sitemap features clean handcrafted XHTML, XML with XSLT and custom finder options for your named routes.
Clone URL: git://github.com/queso/sitemap.git
queso (author)
Sat Mar 22 23:14:20 -0700 2008
commit  fada982cca27f23f9b3f054a83b6eab8605cbeac
tree    84071843693ccba42504648e3297dfdf53e92e4a
parent  5548eb300c1415a346f9d0d51235c474bfa4cfe5
sitemap / lib / sitemap_fu.rb
100644 38 lines (29 sloc) 0.846 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
module Queso
  module Acts
    module Sitemap
   
      def self.included(base)
        base.extend ClassMethods
      end
      
      module ClassMethods
        
        def has_sitemap
          after_save :ping_all_search_engines
          include Queso::Acts::Sitemap::InstanceMethods
        end
        
      end
      
      module InstanceMethods
        require 'open-uri'
        
        def ping_all_search_engines
          return true
          ensure
            ping_search_engine(google.com)
        end
        
        def ping_search_engine(url)
          if location = SitemapSetting.find(:first).xml_location
            response = open("http://#{url}//ping?sitemap=#{location}")
            logger.info("Just tried to ping #{url} with a sitemap update.")
          end
        end
        
      end
    end
  end
end