Skip to content
Snippets Groups Projects
Commit 03b6eba4 authored by Nigel Kukard's avatar Nigel Kukard
Browse files

Added support to webserver to maintain a sidebar menu

parent 851c1905
No related branches found
No related tags found
No related merge requests found
...@@ -146,9 +146,11 @@ sub handle_request ...@@ -146,9 +146,11 @@ sub handle_request
} elsif (ref($res) eq "HTTP::Response") { } elsif (ref($res) eq "HTTP::Response") {
$response = $res; $response = $res;
# TODO: This is a bit dirty # TODO: This is a bit dirty
# Extra in this case is the sidebar menu items
} elsif ($res == HTTP_OK) { } elsif ($res == HTTP_OK) {
$response = httpCreateResponse($content); $response = httpCreateResponse($module,$daction,$content,$extra);
# TODO - redirect? # TODO - redirect?
# Extra in this case is the error description
} else { } else {
httpDisplayFault($res,$content,$extra); httpDisplayFault($res,$content,$extra);
} }
...@@ -204,13 +206,51 @@ EOF ...@@ -204,13 +206,51 @@ EOF
# Create a response object # Create a response object
sub httpCreateResponse sub httpCreateResponse
{ {
my ($msg) = @_; my ($module,$daction,$content,$menu) = @_;
# Throw out message to client to authenticate first # Throw out message to client to authenticate first
my $headers = HTTP::Headers->new; my $headers = HTTP::Headers->new;
$headers->content_type("text/html"); $headers->content_type("text/html");
# Check if we have a menu structure, if we do, display the sidebar
my $menuStr = "";
if (defined($menu)) {
$menuStr =<<EOF;
<div class="span1">
<div class="well sidebar-nav">
<ul class="nav nav-list">
EOF
# Loop with sub menu sections
foreach my $section (keys %{$menu}) {
# <li class="nav-header">Sidebar</li>
# <li class="active"><a href="#">Link</a></li>
# <li><a href="#">Link</a></li>
# <li class="nav-header">Sidebar</li>
# <li><a href="#">Link</a></li>
# Loop with menu items
foreach my $item (keys %{$menu->{$section}}) {
my $link = $module . "/" . $menu->{$section}->{$item};
# Sanitize slightly
$link =~ s,/+$,,;
# Build sections
$menuStr .=<<EOF;
<li class="nav-header">$section</li>
<li><a href="$link">$item</a></li>
EOF
}
}
$menuStr .=<<EOF;
</ul>
</div><!--/.well -->
</div><!--/span-->
EOF
}
# Build action response
my $resp = HTTP::Response->new( my $resp = HTTP::Response->new(
HTTP_OK,"Ok", HTTP_OK,"Ok",
$headers, $headers,
...@@ -268,24 +308,14 @@ sub httpCreateResponse ...@@ -268,24 +308,14 @@ sub httpCreateResponse
<div class="container-fluid"> <div class="container-fluid">
<div class="row-fluid"> <div class="row-fluid">
<div class="span1"> $menuStr
<div class="well sidebar-nav">
<ul class="nav nav-list">
<li class="nav-header">Sidebar</li>
<li class="active"><a href="#">Link</a></li>
<li><a href="#">Link</a></li>
<li class="nav-header">Sidebar</li>
<li><a href="#">Link</a></li>
</ul>
</div><!--/.well -->
</div><!--/span-->
<div class="span10"> <div class="span10">
$msg $content
</div><!--/span--> </div><!--/span-->
</div><!--/row--> </div><!--/row-->
<hr> <hr>
<footer> <footer>
<p>v$globals->{'version'} - Copyright &copy; 2013, <a href="http://www.allworldit.com">AllWorldIT</a></p> <p class="muted">v$globals->{'version'} - Copyright &copy; 2013, <a href="http://www.allworldit.com">AllWorldIT</a></p>
</footer> </footer>
</div><!--/.fluid-container--> </div><!--/.fluid-container-->
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment