Hashar has uploaded a new change for review. https://gerrit.wikimedia.org/r/68343
Change subject: experimental breadcrumb display ...................................................................... experimental breadcrumb display Work in progress. The aim is to use the root index.php as a router that interprets pathinfo. That would let us display directories content wrapped in the bootstrap skin. Related Apache configuration for nightly builds: AcceptPathInfo On RewriteEngine on RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME} !-f RewriteRule ^/(nightly.*) /index.php?path=$1 [last] The RewriteCond ensure Apache serve the file whenever it exists on the filesystem, for example tarballs. Change-Id: I5473866da2e77e538678390b26dfb636879d3448 --- M org/wikimedia/integration/index.php M shared/IntegrationPage.php 2 files changed, 59 insertions(+), 1 deletion(-) git pull ssh://gerrit.wikimedia.org:29418/integration/docroot refs/changes/43/68343/1 diff --git a/org/wikimedia/integration/index.php b/org/wikimedia/integration/index.php index 50fa764..3026787 100644 --- a/org/wikimedia/integration/index.php +++ b/org/wikimedia/integration/index.php @@ -2,5 +2,43 @@ require_once( __DIR__ . '/../../../shared/IntegrationPage.php' ); $p = IntegrationPage::newFromPageName( 'Continuous integration' ); +$p->enableBreadcrumb(); $p->enableFooter(); -$p->addHtmlFile('mainpage.html'); +$p->setBootstrapPath( '/bootstrap' ); + +$defaultPage = 'mainpage.html'; +if( !isset( $_GET['path'] ) ) { + $p->addHtmlFile( $defaultPage ); + exit(0); +} + +$path = preg_replace( '/\.\./', '', $_GET['path'] ); +$path = rtrim( $path, '/' ); +$localPath = __DIR__ . "/$path"; + +$candidate = "$localPath/$defaultPage"; +if( is_file( $candidate ) ) { + $p->addHtmlFile( $candidate ); + continue; +} + +if( is_dir( $localPath ) ) { + $html = '<ul>'; + foreach( new DirectoryIterator( $localPath ) as $fileInfo ) { + if( $fileInfo->isDot() ) { + continue; + } + $fname = $fileInfo->getFilename(); + if( $fileInfo->isDir() ) { + $html .= "<li><a href=\"/$path/$fname/\">$fname/</a></li>"; + } else { + $modified = date( 'd-M-Y H:i', $fileInfo->getMTime() ); + $size = $fileInfo->getSize(); + $html .= "<li><a href=\"$fname\">$fname</a> - $modified - $size bytes</li>"; + } + } + $html .= '</ul>'; + $p->addHtmlContent( $html ); +} + +// TODO error? diff --git a/shared/IntegrationPage.php b/shared/IntegrationPage.php index 17de7da..45c4ea4 100644 --- a/shared/IntegrationPage.php +++ b/shared/IntegrationPage.php @@ -5,6 +5,7 @@ protected $embeddedCSS = array(); protected $scripts = array(); protected $content = ''; + protected $hasBreadcrumb = false; protected $hasFooter = false; /** @@ -79,6 +80,24 @@ */ public function addScript( $src ) { $this->scripts[] = $src; + } + + public function enableBreadcrumb() { + $this->hasBreadcrumb = true; + } + + public function getBreadcrumb() { + $bits = explode( '/', trim( htmlspecialchars($_SERVER['SCRIPT_URL']), '/' ) ); + $html = '<ul class="breadcrumb">'; + $html .= '<li><a href="/">CI</a> <span class="divider">/</span></li>'; + + $last = array_pop($bits); + foreach( $bits as $dir ) { + $html .= "<li><a href=\"#\">$dir</a> <span class=\"divider\">/</span></li>\n"; + } + $html .= "<li class=\"active\">$last</li>\n</ul>\n"; + + return $html; } public function enableFooter() { @@ -202,6 +221,7 @@ <?php echo htmlentities( $this->pageName ); ?> </h2> </div> +<?php if ( $this->hasBreadcrumb ) { echo $this->getBreadcrumb(); } ?> <?php echo "\t\t" . implode( "\n\t\t", explode( "\n", $this->content ) ) . "\n"; ?> </div><!-- /.container --> <?php if ( $this->hasFooter ) { echo "\t<div class=\"push\"></div>\n"; } ?> -- To view, visit https://gerrit.wikimedia.org/r/68343 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I5473866da2e77e538678390b26dfb636879d3448 Gerrit-PatchSet: 1 Gerrit-Project: integration/docroot Gerrit-Branch: master Gerrit-Owner: Hashar <has...@free.fr> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits