Rosio Pavoris a blog

Incidentally

My blog now supports the use of tripcodes and secure tripcodes by commenters. The tripcode algorithm should be less broken than Shiichan’s while still not really entirely not being broken. The secure tripcode algorithm is crap and probably not portable.

The source for the plugin is here.

(I don’t approve of tripfaggery any more than the next guy. However, I have too much free time.)

Permalink 10 Comments

Simple Footnoter

Time for another quick-and-dirty WordPress plugin.
Since Emiry likes my footnotes, I wrote a plugin that makes making them a bit easier.

Basically, the idea is that you write [1] (where 1 can be any number), and this plugin will replace it with 1. Then, at the bottom of the post (typically, but not necessarily), you write [f1], and it will replace it with 1. If the latter is at the start of a paragraph, it will also make said paragraph of class “footnote”, which you can then define in your CSS file or what have you to have a different style, if you so desire.

You’ll note that the ID of the anchor tag starts with a random number. This is to prevent (or at least make very unlikely) collisions in IDs if more than one post is being displayed at a time, since that breaks things. Ideally, it would use the post slug for that, but if there’s a way to retrieve a post slug from within a filter, I couldn’t find it in the WordPress API in under two minutes.

It’s not awesomely efficient (it uses regular expressions), or awesomely awesome, but it works well enough.
The code is here; as always, save that as a .php file, upload to your plugins folder, and activate. If you have suggestions for improvement, let me know.

Permalink 1 Comment

Planning ahead

Next of Kin is a really handy WordPress plug-in Terru pointed out to me.
It keeps track of how often you visit your blog, and after a certain amount of time it sends you a warning e-mail. If you don’t visit your blog for another while, it sends you another one. Then, after a third while, it e-mails one or more e-mail addresses of your choice.

Almost nobody on the internet bothers to plan for what’ll happen after they die, and it’s caused some problems before. I’ve already done some planning, but this is definitely a very handy plug-in.

Permalink Comments

Updated~

I’ve updated the blog theme to the latest version. Not as easy as it sounds, since I’ve edited most files myself for great awesome.
Beccary fixed some bugs I had already found and fixed myself, and one that I got used to so I unfixed it (a class=”commentmeta” that should have been class=”postmeta”, but which I like better as class=”commentmeta”), and left in a bug I’d found and fixed before, which I had to refix (permalinks on the index page; she forgot to properly close a tag).
Basically, the changes are that there are optional CSS classes for images now (which I’d meant to write myself but hadn’t gotten around to), and some extra things at the bottom of the individual post pages (some of which I removed because it was too cluttery).

If you notice any other changes, let me know, because that means I screwed up somewhere.
(You might ask why I updated everything, then, if I just want most things to stay the same. In doing so, you would demonstrate that you do not understand how my mind works.)

Also, I rewrote the simple disemvoweler plugin on the WordPress wiki to suit my needs better. It just retains the [troll] thing from the modification there, since disemvoweling by IP isn’t something I’m very likely to do.
Here’s the code, if you want it. Simple desu~

<?php

/*
Plugin Name: Better Disemvoweler
Plugin URI: http://wordpress.org/#
Description: Use [troll] to disemvowel comments.
Version: 0.0
Author: Some Guy
*/

function disemvowel($content) {
	if (ereg("^\\[troll\\]", $content)) {
		$content = substr($content, 7);
		$content = preg_replace("/[aeiou]/i", '', $content);
	}
	return $content;
}

add_filter('comment_text', 'disemvowel');

?>

Permalink Comments

Wikilinkifier

As you may have noticed, I link to Wikipedia a lot, and having to type the entire address out bothers me, so I wrote a WordPress plugin to do it for me.

