User:Ahmad252/Wiktionary Main Page transition

From Wikidata
Jump to navigation Jump to search

I learned this from the English Wiktionary and I have implemented it in Persian Wiktionary. It works.

Important: Interface Administrator right is needed for this process to work.

  1. Go to MediaWiki:Common.css on your local Wiktionary, and add the following piece of code to the bottom of the page:
    /* Main Page heading removal */
    .page-Wiktionary_Main_Page #lastmod,
    .page-Wiktionary_Main_Page #siteSub,
    .page-Wiktionary_Main_Page #contentSub,
    /* .page-Wiktionary_Main_Page #siteNotice, */
    .page-Wiktionary_Main_Page h1.firstHeading,
    .page-Wiktionary_Main_page #lastmod,
    .page-Wiktionary_Main_page #siteSub,
    .page-Wiktionary_Main_page #contentSub,
    .page-Wiktionary_Main_page #firstHeading {
    	display: none; /* NOT important */
    }
    
    Note that you should change "Wiktionary_Main_page" to the title of the new main page. For example, in Persian Wiktionary, the new main page is located at "ویکی‌واژه:صفحهٔ_اصلی", so the correct version of the code is:
    /* Main Page heading removal */
    .page-ویکیواژه_صفحهٔ_اصلی #lastmod,
    .page-ویکیواژه_صفحهٔ_اصلی #siteSub,
    .page-ویکیواژه_صفحهٔ_اصلی #contentSub,
    /* .page-ویکی‌واژه_صفحهٔ_اصلی #siteNotice, */
    .page-ویکیواژه_صفحهٔ_اصلی h1.firstHeading,
    .page-ویکیواژه_صفحهٔ_اصلی #lastmod,
    .page-ویکیواژه_صفحهٔ_اصلی #siteSub,
    .page-ویکیواژه_صفحهٔ_اصلی #contentSub,
    .page-ویکیواژه_صفحهٔ_اصلی #firstHeading {
    display: none; /* NOT important */
    }
    
  2. Go to MediaWiki:Common.js on your local Wiktionary, and add the following piece of code to the bottom of the page:
    /* ==Page specific extensions== */
    /* ===[[Wiktionary:Main Page]]=== */
    mw.loader.using("mediawiki.util", function(){
    	// Hide the title and "Redirected from" (maybe we should keep the redirected from so's people update their bookmarks ;)
    	// Broken in IE!
    	if (mw.config.get('wgIsMainPage') && !(mw.config.get('wgAction') === 'view' || mw.config.get('wgAction') === 'submit')) {
    		mw.util.addCSS('.firstHeading { display: block !important; }');
    		mw.util.addCSS('#contentSub { display: inline !important; }');
    	}
    	
    	if (mw.config.get('wgIsMainPage')) {
    		$(function(){
    			mw.util.addPortletLink('p-lang', '//meta.wikimedia.org/wiki/Wiktionary#List_of_Wiktionaries',
    				'Complete list', 'interwiki-completelist', 'Complete list of Wiktionaries');
    		});
    	}
    });
    
    There are no technical changes necessary here, but you should preferably translate "Complete list" and "Complete list of Wiktionaries" to the language of your Wiktionary.
  3. Create MediaWiki:Mainpage and MediaWiki:Mainpage-url on your local Wiktionary with the name of the new main page. Don't add anything else. For English Wiktionary, for example, the content of these pages should be "Wiktionary:Main Page". For Persian Wiktionary, it should be "ویکی‌واژه:صفحهٔ اصلی". For French Wiktionary, it should be "Wiktionnaire:Page d’accueil", and so on.
  4. Create MediaWiki:Mainpage-text on your local Wiktionary with the name of the main page, excluding the namespace. It's basically translating "Main page" into your Wiktionary's language. So, for English Wiktionary, it should be "Main page", for Persian Wiktionary, it should be "صفحهٔ اصلی", for French Wiktionary, it should be "Page d’accueil", and so on. This step is apparently not necessary and can be ignored, but just in case.
  5. Now, move the main page to the project namespace. Make sure to leave a redirect behind. Preferably check the Wikidata item, Q5296, to see if it has been automatically updated when you moved the page. If not, edit it manually and update it. Some changes might not take effect immediately. You can try to purge the new main page to fix the problem; it worked for me.


I suspect that the need to edit and effect of editing MediaWiki:Mainpage-url and MediaWiki:Mainpage-text depend on MediaWiki:Sidebar, and most wikis have "mainpage|mainpage-description" there, thus MediaWiki:Mainpage must be edited. Taylor 49 (talk) 23:12, 20 April 2021 (UTC)