Commit 95fee40d authored by gbyte.co's avatar gbyte.co Committed by gbyte.co

Issue #3026182 by gbyte.co: Clean up nofollow logic in xsl output

parent 542734ae
......@@ -43,17 +43,16 @@ class SimplesitemapController extends ControllerBase {
* or its sitemap index file.
* Caches the response in case of expected output, prevents caching otherwise.
*
* @param \Symfony\Component\HttpFoundation\Request $request
* The request object.
*
* @param string $variant
* Optional name of sitemap variant.
* @see \hook_simple_sitemap_variants_alter()
* @see SimplesitemapManager::getSitemapVariants()
*
* @param \Symfony\Component\HttpFoundation\Request $request
* The request object.
*
* @throws NotFoundHttpException
*
* @return object
* @return \Symfony\Component\HttpFoundation\Response|false
* Returns an XML response.
*/
public function getSitemap(Request $request, $variant = NULL) {
......@@ -63,13 +62,15 @@ class SimplesitemapController extends ControllerBase {
}
return new Response($output, Response::HTTP_OK, [
'content-type' => 'application/xml',
'X-Robots-Tag' => 'noindex', // Tell search engines not to index the sitemap itself.
'Content-type' => 'application/xml; charset=utf-8',
'X-Robots-Tag' => 'noindex, follow',
]);
}
/**
* Returns the XML stylesheet for the sitemap.
*
* @return \Symfony\Component\HttpFoundation\Response
*/
public function getSitemapXsl() {
......@@ -80,7 +81,7 @@ class SimplesitemapController extends ControllerBase {
// Replace custom tokens in the XSL content with appropriate values.
$replacements = [
'[title]' => $this->t('Sitemap file'),
'[generated-by]' => $this->t('Generated by the <a href="@link">Simple XML sitemap</a> Drupal module.', ['@link' => 'https://www.drupal.org/project/simple_sitemap']),
'[generated-by]' => $this->t('Generated by the <a href="@link">@module_name</a> Drupal module.', ['@link' => 'https://www.drupal.org/project/simple_sitemap', '@module_name' => 'Simple XML sitemap']),
'[number-of-sitemaps]' => $this->t('Number of sitemaps in this index'),
'[sitemap-url]' => $this->t('Sitemap URL'),
'[number-of-urls]' => $this->t('Number of URLs in this sitemap'),
......@@ -96,14 +97,12 @@ class SimplesitemapController extends ControllerBase {
'[xsl-js]' => base_path() . $module_path . '/xsl/simple_sitemap.xsl.js',
'[xsl-css]' => base_path() . $module_path . '/xsl/simple_sitemap.xsl.css',
];
$xsl_content = strtr($xsl_content, $replacements);
// Output the XSL content.
$response = new Response($xsl_content);
$response->headers->set('Content-type', 'application/xml; charset=utf-8');
$response->headers->set('X-Robots-Tag', 'noindex, follow');
return $response;
return new Response(strtr($xsl_content, $replacements), Response::HTTP_OK, [
'Content-type' => 'application/xml; charset=utf-8',
'X-Robots-Tag' => 'noindex, nofollow',
]);
}
}
......@@ -110,7 +110,7 @@
<xsl:variable name="url_location">
<xsl:value-of select="sitemap:loc"/>
</xsl:variable>
<a href="{$url_location}" rel="nofollow">
<a href="{$url_location}">
<xsl:value-of select="$url_location"/>
</a>
</td>
......@@ -164,7 +164,7 @@
<xsl:value-of select="$url_language"/>
</dt>
<dd>
<a href="{$url_location}" rel="nofollow">
<a href="{$url_location}">
<xsl:value-of select="$url_location"/>
</a>
</dd>
......@@ -176,7 +176,7 @@
<xsl:value-of select="image:loc"/>
</xsl:variable>
<li>
<a href="{$image_location}" rel="nofollow">
<a href="{$image_location}">
<xsl:value-of select="$image_location"/>
</a>
</li>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment