From 43456295268af451cd68ab0a6d70009a94e99a1a Mon Sep 17 00:00:00 2001 From: Kunal Mehta Date: Thu, 25 Jun 2015 18:30:40 -0700 Subject: [PATCH] Improve appearance of libraries on Special:Version * Added licenses * Added description (will always be in English) * Added authors * Bold library name, like we do with extensions and skins Change-Id: I880756b489fb5a3f81d398d32162a186a1b919d8 --- includes/libs/composer/ComposerLock.php | 3 + includes/specials/SpecialVersion.php | 27 ++++++-- languages/i18n/en.json | 3 + languages/i18n/qqq.json | 3 + .../mediawiki.special.version.css | 3 +- .../libs/composer/ComposerLockTest.php | 61 +++++++++++++++++++ 6 files changed, 95 insertions(+), 5 deletions(-) diff --git a/includes/libs/composer/ComposerLock.php b/includes/libs/composer/ComposerLock.php index 9c7bf2f9ac..22c33191d7 100644 --- a/includes/libs/composer/ComposerLock.php +++ b/includes/libs/composer/ComposerLock.php @@ -30,6 +30,9 @@ class ComposerLock { $deps[$installed['name']] = array( 'version' => ComposerJson::normalizeVersion( $installed['version'] ), 'type' => $installed['type'], + 'licenses' => isset( $installed['license'] ) ? $installed['license'] : array(), + 'authors' => isset( $installed['authors'] ) ? $installed['authors'] : array(), + 'description' => isset( $installed['description'] ) ? $installed['description']: '', ); } diff --git a/includes/specials/SpecialVersion.php b/includes/specials/SpecialVersion.php index 4442d811e9..0a91957bf7 100644 --- a/includes/specials/SpecialVersion.php +++ b/includes/specials/SpecialVersion.php @@ -522,6 +522,9 @@ class SpecialVersion extends SpecialPage { $out .= Html::openElement( 'tr' ) . Html::element( 'th', array(), $this->msg( 'version-libraries-library' )->text() ) . Html::element( 'th', array(), $this->msg( 'version-libraries-version' )->text() ) + . Html::element( 'th', array(), $this->msg( 'version-libraries-license' )->text() ) + . Html::element( 'th', array(), $this->msg( 'version-libraries-description' )->text() ) + . Html::element( 'th', array(), $this->msg( 'version-libraries-authors' )->text() ) . Html::closeElement( 'tr' ); foreach ( $lock->getInstalledDependencies() as $name => $info ) { @@ -530,13 +533,28 @@ class SpecialVersion extends SpecialPage { // in their proper section continue; } + $authors = array_map( function( $arr ) { + // If a homepage is set, link to it + if ( isset( $arr['homepage'] ) ) { + return "[{$arr['homepage']} {$arr['name']}]"; + } + return $arr['name']; + }, $info['authors'] ); + $authors = $this->listAuthors( $authors, false, "$IP/vendor/$name" ); $out .= Html::openElement( 'tr' ) . Html::rawElement( 'td', array(), - Linker::makeExternalLink( "https://packagist.org/packages/$name", $name ) + Linker::makeExternalLink( + "https://packagist.org/packages/$name", $name, + true, '', + array( 'class' => 'mw-version-library-name' ) + ) ) . Html::element( 'td', array(), $info['version'] ) + . Html::element( 'td', array(), $this->listToText( $info['licenses'] ) ) + . Html::element( 'td', array(), $info['description'] ) + . Html::rawElement( 'td', array(), $authors ) . Html::closeElement( 'tr' ); } $out .= Html::closeElement( 'table' ); @@ -959,7 +977,8 @@ class SpecialVersion extends SpecialPage { * 'and others' will be added to the end of the credits. * * @param string|array $authors - * @param string $extName Name of the extension for link creation + * @param string|bool $extName Name of the extension for link creation, + * false if no links should be created * @param string $extDir Path to the extension root directory * * @return string HTML fragment @@ -972,7 +991,7 @@ class SpecialVersion extends SpecialPage { if ( $item == '...' ) { $hasOthers = true; - if ( $this->getExtAuthorsFileName( $extDir ) ) { + if ( $extName && $this->getExtAuthorsFileName( $extDir ) ) { $text = Linker::link( $this->getPageTitle( "Credits/$extName" ), $this->msg( 'version-poweredby-others' )->escaped() @@ -991,7 +1010,7 @@ class SpecialVersion extends SpecialPage { } } - if ( !$hasOthers && $this->getExtAuthorsFileName( $extDir ) ) { + if ( $extName && !$hasOthers && $this->getExtAuthorsFileName( $extDir ) ) { $list[] = $text = Linker::link( $this->getPageTitle( "Credits/$extName" ), $this->msg( 'version-poweredby-others' )->escaped() diff --git a/languages/i18n/en.json b/languages/i18n/en.json index 25ae0a25e4..b63ddf4095 100644 --- a/languages/i18n/en.json +++ b/languages/i18n/en.json @@ -3352,6 +3352,9 @@ "version-libraries": "Installed libraries", "version-libraries-library": "Library", "version-libraries-version": "Version", + "version-libraries-license": "License", + "version-libraries-description": "Description", + "version-libraries-authors": "Authors", "redirect": "Redirect by file, user, page or revision ID", "redirect-legend": "Redirect to a file or page", "redirect-text": "", diff --git a/languages/i18n/qqq.json b/languages/i18n/qqq.json index 7288066925..11ea692569 100644 --- a/languages/i18n/qqq.json +++ b/languages/i18n/qqq.json @@ -3522,6 +3522,9 @@ "version-libraries": "Header on [[Special:Version]] above a table that lists installed external libraries and their version numbers.", "version-libraries-library": "Column header for the library's name\n{{Identical|Library}}", "version-libraries-version": "Column header for the library's version number\n{{Identical|Version}}", + "version-libraries-license": "Column header for the library's license", + "version-libraries-description": "Column header for the library's description", + "version-libraries-authors": "Column header for the library's authors", "redirect": "{{doc-special|Redirect}}\nThis means \"Redirect by file'''name''', user '''ID''', page '''ID''', or revision ID\".", "redirect-legend": "Legend of fieldset around input box in [[Special:Redirect]]", "redirect-text": "Inside fieldset for [[Special:Redirect]]", diff --git a/resources/src/mediawiki.special/mediawiki.special.version.css b/resources/src/mediawiki.special/mediawiki.special.version.css index b4efa9a58a..5b259e70ab 100644 --- a/resources/src/mediawiki.special/mediawiki.special.version.css +++ b/resources/src/mediawiki.special/mediawiki.special.version.css @@ -1,7 +1,8 @@ /*! * Styling for Special:Version */ -.mw-version-ext-name { +.mw-version-ext-name, +.mw-version-library-name { font-weight: bold; } diff --git a/tests/phpunit/includes/libs/composer/ComposerLockTest.php b/tests/phpunit/includes/libs/composer/ComposerLockTest.php index b5fd5f6e71..cac3b10145 100644 --- a/tests/phpunit/includes/libs/composer/ComposerLockTest.php +++ b/tests/phpunit/includes/libs/composer/ComposerLockTest.php @@ -27,34 +27,95 @@ class ComposerLockTest extends MediaWikiTestCase { 'wikimedia/cdb' => array( 'version' => '1.0.1', 'type' => 'library', + 'licenses' => array( 'GPL-2.0' ), + 'authors' => array( + array( + 'name' => 'Tim Starling', + 'email' => 'tstarling@wikimedia.org', + ), + array( + 'name' => 'Chad Horohoe', + 'email' => 'chad@wikimedia.org', + ), + ), + 'description' => 'Constant Database (CDB) wrapper library for PHP. Provides pure-PHP fallback when dba_* functions are absent.', ), 'cssjanus/cssjanus' => array( 'version' => '1.1.1', 'type' => 'library', + 'licenses' => array( 'Apache-2.0' ), + 'authors' => array(), + 'description' => 'Convert CSS stylesheets between left-to-right and right-to-left.', ), 'leafo/lessphp' => array( 'version' => '0.5.0', 'type' => 'library', + 'licenses' => array( 'MIT', 'GPL-3.0' ), + 'authors' => array( + array( + 'name' => 'Leaf Corcoran', + 'email' => 'leafot@gmail.com', + 'homepage' => 'http://leafo.net', + ), + ), + 'description' => 'lessphp is a compiler for LESS written in PHP.', ), 'psr/log' => array( 'version' => '1.0.0', 'type' => 'library', + 'licenses' => array( 'MIT' ), + 'authors' => array( + array( + 'name' => 'PHP-FIG', + 'homepage' => 'http://www.php-fig.org/', + ), + ), + 'description' => 'Common interface for logging libraries', ), 'oojs/oojs-ui' => array( 'version' => '0.6.0', 'type' => 'library', + 'licenses' => array( 'MIT' ), + 'authors' => array(), + 'description' => '', ), 'composer/installers' => array( 'version' => '1.0.19', 'type' => 'composer-installer', + 'licenses' => array( 'MIT' ), + 'authors' => array( + array( + 'name' => 'Kyle Robinson Young', + 'email' => 'kyle@dontkry.com', + 'homepage' => 'https://github.com/shama', + ), + ), + 'description' => 'A multi-framework Composer library installer', ), 'mediawiki/translate' => array( 'version' => '2014.12', 'type' => 'mediawiki-extension', + 'licenses' => array( 'GPL-2.0+' ), + 'authors' => array( + array( + 'name' => 'Niklas Laxström', + 'email' => 'niklas.laxstrom@gmail.com', + 'role' => 'Lead nitpicker', + ), + array( + 'name' => 'Siebrand Mazeland', + 'email' => 's.mazeland@xs4all.nl', + 'role' => 'Developer', + ), + ), + 'description' => 'The only standard solution to translate any kind of text with an avant-garde web interface within MediaWiki, including your documentation and software', ), 'mediawiki/universal-language-selector' => array( 'version' => '2014.12', 'type' => 'mediawiki-extension', + 'licenses' => array( 'GPL-2.0+', 'MIT' ), + 'authors' => array(), + 'description' => 'The primary aim is to allow users to select a language and configure its support in an easy way. Main features are language selection, input methods and web fonts.', ), ), $lock->getInstalledDependencies(), false, true ); } -- 2.20.1