Media Wiki Concepts: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
 
(59 intermediate revisions by the same user not shown)
Line 6: Line 6:
=Directory Layout=
=Directory Layout=


<font size=-2>
  /
  /
  ├── etc
  ├── etc
  │    ├── [[#php.ini|php.ini]]
  │    ├── [[PHP#php.ini|php.ini]]
  │    └── php.d
  │    └── php.d
  │
  │
Line 28: Line 29:
               │     └── ...
               │     └── ...
                └── ...
                └── ...
</font>


=Versions=
=Versions=
The MediaWiki version, as well as PHP, database and extension versions can be read from Special pages → Version → Installed software.
See: {{Internal|Media_Wiki_Operations#Get_Media_Wiki_Version|Media Wiki Operations &#124; Get Media Wiki Version}}
=php.ini=
==LTS==
php.ini is the PHP configuration file. After changing it, use:
Long Term Support
<syntaxhighlight lang='shell'>
apachectl graceful
</syntaxhighlight>
to reload the configuration file without killing the server.
 
To find the location for the command line interpreter, run:
<syntaxhighlight lang='bash'>
php --ini
</syntaxhighlight>
To find the location for the web module, create a "phpinfo.php" file in http root, with the following content:
<syntaxhighlight lang='php'>
<?php
phpinfo();
</syntaxhighlight>
and load it through the web server.


=<tt>LocalSettings.php</tt>=
=<tt>LocalSettings.php</tt>=
{{External|https://www.mediawiki.org/wiki/Manual:LocalSettings.php}}
{{External|https://www.mediawiki.org/wiki/Manual:LocalSettings.php}}
The file is located in the root of the MediaWiki installation /var/www/<installation-dir>/LocalSettings.php. To enable a change, the web server needs to be restarted with:
The file is located in the root of the MediaWiki installation <code>/var/www/<installation-dir>/LocalSettings.php</code>. A fresh Media Wiki installation does not come with a <code>LocalSettings.php</code> file. The file must be generated by going to a configuration procedure driven by the web site, then manually placed in the directory.
 
To enable a change, the web server needs to be restarted with:
<syntaxhighlight lang='bash'>
<syntaxhighlight lang='bash'>
apachectl graceful
apachectl graceful
</syntaxhighlight>
</syntaxhighlight>
 
<code>LocalSettings.php</code> contains, among others, the following:
Contains, among others, the following:
==Database Type==
====Database Type====
<syntaxhighlight lang='php'>
<syntaxhighlight lang='php'>
$wgDBtype = "mysql";
$wgDBtype = "mysql";
</syntaxhighlight>
</syntaxhighlight>
====Database Hostname====
==Database Hostname==
<syntaxhighlight lang='php'>
<syntaxhighlight lang='php'>
$wgDBserver = "localhost";
$wgDBserver = "localhost";
</syntaxhighlight>
</syntaxhighlight>
====Database User ID====
==Database User ID==
<syntaxhighlight lang='php'>
<syntaxhighlight lang='php'>
$wgDBuser = "c3kb_wiki";
$wgDBuser = "c3kb_wiki";
</syntaxhighlight>
</syntaxhighlight>
====Database Password====
==Database Password==
<syntaxhighlight lang='php'>
<syntaxhighlight lang='php'>
$wgDBpassword = "...";
$wgDBpassword = "...";
</syntaxhighlight>
</syntaxhighlight>
====Database Default Character Set====
==Database Default Character Set==
<syntaxhighlight lang='php'>
<syntaxhighlight lang='php'>
$wgDBTableOptions = "ENGINE=InnoDB, DEFAULT CHARSET=binary";
$wgDBTableOptions = "ENGINE=InnoDB, DEFAULT CHARSET=binary";
</syntaxhighlight>
</syntaxhighlight>
====Database Name====
==Database Name==
<syntaxhighlight lang='php'>
<syntaxhighlight lang='php'>
$wgDBname = "c3kb_wiki";
$wgDBname = "c3kb_wiki";
</syntaxhighlight>
</syntaxhighlight>
====Site Name====
==<span id='Name_of_Wiki'></span><span id='Site_Name'></span>Name of Wiki (Site Name)==
This is a configuration element that needs to be specified during the [[Media_Wiki_Installation#Name_of_Wiki|wiki initialization procedure]], as the '''name of wiki'''. It will appear in the title bar of the browser and in various other places. It is also referred to as '''site name''' and configured in <code>LocalSettings.php</code> as:
<syntaxhighlight lang='php'>
<syntaxhighlight lang='php'>
$wgSitename = "Nova Ordis Knowledge Base";
$wgSitename = "NovaOrdis Knowledge Base";
</syntaxhighlight>
</syntaxhighlight>
====Server Name====
 
==Server Name==
{{External|https://www.mediawiki.org/wiki/Manual:$wgServer}}
{{External|https://www.mediawiki.org/wiki/Manual:$wgServer}}
<syntaxhighlight lang='php'>
<syntaxhighlight lang='php'>
$wgServer = "https://kb.novaordis.com";
$wgServer = "https://kb.novaordis.com";
</syntaxhighlight>
</syntaxhighlight>
<code>$wgServer</code> contains the base URL of the server, including protocol and optionally the port, if non-standard, but without the trailing slash and without the subdirectory if any (e.g., https://www.mediawiki.org). The links to the wiki site from inside the pages will contain this value, so it is important to set correctly, otherwise the links embedded in pages will not work.
<code>$wgServer</code> contains the base URL of the server, including protocol and optionally the port, if non-standard, but without the trailing slash and without the subdirectory if any (e.g., https&#58;//www.mediawiki.org). The links to the wiki site from inside the pages will contain this value, so it is important to set correctly, otherwise the links embedded in pages will not work.


For example, if the site will be accessed over a ssh tunnel from the local host over a non-standard port, then <code>wgServer</code> should be:
For example, if the site will be accessed over a ssh tunnel from the local host over a non-standard port, then <code>wgServer</code> should be:
Line 96: Line 86:
$wgServer = "http://localhost:10080";
$wgServer = "http://localhost:10080";
</syntaxhighlight>
</syntaxhighlight>
====wfLoadExtension====
 
==wfLoadExtension==
See [[#Extensions|Extensions]] below.
See [[#Extensions|Extensions]] below.
==Site Logo==
{{Internal|Media Wiki Configure Site Logo|Configure Site Logo}}
==<tt>wgFileExtensions</tt>==
See: {{Internal|Media_Wiki_Installation#Allow_PDF_Uploading|Media Wiki Installation &#124; Allow PDF Uploading}}
=<tt>index.php</tt>=
=<tt>index.php</tt>=
See: {{Internal|Media_Wiki_Troubleshooting#PHP_Errors|Media Wiki Troubleshooting &#124; PHP Errors}}


=DefaultSettings.php=
=<tt>DefaultSettings.php</tt>=


=MediaWiki:Common.css=
=<tt>MediaWiki:Common.css</tt>=
A page that contains CSS modifications to be applied to all skins. If it does not exist, it can be created.
A page that contains CSS modifications to be applied to all skins. It can be accessed by name: <code>[[MediaWiki:Common.css]]</code>. If it does not exist, it can be created. It is used by [[MediaWiki_Extension_SyntaxHighlight#Reduce_Font_Size|SyntaxHighlight extension]] and it can also be used to customize the rendering of HTML tags, such as <code>[[Media_Wiki_Concepts#.3Ccode.3E|&lt;code>]]</code>.
 
Used by:
* [[MediaWiki_Extension_SyntaxHighlight#Reduce_Font_Size|SyntaxHighlight extension]]


=Security=
=Security=
 
{{Internal|Media Wiki Security Concepts|Media Wiki Security Concepts}}
{{Internal|Media Wiki Security Concepts|Security Concepts}}


=Transclusion=
=Transclusion=
 
{{External|https://www.mediawiki.org/wiki/Transclusion}}
<blockquote style="background-color: AliceBlue; border: solid thin LightSteelBlue;">
'''Transclusion''' means the inclusion of the content of a document into another document by reference. The most common situation where transclusion is used is the use of [[#Templates|templates]]: the same content can be included in multiple documents without having having to edit those documents separately.
:https://www.mediawiki.org/wiki/Transclusion<br>
</blockquote>
 
''Transclusion'' means the inclusion of the content of a document into another document by reference. The most common situation where transclusion is used is the use of [[#Templates|templates]]: the same content can be included in multiple documents without having having to edit those documents separately.


=Namespace=
=Namespace=
{{External|https://www.mediawiki.org/wiki/Help:Namespaces}}
==Project namespace==
Following Wikipedia's example, many wikis keep their policy pages separate from their content pages, in a project namespace. All page titles in this namespace start with a certain prefix, which you can specify here. Usually, this prefix is derived from the name of the wiki, but it cannot contain punctuation characters such as "#" or ":".


<blockquote style="background-color: AliceBlue; border: solid thin LightSteelBlue;">
The project namespace is configuration element provided during the [[Media_Wiki_Installation#Project_Namespace|wiki initialization procedure]].
:https://www.mediawiki.org/wiki/Help:Namespaces<br>
</blockquote>


=Templates=
=Templates=
 
{{External|https://www.mediawiki.org/wiki/Help:Templates}}
<blockquote style="background-color: AliceBlue; border: solid thin LightSteelBlue;">
A '''template''' is a page in the "Template:" namespace that gets [[#Transclusion|transcluded]] in regular pages that refer to it. This mechanism is useful to disseminate complex content into multiple target pages, while editing the source context in just one place and referring to it via a simple name from the target pages.
:https://www.mediawiki.org/wiki/Help:Templates<br>
</blockquote>
 
 
A ''template'' is a page in the "Template:" namespace that gets [[#Transclusion|transcluded]] in regular pages that refer to it. This mechanism is useful to disseminate complex content into multiple target pages, while editing the source context in just one place and referring to it via a simple name from the target pages.


==Template Declaration==
==Template Declaration==
To start a new template, declare a link in the "Template:" namespace, as shown below
To start a new template, declare a link in the "Template:" namespace, as shown below
<pre>
<pre>
[[Template:TestTemplate]]
[[Template:TestTemplate]]
</pre>
</pre>
follow the link, and edit it. The initiating page will contain the link to the template and can be used for access. For an example of actual template declarations see the "[[Media Wiki Editing#Blockquote|Editing - Blockquote]]" section.
follow the link, and edit it. The initiating page will contain the link to the template and can be used for access. For an example of actual template declarations see the "[[Media Wiki Editing#Blockquote|Editing - Blockquote]]" section.


==Parameterized Templates==
==Parameterized Templates==


MediaWiki performs variable substitution in templates, where the variables are declared as {{{1}}}, {{{2}}}, etc. A template that contains variables is called a ''parameterized template''.
MediaWiki performs variable substitution in templates, where the variables are declared as {{{1}}}, {{{2}}}, etc. A template that contains variables is called a '''parameterized template'''.


==Template Invocation==
==Template Invocation==
Line 171: Line 153:
=Extensions=
=Extensions=
{{External|https://www.mediawiki.org/wiki/Manual:Extensions}}
{{External|https://www.mediawiki.org/wiki/Manual:Extensions}}
Extensions provide customizations on how MediaWiki looks and works. Extensions can be installed by system administrators. Extensions are usually distributed as modular packages. They are installed in their own "extensions" subdirectory, and, after installation, they are declared in [[#LocalSettings.php|LocalSettings.php]] as:
Extensions provide customizations on how MediaWiki looks and works. Extensions can be installed by system administrators. Extensions are usually distributed as modular packages. They are installed in their own "extensions" subdirectory, and, after installation, they are declared in <code>[[#LocalSettings.php|LocalSettings.php]]</code> as:
<syntaxhighlight lang='php'>
<syntaxhighlight lang='php'>
wfLoadExtension( 'ExtensionName' );
wfLoadExtension( 'ExtensionName' );
Line 178: Line 160:
To get a list of installed extensions and their versions go to 'Special pages' → Version.
To get a list of installed extensions and their versions go to 'Special pages' → Version.
==Useful Extensions==
==Useful Extensions==
====BreadCrumbs====
====JSBreadCrumbs====
{{Internal|MediaWiki Extension BreadCrumbs|BreadCrumbs}}
{{Internal|MediaWiki Extension JSBreadCrumbs|JSBreadCrumbs}}
====BreadCrumbs2====
{{Internal|MediaWiki Extension BreadCrumbs2|BreadCrumbs2}}
{{Internal|MediaWiki Extension BreadCrumbs2|BreadCrumbs2}}
====SyntaxHighlight====
====SyntaxHighlight====
Line 185: Line 168:
====Math====
====Math====
{{Internal|MediaWiki Extension Math|Math}}
{{Internal|MediaWiki Extension Math|Math}}
====BreadCrumbs====
{{Internal|MediaWiki Extension BreadCrumbs|BreadCrumbs (obsolete)}}
=SELinux Support=
=SELinux Support=
{{External|https://www.mediawiki.org/wiki/SELinux}}
{{External|https://www.mediawiki.org/wiki/SELinux}}
=MediaWiki Tags=
=Tags=
==<tt>&lt;code></tt>==
==HTML Tags==
The following HTML tags are handled by MediaWiki:
===<span id='code_tag'></span><tt>&lt;code></tt>===
By default, the HTML <code>&lt;code></code> tag is displayed in the browser's default monospace font. CSS declared in <code>[[Media_Wiki_Concepts#MediaWiki:Common.css|MediaWiki:Common.css]]</code> can be used to modify the rendering of the &lt;code> elements, by adding a sequence similar to:
<syntaxhighlight lang='css'>
code {
  font-family: Consolas,"menlo";
  color: DarkSlateGray;
  padding: 1px;
  background-color: #FCFCFC;
  border-color: Gainsboro;
  font-size: 77%;
}
</syntaxhighlight>
Also see: {{Internal|Media_Wiki_Editing#In-Line_Code|MediaWiki Editing &#124; In-Line Code}}{{Internal|HTML code#Overview|HTML &lt;code>}}
 
==MediaWiki Tags==
===<span id='ref_tag'></span><tt>&lt;ref></tt>===
Creates a numbered reference to the bottom of the page:
<ref>Example</ref>
=Skin=
{{External|https://www.mediawiki.org/wiki/Manual:Skin_configuration}}
 
To configure the default skin, set the variable <code>$wgDefaultSkin</code> in <code>[[#LocalSettings.php|LocalSettings.php]]</code> to the lowercase skin name specified in the skin file.
<syntaxhighlight lang='php'>
$wgDefaultSkin = "vector";
</syntaxhighlight>

Latest revision as of 04:55, 1 January 2024

Internal

Directory Layout

/
├── etc
│    ├── php.ini
│    └── php.d
│
└── var/www/mediawiki-X.Y.Z
              ├── LocalSettings.php
              ├── includes
              │     └── DefaultSettings.php
              ├── images
              │     ├── .htaccess
              │     ├── archive
              │     ├── lockdir
              │     ├── thumb
              │     └── c
              │         └── cf
              │             └── SomeImage.png
              ├── extensions
              │     ├── BreadCrumbs
              │     ├── CategoryTree
              │     └── ...
              └── ...

Versions

See:

Media Wiki Operations | Get Media Wiki Version

LTS

Long Term Support

LocalSettings.php

https://www.mediawiki.org/wiki/Manual:LocalSettings.php

The file is located in the root of the MediaWiki installation /var/www/<installation-dir>/LocalSettings.php. A fresh Media Wiki installation does not come with a LocalSettings.php file. The file must be generated by going to a configuration procedure driven by the web site, then manually placed in the directory.

To enable a change, the web server needs to be restarted with:

apachectl graceful

LocalSettings.php contains, among others, the following:

Database Type

$wgDBtype = "mysql";

Database Hostname

$wgDBserver = "localhost";

Database User ID

$wgDBuser = "c3kb_wiki";

Database Password

$wgDBpassword = "...";

Database Default Character Set

$wgDBTableOptions = "ENGINE=InnoDB, DEFAULT CHARSET=binary";

Database Name

$wgDBname = "c3kb_wiki";

Name of Wiki (Site Name)

This is a configuration element that needs to be specified during the wiki initialization procedure, as the name of wiki. It will appear in the title bar of the browser and in various other places. It is also referred to as site name and configured in LocalSettings.php as:

$wgSitename = "NovaOrdis Knowledge Base";

Server Name

https://www.mediawiki.org/wiki/Manual:$wgServer
$wgServer = "https://kb.novaordis.com";

$wgServer contains the base URL of the server, including protocol and optionally the port, if non-standard, but without the trailing slash and without the subdirectory if any (e.g., https://www.mediawiki.org). The links to the wiki site from inside the pages will contain this value, so it is important to set correctly, otherwise the links embedded in pages will not work.

For example, if the site will be accessed over a ssh tunnel from the local host over a non-standard port, then wgServer should be:

$wgServer = "http://localhost:10080";

wfLoadExtension

See Extensions below.

Configure Site Logo

wgFileExtensions

See:

Media Wiki Installation | Allow PDF Uploading

index.php

See:

Media Wiki Troubleshooting | PHP Errors

DefaultSettings.php

MediaWiki:Common.css

A page that contains CSS modifications to be applied to all skins. It can be accessed by name: MediaWiki:Common.css. If it does not exist, it can be created. It is used by SyntaxHighlight extension and it can also be used to customize the rendering of HTML tags, such as <code>.

Security

Media Wiki Security Concepts

Transclusion

https://www.mediawiki.org/wiki/Transclusion

Transclusion means the inclusion of the content of a document into another document by reference. The most common situation where transclusion is used is the use of templates: the same content can be included in multiple documents without having having to edit those documents separately.

Namespace

https://www.mediawiki.org/wiki/Help:Namespaces

Project namespace

Following Wikipedia's example, many wikis keep their policy pages separate from their content pages, in a project namespace. All page titles in this namespace start with a certain prefix, which you can specify here. Usually, this prefix is derived from the name of the wiki, but it cannot contain punctuation characters such as "#" or ":".

The project namespace is configuration element provided during the wiki initialization procedure.

Templates

https://www.mediawiki.org/wiki/Help:Templates

A template is a page in the "Template:" namespace that gets transcluded in regular pages that refer to it. This mechanism is useful to disseminate complex content into multiple target pages, while editing the source context in just one place and referring to it via a simple name from the target pages.

Template Declaration

To start a new template, declare a link in the "Template:" namespace, as shown below

[[Template:TestTemplate]]

follow the link, and edit it. The initiating page will contain the link to the template and can be used for access. For an example of actual template declarations see the "Editing - Blockquote" section.

Parameterized Templates

MediaWiki performs variable substitution in templates, where the variables are declared as {{{1}}}, {{{2}}}, etc. A template that contains variables is called a parameterized template.

Template Invocation

The template is invoked by enclosing the template name (without the Template: namespace prefix) between {{ }}.

Example:

{{SomeTemplate}}

If the template is parameterized, the parameters are provided in order, after the template name, preceded by "|".

Example:

{{SomeTemplate|paramenter one content|parameter two content}}

ImageMap

https://www.mediawiki.org/wiki/Extension:ImageMap

Extensions

https://www.mediawiki.org/wiki/Manual:Extensions

Extensions provide customizations on how MediaWiki looks and works. Extensions can be installed by system administrators. Extensions are usually distributed as modular packages. They are installed in their own "extensions" subdirectory, and, after installation, they are declared in LocalSettings.php as:

wfLoadExtension( 'ExtensionName' );

Installed Extensions

To get a list of installed extensions and their versions go to 'Special pages' → Version.

Useful Extensions

JSBreadCrumbs

JSBreadCrumbs

BreadCrumbs2

BreadCrumbs2

SyntaxHighlight

SyntaxHighlight

Math

Math

BreadCrumbs

BreadCrumbs (obsolete)

SELinux Support

https://www.mediawiki.org/wiki/SELinux

Tags

HTML Tags

The following HTML tags are handled by MediaWiki:

<code>

By default, the HTML <code> tag is displayed in the browser's default monospace font. CSS declared in MediaWiki:Common.css can be used to modify the rendering of the <code> elements, by adding a sequence similar to:

code {
  font-family: Consolas,"menlo";
  color: DarkSlateGray;
  padding: 1px;
  background-color: #FCFCFC;
  border-color: Gainsboro;
  font-size: 77%;
}

Also see:

MediaWiki Editing | In-Line Code
HTML <code>

MediaWiki Tags

<ref>

Creates a numbered reference to the bottom of the page: [1]

Skin

https://www.mediawiki.org/wiki/Manual:Skin_configuration

To configure the default skin, set the variable $wgDefaultSkin in LocalSettings.php to the lowercase skin name specified in the skin file.

$wgDefaultSkin = "vector";
  1. Example