Mailing List Archive

[MediaWiki-commits] [Gerrit] integration/docroot[master]: cover: Fix cover-extension breadcrumsb to work on different ...
Krinkle has uploaded a new change for review. ( https://gerrit.wikimedia.org/r/405986 )

Change subject: cover: Fix cover-extension breadcrumsb to work on different mount paths
......................................................................

cover: Fix cover-extension breadcrumsb to work on different mount paths

For local dev. Matches logic we use in top nav already.

Change-Id: Ifcd41842ca5944ef29ca6c4d04d4e466fb69271c
---
M shared/CoveragePage.php
M shared/Page.php
2 files changed, 13 insertions(+), 6 deletions(-)


git pull ssh://gerrit.wikimedia.org:29418/integration/docroot refs/changes/86/405986/1

diff --git a/shared/CoveragePage.php b/shared/CoveragePage.php
index 67d583a..8bb60e5 100644
--- a/shared/CoveragePage.php
+++ b/shared/CoveragePage.php
@@ -48,16 +48,18 @@
$this->embedCSS( file_get_contents( __DIR__ . '/cover.css' ) );

if ( $this->pageName === 'Test coverage' ) {
+ $href = $this->fixNavUrl( '/cover-extensions/' );
$breadcrumbs = <<<HTML
<ol class="breadcrumb">
<li class="active">Coverage home</li>
- <li><a href="/cover-extensions/">MediaWiki extensions</a></li>
+ <li><a href="$href">MediaWiki extensions</a></li>
</ol>
HTML;
} else {
+ $href = $this->fixNavUrl( '/cover/' );
$breadcrumbs = <<<HTML
<ol class="breadcrumb">
- <li><a href="/cover/">Coverage home</a></li>
+ <li><a href="$href">Coverage home</a></li>
<li class="active">MediaWiki extensions</li>
</ol>
HTML;
diff --git a/shared/Page.php b/shared/Page.php
index 801aa40..c82aa7a 100644
--- a/shared/Page.php
+++ b/shared/Page.php
@@ -248,15 +248,20 @@
);
}

+ protected function fixNavUrl( $href ) {
+ if ( $href[0] === '/' ) {
+ // Expand relatively so that it works even if the site is mounted in a sub directory.
+ $href = substr( $this->getRootPath(), 0, -1 ) . $href;
+ }
+ return $href;
+ }
+
protected function getNavHtml() {
$html = '<ul class="navbar-nav nav">';
$cur = $this->getRequestPath();
foreach ( $this->getNavItems() as $href => $text ) {
$active = ( $href === "/$cur" ? ' class="active"' : '' );
- if ( $href[0] === '/' ) {
- // Expand relatively so that it works even if the site is mounted in a sub directory.
- $href = substr( $this->getRootPath(), 0, -1 ) . $href;
- }
+ $href = $this->fixNavUrl( $href );
$html .= '<li' . $active . '><a href="' . htmlspecialchars( $href ) . '">' . htmlspecialchars( $text ) . '</a></li>';
}
$html .= '</ul>';

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ifcd41842ca5944ef29ca6c4d04d4e466fb69271c
Gerrit-PatchSet: 1
Gerrit-Project: integration/docroot
Gerrit-Branch: master
Gerrit-Owner: Krinkle <krinklemail@gmail.com>

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