Topic on Skin talk:Minerva Neue

Enabling AMC (Advanced Mobile Contributions) on a private wiki

4
Tinss (talkcontribs)

To enable AMC on your private wiki. In LocalSettings.php:

wfLoadSkin( 'MinervaNeue' );
...
$wgMinervaAdvancedMainMenu = ['base' => true];
$wgMinervaPersonalMenu = ['base' => true];

Then, in skins/MinervaNeue/includes/Menu/User/AdvancedUserMenuBuilder.php replace the getGroup method with the following code and set the mobile-frontend-user-create-account message.

	public function getGroup( array $personalTools ): Group {
                $group = new Group( 'p-personal' );

                if ( $this->user->isAnon() ) {
                        $entry = SingleMenuEntry::create(
                                'userContributions',
                                $this->messageLocalizer->msg( 'mobile-frontend-user-create-account' )->escaped(),
                                \SpecialPage::getSafeTitleFor('Create_account')->getLocalURL()
                        );
                        $group->insertEntry( $entry );

                        $this->definitions->insertLogInMenuItem( $group );
                        Hooks::run( 'MobileMenu', [ 'user', &$group ] );
                        return $group;
                }

                $group->insertEntry( new ProfileMenuEntry( $this->user ) );
                $talkPage = $this->user->getUserPage()->getTalkPageIfDefined();
                if ( $talkPage ) {
                        $entry = SingleMenuEntry::create(
                                'userTalk',
                                $this->messageLocalizer->msg( 'mobile-frontend-user-page-talk' )->escaped(),
                                $talkPage->getLocalURL()
                        );
                        $entry->setIcon( 'userTalk', 'before' );
                        $group->insertEntry( $entry );
                }

                $this->definitions->insertWatchlistMenuItem( $group );
                $this->definitions->insertContributionsMenuItem( $group );
                $this->definitions->insertLogOutMenuItem( $group );
                Hooks::run( 'MobileMenu', [ 'user', &$group ] );
                return $group;
        }

This code assumes that your wiki is private, but that users are free to create an account. If that is not the case, simply remove the line that adds a link to create an account.

If someone is willing to make that menu adapt to user permissions and commit it to the Minerva skin that would be great.

Jdlrobson (talkcontribs)
Tinss (talkcontribs)

In the user menu, Minerva will display for anonymous users the user's IP address, contributions, watchlist and so on. This makes sense for Wikipedia which allows anonymous users to edit, but on a private wiki which requires logging in for editing, this is not appropriate. In this cas, the only menu items for anonymous users should be to create an account or log in.

Jdlrobson (talkcontribs)

Ah thanks for clarifying.

In 1.38, you can use the following code in LocalSettings.php to disable menu items:

$wgHooks['SkinTemplateNavigation::Universal'][] = function ( $skinTemplate, &$links ) {
unset( $links['user-menu']['createaccount'] );
unset( $links['user-menu']['login'] );
unset( $links['user-menu']['login-private'] );
unset( $links['user-menu']['anoncontribs'] );
};

In MediaWiki < 1.38 I suggest hiding these elements by editing MediaWiki:Minerva.css add using


$wgMFSiteStylesRenderBlocking = true;
Reply to "Enabling AMC (Advanced Mobile Contributions) on a private wiki"