Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
O
opentrafficshaper
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Francisco Manuel Cardoso
opentrafficshaper
Commits
03b6eba4
Commit
03b6eba4
authored
11 years ago
by
Nigel Kukard
Browse files
Options
Downloads
Patches
Plain Diff
Added support to webserver to maintain a sidebar menu
parent
851c1905
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
opentrafficshaper/plugins/webserver/webserver.pm
+45
-15
45 additions, 15 deletions
opentrafficshaper/plugins/webserver/webserver.pm
with
45 additions
and
15 deletions
opentrafficshaper/plugins/webserver/webserver.pm
+
45
−
15
View file @
03b6eba4
...
...
@@ -146,9 +146,11 @@ sub handle_request
}
elsif
(
ref
(
$res
)
eq
"
HTTP::Response
")
{
$response
=
$res
;
# TODO: This is a bit dirty
# Extra in this case is the sidebar menu items
}
elsif
(
$res
==
HTTP_OK
)
{
$response
=
httpCreateResponse
(
$
content
);
$response
=
httpCreateResponse
(
$
module
,
$daction
,
$content
,
$extra
);
# TODO - redirect?
# Extra in this case is the error description
}
else
{
httpDisplayFault
(
$res
,
$content
,
$extra
);
}
...
...
@@ -204,13 +206,51 @@ EOF
# Create a response object
sub
httpCreateResponse
{
my
(
$m
sg
)
=
@_
;
my
(
$m
odule
,
$daction
,
$content
,
$menu
)
=
@_
;
# Throw out message to client to authenticate first
my
$headers
=
HTTP::
Headers
->
new
;
$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
(
HTTP_OK
,"
Ok
",
$headers
,
...
...
@@ -268,24 +308,14 @@ sub httpCreateResponse
<
div
class
=
"
container-fluid
"
>
<
div
class
=
"
row-fluid
"
>
<
div
class
=
"
span1
"
>
<
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
-->
$menuStr
<
div
class
=
"
span10
"
>
$
msg
$
content
<
/div><!--/span
-->
<
/div><!--/
row
-->
<
hr
>
<
footer
>
<
p
>
v$globals
->
{'
version
'}
-
Copyright
©
;
2013
,
<
a
href
=
"
http://www.allworldit.com
"
>
AllWorldIT
<
/a></p
>
<
p
class
=
"
muted
"
>
v$globals
->
{'
version
'}
-
Copyright
©
;
2013
,
<
a
href
=
"
http://www.allworldit.com
"
>
AllWorldIT
<
/a></p
>
</
footer
>
<
/div><!--/
.
fluid
-
container
-->
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment