EzDevInfo.com

mediawiki interview questions

Top mediawiki frequently asked interview questions

How can I add per page permissions to a user in MediaWiki?

In MediaWiki, how can a user be given permission to edit only certain pages? This way, the administrator can create a page for the user and the user will be able to edit this particular page only.


Source: (StackOverflow)

All my MediaWiki pages are blank

All of a sudden, all my Mediawiki pages are blank. If I click the edit field, the content is still, there. Ive checked the sqlite file and it looks just fine. Ive turned on debugging output and get the following:

Warning: preg_match(): Compilation failed: group name must start with a non-digit at offset 8 in /usr/share/webapps/mediawiki/includes/MagicWord.php on line 907

Warning: preg_match_all(): Compilation failed: group name must start with a non-digit at offset 4 in /usr/share/webapps/mediawiki/includes/MagicWord.php on line 881

Warning: Invalid argument supplied for foreach() in /usr/share/webapps/mediawiki/includes/MagicWord.php on line 882

Warning: preg_replace(): Compilation failed: group name must start with a non-digit at offset 4 in /usr/share/webapps/mediawiki/includes/MagicWord.php on line 886

Warning: preg_match_all(): Compilation failed: group name must start with a non-digit at offset 4 in /usr/share/webapps/mediawiki/includes/MagicWord.php on line 881

Warning: Invalid argument supplied for foreach() in /usr/share/webapps/mediawiki/includes/MagicWord.php on line 882

Warning: preg_replace(): Compilation failed: group name must start with a non-digit at offset 4 in /usr/share/webapps/mediawiki/includes/MagicWord.php on line 886

Warning: preg_match(): Compilation failed: group name must start with a non-digit at offset 8 in /usr/share/webapps/mediawiki/includes/MagicWord.php on line 907

Warning: preg_match(): Compilation failed: group name must start with a non-digit at offset 8 in /usr/share/webapps/mediawiki/includes/MagicWord.php on line 907

Warning: preg_match(): Compilation failed: group name must start with a non-digit at offset 8 in /usr/share/webapps/mediawiki/includes/MagicWord.php on line 907

Warning: preg_match(): Compilation failed: group name must start with a non-digit at offset 8 in /usr/share/webapps/mediawiki/includes/MagicWord.php on line 907

Warning: preg_match(): Compilation failed: group name must start with a non-digit at offset 8 in /usr/share/webapps/mediawiki/includes/MagicWord.php on line 907

Warning: preg_match(): Compilation failed: group name must start with a non-digit at offset 8 in /usr/share/webapps/mediawiki/includes/MagicWord.php on line 907

Warning: preg_match(): Compilation failed: group name must start with a non-digit at offset 8 in /usr/share/webapps/mediawiki/includes/MagicWord.php on line 907

Warning: preg_match_all(): Compilation failed: group name must start with a non-digit at offset 4 in /usr/share/webapps/mediawiki/includes/MagicWord.php on line 881

Warning: Invalid argument supplied for foreach() in /usr/share/webapps/mediawiki/includes/MagicWord.php on line 882

Warning: preg_replace(): Compilation failed: group name must start with a non-digit at offset 4 in /usr/share/webapps/mediawiki/includes/MagicWord.php on line 886

Warning: preg_match_all(): Compilation failed: group name must start with a non-digit at offset 4 in /usr/share/webapps/mediawiki/includes/MagicWord.php on line 881

Warning: Invalid argument supplied for foreach() in /usr/share/webapps/mediawiki/includes/MagicWord.php on line 882

Warning: preg_replace(): Compilation failed: group name must start with a non-digit at offset 4 in /usr/share/webapps/mediawiki/includes/MagicWord.php on line 886

Warning: preg_match(): Compilation failed: group name must start with a non-digit at offset 8 in /usr/share/webapps/mediawiki/includes/MagicWord.php on line 907

Warning: preg_match(): Compilation failed: group name must start with a non-digit at offset 8 in /usr/share/webapps/mediawiki/includes/MagicWord.php on line 907

Warning: preg_match(): Compilation failed: group name must start with a non-digit at offset 8 in /usr/share/webapps/mediawiki/includes/MagicWord.php on line 907

Are these errors most likely the cause of the issue? If so, how do I resolve it? And if not, anyone have any idea on what might be the problem?


Source: (StackOverflow)

Advertisements

How to add a link in MediaWiki VisualEditor Toolbar?

I`m trying to insert a custom link to a special page in VisualEditor toolbar. See the image below.

Link Position See Image

I googled a lot but without success. Someone please give a path...


Source: (StackOverflow)

How to get plain text out of wikipedia

I've been searching for about 2 months now to find a script that gets the Wikipedia description section only. (It's for a bot i'm building, not for IRC.) That is, when I say

/wiki bla bla bla

it will go to the Wikipedia page for bla bla bla, get the following, and return it to the chatroom:

"Bla Bla Bla" is the name of a song made by Gigi D'Agostino. He described this song as "a piece I wrote thinking of all the people who talk and talk without saying anything". The prominent but nonsensical vocal samples are taken from UK band Stretch's song "Why Did You Do It"

Here is the closest I've found, but it only gets the URL:

import json
import urllib.request, urllib.parse

def google(searchfor):
  query = urllib.parse.urlencode({'q': searchfor})
  url = 'http://ajax.googleapis.com/ajax/services/search/web?v=1.0&%s' % query

  search_response = urllib.request.urlopen(url)
  search_results = search_response.read().decode("utf8")
  results = json.loads(search_results)
  data = results['responseData']
  hits = data['results']

  if len(hits) > 0:
    return hits[0]['url']
  else:
    return "No results found."

(Python 3.1)


Source: (StackOverflow)

How to export text from all pages of a MediaWiki?

I have a MediaWiki running which represents a dictionary of German terms and their translation to a local dialect. Each page holds one term, its translation and a number of additional infos.

Now, for a printable version of the dictionary, I need a full export of all terms and their translation. Since this is an extract of a page's content, I guess I need a complete export of all pages in their newest version in a parsable format, e.g. xml or csv.

Has anyone done that or can point me to a tool? I should mention, that I don't have full access to the server, e.g. no command line, but I am able to add MediaWiki extensions or access the MySQL database.


Source: (StackOverflow)

How do I create my own custom group in mediawiki?

I have been reading carefully through the mediawiki documentation but I have not been able to find out how to create new groups.

When I look at Special:Userrights, I see only 3 groups : Bots, Sysops, Bureaycrats

I would like to create my own custom groups, so I can use some extensions like the http://www.mediawiki.org/wiki/Extension:Group_Based_Access_Control.

Can someone tell me how it's done, or point me to some documentation?


Source: (StackOverflow)

Is there any way to convert Wikitext to Markdown in python?

Is there a python library which takes wikitext (as used in mediawiki) input and converts it to markdown?


Source: (StackOverflow)

How to encourage non-anonymous editing on MediaWiki?

Problem

At work we have a department wiki (running Mediawiki). Unfortunately several persons edit without logging in, and that makes it very difficult to track down editors to ask questions about the content.

There are two strategies to improve this

  • encourage logged in editing
  • discourage anonymous editing.

Encouraging

For this part, any tips are welcome. But of course there is always risks involved in rewarding behaviours.

Discourage

I know that this must be kept low or else it will discourage any editing. But something just slightly annoying would be nice to have.

[update] I know it is possible to just disallow anonymous editing, but that will put a high barrier to any first time contribution (especially for people outside our department!), so I do not think that is an option. [/update]

[update2] Using LDAP or Active Directory does not solve the problem since the wiki is also accessible and used by external contractors. [/update2]

[update3] I am no longer working for this company. That does not mean that I completely have lost interest in this question, but from my current interest point the most valuable part is the "Did you forget to log in?" part below, and I will accept answers based on this part of the question. [/update3]

Confirmation

One thought was to have an additional confirmation step for anonymous users - "Are you really sure you want to submit this anonymously?", although with such a question there is a risk that people will give up or resist editing. However, if that question is re-phrased in a more diplomatic way as "Did you forget to log in?" I think it will appear as much more acceptable. And besides that will also capture those situations where the author did in fact forget to log in, but actually would want to have his/her contributions credited his/her user. This last point is by itself a good enough reason for wanting it.

Is this possible?

Delay

Another thought for something to be slightly annoying is to add an extra forced delay after "save page" displaying something like "If you had logged in you would not have to wait x seconds". Selecting a right x is difficult because if it is to high it will be a barrier and if it too low might not make any difference. But then I started thinking, what about starting at zero and then add one second delay for each anonymous edit by a given IP address in a given time frame? That way there will be no barrier for starting to use the wiki, and by the time the delay is getting significant the user has already contributed a lot so I think the outcome is much more likely to be that the editor eventually creates a user rather than giving up. This assumes IP addresses are rather static, but that is very typically is the case in a business network.

Is this possible?


Source: (StackOverflow)

TEXTAREAs scroll by themselves (on IE8) every time you type one character

IE8 has a known bug (per connect.microsoft.com) where typing or pasting text into a TEXTAREA element will cause the textarea to scroll by itself. This is hugely annoying and shows up in many community sites, including Wikipedia. The repro is this:

  1. open the HTML below with IE8 (or use any long page on wikipedia which will exhibit the same problem until they fix it)
  2. size the browser full-screen
  3. paste a few pages of text into the TEXTAREA
  4. move the scrollbar to the middle position
  5. now type one character into the textarea

Expected: nothing happens Actual: scrolling happens on its own, and the insertion point ends up near the bottom of the textarea!

Below is repro HTML (can also see this live on the web here: http://en.wikipedia.org/w/index.php?title=Text_box&action=edit)

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" ><body>
 <div style="width: 80%">
   <textarea rows="20" cols="80" style="width:100%;" ></textarea>
 </div>
</body></html>

I know I can avoid this by forcing the website into IE7 compatibility mode, but what's the best other way to work around this bug while causing as few side-effects as possible?


Source: (StackOverflow)

Reliably detecting PhantomJS-based spam bots

Is there any way to consistently detect PhantomJS/CasperJS? I've been dealing with a spat of malicious spambots built with it and have been able to mostly block them based on certain behaviours, but I'm curious if there's a rock-solid way to know if CasperJS is in use, as dealing with constant adaptations gets slightly annoying.

I don't believe in using Captchas. They are a negative user experience and ReCaptcha has never worked to block spam on my MediaWiki installations. As our site has no user registrations (anonymous discussion board), we'd need to have a Captcha entry for every post. We get several thousand legitimate posts a day and a Captcha would see that number divebomb.


Source: (StackOverflow)

MediaWiki Extension:GoogleAppsAuthentification Multiple Domains

I've been using the great GoogleAppsAuthentification extension for mediawiki to allow my users to log in with their Google Apps account. We recently added another domain to our Google Apps and I'd like to offer those users the option to log into our wiki with their Google Apps Domain.

Out of the box, this isn't possible with the extension, however it seems pretty trivial to add multiple domain support.

The idea is to prompt the user with a dropdown list of available domains prior to executing the redirect to Google's login screen.

My knowledge of the mediawiki API is rather limited and I could use some pointers.

the extension hooks into the UserLoadFromSession hook, which is called before the UserLoginForm hook. I would have to add code to this function to prompt the user for a domain, and return to this function, passing the selected domain to getGoogleAccount()

// in LocalSettings.py
$wgDefaultUserOptions['GoogleAppsDomainList'] = array("domain.com", "otherdomain.com");

// in GoogleAppsAuthentication.php
function fnGoogleAppsAuthenticateHook($user, &$result){
    global $IP, $wgLanguageCode, $wgRequest, $wgOut, $wgDefaultUserOptions;
    if (isset($_REQUEST["title"])){
            $lg = Language::factory($wgLanguageCode);

            if ($_REQUEST["title"] == $lg->specialPage("Userlogin")){
                    // this is where we need to add the prompt 
                    // that asks the user which domain to chose
                    $domain = getDomainFromUser($wgDefaultUserOptions['GoogleAppsDomainList'])

                    // Setup for a web request
                    require_once("$IP/includes/WebStart.php");

                    // Here we do our stuff
                    $googleAccount = getGoogleAccount('title=' . $_REQUEST["title"], $domain);

                    // whole bunch of code here that won't be affected by our change
                    ...
                    // end whole bunch of code that won't be affected by our change
            } else if ($_REQUEST["title"] == $lg->specialPage("Userlogout")) {
                    session_unset();
                    // Logout
                    $user->logout();
            }
    }

    // Back to MediaWiki home after login
    return true;
}


function getDomainFromUser($domainList) {
    // render page with dropdown containing domains in $domainList
    // get selected dropdown on page submit
    // return selected domain
}

I need some help with the getDomainFromUser() function. I don't know how to redirect to a new page that shows a dropdown menu populated by an array defined in the LocalSettings.py and return the selected value back to the fnGoogleAppsAuthenticateHook function.

Any help would be sincerely appreciated. I believe a lot more people can benefit from this additional functionality added to this extension.


Source: (StackOverflow)

Get Text Content from mediawiki page via API

I'm quite new to MediaWiki, and now I have a bit of a problem. I have the title of some Wiki page, and I want to get just the text of a said page using api.php, but all that I have found in the API is a way to obtain the Wiki content of the page (with wiki markup). I used this HTTP request...

/api.php?action=query&prop=revisions&rvlimit=1&rvprop=content&format=xml&titles=test

But I need only the textual content, without the Wiki markup. Is that possible with the MediaWiki API?


Source: (StackOverflow)

Any better way to create MediaWiki numbered lists?

When using MediaWiki's markup language, the only thing that I hate is creating numbered lists. The only way I know to create a list is to do something like this:

#Item1
#Item2

However, if I want to add spaces or some other text between those lines, the numbering gets lost. For example, the following will create text that has two number one items:

#Item1
Somestuff
#Item2

Is there any way around this, or should I just use bullet points instead? I noticed just now that the stackoverflow system does not allow numbering like this, you have to do it all manually.


Source: (StackOverflow)

How to use wikipedia api if it exists? [closed]

I'm trying to find out if there's a wikipedia api (I Think it is related to the mediawiki?).

If so, I would like to know how I would tell wikipedia to give me an article about the new york yankees for example.

What would the REST url be for this example?

All the docs on this subject seem fairly complicated.


Source: (StackOverflow)

Code block in numbered list (Wiki syntax)

In MediaWiki (wikipedia's) wiki syntax, is there a way to have a numbered list with a code block in the middle?

For example:

# Number 1
# Number 2
  Indented section that will become a code block
# Number 3
# Number 4

What happens in MediaWiki is you end up with something like this:

1. Number 1
2. Number 2
   Indented section that will become a code block
1. Number 3
2. Number 4

(Note how "Number 3" and "Number 4" are reset as 1 and 2... It looks like StackOverflow is much smarter than MediaWiki, i had to put my example in PRE tags to make it screw up!)

I know you can indent text using "#:" syntax...

# Number 1
# Number 2
#: Indented section that will merely be indented
# Number 3
# Number 4

...but I really would like to get the same visual CSS class for my code even if it's in a numbered list.

It gets even more entertaining with nested lists. This syntax...

# MainEntry 1
## Number 1
## Number 2
# MainEntry 2
## Number 1
## Number 2
  Indented section that will become a code block
## Number 3
## Number 4

...becomes...

1. MainEntry 1
   1. Number 1
   2. Number 2
2. MainEntry 2
   1. Number 1
   2. Number 2
      Indented section that will become a code block
1. 1. Number 3
   2. Number 4

(Note how "Number 3" is now "1. 1.")


Source: (StackOverflow)