I’m currently trying to write a Mediawiki extension for a custom wiki site which will allow for uploading a file from a wiki page, process it and write the result back to it (e.g. populate a table on that page) .
More specifically, the functionality should be like this:
- An upload button shall be present on a normal wiki page, but only if a page has a specific category, e.g. [[Category:Pages with upload button]];
- When user presses an “Upload” button, it brings them to an upload dialog/page where they pick a file;
- After the file is uploaded, a python script is called which processes the file and writes the result back to a wiki page (from where the upload button was pressed) along with a reference to the page which contains file info (e.g. link to File: info.txt page)
I already have written the draft extension which partly do this functionality (https://github.com/vscam/FileProcess), but it currently has a few problems:
- Couldn’t escape from adding changes to core mediawiki code: added minor changes to includes/specials/SpecialUpload.php:
- Commented redirection to the file page after uploading (so my extension could redirect me back to the previous page to further populate it with the file processing result)
- Link to the file description page (e.g. File: info.txt) is written to a server file. I need to remember this link to further put it to a page from which upload request was called (along with the file processing result)
- Still working on how to automatically insert upload button on a wiki page, when it has a specific category;
- Using files on mediawiki server to store http links (to the uploaded file and to the page from which upload request was called). So after uploading a file, the extension read these links and goes back to a page where it populates a wiki table: writes reference to the uploaded file and the result of processing this file. I know it’s probably not the best way of doing this logic. I tried to use mediawiki classes. But since php reruns every time when a page is uploaded, I cannot store these links in object parameters.
Would very much appreciate if you could give me a clue or point to some specific documentation (or even similar extensions) regarding how to deal with the aforementioned problems and improve/change this code.
P.S. Please, don’t judge me strictly as I’ve been working with Mediawiki code only for a couple of weeks