Jdlrobson has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/58997


Change subject: Make the universe explode by making a desktop AND mobile skin 
called Minerva
......................................................................

Make the universe explode by making a desktop AND mobile skin called Minerva

This fills in various functions to make the skin work for desktop as well
as mobile

On mobile it adds reporttime to allow us to see how long it took for
the page to be served

To enable:
Add $wgValidSkinNames['minerva'] = "Minerva"; to LocalSettings.php
This kicks off some work which can lead to consistency between
desktop html markup and mobile html markup by beginning to surface
the mobile skin on the desktop site o_O
To test on desktop apply query string parameter ?useskin=minerva
or set $wgDefaultSkin = 'minerva';
Currently desktop skin is just bare bones content
with search (uses desktop search javascript)

TODO: Make Special:MobileMenu work
TODO: Probably want to rewrite footer without ob_start (also
        add desktop footer)
TODO: Ideally want to use a template engine such as mustache

Change-Id: Icfb9e570da7a15ea154ca1377fb245725279146d
---
M MobileFrontend.php
M includes/modules/MFResourceLoaderModule.php
M includes/skins/MinervaTemplate.php
A includes/skins/SkinMinerva.php
M includes/skins/SkinMobileBase.php
M includes/skins/SkinMobileTemplate.php
6 files changed, 103 insertions(+), 17 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MobileFrontend 
refs/changes/97/58997/1

diff --git a/MobileFrontend.php b/MobileFrontend.php
index 64657ba..d0b2eef 100644
--- a/MobileFrontend.php
+++ b/MobileFrontend.php
@@ -64,6 +64,7 @@
        'UnlistedSpecialMobilePage' => 'specials/UnlistedSpecialMobilePage',
        'SpecialLoginHandshake' => 'specials/SpecialLoginHandshake',
 
+       'SkinMinerva' => 'skins/SkinMinerva',
        'MinervaTemplate' => 'skins/MinervaTemplate',
        'SkinMobile' => 'skins/SkinMobile',
        'SkinMobileTemplate' => 'skins/SkinMobileTemplate',
@@ -158,7 +159,7 @@
        'raw' => true,
        'localBasePath' => $localBasePath,
        'remoteExtPath' => $remoteExtPath,
-       'targets' => 'mobile',
+       'targets' => array( 'mobile', 'desktop' ),
 );
 
 /**
@@ -206,6 +207,7 @@
        'position' => 'top',
 );
 
+// Important: This module is loaded on both mobile and desktop skin
 $wgResourceModules['mobile.startup'] = $wgMFMobileResourceBoilerplate + array(
        'styles' => array(
        ),
@@ -384,14 +386,11 @@
        'position' => 'top',
 );
 
-$wgResourceModules['mobile.stable'] = $wgMFMobileResourceBoilerplate + array(
+// Important: This module is loaded on both mobile and desktop skin
+$wgResourceModules['mobile.stable.universal'] = $wgMFMobileResourceBoilerplate 
+ array(
        'dependencies' => array(
-               'mediawiki.jqueryMsg',
                'mobile.startup',
                'mobile.stable.dependencies',
-               'mediawiki.util',
-               'mobile.stable.styles',
-               'mobile.site',
        ),
        'scripts' => array(
                'javascripts/externals/hogan.js',
@@ -400,6 +399,19 @@
                'javascripts/common/mf-view.js',
                'javascripts/widgets/progress-bar.js',
                'javascripts/common/mf-navigation.js',
+       ),
+);
+
+$wgResourceModules['mobile.stable'] = $wgMFMobileResourceBoilerplate + array(
+       'dependencies' => array(
+               'mediawiki.jqueryMsg',
+               'mobile.startup',
+               'mobile.stable.universal',
+               'mediawiki.util',
+               'mobile.stable.styles',
+               'mobile.site',
+       ),
+       'scripts' => array(
                'javascripts/common/mf-notification.js', 
'javascripts/modules/mf-homepage.js',
                'javascripts/modules/mf-cleanuptemplates.js',
                'javascripts/modules/mf-last-modified.js',
diff --git a/includes/modules/MFResourceLoaderModule.php 
b/includes/modules/MFResourceLoaderModule.php
index 2737ee4..a1cecb2 100644
--- a/includes/modules/MFResourceLoaderModule.php
+++ b/includes/modules/MFResourceLoaderModule.php
@@ -9,7 +9,7 @@
        protected $messages = array();
        protected $templates = array();
        protected $localBasePath;
-       protected $targets = array( 'mobile' );
+       protected $targets = array( 'mobile', 'desktop' );
        /** String: The local path to where templates are located, see 
__construct() */
        protected $localTemplateBasePath = '';
 
diff --git a/includes/skins/MinervaTemplate.php 
b/includes/skins/MinervaTemplate.php
index 2eb9bc5..6b91aee 100644
--- a/includes/skins/MinervaTemplate.php
+++ b/includes/skins/MinervaTemplate.php
@@ -2,9 +2,7 @@
 class MinervaTemplate extends BaseTemplate {
        private function prepareCommonData() {
                // set defaults
-               $this->set( 'content_navigation', array(
-                       'variants' => array(),
-               ) );
+               $this->set( 'postbodytext', '' );
                $this->set( 'language_urls', array() );
 
                $this->set( 'search-input-placeholder', wfMessage( 
'mobile-frontend-placeholder' )->escaped() );
@@ -40,7 +38,8 @@
                );
        }
 
-       public function prepareData() { // expects to be overriden
+       public function prepareData() {
+               $this->set( 'prebodytext', '<h1>' . $this->data[ 'title' ] . 
'</h1>' );
        }
 
        private function prepareBannerData() {
@@ -78,7 +77,30 @@
                return $this->data['language_urls'];
        }
 
-       public function renderLanguages( $languageTemplateData ) {
+       public function getDiscoveryTools() {
+               return $this->data['sidebar']['navigation'];
+       }
+
+       // FIXME: Design means that currently this menu can only cope with one 
item
+       public function getUserActionTools() {
+               if ( isset( $this->data['content_navigation']['actions'] ) ) {
+                       $actions = $this->data['content_navigation']['actions'];
+
+                       if ( isset( $actions['unwatch'] ) ) {
+                               $actions['unwatch']['class'] = 
'watch-this-article';
+                               $menu['unwatch'] = $actions['unwatch'];
+                       } else if ( isset( $actions['watch'] ) ) {
+                               $actions['watch']['class'] = 
'watch-this-article';
+                               $menu['watch'] = $actions['watch'];
+                       }
+
+               } else {
+                       $menu = array();
+               }
+               return $menu;
+       }
+
+       private function renderLanguages( $languageTemplateData ) {
                if ( $languageTemplateData['languages'] && count( 
$languageTemplateData['languages'] ) > 0 ) {
                ?>
                <div class="section" id="mw-mf-language-section">
@@ -144,6 +166,11 @@
                                        echo $this->html( 'header' );
                                ?>
                                        <ul id="mw-mf-menu-page">
+                                               <?php
+                                                       foreach( 
$this->getUserActionTools() as $key => $val ):
+                                                               echo 
$this->makeListItem( $key, $val );
+                                                       endforeach;
+                                               ?>
                                        </ul>
                                </div>
                                <div class='show' id='content_wrapper'>
@@ -173,7 +200,8 @@
                        </div><!-- close #mw-mf-page-center -->
                </div><!-- close #mw-mf-viewport -->
                <?php
-                       echo $data['bottomScripts'];
+                       echo $data['reporttime'];
+                       echo $data['bottomscripts'];
                ?>
                </body>
                </html>
diff --git a/includes/skins/SkinMinerva.php b/includes/skins/SkinMinerva.php
new file mode 100644
index 0000000..27d1216
--- /dev/null
+++ b/includes/skins/SkinMinerva.php
@@ -0,0 +1,45 @@
+<?php
+
+/**
+ * Minerva: Born from the godhead of Jupiter with weapons!
+ * A skin that works on both desktop and mobile
+ * @ingroup Skins
+ */
+class SkinMinerva extends SkinTemplate {
+       var $skinname = 'minerva',
+               $template = 'MinervaTemplate', $useHeadElement = true;
+
+       /**
+        * Initializes output page and sets up skin-specific parameters
+        * @param $out OutputPage object to initialize
+        */
+       public function initPage( OutputPage $out ) {
+               global $wgLocalStylePath;
+
+               parent::initPage( $out );
+               $modules = array(
+                       'mobile.startup',
+                       'mobile.stable.universal',
+               );
+               $out->addModules( $modules );
+
+       }
+
+       protected function prepareTemplate() {
+               $tpl = parent::prepareTemplate();
+               return $tpl;
+       }
+
+       /**
+        * @param $out OutputPage
+        */
+       public function setupSkinUserCss( OutputPage $out ) {
+               parent::setupSkinUserCss( $out );
+               // Add the ResourceLoader module to the page output
+               $styles = array(
+                       'mobile.styles',
+                       'mobile.styles.page',
+               );
+               $out->addModuleStyles( $styles );
+       }
+}
diff --git a/includes/skins/SkinMobileBase.php 
b/includes/skins/SkinMobileBase.php
index 32852dc..472112f 100644
--- a/includes/skins/SkinMobileBase.php
+++ b/includes/skins/SkinMobileBase.php
@@ -1,6 +1,6 @@
 <?php
 
-abstract class SkinMobileBase extends SkinTemplate {
+class SkinMobileBase extends SkinMinerva {
        /**
         * @var ExtMobileFrontend
         */
@@ -92,6 +92,7 @@
                        $notice = '';
                        wfRunHooks( 'GetMobileNotice', array( $this, &$notice ) 
);
                        $tpl->set( 'notice', $notice );
+                       $tpl->set( 'reporttime', wfReportTime() );
                        $tpl->execute();
                        wfProfileOut( __METHOD__  . '-tpl' );
                }
diff --git a/includes/skins/SkinMobileTemplate.php 
b/includes/skins/SkinMobileTemplate.php
index f2d7642..56598f4 100644
--- a/includes/skins/SkinMobileTemplate.php
+++ b/includes/skins/SkinMobileTemplate.php
@@ -2,14 +2,14 @@
 
 class SkinMobileTemplate extends MinervaTemplate {
        public function prepareData() {
-               global $wgExtensionAssetsPath,
-                       $wgMobileFrontendLogo;
+               global $wgExtensionAssetsPath;
                $data = $this->data;
 
                wfProfileIn( __METHOD__ );
                $this->setRef( 'wgExtensionAssetsPath', $wgExtensionAssetsPath 
);
-               $this->set( 'wgMobileFrontendLogo', $wgMobileFrontendLogo );
 
+               $this->set( 'bodytext', $data['bodytext'] );
+               $this->set( 'bottomscripts', $data['bcHack'] . 
$data['bottomScripts'] );
                if ( isset( $data['specialPageHeader'] ) ) {
                        $this->set( 'header', $data['specialPageHeader'] );
                }

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Icfb9e570da7a15ea154ca1377fb245725279146d
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/MobileFrontend
Gerrit-Branch: master
Gerrit-Owner: Jdlrobson <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to