======SpectreMoo====== >>Other Interests: ~-Biologically inspired computing (Genetic Programming, Neural Nets, etc.) ~-Astronomy; mostly reading, I'm no amateur astronomer ~-Physics >>I've installed Wikka to augment our company intranet, and in the process I've made a number of both superficial and functional changes to the code. Many of the changes I've made work only within my company intranet environment (auto-linking of java class names to our javadocs, for instance), but I've tried to post general changes here -- for instance, the SpellcheckHack. Lately (as of early 2009) I've done a lot of work with our internal wiki to make it more usable within our company. Some of the changes I've made include page categorization including search, Ajax-y menus (used for categories, among other things), and use of script.aculo.us. Unfortunately our internal version is now significantly different from the main dev branch and we have several tool / library dependencies which make posting the changes back here difficult. I intend to post some of the more straightforward ones in the next few months. (We have a googlebox in-house which we use for search, and I'm using ""ExtJS"" for our Ajax stuff.) I hope that in the next year or two (regardless of today's date!) we'll see functional, robust WYSIWYG editors for wikis which will make them even more accessible to common folk, and that will be a good day -- especially for users supporting wiki use in a corporate environment such as myself. Thank you for a great wiki engine! ---- ====Fortune Action==== First off: the latest iteration of my ""{{fortune}}"" action: %%(php)IsWikiName ($location)) { if (!$this->ExistsPage ($location)) { echo "The specified page does not exist."; return; } $page = $this->LoadPage ($location); if ($page) { $line = 0; $pagelines = explode ("\n", $page["body"]); for ($i = 0; $i < count ($pagelines); $i++) { if (preg_match ("/[ ~]*-(.*)/",$pagelines[$i],$matches)) { $lines[$line++] = $matches[1]; } } } } } echo $lines[array_rand ($lines)]; ?>%% To use, save as fortune.php in the actions directory. Usage: ""{{fortune location="URL|WikiPage"}}"" ~- URLs need to point to one line quotes which end in newlines, as in the example URL included in the source. ~- Wiki pages are parsed for lines starting with a bullet point (""~-"" and its variants), which I've used as a source of random wiki tips. ---- =====Grab Table as .csv File===== One of the things users in my intranet have wanted to do is export tables to .csv files. We're based on the 1.1.6.2 code line with older simple tables (the version sans formatting) added. Because I've got a personal wiki which uses a build of 1.1.6.4, I'll try to put this together for the more modern version of SimpleTables as well. SimpleTables isn't in 1.1.6.4 (looks like it's targetted for 1.1.7), this version will be ported to [[http://wush.net/trac/wikka/browser/trunk/formatters/wakka.php?rev=761 | rev 761]] of the wikka formatter. Here's how it works: Tables are formatted as normal, only we add a "Grab" button to each when we close a table. Each table in a page is assigned a unique number, so when the Grab action submits to the grabtable formatter, we know which table to convert and send as a .csv file. This method is easier than trying to adapt grabcode wholesale, as grabbing each cell's contents and urlencoding them proved... well, very, very difficult. To start, you need to add a page handler, which I've called grabtable.php: %%(php)GetConfigValue('grabtable_button') == 1) { //get URL parameters $table = getTableCSV ($this->page['body'], $_POST['tablenumber']); // TODO: use central regex library for filename validation $filename = (isset($_POST['filename']) && preg_match('/\w[-.\w]*/', $_POST['filename']))? urldecode($_POST['filename']).FILE_EXTENSION : DEFAULT_FILENAME; //set HTTP headers header('Content-type: text/plain'); header('Expires: ' . gmdate('D, d M Y H:i:s') . ' GMT'); //TODO: check for consistency with server time format header('Content-Length: '.strlen($table)); header('Content-Description: '.$filename.' Download Data'); header('Pragma: no-cache'); header('Content-Disposition: attachment; filename="'.$filename.'"'); //print code block echo $table; } else { echo ERROR_NO_CODE; } ?>%% Anyone familiar with grabcode.php will see the obvious similarities to the above code, I adapted that handler for my needs. I didn't break the getTableCSV function apart into a formatter; this inline style works and I'm not sure it makes sense to separate the two functions. Next, add the following Wakka.class.php after the grabcode block (search for """// grabcode page handler"""): %%(php) // grabtable page handler elseif ($this->method == "grabtable") { print($this->Method($this->method)); } %% Modifying the wakka page formatter is a bit trickier, add the following: %%(php) static $table_count = 0; # near line 148 of rev 761 wakka.php, in the static declarations %% %%(php)# This block replaces the existing block in the $trigger_table == 1 section: else if ($thing != "") { $trigger_table = 0; $output = ''; // display grab button if option is set in the config file if ($wakka->config['grabtable_button'] == '1') { $output .= $wakka->FormOpen("grabtable"); // build form $output .= ''; $output .= ''; $output .= ''; $output .= $wakka->FormClose(); } return "\n".$output.wakka2callback($things); } %% wikka.config.php gets: %%(php) "grabtable_button" => "1",%% The same can be added to wikka.php. Also modify the following line in wikka.php: %%(php)if (!preg_match("/(xml|raw|mm|grabcode|grabtable)$/", $method))%% ...and you should now be able to download table.csv files for tables in the same way you'd grab code to codesnippet.txt. Consider this beta for now, especially given the fact I'm working on a modified 1.1.6.2 version of Wikka. I'll post this to a separate page once I've ported it to 1.1.6.4. Suggestions, comments, and questions are appreciated! ---- Moved spellchecking to SpellcheckHack. ---- CategoryUsers