From 71eaa115f831e872be84851ef48d88eec9c57329 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Fri, 26 Apr 2013 13:23:34 +0200 Subject: [PATCH] Ellipsize long jobset/job names to prevent bootstrap navbar breakage --- src/lib/Hydra/View/TT.pm | 7 ++++++- src/root/topbar.tt | 4 ++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/lib/Hydra/View/TT.pm b/src/lib/Hydra/View/TT.pm index ab4965b4..ece42f65 100644 --- a/src/lib/Hydra/View/TT.pm +++ b/src/lib/Hydra/View/TT.pm @@ -8,7 +8,7 @@ __PACKAGE__->config( TEMPLATE_EXTENSION => '.tt', PRE_CHOMP => 1, POST_CHOMP => 1, - expose_methods => [qw/log_exists/]); + expose_methods => [qw/log_exists ellipsize/]); sub log_exists { my ($self, $c, $drvPath) = @_; @@ -16,4 +16,9 @@ sub log_exists { return defined $x; } +sub ellipsize { + my ($self, $c, $s, $n) = @_; + return length $s <= $n ? $s : substr($s, 0, $n - 3) . "..."; +} + 1; diff --git a/src/root/topbar.tt b/src/root/topbar.tt index 3b66ba3d..2bd3a066 100644 --- a/src/root/topbar.tt +++ b/src/root/topbar.tt @@ -61,7 +61,7 @@ [% END %] [% IF jobset %] - [% WRAPPER makeSubMenu title=("Jobset: " _ jobset.name) %] + [% WRAPPER makeSubMenu title=("Jobset: " _ ellipsize(jobset.name, 30)) %] [% INCLUDE makeLink uri = c.uri_for(c.controller('Jobset').action_for('index'), [project.name, jobset.name]) title = "Overview" %] @@ -109,7 +109,7 @@ [% END %] [% IF job %] - [% WRAPPER makeSubMenu title=("Job: " _ job.name) %] + [% WRAPPER makeSubMenu title=("Job: " _ ellipsize(job.name, 30)) %] [% INCLUDE makeLink uri = c.uri_for(c.controller('Job').action_for('overview'), [project.name, jobset.name, job.name]) title = "Overview" %]