[smokeping-users] Patch for active menu styles

Daniel Rich drich at employees.org
Thu Apr 24 18:35:15 CEST 2008


I just started working with smokeping, and in trying to make it look 
more like the rest of our monitoring tools I ran into a display feature 
that would be nice to have.  Most of the rest of our tools that have 
menus have the active menu reversed from the rest of the menu system.  
So, in the case of the default smokeping navigation menu, I wanted to 
active/open menu to have gray text on a white background instead of the 
the default colors.

In trying to do this, I noticed that there was a style for menulink and 
a style for the active menu, but no style for the active menu itself if 
it is a link.  So when I tried my color scheme above I ended up with a 
menu that was gray on gray -- which makes it a little hard to read. :)  
The patch below creates a new style -- menulinkactive, which will be 
applied to the currently selected menu.  Is there any chance this can 
make it into the next release?

--- lib/Smokeping.pm.orig       2008-04-24 08:08:53.000000000 -0700
+++ lib/Smokeping.pm    2008-04-24 08:28:14.000000000 -0700
@@ -660,7 +660,11 @@
            $menu =~ s/ / /g;
                my $menuadd ="";
                    $menuadd = "&nbsp;" x (20 - length($menu)) if length($menu) < 20;
-               $print .= qq{<tr><td class="$class" colspan="2">&nbsp;-&nbsp;<a class="menulink" HREF="$path$key$suffix">$menu</a>$menuadd</td></tr>\n};
+               my $menuclass = "menulink";
+               if ($key eq $current and !@$open) {
+                   $menuclass = "menulinkactive";
+               }
+               $print .= qq{<tr><td class="$class" colspan="2">&nbsp;-&nbsp;<a class="$menuclass" HREF="$path$key$suffix">$menu</a>$menuadd</td></tr>\n};
            if ($key eq $current){
                    my $prline = target_menu $tree->{$key}, $open, "$path$key.",$filter, $suffix;
                    $print .= qq{<tr><td class="$class">&nbsp;&nbsp;</td><td align="left">$prline</td></tr>}



And my style sheet in basepage.html looks like (which gives me the 
inverted active menu I was looking for):

.menubar {
    background: #1280d7;
    color: white;
}

.menu,
.menuitem,
.menuopen,
.menuactive
 {      font-size: small;
        font-family: sans-serif;
       }

.menuactive {
        background: white;
       }

a.menulink {
        color: white;
        }
a.menulinkactive {
        color: #1280d7;
        }

a.menulink:hover       {
        color: #ffcc00;
        }
a.menulinkactive:hover       {
        color: #ffcc00;
        }


-- 
Dan Rich <drich at employees.org> |   http://www.employees.org/~drich/
                               |  "Step up to red alert!"  "Are you 
sure, sir?
                               |   It means changing the bulb in the 
sign..."
                               |          - Red Dwarf (BBC)

-- 
Dan Rich <drich at employees.org> |   http://www.employees.org/~drich/
                               |  "Step up to red alert!"  "Are you sure, sir?
                               |   It means changing the bulb in the sign..."
                               |          - Red Dwarf (BBC)



More information about the smokeping-users mailing list