Moving from MediaWiki to SharePoint O365 - part 1

Some clever person at Microsoft understood the wiki hype and decided to call some component of their SharePoint platform 'wiki', never mind if it really is one or has some of the much-used functionalities of such things. They knew management would fall for it. And in my case (and yours apparently), they did. It's just another wiki right?

From the articles I've written before, you know I'm a fan of good software being used for what it's meant to do. Like MediaWiki for wikis. So if you've ended up on this page because you're being forced to move away from MediaWiki instead of towards it, let me tell you: I feel your pain. I understand your frustration. If you've never worked with SharePoint before, I understand the frustration you're about to have.
But let's not mix these feelings with the work that needs to be done. So here's some empty space where you're allowed to feel sorry for yourself:





... and done.

Now we get to work.



Understanding the setting

I'm working within the limitations of not being a SharePoint admin, not having administration rights on my computer (= I can't install anything), and having no monetary budget to buy software anyway. Add to that a very strict firewall/scanner thing that blocks you from most websites offering code (usually the code you need to get something done), and then you're about in my situation. 
It seems funny to have to do work in software with those types of limitations, but let me assure you, there's nothing funny about it. The only upside is that you're forced to learn new things faster than the IT admins so you can stay a step ahead of them and rescue the tools you need to still get some work done :-)

So what do I have at my disposal? 
  • I can read from USB and so copy stuff to my computer. 
  • I'm the guy who got the MediaWiki in, so I have direct access to that system.
  • I have a Windows 7 laptop (with not enough RAM). It includes PowerShell (how could it not?).
  • SharePoint O365 has something called "sites". I have one of those for which I'm the owner. As the IT staff can create as many of these "sites" as they want, I'm going to assume its not a problem for you to get one either. SharePoint designer, I do not have. OneDrive for Business, I do not have.

Let's set up some software

To create the scripts, I've needed a code editor. If you plan on tinkering with my scripts to make them better suited to your unique situation (or to just plain make them better), then you'll be needing a code editor. I have a personal preference for Eclipse, mainly because it's the one that was heavily used at university and also because until now I haven't found another tool that offers enough interesting extra functionality to seduce me into switching.
So head over here and download the Eclipse for PHP that suits your system. It doesn't require installing, you can just unzip it and run the executable. If the download itself is being blocked by your firewall, I'm sure there's a way you can get it onto your computer anyway. Cough*USB*cough.
If you plan to use the scripts mostly as-is, you don't necessarily need a code-editor: you can always use WordPad or Notepad.

So we'll be using PHP then? Yes, and also a bit of JavaScript and jQuery. The JavaScript and jQuery is going into scripts that we're going to install in our SharePoint site to give it at least a basic version of some of MediaWiki's standard/extension functionalities. The PHP is for scripts to do the actual migration: exporting and manipulating your MediaWiki content. The actual upload into SharePoint will be handled by PowerShell. And we'll also need to make some updates to the master page for wiki pages in your SharePoint site, which is some meta version of ASP (don't ask, I don't know either: my knowledge of computer languages invented by Microsoft is limited). 
Anyway, back to the PHP scripts: we'll need something to run them on. Chances are you can simply use the server MediaWiki is using for this, because it has all necessary components anyway (Apache, PHP). Me, I don't like to have to continually upload stuff, so I've got a webserver running on my laptop. 
What? I thought you couldn't install anything??
That's right. I've got a portable, non-install version of a webserver which allows me to do data manipulations in my own MySQL (or MariaDB, which also comes in a portable version) and using PHP scripts (or Java programs for the heavier stuff).
How?
Right here my friend: Uniform Server. I had a small issue with it at the start: I got an error saying my port 80 was already in use (due to IIS, which I couldn't kill, not having admin rights and all...), and I couldn't get into the control panel to change it. Since it's portable, just start it up on a computer on which port 80 is not yet in use (like a personal computer), go into the control panel, change the port to 8080 or something, and copy the result back to your work pc. 


Getting to know your SharePoint site

SharePoint offers you a site. The site has apps/libraries (they're rather loose with the term). There's one called Site Pages, which is where your wiki pages go. You're thinking you can just upload pages in there and you're good? Sorry, no go.
We'll be using three libraries (ok four) - you can find these by clicking the cog-wheel icon at the top right of your SharePoint site and then clicking Site Contents:
  • Site Pages: your wiki content will go here.
  • Site Assets: this is where we'll be putting our javascript. It is also the default location for SharePoint to put the images used in the Site Pages when you're uploading them from inside the page content editor. Unfortunately, SharePoint creates a folder per wiki page and puts the content in that folder, as if the same image couldn't be reused on multiple pages. We'll put the images uploaded in MediaWiki there as well, but in one common folder. 
  • Documents: your users can upload stuff here to share it with others. This is where we'll put the files that were uploaded to your wiki which weren't images.
There's also a fourth library, but you can't find it in Site Contents. You need to go to Site Settings (it's also one of the links behind the cogwheel) and then find the link Master pages. It's under the heading Web designer galleries. That library contains the master page, i.e. the template behind all our wiki pages. By making changes to this page, we can change all pages, which is handy when we want to run some javascript on all our pages without having to add web parts to all of them. You don't know what web parts are? Count your blessings.