Add support for pinging bing (Fixes #22)

- Fix README install link
- Update documentation
This commit is contained in:
Will Rossiter 2016-09-17 08:27:16 +12:00
parent 31f9182e95
commit e607ea9fc4
5 changed files with 75 additions and 52 deletions

View File

@ -12,23 +12,24 @@
## Installation
> composer require "silverstripe/googlesitemaps"
> composer require "wilr/googlesitemaps"
## Documentation
SilverStripe provides support for the Google Sitemaps XML system, enabling
Google and other search engines to see all urls on your site. This helps
your SilverStripe website rank well in search engines, and to encourage the
information on your site to be discovered by Google quickly.
Provides support for the [Sitemaps XML Protocol](http://www.sitemaps.org/protocol.html),
enabling Google, Bing and other search engines to index the web pages on your
site. This helps your SilverStripe website rank well in search engines, and to
encourage the information on your site to be discovered by Google quickly.
Therefore, all Silverstripe websites contain a special controller which can
be visited: http://yoursite.com/sitemap.xml
Any new pages published or unpublished on your website automatically update the
Sitemap.
Flush this route to ensure the changes take effect with: http://yoursite.com/sitemap.xml?flush=1
See http://en.wikipedia.org/wiki/Sitemaps for info on this format.
The XML Sitemap can be accessed by going to http://yoursite.com/sitemap.xml
## Usage Overview
See docs/en for more information about configuring the module.
## Troubleshooting
* Flush this route to ensure the changes take effect (e.g http://yoursite.com/sitemap.xml?flush=1)

View File

@ -431,7 +431,7 @@ class GoogleSitemap extends Object
* If the site is in development mode no ping will be sent regardless whether
* the Google notification is enabled.
*
* @return string Response text
* @return boolean
*/
public static function ping()
{
@ -443,7 +443,7 @@ class GoogleSitemap extends Object
$active = Config::inst()->get('GoogleSitemap', 'google_notification_enabled');
if (!$active || Director::isDev()) {
return;
return false;
}
$location = urlencode(Controller::join_links(
@ -451,11 +451,20 @@ class GoogleSitemap extends Object
'sitemap.xml'
));
$response = self::send_ping(
$googleResponse = self::send_ping(
"www.google.com", "/webmasters/sitemaps/ping", sprintf("sitemap=%s", $location)
);
return $response;
// bing
$bing = Config::inst()->get('GoogleSitemap', 'bing_notification_enabled');
if($bing) {
$bingResponse = self::send_ping(
"www.bing.com", "/ping", sprintf("sitemap=%s", $location)
);
}
return true;
}
/**
@ -491,7 +500,8 @@ class GoogleSitemap extends Object
/**
* Convenience method for manufacturing an instance for hew instance-level methods (and for easier type definition).
* Convenience method for manufacturing an instance for hew instance-level
* methods (and for easier type definition).
*
* @return GoogleSitemap
*/

View File

@ -1,6 +1,6 @@
{
"name": "wilr/silverstripe-googlesitemaps",
"description": "SilverStripe support for the Google Sitemaps XML, enabling Google and other search engines to see all urls on your site. This helps your SilverStripe website rank well in search engines, and to encourage the information on your site to be discovered by Google quickly.",
"description": "SilverStripe support for the Google Sitemaps XML, enabling Google and other search engines to see all urls on your site. This helps your SilverStripe website rank well in search engines, and to encourage the information on your site to be discovered quickly.",
"type": "silverstripe-module",
"keywords": ["silverstripe", "googlesitemaps", "seo"],
"homepage": "https://github.com/wilr/silverstripe-googlesitemaps",

View File

@ -55,6 +55,18 @@ editing the `google_notification_enabled` option to true
google_notification_enabled: true
use_show_in_search: true
### Bing Ping Support
To ping Bing whenever your sitemap is updated, set `bing_notification_enabled`
---
Name: customgooglesitemaps
After: googlesitemaps
---
GoogleSitemap:
enabled: true
bing_notification_enabled: true
### Including DataObjects
The module provides support for including DataObject subclasses as pages in the