Sbisson has uploaded a new change for review. (
https://gerrit.wikimedia.org/r/403416 )
Change subject: Implement robot-policy
......................................................................
Implement robot-policy
* Actions other than 'view' have 'noindex,nofollow'
* Hidden topics have 'noindex,nofollow'
* View board and view (visible) topic use the
Article getRobotPolicy algorithm using the board
title. It respects $wgArticleRobotPolicies,
$wgNamespaceRobotPolicies and $wgDefaultRobotPolicy.
* Magic words are not currently supported.
Bug: T105322
Bug: T184185
Change-Id: Idefb5ee59e809a0e11edc1948295405ac57fea42
---
M includes/View.php
1 file changed, 33 insertions(+), 2 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Flow
refs/changes/16/403416/1
diff --git a/includes/View.php b/includes/View.php
index dbb547e..f1284e8 100644
--- a/includes/View.php
+++ b/includes/View.php
@@ -2,8 +2,10 @@
namespace Flow;
+use Article;
use ContextSource;
use Flow\Block\AbstractBlock;
+use Flow\Block\TopicBlock;
use Flow\Exception\InvalidActionException;
use Flow\Model\Anchor;
use Flow\Model\HtmlRenderingInformation;
@@ -75,7 +77,33 @@
$block->setPageTitle( $output );
}
- $this->renderApiResponse( $apiResponse );
+ $robotPolicy = $this->getRobotPolicy( $action,
$loader->getWorkflow(), $blocks );
+ $this->renderApiResponse( $apiResponse, $robotPolicy );
+ }
+
+ private function getRobotPolicy( $action, $workflow, $blocks ) {
+ if ( $action !== 'view' ) {
+ // consistent with 'edit' and other action pages in Core
+ return [
+ 'index' => 'noindex',
+ 'follow' => 'nofollow',
+ ];
+ }
+
+ if ( $workflow->getType() === 'topic' ) {
+ /** @var TopicBlock $topic */
+ $topic = $blocks[ 'topic' ];
+ if ( $topic->loadTopicTitle()->isHidden() ) {
+ return [
+ 'index' => 'noindex',
+ 'follow' => 'nofollow',
+ ];
+ }
+ }
+
+ $boardTitle = $workflow->getOwnerTitle();
+ $article = Article::newFromTitle( $boardTitle,
$this->getContext() );
+ return $article->getRobotPolicy( /* unused $action parameter */
null );
}
protected function addModules( OutputPage $out, $action ) {
@@ -241,7 +269,7 @@
return $apiResponse;
}
- protected function renderApiResponse( array $apiResponse ) {
+ protected function renderApiResponse( array $apiResponse, array
$robotPolicy ) {
// Render the flow-component wrapper
if ( empty( $apiResponse['blocks'] ) ) {
return [];
@@ -325,6 +353,9 @@
],
$template( $apiResponse )
) );
+
+ $out->setIndexPolicy( $robotPolicy[ 'index' ] );
+ $out->setFollowPolicy( $robotPolicy[ 'follow' ] );
}
}
--
To view, visit https://gerrit.wikimedia.org/r/403416
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Idefb5ee59e809a0e11edc1948295405ac57fea42
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Flow
Gerrit-Branch: master
Gerrit-Owner: Sbisson <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits