Media Wiki Concepts: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
Line 110: Line 110:


==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
 
<font size=-2>
<pre>
[[Template:TestTemplate]]
[[Template:TestTemplate]]
</font>
</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.



Revision as of 18:47, 29 December 2023

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

The MediaWiki, PHP, database and extension versions can be read from Special pages → Version → Installed software.

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";

Site Name

$wgSitename = "Nova Ordis 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

index.php

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

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

BreadCrumbs

BreadCrumbs
BreadCrumbs2

SyntaxHighlight

SyntaxHighlight

Math

Math

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