jenkins-bot has submitted this change and it was merged.

Change subject: Clean up blueprint left nav
......................................................................


Clean up blueprint left nav

Make it configurable and fix display when
on a page not in the left nav.

Bug: T99757
Change-Id: Icfd60fcb6f229f6c535121cc27cd88f6b4c5207e
---
M Blueprint.php
A i18n/en.json
A i18n/qqq.json
M resources/toc.js
M src/BlueprintSkinTemplate.php
5 files changed, 50 insertions(+), 31 deletions(-)

Approvals:
  Prtksxna: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/Blueprint.php b/Blueprint.php
index 503e8f1..bb29502 100644
--- a/Blueprint.php
+++ b/Blueprint.php
@@ -82,17 +82,4 @@
 
 $wgValidSkinNames['blueprint'] = 'Blueprint';
 
-$wgBlueprintLeftNav = array(
-       'Main Page',
-       'Buttons',
-       'Inputs',
-       'Selects',
-       'Checks, radios and toggles',
-       'Guiders',
-       'Progress and loading indicators',
-       'Dialogs',
-       'Form layouts',
-       'Animation',
-       'Content views',
-       'FAQ',
-);
+$wgMessagesDirs['OOUIPlayground'] = __DIR__ . '/i18n';
diff --git a/i18n/en.json b/i18n/en.json
new file mode 100644
index 0000000..e44a6d5
--- /dev/null
+++ b/i18n/en.json
@@ -0,0 +1,3 @@
+{
+       "blueprint-left-nav": "* [[Main Page]]\n"
+}
diff --git a/i18n/qqq.json b/i18n/qqq.json
new file mode 100644
index 0000000..b9e22a9
--- /dev/null
+++ b/i18n/qqq.json
@@ -0,0 +1,3 @@
+{
+       "blueprint-left-nav": "List of links to show in the left navigation for 
the skin"
+}
diff --git a/resources/toc.js b/resources/toc.js
index ad3b535..f99bfd7 100644
--- a/resources/toc.js
+++ b/resources/toc.js
@@ -7,5 +7,6 @@
 
        $( '#toc' )
                .detach()
+               .addClass( 'sidebar-toc' )
                .appendTo( $appendTo );
 } );
diff --git a/src/BlueprintSkinTemplate.php b/src/BlueprintSkinTemplate.php
index 346c90c..76078b3 100755
--- a/src/BlueprintSkinTemplate.php
+++ b/src/BlueprintSkinTemplate.php
@@ -3,26 +3,51 @@
 class BlueprintSkinTemplate extends LightNCandyTemplate {
        public function execute() {
                global $wgBlueprintLeftNav;
-               // Someone may have used {{DISPLAYTITLE:}} to monkey with the 
title, e.g.
-               // to hide or color it; then data['title'] has the <div> 
contents in it
-               // (T103454). Could use Sanitizer::stripAllTags( 
$this->data['title'] ),
-               // but instead use thispage.
-               $this->data['left_nav_sections'] = array_map(
-                       function($title) {
-                               $title = Title::newFromText( $title );
-                               return array(
-                                       'text' => $title->getPrefixedText(),
-                                       'title' => $title,
-                                       'url' => $title->getFullUrl(),
-                                       'current' => $title->equals( 
Title::newFromText( $this->data['thispage'] ) ),
-                               );
-                       },
-                       $wgBlueprintLeftNav
-               );
-               // die( var_dump( $this->data['left_nav_sections'] ) );
+
+               $this->data['left_nav_sections'] = $this->getLeftNav();
                return parent::execute();
        }
 
+       protected function getLeftNav() {
+               global $wgMemc;
+
+               $cacheKey = wfMemcKey( 'blueprint', 'left-nav' );
+
+               $cacheVal = $wgMemc->get( $cacheKey );
+
+               if ( $cacheVal ) {
+                       return $cacheVal;
+               } else {
+                       $text = wfMessage( 'blueprint-left-nav' )->plain();
+                       $leftNav = array();
+                       $page_regex = '([^\[\]\|]+)';
+                       $line_regex = 
'/^[#*]\s*\[\['.$page_regex.'(?:\|'.$page_regex.')?\]\]$/';
+
+                       foreach( explode( "\n", $text ) as $line ) {
+                               $matches = null;
+                               if ( preg_match( $line_regex, $line, $matches ) 
) {
+                                       $title = Title::newFromText( 
$matches[1] );
+                                       $text = isset( $matches[2] ) ? 
$matches[2] : $matches[1];
+
+                                       // Someone may have used 
{{DISPLAYTITLE:}} to monkey with the title, e.g.
+                                       // to hide or color it; then 
data['title'] has the <div> contents in it
+                                       // (T103454). Could use 
Sanitizer::stripAllTags( $this->data['title'] ),
+                                       // but instead use thispage.
+                                       $leftNav[] = array(
+                                               'text' => $text,
+                                               'title' => $title,
+                                               'url' => $title->getFullUrl(),
+                                               'current' => $title->equals( 
Title::newFromText( $this->data['thispage'] ) ),
+                                       );
+                               }
+                       }
+
+                       $wgMemc->set( $cacheKey, $leftNav, 300 ); // Cache for 
five minutes
+
+                       return $leftNav;
+               }
+       }
+
        public function getTemplate() {
                $templating = new SimpleLightNCandy( __DIR__ . '/../templates' 
);
 

-- 
To view, visit https://gerrit.wikimedia.org/r/205217
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Icfd60fcb6f229f6c535121cc27cd88f6b4c5207e
Gerrit-PatchSet: 4
Gerrit-Project: mediawiki/skins/Blueprint
Gerrit-Branch: master
Gerrit-Owner: Werdna <agarr...@wikimedia.org>
Gerrit-Reviewer: Prtksxna <psax...@wikimedia.org>
Gerrit-Reviewer: Siebrand <siebr...@kitano.nl>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to