Configure for HTML

From mw.mh370.wiki
Jump to navigation Jump to search


A Guide to Using MediaWiki in a Hosted Environment

An instructional website by the developer of mh370wiki.net - a MediaWiki site about Malaysia Airlines Flight MH370.


HTML and MediaWiki

MediaWiki has it's own text-formatting system called wikitext.

One of the early decisions I made when developing the mh370wiki.net site was to use HTML instead of wikitext. The entire site is formatted using html and css.

MediaWiki does allow many common HTML tags but full use of HTML is restricted by default. None of the Wikimedia websites allow full use of HTML.

Consequently I also needed to enable raw HTML. There is a warning about this in the Manual:$wgRawHtml:-

Warning: This is very dangerous on a publicly editable site, because it allows for arbitrary JavaScript code to be inserted, opening the door for session hijacking. Thus, you shouldn't enable $wgRawHtml unless you've restricted editing to trusted users only with $wgGroupPermissions. See Manual:Preventing access for more information on restricting write access.

$wgRawHtml

To enable full use of HTML, add this line in LocalSettings.php:-

$wgRawHtml = true;

Or change an existing setting from false to true.

HTML Tags

HTML which, by default, is not allowed by MediaWiki but which has been enabled by the setting $wgRawHtml = true; must be embedded between HTML tags.

Several examples follow.

External Links

My preference is to allow internal links to open in the same browser tab, and require external links to open in a new browser tab.

An example is one of the external links below. The target="_blank" opens a new browser tab.

<p>Wikitext <html><a href="https://www.mediawiki.org/wiki/Wikitext" target="_blank">https://www.mediawiki.org/wiki/Wikitext</a></html></p>

If the same page was linked like this:

[https://www.mediawiki.org/wiki/Wikitext Wikitext]

Then the link would look like this: Wikitext and will open in the same tab and take the reader away from my website.

So the only way I know of to require a link to an external website to open in a new tab is to enable $wgRawHtml and format links using html tags and set target="_blank".

HTML for Internal Links

I created custom horizontal menus for the mh370wiki.net website. Each menu has several 'buttons'. Each button contains a link to a page. Each link uses the same format as an external link, as shown below:-.

<onlyinclude>
   <html><div class="solid-btn-body"><a class="solid-btn-label" href="/Reports/SAR/Malaysia">SAR Reports - Malaysia</a></div> </html>
</onlyinclude>

This button, labelled SAR Reports - Malaysia is on the menu for Search Reports.

These menus and buttons require $wgRawHtml = true; but there was an unexpected consequence:-

Because MediaWiki does not see a 'normal' link coded between square brackets [[ ]], and unless there is some other link to the same destination page, MediaWiki will count this as an 'orphan page'.

I don't know how many 'Orphaned pages' are on that site because MediaWiki only lists the first 500...

When I realised this consequence I minimised the use of internal links in the html format and used the standard [[ ]] format more often.



Links

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

Using HTML tags in Wikitext https://www.mediawiki.org/wiki/Help:HTML_in_wikitext

Manual:$wgRawHtml https://www.mediawiki.org/wiki/Manual:$wgRawHtml

Manual:Preventing access https://www.mediawiki.org/wiki/Manual:Preventing_access