From 9666a31ad92dcf547f90d775cf00b235a188fd98 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Oudot?= Date: Sat, 3 Mar 2012 22:49:10 +0000 Subject: [PATCH] First code for a floating menu for a protected application (#417) --- _example/etc/handler-apache2.conf | 3 + _example/test/index.pl | 6 +- lemonldap-ng-handler/MANIFEST | 1 + .../lib/Lemonldap/NG/Handler/Menu.pm | 75 +++++++++++++++++++ 4 files changed, 81 insertions(+), 4 deletions(-) create mode 100644 lemonldap-ng-handler/lib/Lemonldap/NG/Handler/Menu.pm diff --git a/_example/etc/handler-apache2.conf b/_example/etc/handler-apache2.conf index 21b0b29fa..963fbc514 100644 --- a/_example/etc/handler-apache2.conf +++ b/_example/etc/handler-apache2.conf @@ -22,6 +22,9 @@ ErrorDocument 503 http://auth.__DNSDOMAIN__/?lmError=503 # SSO protection PerlHeaderParserHandler My::Package + # Display Menu + PerlOutputFilterHandler Lemonldap::NG::Handler::Menu + # DocumentRoot DocumentRoot __TESTDIR__ diff --git a/_example/test/index.pl b/_example/test/index.pl index a3979c388..777376952 100755 --- a/_example/test/index.pl +++ b/_example/test/index.pl @@ -15,7 +15,6 @@ my $color = $cgi->param("color") || "#ddd"; # Local parameters my $manager_url = "http://manager.__DNSDOMAIN__"; -my $portal_url = "http://auth.__DNSDOMAIN__"; # CSS my $css = <\n"; print "

$name

\n"; -print "\n"; - print "

Main informations

\n"; print "
    \n"; print "
  • Authentication status: SUCCESS
  • \n"; diff --git a/lemonldap-ng-handler/MANIFEST b/lemonldap-ng-handler/MANIFEST index d69e20cee..1e90d5160 100644 --- a/lemonldap-ng-handler/MANIFEST +++ b/lemonldap-ng-handler/MANIFEST @@ -13,6 +13,7 @@ lib/Lemonldap/NG/Handler.pm lib/Lemonldap/NG/Handler/AuthBasic.pm lib/Lemonldap/NG/Handler/CDA.pm lib/Lemonldap/NG/Handler/CGI.pm +lib/Lemonldap/NG/Handler/Menu.pm lib/Lemonldap/NG/Handler/Proxy.pm lib/Lemonldap/NG/Handler/SecureToken.pm lib/Lemonldap/NG/Handler/SharedConf.pm diff --git a/lemonldap-ng-handler/lib/Lemonldap/NG/Handler/Menu.pm b/lemonldap-ng-handler/lib/Lemonldap/NG/Handler/Menu.pm new file mode 100644 index 000000000..9bb2fd359 --- /dev/null +++ b/lemonldap-ng-handler/lib/Lemonldap/NG/Handler/Menu.pm @@ -0,0 +1,75 @@ +##@file +# Menu + +##@class +# Menu +# +# Display a menu on protected applications +package Lemonldap::NG::Handler::Menu; + +use strict; +use Lemonldap::NG::Handler::SharedConf qw(:all); +use base qw(Lemonldap::NG::Handler::SharedConf); +use Apache2::Filter (); +use constant BUFF_LEN => 1024; + +## @rmethod Apache2::Const run(Apache2::Filter f) +# Overload main run method +# @param f Apache2 Filter +# @return Apache2::Const::OK +sub run { + my $class = shift; + my $f = $_[0]; + + unless ( $f->ctx ) { + $f->r->headers_out->unset('Content-Length'); + $f->ctx(1); + } + + # CSS parameters + my $background = "#ccc"; + my $border = "#aaa"; + my $width = "30%"; + my $marginleft = "35%"; + my $marginright = "35%"; + my $height = "20px"; + + my $menudiv = " + +"; + + while ( $f->read( my $buffer, BUFF_LEN ) ) { + $buffer =~ s/<\/body>/$menudiv<\/body>/g; + $f->print($buffer); + } + + return OK; + +} + +1;