r95320 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r95319‎ | r95320 | r95321 >
Date:19:27, 23 August 2011
Author:johnduhart
Status:ok (Comments)
Tags:
Comment:
(bug 30344) Add configuration variable for setting custom priorities when generating sitemaps
Modified paths:
  • /trunk/phase3/includes/DefaultSettings.php (modified) (history)
  • /trunk/phase3/maintenance/generateSitemap.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/DefaultSettings.php
@@ -4250,6 +4250,20 @@
42514251 */
42524252 $wgSitemapNamespaces = false;
42534253
 4254+/**
 4255+ * Custom namespace priorities for sitemaps. Setting this will allow you to
 4256+ * set custom priorities to namsepaces when sitemaps are generated using the
 4257+ * maintenance/generateSitemap.php script.
 4258+ *
 4259+ * This should be a map of namespace IDs to priority
 4260+ * Example:
 4261+ * $wgSitemapNamespacesPriorities = array(
 4262+ * NS_USER => '0.9',
 4263+ * NS_HELP => '0.0',
 4264+ * );
 4265+ */
 4266+$wgSitemapNamespacesPriorities = false;
 4267+
42544268 /** @} */ # end of search settings
42554269
42564270 /************************************************************************//**
Index: trunk/phase3/maintenance/generateSitemap.php
@@ -162,6 +162,8 @@
163163 }
164164
165165 private function setNamespacePriorities() {
 166+ global $wgSitemapNamespacesPriorities;
 167+
166168 // Custom main namespaces
167169 $this->priorities[self::GS_MAIN] = '0.5';
168170 // Custom talk namesspaces
@@ -183,6 +185,19 @@
184186 $this->priorities[NS_HELP_TALK] = '0.1';
185187 $this->priorities[NS_CATEGORY] = '0.5';
186188 $this->priorities[NS_CATEGORY_TALK] = '0.1';
 189+
 190+ // Custom priorities
 191+ if ( $wgSitemapNamespacesPriorities !== false ) {
 192+ foreach ( $wgSitemapNamespacesPriorities as $namespace => $priority ) {
 193+ $float = floatval( $priority );
 194+ if ( $float > 1.0 ) {
 195+ $priority = '1.0';
 196+ } elseif ( $float < 0.0 ) {
 197+ $priority = '0.0';
 198+ }
 199+ $this->priorities[$namespace] = $priority;
 200+ }
 201+ }
187202 }
188203
189204 /**

Follow-up revisions

RevisionCommit summaryAuthorDate
r95323Updating release-notes for r95320johnduhart19:42, 23 August 2011

Comments

#Comment by 😂 (talk | contribs)   19:32, 23 August 2011

Needs release notes. Otherwise ok :)

#Comment by Nikerabbit (talk | contribs)   05:28, 24 August 2011

Shouldn't the default values moved into DefaultSettings from the maintenance script?

#Comment by Nikerabbit (talk | contribs)   05:29, 24 August 2011

Also, the docs don't really say what is the effect or namespace priority.

Status & tagging log