Wikipedia desu~What this plugin does it take your post and, before it’s displayed, replaces [[foo]] and [[bar|baz]] with links to Wikipedia. In the first case, foo, in the second bar.
Like my Cthulheriser plugin, it doesn’t actually change anything in the database, so if it acts up, you can just turn it off with no damage to your data.
It doesn’t convert spaces to underscores, or change the first letter to a capital letter, both because Wikipedia does that for you anyway, and because PHP is awkward about regular expressions.
I know how to do it in Perl, dammit. ;.;

The code is below, or here. Copy that code to a textfile (or just download that textfile), change the extension to .php, upload it to your /wp-content/plugins/ folder, and activate it from you Plugins page.
(Licensed under the GPL, of course.)

<?php
/*
Plugin Name: Wikilinkifier
Plugin URI: http://cairnarvon.rotahall.org/?p=586
Description: Replaces Wikitext link syntax with links to Wikipedia.
Version: 1.0
Author: Koen Crolla
Author URI: http://cairnarvon.rotahall.org/
*/

function wikilink($content) {

  $pattern = array('/\[\[([^\]|]+)([^\]|]+)?\]\]/',
                   '/\[\[([^\]|]+)\|([^\]]+)?\]\]/');
  $replace = array("<a href=\"http://en.wikipedia.org/wiki/$1\">$1</a>",
                   "<a href=\"http://en.wikipedia.org/wiki/$2\">$1</a>");

  $content = preg_replace($pattern, $replace, $content);
  return $content;

}

add_filter('the_content', 'wikilink');

?>

Permalink 6 Comments

In which I write a WordPress plugin

Mighty CthulhuI give you the Cthulheriser!
This is a very simple WordPress plug-in that automatically replaces some Christianity-related words in comments with some more Lovecraftian ones.
As written, there’s no way to exempt certain individual comments or authors (though I could make it so it exempts certain IPs, I guess), and there’s no control panel for it or anything.

You can change the words it changes yourself, if you like. The code should be pretty transparent. It’s a good idea to keep as many entries in the $pattern array as in the $replace array, because of the way preg_replace() works, but how many entries they have exactly doesn’t matter. Add or delete at will~

To use it, just paste the code below into a regular textfile, rename the file to “cthulheriser.php” (or anything, really, as long as it’s a .php file) and upload it to /wp-content/plugins/. You can then turn it on in your WordPress admin panel thing, in the Plugins section.
Because of the way WordPress’s comment parsing works, it doesn’t actually change the comments in the database, so if you disable the plugin, everything will just go back to normal, no harm done.

As far as licensing goes, it’s in the public domain, as far as I’m concerned. Code is too simple not to be. I’d still appreciate it if the header thing with the credit were preserved, though.
This is version 0.1, and it won’t be 1.0 until I add a proper user interface.
Which is to say, never.

<?php
/*
Plugin Name: Cthulheriser
Plugin URI: http://cairnarvon.rotahall.org/?p=494
Description: Makes comments more Lovecraftian, for great justice.
Version: 0.1
Author: Koen Crolla
Author URI: http://cairnarvon.rotahall.org/
*/

function cthulherise($content) {

	$pattern = array('/God/',
			 '/Jesus/',
			 '/Holy Ghost/',
			 '/Moses/',
			 '/Virgin Mary/',
			 '/Amen[!.]?)/',
			 '/Apostle/',
			 '/apostle/',
			 '/Bible/',
			 '/Heaven/',
			 '/Hell/',
			 '/[Gg]ospels?/');
	$replace = array('Azathoth',
			 'Nyarlathotep',
			 'Crawling Horror',
			 'Cthulhu',
			 'Black Goat of the Woods',
			 'Ia! Ia! Cthulhu fhtagn!',
			 'High Priest',
			 'cultist',
			 'Necronomicon',
			 'the Great Beyond',
			 'the Chaos',
			 'Cryptical Books of Hsan');

	$content = preg_replace($pattern, $replace, $content);
	return $content;

}

add_filter('comment_text', 'cthulherise');

?>

Permalink 8 Comments