Skip to content

Instantly share code, notes, and snippets.

@harry-wood
Created September 20, 2014 15:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save harry-wood/7dd9af2de1a59bfc3087 to your computer and use it in GitHub Desktop.
Save harry-wood/7dd9af2de1a59bfc3087 to your computer and use it in GitHub Desktop.
Converts text copied out of adium IRC, into mediawiki syntax suitable for pasting into a wiki as minutes of a meeting. Use it here: http://harrywood.dev.openstreetmap.org/adiumirc2mediawiki.php
<?php
/**
* Converts text copied out of adium IRC, into mediawiki syntax
* suitable for pasting into a wiki as minutes of a meeting
*/
header('Content-Type: text/html; charset=utf-8');
?>
<html>
<head>
<title>adium IRC to MediaWiki formatting converter</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
</head>
<body>
<?php
if (isset($_POST["irclog"])) {
$content = $_POST["irclog"];
//$content = utf8_encode($content);
$output = "===IRC log:===\n";
foreach (explode("\n", $content) as $line) {
$line = trim($line);
$cols = explode("\t", $line);
if (count($cols) > 3) {
$user = $cols[0];
$message = $cols[2];
if ($message=="") {
$notice = $cols[0];
$time = rtrim($cols[3]);
$output .= "''".$time."'' : ''".$notice."''<br>\n";
} else {
if (count($cols) < 6) {
$time = "";
} else {
$time = rtrim($cols[5]);
}
$output .= "''".$time."'' '''".$user."''': ".$message."<br>\n";
}
}
}
print "<pre>";
$output = str_replace("\'", "'", $output);
//print htmlentities($output);
print htmlspecialchars($output);
print "</pre>";
} else {
?>
<form action="" method="post" accept-charset="UTF-8">
<p>Copy and paste from an adium IRC window into here:</p>
<textarea name="irclog" rows="30" cols="80">
</textarea>
<input type="submit" value="2 mediawiki!" />
</form>
<p>(assumes adium is set up like harry's. Maybe needs message style set to 'yMous')</p>
<?php
}
?>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment