My wonderful wife Angela and her students have been blogging up a storm in two--count 'em TWO-- of her courses,"The Afterlife in Classical and Italian Traditions" and "Homer". T.S. Eliot might have called this "the superfetation of τὸ ἔν." We've talked off and on about finding ways to work with the Ancient Greek characters--here's a way to add them in to the TinyMCE WYSIWYG editor used by WordPress, available for Drupal, and used in plenty of other apps. This will add the unicode Greek Extended block to tinyMCE's character map, which still means hunt-and-pecking your way through the Greek. That's clearly not so happy for a long passage, but it'll do the trick for shortish phrases.
N.B. Internet Explorer users seem to be out of luck on the unicode support. In using this, you might want to add a note that it looks better in Mozilla Firefox, and suggest that they get it here.
There are two parts--modifying the tinyMCE javascripts, then making sure that the character map is turned on in whatever application you are working with.
Step 1: Hack tinyMCE
The tinyMCE file you'll need to work with is charmap.js, located in your tinymce directory under themes/advanced/jscripts. The biggest section of it is a long array for all the special characters to include in the character map. Each entry in the array is another array with four elements:
['&', '&', true, 'ampersand'],
The first entry is the html entity, the second is the unicode decimal reference, the third is a boolean saying whether to display the character, and the fourth is a short description of what the character is. To add the Greek Extended block of unicode (or, for that matter, any of the unicode blocks), just follow the pattern to add arrays for each of characters, like so:
['', 'ἀ', true, ''],
['', 'ἁ', true, ''],
['', 'ἂ', true, ''],
['', 'ἃ', true, ''],
...
['', '῾', true, ''],
The first and last entries for these array are left empty because in the first case, there is no corresponding html entity reference, and in the last case I don't know the Greek to be able to give the description. Also note that not every number between 7936 and 8190 is part of the block. I've put a copy of just the arrays to add to the big array here, and the full modified charmap.js here.
The new window for the character map then needs to be made larger to fit all the characters. To do that, look in the init() function at the beginning of the file and add the following line to the end of it:
window.resizeBy(200, 200);
That makes the window bigger by 200 pixels in both directions. Add size to taste. That's worked well for me, but I've also changed the table size used in the popup. To do that, look in the function renderCharMapHTML() around line 483 and change the appropriate variables. Here's what I have:
function renderCharMapHTML() {
var charsPerRow = 30, tdWidth=20, tdHeight=20;
That takes care of the tinyMCE end.
Step 2: Setting up Drupal or WordPress
Drupal's tinyMCE module is nicely and easily configurable for all the buttons from the Drupal administration menus, so there's little to say about that. The download and documentation are here.
WordPress was trickier. TinyMCE comes with it out of the box, but without an mechanism for changing the tinymce settings. I'm grateful to this blog for setting me on the right track. Everything I have below is only a wee adaptation of what is there.
This will require editing the tiny_mce_gzip.php file, located under wp-inst/wp-includes/js/tinymce.
First, to have the WP tinymce see the character map functionality, find the code that looks like this (around line 97):
// Load all plugins and their language packs
$plugins = apply_filters('mce_plugins', array('wordpress', 'autosave', 'wphelp'));
Add 'charmap' to the array, like so:
$plugins = apply_filters('mce_plugins', array('wordpress', 'autosave','wphelp', 'charmap'));
Then, to add the button to the editor, find the lines (about 127) that look like:
$mce_buttons = apply_filters('mce_buttons', array('bold', 'italic', 'strikethrough', 'separator', 'bullist', 'numlist', 'outdent', 'indent', 'separator', 'justifyleft', 'justifycenter', 'justifyright' ,'separator', 'link', 'unlink', 'image', 'wordpress', 'separator', 'undo', 'redo', 'code', 'wphelp'));
and add 'charmap' to the array:
$mce_buttons = apply_filters('mce_buttons', array('bold', 'italic', 'strikethrough', 'separator', 'bullist', 'numlist', 'outdent', 'indent', 'separator', 'justifyleft', 'justifycenter', 'justifyright' ,'separator', 'link', 'unlink', 'image', 'wordpress', 'separator', 'undo', 'redo', 'code', 'wphelp', 'charmap'));
With that, you're ready to go with the Ancient Greek!
I am am gonna have to bust out my cunieform soon now that i know WordPress can HACK it. Great stuff.
Post new comment