|
From: <buc...@us...> - 2016-01-08 10:19:02
|
Revision: 253
http://sourceforge.net/p/devmon/code/253
Author: buchanmilne
Date: 2016-01-08 10:18:59 +0000 (Fri, 08 Jan 2016)
Log Message:
-----------
Enforcing a maximum title length (82 chars), and do various changes to
accommodate as much of the description as possible if the title is too long
Modified Paths:
--------------
trunk/extras/devmongraphtitle.pl
Modified: trunk/extras/devmongraphtitle.pl
===================================================================
--- trunk/extras/devmongraphtitle.pl 2015-09-15 15:18:07 UTC (rev 252)
+++ trunk/extras/devmongraphtitle.pl 2016-01-08 10:18:59 UTC (rev 253)
@@ -12,6 +12,9 @@
my $graphinstance = shift || "";
my $period = shift||"";
my @files = @ARGV;
+my $maxdesclen = 82;
+my $longheader = "Network traffic on";
+my $shortheader = "Traffic on";
my $intdesc;
@@ -39,7 +42,7 @@
print if $ENV{'DEBUG'};
if (m(^<tr><td>$intname ([^<]+)?<\/td><td>)) {
$intdesc = $1;
- print "Network Traffic on $intname ($intdesc) $period\n";
+ print generate_title($intname,$intdesc), "\n";
exit 0;
}
}
@@ -48,8 +51,34 @@
print if $ENV{'DEBUG'};
if (m(^<tr><td>$intname ([^<]+)?<\/td><td>)) {
$intdesc = $1;
- print "Network Traffic on $intname ($intdesc) $period\n";
+ print generate_title($intname,$intdesc), "\n";
exit 0;
}
}
print "Network Traffic on $intname $period\n";
+
+sub generate_title {
+ my ($int,$descr) = @_;
+ my $title;
+ $title = "$longheader $int ($descr) $period";
+ return $title if (length($title) <= $maxdesclen);
+
+ if (length($title) > $maxdesclen + length($longheader) - length($shortheader) ) {
+ $period =~ s/ Hours/h/;
+ $period =~ s/ Days/d/;
+ }
+ $title = "$shortheader $int ($descr) $period";
+ return $title if (length($title) <= $maxdesclen);
+
+ $title = "$int ($descr) $period";
+ return $title if (length($title) <= $maxdesclen);
+
+ $title = "$int ($descr)";
+ if ( length($title) > $maxdesclen ) {
+ substr($descr,length($descr) - length($title) + $maxdesclen - 3,length($title) - $maxdesclen +3,"..");
+ #$title = "$int ($descr) $period";
+ $title = "$int ($descr)";
+ }
+ return $title;
+}
+
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|