Created
June 17, 2015 22:52
-
-
Save djaiss/16b58f5781978d1ae2f5 to your computer and use it in GitHub Desktop.
HOW TO NOTIFY SEARCH ENGINES WHEN YOU POST TO JEKYLL
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Credit / Stolen from http://natelandau.com/how-to-notify-services-when-post-jekyll/ | |
| # Ping Pingomatic | |
| desc 'Ping pingomatic' | |
| task :pingomatic do | |
| begin | |
| require 'xmlrpc/client' | |
| puts '* Pinging ping-o-matic' | |
| XMLRPC::Client.new('rpc.pingomatic.com', '/').call('weblogUpdates.extendedPing', 'YOURSITE.com' , 'http://YOURSITE.com', 'http://YOURSITE.com/atom.xml') | |
| rescue LoadError | |
| puts '! Could not ping ping-o-matic, because XMLRPC::Client could not be found.' | |
| end | |
| end | |
| # Ping Google | |
| desc 'Notify Google of the new sitemap' | |
| task :sitemapgoogle do | |
| begin | |
| require 'net/http' | |
| require 'uri' | |
| puts '* Pinging Google about our sitemap' | |
| Net::HTTP.get('www.google.com', '/webmasters/tools/ping?sitemap=' + URI.escape('http://YOURSITE.com/sitemap.xml')) | |
| rescue LoadError | |
| puts '! Could not ping Google about our sitemap, because Net::HTTP or URI could not be found.' | |
| end | |
| end | |
| # Ping Bing | |
| desc 'Notify Bing of the new sitemap' | |
| task :sitemapbing do | |
| begin | |
| require 'net/http' | |
| require 'uri' | |
| puts '* Pinging Bing about our sitemap' | |
| Net::HTTP.get('www.bing.com', '/webmaster/ping.aspx?siteMap=' + URI.escape('http://YOURSITE.com/sitemap.xml')) | |
| rescue LoadError | |
| puts '! Could not ping Bing about our sitemap, because Net::HTTP or URI could not be found.' | |
| end | |
| end | |
| # Ping pubsubhubbub | |
| desc 'Notify pubsubhubbub server.' | |
| task :pingpubsubhubbub do | |
| begin | |
| require 'cgi' | |
| require 'net/http' | |
| puts '* Pinging pubsubhubbub server' | |
| data = 'hub.mode=publish&hub.url=' + CGI::escape("http://YOURSITE.com/atom.xml") | |
| http = Net::HTTP.new('pubsubhubbub.appspot.com', 80) | |
| resp, data = http.post('http://pubsubhubbub.appspot.com/publish', | |
| data, | |
| {'Content-Type' => 'application/x-www-form-urlencoded'}) | |
| puts "Ping error: #{resp}, #{data}" unless resp.code == "204" | |
| end | |
| end # task: pubsubhubbub | |
| # rake notify | |
| desc 'Notify various services about new content' | |
| task :notify => [:pingomatic, :sitemapgoogle, :sitemapbing, :pingpubsubhubbub] do | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment