Improve appearance of libraries on Special:Version
authorKunal Mehta <legoktm@gmail.com>
Fri, 26 Jun 2015 01:30:40 +0000 (18:30 -0700)
committerBryanDavis <bdavis@wikimedia.org>
Fri, 26 Jun 2015 21:26:05 +0000 (21:26 +0000)
* 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
includes/specials/SpecialVersion.php
languages/i18n/en.json
languages/i18n/qqq.json
resources/src/mediawiki.special/mediawiki.special.version.css
tests/phpunit/includes/libs/composer/ComposerLockTest.php

index 9c7bf2f..22c3319 100644 (file)
@@ -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']: '',
                        );
                }
 
index 4442d81..0a91957 100644 (file)
@@ -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()
index 25ae0a2..b63ddf4 100644 (file)
        "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": "",
index 7288066..11ea692 100644 (file)
        "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]]",
index b4efa9a..5b259e7 100644 (file)
@@ -1,7 +1,8 @@
 /*!
  * Styling for Special:Version
  */
-.mw-version-ext-name {
+.mw-version-ext-name,
+.mw-version-library-name {
        font-weight: bold;
 }
 
index b5fd5f6..cac3b10 100644 (file)
@@ -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 );
        }