
My National Novel Writing Month project just passed the 40k mark, and I find that I'm in need of a little structure. I know basically what I want for my final two 5k chapters. I have to line a few ducks first, though.
I slowly started putting everything into a wiki last week. Then, yesterday, when I crossed the 40k word barrier, I sped up the process so I could finish. At first I went with Wikka Wiki. It has a cute, handy, and easy to implement word count action. Copy the code. Paste it into a new document. Name the document and upload it to the right directory. Done. Wikka Wikki has ease of plugins down to a science.
However, my first love is MediaWiki. So I did a fair bit of digging and came across a reasonable little word count hack for MediaWiki page content. Thanks to Kishore Asokan.
MediaWiki Article Word Count
<?
// Getting the total words count
global $wgUser, $wgArticle, $db;
//check if its an article
if($wgArticle && !$_GET['action']) {
$c=$wgArticle->getContent();
$stripped= strip_tags($c);
$exploded=explode(" ", $stripped);
//you can print this variable anywhere you want on the page
$totalwords=count($exploded);
}?>
I played with the code a bit, but eventually left it as it was. The code is not perfect. It doesn't give an exact word count, but neither do most word processors. What I get is a very reasonable estimate.
I stuck it on a tab in the MonoBook skin and love it.
Here's how:
<?php
echo htmlspecialchars($tab['text']) ?></a></li>
<?php } ?>
</ul>
</div>
<li><font color="blue"> <?php echo $totalwords ;?> words </font></li>
When you finish, there should be a word count tab at the top of every article page. Some special pages will show the word count tab as well.
| Sun | Mon | Tue | Wed | Thu | Fri | Sat |
|---|---|---|---|---|---|---|
| << < | > >> | |||||
| 1 | 2 | 3 | ||||
| 4 | 5 | 6 | 7 | 8 | 9 | 10 |
| 11 | 12 | 13 | 14 | 15 | 16 | 17 |
| 18 | 19 | 20 | 21 | 22 | 23 | 24 |
| 25 | 26 | 27 | 28 | 29 | 30 | 31 |