User:Cheeyang/sandbox

Source: Wikipedia, the free encyclopedia.

Toolbox

  1. Upload file
  2. Special Pages

Page Tabs

  1. Read
  2. Discussion
  3. Edit
  4. View History
  1. My talk
  2. My Sandbox
  3. My preferences
  4. My watchlist
  5. My contributions
  6. Log out
  1. Create a Book
  2. Download as PDF

Wiki Authoring

Wiki Editor

Wiki Editor should be enabled by default. If it still show old editor, turn on the following options in Special:Preferences#mw-prefsection-editing:

  1. Use live preview (requires JavaScript) (experimental)
  2. Enable enhanced editing toolbar
  3. Enable dialogs for inserting links, tables and more

Reference: mw:Extension:WikiEditor

Visual Editor

Visual Editor is a WYSISYG wiki editor. It is under heavy development now. Visit Special:VisualEditorSandbox to try the editor.

Reference: mw:Extension:VisualEditor

Magic words

Magic words are wiki text that will rendered by Wiki engine to produce meaningful information for user.

Reference: mw:Help:Magic_words

Wiki formatting

The basic wiki tag and formatting like bold, italic, paragraph, leveling and etc.

Reference: mw:Help:Formatting

Source code highlighting

Wiki Text:

<syntaxhighlight lang="delphi">
procedure TThreadList.Add(Item: Pointer);
begin
  LockList;
  try
    if (Duplicates = dupAccept) or
       (FList.IndexOf(Item) = -1) then
      FList.Add(Item)
    else if Duplicates = dupError then
      FList.Error(@SDuplicateItem, IntPtr(Item));
  finally
    UnlockList;
  end;
end;
</syntaxhighlight>

Wiki Output:

procedure TThreadList.Add(Item: Pointer);
begin
  LockList;
  try
    if (Duplicates = dupAccept) or
       (FList.IndexOf(Item) = -1) then
      FList.Add(Item)
    else if Duplicates = dupError then
      FList.Error(@SDuplicateItem, IntPtr(Item));
  finally
    UnlockList;
  end;
end;

Table of Contents

By default, a table of contents is automatically generated on a page when more than 3 sections headings are used.

Reference: mw:Manual:Table of Contents

Redirect a page

When a wiki site operate for a period of time, some topics may have outdated. However, those topics may have been referenced by others in numbers. It is not a good habit to rename the topic directly to make the URL reference dead. Instead, you should make old topic redirect to new topic:

#REDIRECT [[new_topic]]

Reference: mw:Help:Redirects

Template

Wiki Template allow same looks and feels for structured wiki text. A common usage of template is showing an information box of particular object type. By using template, the looks and feels for structured wiki text may change easily by just changing the template. All wiki pages that implement the template remain unchange.

To define template, create a page like:

Template:MyTemplate

To implement the template in your wiki text, enter text like:

{{MyTemplate}}

Reference: mw:Help:Templates

Export and Import

Special:Export allow users to export wiki pages and associated templates recursively into an XML file. The XML file may then import to another Wiki site.

Special:Import allow users to read a Wiki XML file and import into Wiki database.

A common usage of these functions are export templates from other wiki sites and import into your wiki site.

Reference: Special:Export, Special:Import

Interwiki

Interwiki links are links to pages of other projects, using a prefixed internal link style.

For example, a wiki text of:

[[google:estream|eStream Software]]

will rendered HTML text of

eStream Software

and redirect URL of:

http://www.google.com/search?q=estream

The usage of Interwiki reduce typing lengthy URL and provide a rather clean and neat wiki text.

To show a list of available Interwiki links, visit: api.php?action=query&meta=siteinfo&siprop=interwikimap

If an Interwiki extension is installed, the list of Interwiki may view in Special:Interwiki.

Reference: mw:Manual:Interwiki

Namespace

A namespace is a collection of pages which have content with a similar purpose.

Reference: mw:Manual:Namespace

Category

Mediawiki's categories provide automatic indexes that are useful as tables of contents.

To assign a category to a page, simply add a link like:

[[Category:Category name]]

to the page's wikitext. The usual place to add it is at the bottom of the page.

To create a link to a category, use a leading colon before the category name (without this colon, the current page would be added to the category):

[[:Category:Help]]Category:Help

Categories may also organize in a hierarchy by adding category wiki tag into category page.

To get categories information of a wiki site, visit Special:SpecialPages.

Reference: mw:Help:Categories

Change Page display title

A wiki page title always follow the page name by default. It can be change by placing a magic word in wiki text:

{{DISPLAYTITLE:New Page Title}}

Manage wiki site

Host on both HTTP and HTTPS server

Initially, MediaWiki work nice with HTTP protocol. It may work with HTTPS protocol too or work with both protocols in same machine. The HTTPS protocol is important if you allow user login to the site. Sending plain text password over HTTP protocol is not secure. Once the HTTPS service has installed with proper certificate and key, the wiki site should start serve data via HTTPS.

In some situations especially a fresh install wiki, web browse may report un-secure content being transfer. This is due to $wgServer has been fixed work to http protocol most of the time:

$wgServer = "http://<wiki-host>/"

Remove the line or mark $wgServer empty should make the wiki site work nice with both HTTP and HTTPS request.

Cache Control

MediaWiki has built in caching functions by default. This function always confuse users when a page has been edited or updated but it doesn't show changes immediately. To get rid of the problem, add or edit $wgCachePages in LocalSettings.php in wiki directory:

$wgCachePages = false;

Short URL

A default wiki URL use the URL string like:

http://<wiki-host>/wiki/index.php/Main_Page

To implement more clean RESTful URI should be something like:

http://<wiki-host>/wiki/Main_Page

The above URL hide the unnecessary implementation of wiki site. It is neat and shorter.

The following example use different script path (/w) and article path (/wiki):

First, rename wiki installation directory to "w", and change the files:

File: LocalSettings

$wgScriptPath = "/w";
$wgArticlePath = "/wiki/$1";
$wgUsePathInfo = true;

File: .htaccess in DocumentRoot of wiki site

RewriteEngine On
RewriteRule ^/?wiki(/.*)?$ w/index.php/$1 [L,QSA]

Reference: mw:Manual:ShortURL

Extensions

Extensions are always install in extensions directory of wiki root path. For example:

[estream@melaka extensions]$ ls -gG
total 52
drwxrwxr-x 4 4096 Mar 22 11:05 Collection
drwxr-xr-x 2 4096 May  2 21:39 ConfirmEdit
drwxr-xr-x 2 4096 May 24 11:12 EditUser
drwxr-xr-x 2 4096 May  2 21:39 Gadgets
drwxrwxr-x 2 4096 May 26 09:19 HideVariousTabsFromUnauthorizedUsers
drwxr-xr-x 2 4096 May  2 21:39 Nuke
drwxr-xr-x 6 4096 Apr 21 02:20 OpenID
drwxr-xr-x 2 4096 May  2 21:39 ParserFunctions
-rw-r--r-- 1 1053 May  2 21:39 README
drwxr-xr-x 2 4096 May  2 21:39 Renameuser
drwxrwxr-x 3 4096 Mar 10 11:10 SyntaxHighlight_GeSHi
drwxr-xr-x 3 4096 May  2 21:39 Vector
drwxr-xr-x 4 4096 May  2 21:39 WikiEditor

Most extension's configuration parameters are specified in LocalSettings.php.

Refer to each extension's wiki page for detail installation and configuration steps.

Source Code Highlighting

Install SyntaxHighlight GeSHi extension:

require_once( "$IP/extensions/SyntaxHighlight_GeSHi/SyntaxHighlight_GeSHi.php" );

Namespaces

There is a list build-in namespaces in MediaWiki. MediaWiki also allow custom namespaces for ease of Wiki articles management. The custom namespaces are defined in LocalSettings.php, for example:

define("NS_PROJECT1", 500);
define("NS_PROJECT1_TALK", 501);
define("NS_PROJECT2", 502);
define("NS_PROJECT2_TALK", 503);

$wgExtraNamespaces =
        array(
                NS_PROJECT1 => "Project1",
                NS_PROJECT1_TALK => "Project1_talk",
                NS_PROJECT2 => "Project2",
                NS_PROJECT2_TALK => "Project2_talk"
        );

To enable search for namespace, add:

$wgNamespacesToBeSearchedDefault[NS_PROJECT1] = true;
$wgNamespacesToBeSearchedDefault[NS_PROJECT2] = true;

A CSS style (MediaWiki:Common.css) may define for a custom namespace to show unique looks and feels:

.ns-500 #content { background-color: #f4f4f4; }
.ns-502 #content { background-color: #f3f3f3; }

Hide namespace prefix

The namespace prefix always appear in namespace wiki page. If the namespace prefix is some kind of short form, it would make the wiki page harder to read. To hide namespace prefix in wiki pages, install mw:Extension:HidePrefix extension:

require_once( "$IP/extensions/HidePrefix/HidePrefix.php" );

Reference: mw:Help:Namespaces

Disable Captcha

A new Wiki site may have ConfirmEdit extension installed. This extension have simple captcha enabled. If ConfirmEdit extension was installed, a simple math captcha prompt for answer when saving a wiki page that contain external URL link:

Your edit includes new external links. To help protect against automated spam, please solve the simple sum below and enter the answer in the box:

100+5 =

The purpose of the captcha is to fight against spamming. The captcha prompt may seems unnecessary for wiki site enforce with strict editing policy. e.g: only authorized users may edit wiki text.

To disable it, simply comment the following line in LocalSettings.php:

#require_once( "$IP/extensions/ConfirmEdit/ConfirmEdit.php" );

Interwiki

Install Interwiki extension to ease interwiki management:

require_once( "$IP/extensions/Interwiki/Interwiki.php" );

The following script grant sysops permissions to edit interwiki data:

$wgGroupPermissions['sysop']['interwiki'] = true;

Visit Special:Interwiki to manage Interwikis.

Reference: mw:Extension:Interwiki

PDF and Book

Install Collection extension to print friendly Wiki pages in PDF files. You may print a single topic and collect a group of topics to render in PDF file:

require_once( "$IP/extensions/Collection/Collection.php" );

A Print/export section appears in SideBar after installation.

Access Sidebar to define navigation bar on the left side of wiki page.

Reference: mw:Manual:Sidebar

Wiki Editor

To turn on wiki editor by default for users, add these lines:

$wgDefaultUserOptions['usebetatoolbar'] = true;
$wgDefaultUserOptions['usebetatoolbar-cgd'] = true;
$wgDefaultUserOptions['wikieditor-preview'] = true;

Enable file upload

Most file uploaded to wiki are image files. Those files are stored in OS file system rather than wiki database. To configure a directory storing uploaded file, make sure the web service process possess adequate permissions to store files.

Steps to enable file upload:

  1. Make sure images directory is writable by web server process:
    1. Change permission: chmod 777 wiki/images or
    2. Change owner/group: chown apache.apache wiki/images
  2. In Linux system, configure SELinux or disable it totally to make sure it won’t interrupt file written process.

A good practice to store uploaded files is keep them in separate directory and create a symbolic link "${IP}/images" to link to new image directory. This will make Mediawiki upgrade task easier.

In some situations, the upload might fail. Try install or update the following packages:

# yum install libwmf
# yum install gs

And add a line in LocalSettings.php:

$wgMaxShellMemory = 512000;

Enable SVG image support

SVG image isn't support by MediaWiki by default. Add these lines in LocalSettings.php to enable SVG support:

$wgFileExtensions[] = 'svg';
$wgSVGConverter = 'ImageMagick';

Reference: mw:Manual:Image_Administration

Allow changing page display title

To make DISPLAYTITLE magic word works:

{{DISPLAYTITLE:New Page Title}}

Add the following in LocalSettings.php:

$wgAllowDisplayTitle = true; // Option: true by default
$wgRestrictDisplayTitle = false;

In wikipedia site, a personal sandbox link appears on personal URLs when user login to the site. The personal sandbox link is not a standard feature of mediawiki. It is a customized feature but it's a useful feature. Follow the steps to add personal sandbox link like wikepedia:

  1. Install Gadgets extension:
    require_once( "$IP/extensions/Gadgets/Gadgets.php" );
    
  2. Visit MediaWiki:Gadgets-definition and edit the content to add gadgets. e.g.:
    * mySandbox[ResourceLoader|dependencies=mediawiki.util|default|rights=createpage]|mySandbox.js
  3. Visit Special:Gadgets to perform these 2 tasks:
    1. Add Gadget-mySandbox.js script (e.g.: wikipedia:MediaWiki:Gadget-mySandbox.js)
    2. Edit description for mySandbox gadget (e.g.: wikipedia:MediaWiki:Gadget-mySandbox)
  4. Wiki Users may visit Gadgets tab in Preferences page to enable or disable Gadgets.
  5. The Gadget-mySandbox.js script from wikipedia require a template: Template:User_sandbox. Export the template from wikipedia and import to your wiki site.
  6. Template User_sandbox require an image file: Essay.svg.

Import CSS

MediaWiki provides a specific place MediaWiki:Common.css to store customized CSS style sheet for wiki site. It is a common practice to import many nice templates from other wiki site (e.g.: [[wikipedia:|Wikipedia]]). Combining CSS and templates makes the wiki pages much readable.

Import other wiki site's CSS is fine but it is not easy to maintain especially if you have private CSS for your wiki site. Mixing other CSS and private CSS in a single Common.CSS could be a nightmare for sysops.

A good practice to maintain and use other's CSS is using import url syntax in CSS:

  1. Import other wiki site's CSS (e.g.: wikipedia:MediaWiki:Common.css) to own wiki site (e.g.: MediaWiki:Wikipedia.css).
  2. Update own CSS (e.g.: MediaWiki:Common.css) by adding a line:
    @import url("index.php?title=MediaWiki:Wikipedia.css&ctype=text/css&action=raw");
    
  3. More CSS may add to Common.css by using this method.

Access Control - Authentication

Local Accounts

LDAP Accounts

yum install php-ldap service httpd restart

To enable LDAP authentication a wiki site, install LdapAuthentication extension and enable LDAP setting in LocalSettings.php: require_once( "$IP/extensions/LdapAuthentication/LdapAuthentication.php" );

$wgAuth = new LdapAuthenticationPlugin(); $wgLDAPDomainNames = array( 'DOM'); $wgLDAPServerNames = array( 'DOM' => 'ldap.example.com'); $wgLDAPSearchAttributes = array( 'DOM' => 'uid'); $wgLDAPBaseDNs = array( 'DOM' => 'ou=staff,dc=example,dc=com'); $wgLDAPEncryptionType = array( 'DOM' => 'tls'); $wgMinimalPasswordLength = 1; There are 3 types of encryption available for $wgLDAPEncryptionType: ssl, tls and clear. The example use tls type. To use both local and LDAP authentication, set $wgLDAPUseLocal = true; To pull user preference, use something like this: $wgLDAPRetrievePrefs = array( 'DOM' => true ); $wgLDAPPreferences = array('DOM'=>array( "email"=>"mail","realname"=>"cn","nickname"=>"displayName")); MediaWiki in PHP platform requires the TLS certificate format in binary DER format (*.der) and not PEM format. 1.18 – master

The LdapAuthentication doesn’t support alias dereference. A workaround solution is to change line 230 of LdapAuthentication.php as follow: public static function ldap_search( $ldapconn, $basedn, $filter, $attributes=array(), $attrsonly=null, $sizelimit=null, $timelimit=null, $deref=3 null ) Change $deref=null to $deref=3.

OpenID Accounts

To prevent users login with local account, add these lines:

$wgOpenIDOnly = true;
$wgHideOpenIDLoginLink = true;  // optional

Access Control - Authorization

Prevent anonymous users to create account

$wgGroupPermissions['*']['createaccount'] = false;

Once the above rule has been enforce, the "Create Account" link will not appear in Wiki pages (Top left corner). To create user account, login to user who has permissions to do so, and visit Special:UserLogin to create accounts.

Prevent anonymous users edit wiki contents

The Edit and View History tab will disappear in anonymous account after enforce the rule:

$wgGroupPermissions['*']['edit'] = false;

Namespace access control

Assume there a group of wiki topics that you want to make it accessible by a particular user group only, you may organize those topics in a namespace and use Lockdown extension for access control.

For example, define a namespace NS_PRIVATE in LocalSettings.php:

## namespace
define("NS_PRIVATE", 500);
define("NS_PRIVATE_TALK", 501);

$wgExtraNamespaces =
        array(
                NS_PRIVATE => "Private",
                NS_PRIVATE_TALK => "Private_talk",
        );

And define the namespace to be accessed by bureaucrat users only:

$wgNamespacePermissionLockdown[NS_PRIVATE]['read'] = array('bureaucrat');

Miscellaneous

Rename tab name of a namespace

MediaWiki display namespace of an article on first tab of tab headers. The namespace may also show name other than namespace's name on tab header. For example, namespace Main shows "Page" instead of "Main" for a fresh MediaWiki installation.

The namespace description may change by edit the content of page:

[[MediaWiki:Nstab-{namespace}]]

Thus, to edit namespace Main's tab caption, visit MediaWiki:Nstab-main.

Hide Powered by Icon

Powered by icon are shown in wiki pages automatically. Add this line to hide it:

unset($wgFooterIcons['poweredby']);

Add this:

$wgShowIPinHeader = false;