User:CoolCornucopia

Hi! Welcome to my homepage where I am happy to share with you small pieces of codes to improve the wonderful Mediawiki engine and its extensions...

ods2wiki (also named xls2wiki)
I did a script to convert tables from Microsoft Excel (ods format), OpenOffice or LibreOffice documents to the MediaWiki syntax. I know such scripts are already available here and here and I know LibreOffice embbeds a wiki converter (but only for Writer)... but in my case, I have the following requirements from my wiki users:
 * 1st: the conversion must handle vertically, horizontally and both.
 * 2nd: the conversion must like cell colors and sizes because the result is copy/paste in a wiki where tables "look-and-feel" must be homogeneous.
 * 3rd: the conversion must preserve all references, templates and links in cells.
 * 4th: the conversion should be as simple as possible.

Installation and usage

 * STEP 1 : Create your table spreadsheet with Microsoft Excel, LibreOffice or Apache OpenOffice and save it in the OpenDocument format (.ods extension). Do not hesitate to create a "complex" table, to merge rows or columns, to add links, images, templates and references... Save and close your spreadsheet.
 * STEP 2 : Save the Ods2wiki.tar gawk script (see below to get the full script) in your spreadsheet directory

Linux Ubuntu users
unzip *.ods tar xf Ods2wiki.tar gawk -f ods2wiki.gawk content.xml
 * STEP 3 : enter the following commands:
 * STEP 4 : Then copy/paste the result into your wiki.

Microsoft Windows users
For Microsoft Windows users, you can download GNU Win32 gawk for Windows with this direct link. Then update your PATH env variable (probably with "C:\Program Files (x86)\GnuWin32\bin"). You may prefer to enter the following command before invoking the gawk script: path C:\Program Files (x86)\GnuWin32\bin;%PATH% gawk -f ods2wiki.gawk your_spreadsheet_filename\content.xml
 * STEP 3 : Unzip your spreadsheet, then enter:
 * STEP 4 : Then copy/paste the result into your wiki.

Tests
Tested: Not tested:
 * Mediawiki 1.17
 * Several Excel and LibreOffice ods spreadsheets with complex merged cells.
 * Very very complex spreadsheets, I am pretty sure it is easy to find spreadsheets that are not properly handled : (

Example of a complex table
This complex table has been created with LibreOffice and converted with ods2wiki.gawk script. Some template are missing in this wiki (but they are there on my wikis), the Spreadsheet_Example.ods can not be uploaded on this wiki too (ods format not supported).

Feature description
I have added the "stayed opened" feature to the Mediawiki CategoryTree extension. Now, when "my" users browse the wiki, the sidebar category tree stayed opened and it was the major "complaint" of my wiki users and they are very happy now :)

Installation
On Mediawiki 1.17 and CategoryTree-MW1.17-r85033, Only the file CategoryTree.js has been modified so simply copy/paste the related source code (see the attached source code below). Should work on recent Mediawiki and CategoryTreee releases but a merge is required.

How does it work?

 * A cookie is created when the user expands a node (the cookie name is the category name).
 * This cookie is deleted when the user collapses the node.
 * When the page is loaded, the cookie are read and a jquery call simulates a user click on the related categories.

Tests
Tested: Not tested:
 * Mediawiki 1.17 and CategoryTree-MW1.17-r85033.
 * Category tree in the sidebar.
 * On several Mediawiki instances on the same server.
 * With category names containing spaces and special characters like "&".
 * Latest Chrome, latest Firefox, Internet Explorer 9
 * "in-page" category trees.
 * Old Internet Explorer versions, Internet Explorer 10

Extra technical comments
Cookie expiration:
 * By default in this js source code, cookies are session-based, means they are clean-up when ~the browser is closed. Uncomment and adjust "'expires': XX," if you want your cookie to be more "permanent"...

New feature: "highlight all areas"
Based on the wonderful javascript code from [User:קיפודנחש], I add the feature to highlight all areas in grey when the image is loaded so it helps users to know where are the inter-active areas without searching them by using the mouse everywhere on the image (of course, yellow-highlighted areas are still there) because some users prefer searching areas on the image instead of using titles below the image. IMPORTANT NOTE: This feature is only for my wiki users and be sure you need such feature before adding it to your wiki.

Please refer to the discussion thread (show replies).

The full script is there:

Tools for creating image map

 * GIMP: Using the menu filters/web/Image Map, you can create and save your image maps. It is preferred to save your image maps (coordinates and shapes) so then you can easily update them when you have a new revision of your image or diagram.

To ease the conversion from html to wiki, copy the following lines in a file named html2wiki_map.sed: /area shape/!d s/,/ /g s/<area shape="\(.*\)" coords="\(.*\)" href="\(.*\)".*$/\1 \2 \3/ and then enter: sed -f html2wiki_map.sed < my_html_gimp_image_map.map
 * 1) Keep only lines containing "area shape"
 * 1) Convert comma to space
 * 1) Get the final result