Importing selected Wordpress posts to DeepaMehta
0. Introduction
DeepaMehta's affordance of extremely immediate bimodal manipulation of topics/ texts (namely viewing and connecting/ rearranging them) is IMO so rewarding that it justifies an import procedure which is currently still very cumbersome, especially if done for the first time. (More here.)
My report is based on the following scenario
- a running DeepaMehta installation (see InstallationDescriptionForWindows Wiki text),
- Wordpress locally installed (probably using the same xampp and the same mysql as DeepaMehta);
- an SQL frontend such as heidiSQL, and a query snippet like catselect.sql,
- access to a Unix shell for a single execution of an awk command (perhaps on a friend's MacOS? X), or a locally installed (g)awk on Windows, and an awk file like wp2dm.awk, uploaded there;
- additional stuff types.xml and a folder called icons to append and zip together;
The import procedure involves the following steps:
- fetching the posts from Wordpress's MySQL? database using sql front and exporting them
- transferring them to a platform offering the awk program, executing the awk command and transferring the resulting topicmap xml file back,
- adding stuff that seems to be required for DeepaMehta import (no idea why),
- finally importing the map in DeepaMehta.
1. Fetching from MySQL
After the SQL frontend program HeidiSQL? is installed and started,
- connect to Wordpress's MySQL? database (its name and the root password can probably be found in (Program Files)\xampp\htdocs\wordpress\wp-config.php );
- in the explorer pane on the left, expand the wp database by clicking on the + sign, > and click wp_categories,
- in the main pane, click the data tab > click cat_name to sort and find the category that you want to have; note its number in the column cat_ID left to it, for later use;
- click the Query tab > click the folder icon "Load SQL from textfile" > choose catselect.sql
- insert the cat_ID noted down earlier, just before the semicolon at the end of the long select statement;
- click the blue arrow "Execute SQL...",
- from the menu bar, click Export > Export data... > Filetype: XML file > (accept the suggested name) SQL-query.xml.
2. Transfer for awk and back
(This step would perhaps be simpler with an XSLT transformation but I hope it will be altogether hidden behind a nice import interface.)
- Make sure that the file wp2dm.awk is uploaded to the site where awk is installed.
(If your browser insists that this should be of filetype .xml you may have to rename it back.)
- File-transfer the export file SQL-query.xml to this site, using the option ascii;
- in a command shell, execute
awk -f wp2dm.awk SQL-query.xml > map.xml
(it is assumed that all 3 files are in the home directory which is current at the prompt)
- File-transfer the generated topicmap file map.xml back, again with option ascii,
3. Add some stuff
- Open the add-on file called types.xml in Notepad and select and copy all lines except the first two and last one, i. e. from <topictype through </assoctype ;
- Paste them right before the last line of the downloaded map.xml, i. e., before </topicmap
- Search and replace all occurrences of < by < and of > by >
(this was necessary because the HeidiSQL? preferences checkbox of "Convert HTML entities..." seems to be ignored; someone who is familiar with the unix command line will probably pipe the awk output to a small sed command).
- save the resultant file using save as... with the options filetype: all files and Encoding: UTF-8 (acknowledging the replacement warning);
- Zip the map file together with the folder icons into a zip file called, say, Desktop.zip,
4. Import the topicmap
- Start DeepaMehta using the normal (albeit very awkward) procedure (Start > All Programs > Accessories > Command Prompt > cd (Driveletter):\Dee (tab key), ant dm > Username root, Passwort empty enter.
- In the dropdown selector in the upper left, select the orange person icon root
- Rightclick the empty backdrop and select Import Topic Map,
- In the Open dialog, navigate to the import file, e. g. using the house icon for the desktop and scroll through the funny arrangement of files, click Desktop.zip and click Open (doubleclick does not work)
- Bring the black command prompt window to the foreground to see if there are errors. If there are errors, the procedure must not be repeated until after DeepaMehta is closed and restarted, otherwise there would be no reaction at all (neither errors nor success).
- If the messages read like topicmap import complete plus some lines of statistics, go to the DeepaMehta window again.
- Look for the label of the newly imported topicmap, whose icon is probably hidden under the upper left arrow button. Drag it down, doubleclick it and - hopefully your're done!.