Random RT hack

There is a separate entry for the RT hack I made last night: poller-script

Posted Tue 07 Jun 2011 07:55:10 PM CEST Tags: code

Request tracker poller script

I am the sysadmin who takes care RT at work. (More or less the whole IT team uses it for work related task/case management.)

I needed a solution to keep track what comes in and what leaves the system. There is a way to do that from the web UI. But I am more accustomed to the CLI so that was not what I wanted.

I already used rt the command line tool which talks the REST (like) API what RT uses.

RT::Client::REST client is here that basically takes care of the communication: it sends queries to the RT server parses the answers and makes it all available to the application as pure perl data structures.

The REST interface did not provide To or Cc values for transactions, so I added that (it took a while to find the right file :)

--- /usr/local/rt-3.8.2/share/rt3/html/REST/1.0/Forms/ticket/history    2009-01-28 09:10:02.000000000 +0100
+++ history     2011-06-07 03:05:00.457357787 +0200
@@ -122,18 +122,6 @@
    if (!%$fields || exists $fields->{lc 'TimeTaken'});
 push @data, [ Type    => $t->Type   ]
    if (!%$fields || exists $fields->{lc 'Type'});
+    if( defined $t->ContentObj ) {
+      push @data, [ To     => $t->ContentObj->GetHeader("To")   ]
+       if (!%$fields || exists $fields->{lc 'To'});
+      push @data, [ Cc     => $t->ContentObj->GetHeader("Cc")   ]
+       if (!%$fields || exists $fields->{lc 'Cc'});
+    }
+    else {
+      push @data, [ To     => ""   ]
+       if (!%$fields || exists $fields->{lc 'To'});
+      push @data, [ Cc     => ""   ]
+       if (!%$fields || exists $fields->{lc 'Cc'});
+    }
 push @data, [ Field    => $t->Field   ]
    if (!%$fields || exists $fields->{lc 'Field'});
 push @data, [ OldValue    => $t->OldValue   ]

I also include the RT client side poller script which runs on my machine. (We use http auth for now, so some changes can be necessary if using form based auth.)

Posted Tue 07 Jun 2011 05:59:12 PM CEST Tags: code

Ikiwiki: a good, but not general enought way to remove accents from page titles

The reason that I say a good way, because I already made autocreatetagpage which is obviously an ugly hack. But this one is implemented right, but not as a plugin so it makes Ikiwiki to depend on one another Perl module. So I am not sure if this is ok for inclusion in Ikiwiki. But whatever, I put it here.

--- IkiWiki.pm  2008-01-30 14:37:30.000000000 +0100
+++ IkiWiki.pm  2008-01-31 22:09:47.000000000 +0100
@@ -6,6 +6,7 @@
 use Encode;
 use HTML::Entities;
 use URI::Escape q{uri_escape_utf8};
+use Text::Unaccent;
 use POSIX;
 use open qw{:utf8 :std};

@@ -556,14 +555,6 @@

    $link=~s/\/$//;

-   my $bestlink;
-   if (! $opts{forcesubpage}) {
-       $bestlink=bestlink($lpage, $link);
-   }
-   else {
-       $bestlink="$lpage/".lc($link);
-   }
-
    my $linktext;
    if (defined $opts{linktext}) {
        $linktext=$opts{linktext};
@@ -571,6 +562,17 @@
    else {
        $linktext=pagetitle(basename($link));
    }
+
+        # cstamas UTF8 removal
+        $link = unac_string("UTF-8", $link);
+
+   my $bestlink;
+   if (! $opts{forcesubpage}) {
+       $bestlink=bestlink($lpage, $link);
+   }
+   else {
+       $bestlink="$lpage/".lc($link);
+   }

    return "<span class=\"selflink\">$linktext</span>"
        if length $bestlink && $page eq $bestlink &&

In fact this is a one liner change (twice), but I have to reorder the code a bit to work right.

Posted Thu 31 Jan 2008 10:50:44 PM CET Tags: code

Ikiwiki: a dirty way to auto create tag pages.

I needed the feature described here: http://ikiwiki.info/plugins/tag/discussion/

This is a dirty way. You should not use it, I want to replace it with a better one.

--- tag.pm  2007-12-15 23:47:25.000000000 +0100
+++ tag.pm.new  2007-12-27 22:58:16.000000000 +0100
@@ -24,12 +24,28 @@

 sub tagpage ($) { #{{{
    my $tag=shift;
+
+   my $origtag=$tag;

    if (exists $config{tagbase} &&
    defined $config{tagbase}) {
        $tag=$config{tagbase}."/".$tag;
    }

+   my $tagpagetocreate=$config{srcdir}."/".$tag.'.mdwn';
+        if (! -f $tagpagetocreate ) {
+       open(MYF, ">$tagpagetocreate");
+       print MYF <<END;
+[[inline pages="link($config{tagbase}/$origtag)" template="titlepage"]]
+END
+       close(MYF);
+   }
+
    return $tag;
 } #}}}

The main goal is to replace this hack with a clean solution, maybe when I have more time...

Posted Tue 01 Jan 2008 07:26:25 PM CET Tags: code