Difference between revisions of "Mediawiki for personal webs"
Line 31: | Line 31: | ||
==The Changes== | ==The Changes== | ||
{{wbox|However, present versions of Mediawiki ignores 'talk only' directives. To avoid this, the following changes should be done in the ./includes/User.php | |||
<pre> | |||
function isAllowed($action='') { | |||
if ( $action === '' ) | |||
// In the spirit of DWIM | |||
return true; | |||
#Newly added | |||
/* Special Cases */ | |||
global $wgTitle; | |||
//Allow them to edit talk pages | |||
if ($wgTitle->isTalkPage() | |||
&& strcmp("edit", $action) == 0) | |||
return true; | |||
#Newly added (END) | |||
$this->loadFromDatabase(); | |||
return in_array( $action , $this->mRights ); | |||
} | |||
</pre> | |||
}} | |||
Most of the changes could be done by editing LocalSettings.php. (That is the standard way.) | Most of the changes could be done by editing LocalSettings.php. (That is the standard way.) | ||
<pre> | <pre> | ||
Line 43: | Line 63: | ||
</pre> | </pre> | ||
Then, it is needed to change the messages that Mediawiki display when a user attempts to do something that is not allowed, so that users understand what is happening. For example in the original installation of mediawiki, if a user attempts to edit an article that the user is not allowed to the system will display a message like | Then, it is needed to change the messages that Mediawiki display when a user attempts to do something that is not allowed, so that users understand what is happening. For example in the original installation of mediawiki, if a user attempts to edit an article that the user is not allowed to the system will display a message like |
Revision as of 14:01, 14 September 2006
About Wikis, the site mediawiki says the following:
- "A wiki is a type of website that allows users to add and edit content easily and is especially suited for collaborative writing."
So these packages are meant to be used for sites that are intended for collaboration, probably with contributions from thousands of individuals, like the case of wikipedia. The success of metawikipedia:wikipedia shows that this indeed is a workable model. What about using wikimedia for a personal web site. Well, I wanted to do this, mainly because I was lazy, but still needed to boast that I have a personal web site. In late nineties I had a web site. But the main reason why it was not a sustainable project was that it was written using a WYSIWYG software, that makes life extremely easy, the first few times that you work on a new site, but makes it impossibly hard when you want to make a small changes and add a few lines here and there! During my experiments with Wikis (that's another story for another day.) I realized that these Wikis are extremely flexible to grow, although they may have a bit steep learning curve initially. Particularly I liked mediawiki, the software behind the legendary wikipedia.
What is a Wiki
- Note
- First read the entry on mediawiki on wikipedia, which is by far, better than my own explaination.
HTML, the language used to write web pages, is not an easy one to work with, it is easy to make mistakes, and even easy to do the correct thing in a wrong way! A wiki uses a markup language that is far simpler than HTML, so that the 'rest of us' can also contribute to editing web pages. Usually following are the important features of a wiki:
- Readers are also contributers. Anybody can create and edit articles -- even can edit the ones created by others.
- Things can be undone (e.g. if someone does a mistake/unappropriate thing, the next visiter can 'revert' the article back to an older version. So, a wiki should keep track of all the edits.
- Like the web itself, things are extensively linked, so that a user can navigate from an article to another.
When a large number of readers actively participate in a wiki, articles normally 'converge' to a good form, as proven by projects like wikipedia.
How Mediawiki Works
Mediawiki is an open-source wiki implementation with all the important features. Articles and all the details of them (like links between articles, dates of editing, etc.) are stored in a relational database called MySQL. The information in the database are used by programs written in PHP language to create HTML web pages that the user can read. Users can edit articles on the web browser and all the editing information is written back to the database by PHP programs.
When mediawiki is installed in a web site, it can be customized by changing the content of a file called
LocalSettings.php
.
What I needed
I needed a website:
- That I can improve incrementally, whenever I have a minute to spare for that. Probably, I may not have hours of time at one stretch.
- That does not allow readers to add/edit articles (like the case of a normal wiki), but makes it possible for them to contribute by discussing the articles.
I did NOT want to hide that fact that this is a site based on (a hacked version of) mediawiki.
With these requirements, it was rather easy to customize mediawiki to match my needs.
The Changes
However, present versions of Mediawiki ignores 'talk only' directives. To avoid this, the following changes should be done in the ./includes/User.php
function isAllowed($action='') { if ( $action === '' ) // In the spirit of DWIM return true; #Newly added /* Special Cases */ global $wgTitle; //Allow them to edit talk pages if ($wgTitle->isTalkPage() && strcmp("edit", $action) == 0) return true; #Newly added (END) $this->loadFromDatabase(); return in_array( $action , $this->mRights ); }
Most of the changes could be done by editing LocalSettings.php. (That is the standard way.)
$wgGroupPermissions['*']['edit'] = false; # Don't allow all persons to edit. $wgGroupPermissions['*' ]['read'] = true; # But let them read articles $wgGroupPermissions['*' ]['talk'] = false; # Don't let users to participate in discussions if not logged-in. $wgGroupPermissions['user' ]['edit'] = false; # Even logged-in users can not edit articles. $wgGroupPermissions['user' ]['move'] = false; # They can not rename articles $wgGroupPermissions['user' ]['talk'] = true; # But they can participate in discussions. $wgGroupPermissions['sysop']['edit'] = true; # System operator(s) can edit pages.
Then, it is needed to change the messages that Mediawiki display when a user attempts to do something that is not allowed, so that users understand what is happening. For example in the original installation of mediawiki, if a user attempts to edit an article that the user is not allowed to the system will display a message like
- 'This page has been locked to prevent editing; there are a number of reasons why this may be so, please ...'
However, this message is no longer valid in the context of a personal web page, so it should be changed to something like
- 'Editing the article is not recommended. Please use discussion page (after login) to express your openions.'
So that the user knows what is happening.
Such changes can also be done by the system adiministrator(s) using the web browser itself. This is done by editing entries in the page Special:Allmessages.
Finally, there are some changes that need to be done the dirty way, by making some minor changes in the program code. Some examples below:
Removing Edit Tabs
Most users, except the admin are not allowed to edit pages. So, having a edit tab on top of the article (see: wikipedia:wiki page for examples) is confusing for the user.
- Edit the skin file (if you use default 'monobook' style, this is Monobook.php) and change the following part
<?php if($this->data['loggedin']==1) foreach($this->data['content_actions'] as $key => $action) {
?><li id="ca-<?php echo htmlspecialchars($key) ?>" <?php if($action['class']) { ?>class="<?php echo htmlspecialchars($action['class']) ?>"<?php } ?> ><a href="<?php echo htmlspecialchars($action['href']) ?>"><?php echo htmlspecialchars($action['text']) ?></a></li><?php
}?>
to appear as follows
<?php if($this->data['loggedin']==1) foreach($this->data['content_actions'] as $key => $action) {
if($key!='edit'){#change 1-1 ?><li id="ca-<?php echo htmlspecialchars($key) ?>" <?php if($action['class']) { ?>class="<?php echo htmlspecialchars($action['class']) ?>"<?php } ?> ><a href="<?php echo htmlspecialchars($action['href']) ?>"><?php echo htmlspecialchars($action['text']) ?></a></li><?php }#change 1-2}?>
.
- This will remove the edit tab for ALL users including the administrator. But, admin can simply double click anywhere on the article to get in to the edit page.
System Messages that make sense
The original system messages of Mediawiki are obviously meant for its standard application. Once we start using it for a non-standard purpose like the present one, many of these messages become meaningless. Therefore, in order not to confuse the user, it is best to edit these. In the recent versions of Mediawiki it is possible to do this without any changes at the file system. There is a Special page called Special:Allmessages where links are provided to edit those. For example
- The message indicating that editing of a page is not allowed says:
This page has been locked to prevent editing; there are a number of reasons why this may be so, please see Project:Protected page.
You can view and copy the source of this page: .
- It can be changed to the following in the context of a personal web site.
This site is a personal website, so editing of pages is not recommended.
If needed please use respective 'Talk' pages to express your opinions. Project:Protected page.
You can view and copy the source of this page:
See Also: Help:Configuration, MediaWiki_namespace, Customization