Use template loops to display categories and applications - work in progress (#29)

This commit is contained in:
Clément Oudot 2010-09-20 10:39:23 +00:00
parent 59c17a6604
commit 36a1674c09
9 changed files with 115 additions and 11 deletions

View File

@ -171,7 +171,7 @@ localStorageOptions={ 'namespace' => 'MyNamespace', 'default_expires_in' => 600,
;trustedDomains = my.trusted.host example2.com
# MENU
applicationList={ 'Menu' => { type => 'category', 'Example' => { type => 'category', 'test1' => { type => 'application', options => { name => 'Application Test 1', uri => 'http://test1.__DNSDOMAIN__/', description => 'A simple application displaying authenticated user', logo => 'wheels.png', display => 'auto', }, },'test2' => { type => 'application', options => { name => 'Application Test 2', uri => 'http://test2.__DNSDOMAIN__/', description => 'The same simple application displaying authenticated user', logo => 'wheels.png', display => 'auto', }, }, },'Administration' => { type => 'category', 'manager' => { type => 'application', options => { name => 'WebSSO Manager', uri => 'http://manager.__DNSDOMAIN__/', description => 'Configure LemonLDAP::NG WebSSO', logo => 'tools.png', display => 'on', }, },'sessions' => { type => 'application', options => { name => 'Sessions explorer', uri => 'http://manager.__DNSDOMAIN__/sessions.pl', description => 'Explore WebSSO sessions', logo => 'tools.png', display => 'on', }, }, },'Documentation' => { type => 'category', 'localdoc' => { type => 'application', options => { name => 'Local documentation', uri => 'http://manager.__DNSDOMAIN__/doc/', description => 'Documentation supplied with LemonLDAP::NG', logo => 'docs.png', display => 'on', }, },'officialwebsite' => { type => 'application', options => { name => 'Offical Website', uri => 'http://lemonldap.objectweb.org/', description => 'Official LemonLDAP::NG Website', logo => 'web.png', display => 'on', }, }, }, }, }
applicationList={ type => 'category', 'Example' => { type => 'category', 'test1' => { type => 'application', options => { name => 'Application Test 1', uri => 'http://test1.__DNSDOMAIN__/', description => 'A simple application displaying authenticated user', logo => 'wheels.png', display => 'auto', }, },'test2' => { type => 'application', options => { name => 'Application Test 2', uri => 'http://test2.__DNSDOMAIN__/', description => 'The same simple application displaying authenticated user', logo => 'wheels.png', display => 'auto', }, }, },'Administration' => { type => 'category', 'manager' => { type => 'application', options => { name => 'WebSSO Manager', uri => 'http://manager.__DNSDOMAIN__/', description => 'Configure LemonLDAP::NG WebSSO', logo => 'tools.png', display => 'on', }, },'sessions' => { type => 'application', options => { name => 'Sessions explorer', uri => 'http://manager.__DNSDOMAIN__/sessions.pl', description => 'Explore WebSSO sessions', logo => 'tools.png', display => 'on', }, }, },'Documentation' => { type => 'category', 'localdoc' => { type => 'application', options => { name => 'Local documentation', uri => 'http://manager.__DNSDOMAIN__/doc/', description => 'Documentation supplied with LemonLDAP::NG', logo => 'docs.png', display => 'on', }, },'officialwebsite' => { type => 'application', options => { name => 'Offical Website', uri => 'http://lemonldap.objectweb.org/', description => 'Official LemonLDAP::NG Website', logo => 'web.png', display => 'on', }, }, }, }
[handler]

View File

@ -91,9 +91,8 @@ if ( $portal->process() ) {
LOGOUT_URL => "$ENV{SCRIPT_NAME}?logout=1",
REQUIRE_OLDPASSWORD => $portal->{portalRequireOldPassword},
DISPLAY_MODULES => $portal->{menuDisplayModules},
APPSLIST_LOOP => $portal->{menuAppslist},
APPSLIST_MENU => $portal->{menuAppslistMenu},
APPSLIST_DESC => $portal->{menuAppslistDesc},
APPSLIST_MENU => $portal->{menuAppslistMenu}, # For old templates
APPSLIST_DESC => $portal->{menuAppslistDesc}, # For old templates
);
}

View File

Before

Width:  |  Height:  |  Size: 6.5 KiB

After

Width:  |  Height:  |  Size: 6.5 KiB

View File

Before

Width:  |  Height:  |  Size: 6.9 KiB

After

Width:  |  Height:  |  Size: 6.9 KiB

View File

Before

Width:  |  Height:  |  Size: 15 KiB

After

Width:  |  Height:  |  Size: 15 KiB

View File

Before

Width:  |  Height:  |  Size: 18 KiB

After

Width:  |  Height:  |  Size: 18 KiB

View File

@ -33,6 +33,8 @@ $(document).ready(function(){
$("input[type!=hidden]:first").focus();
$("input[type='password']").attr("autocomplete",autocomplete);
/*
$("#appslist li[class!=catname]").hover(
function(){
var appid = $(this).attr("title");
@ -49,6 +51,8 @@ $(document).ready(function(){
}
}
);
*/
if(login){ $("input[type=password]:first").focus(); }
if(newwindow){ $('#appslist a[href^="http://"]').attr("target", "_blank"); }

View File

@ -28,20 +28,118 @@
</TMPL_IF>
<div class="menulogo"></div>
<!-- Tabs content -->
<TMPL_LOOP NAME="DISPLAY_MODULES">
<TMPL_IF NAME="Appslist">
<!-- The old fashion -->
<div id="appslist">
<!-- Plain HTML (no loops)
<TMPL_VAR NAME="APPSLIST_MENU">
<TMPL_VAR NAME="APPSLIST_DESC">
-->
<TMPL_LOOP NAME="APPSLIST_LOOP">
<!-- Template loops -->
<TMPL_IF NAME="category">
<!-- Category -->
<div class="category cat-level-<TMPL_VAR NAME="catlevel">">
<p class="catname"><TMPL_VAR NAME="catname"></p>
<TMPL_IF applications>
<!-- Applications -->
<TMPL_LOOP NAME=applications>
<!-- Application -->
<div class="application <TMPL_VAR NAME="appid">">
<!-- Logo (optional) -->
<TMPL_IF NAME="applogo">
<img src="/skins/common/apps/<TMPL_VAR NAME="applogo">"
class="applogo <TMPL_VAR NAME="appid">"
alt="<TMPL_VAR NAME="appname">" />
</TMPL_IF>
<!-- Name and link (mandatory) -->
<p class="appname <TMPL_VAR NAME="appid">">
<a href="<TMPL_VAR NAME="appurl">" alt="<TMPL_VAR NAME="appname">">
<TMPL_VAR NAME="appname">
</a>
</p>
<!-- Logo (optional) -->
<TMPL_IF NAME="appdesc">
<p class="appdesc <TMPL_VAR NAME="appid">">
<TMPL_VAR NAME="appdesc">
</p>
</TMPL_IF>
</div>
<!-- TODO use LOOPS -->
<!-- End of applications loop -->
</TMPL_LOOP>
</TMPL_IF>
<TMPL_IF categories>
<!-- Sub categories -->
<TMPL_LOOP NAME=categories>
<div class="category cat-level-<TMPL_VAR NAME="catlevel">">
<p class="catname"><TMPL_VAR NAME="catname"></p>
<TMPL_IF applications>
<!-- Applications in sub category -->
<TMPL_LOOP NAME=applications>
<!-- Application in sub category-->
<div class="application <TMPL_VAR NAME="appid">">
<!-- Logo (optional) -->
<TMPL_IF NAME="applogo">
<img src="/skins/common/apps/<TMPL_VAR NAME="applogo">"
class="applogo <TMPL_VAR NAME="appid">"
alt="<TMPL_VAR NAME="appname">" />
</TMPL_IF>
<!-- Name and link (mandatory) -->
<p class="appname <TMPL_VAR NAME="appid">">
<a href="<TMPL_VAR NAME="appurl">" alt="<TMPL_VAR NAME="appname">">
<TMPL_VAR NAME="appname">
</a>
</p>
<!-- Logo (optional) -->
<TMPL_IF NAME="appdesc">
<p class="appdesc <TMPL_VAR NAME="appid">">
<TMPL_VAR NAME="appdesc">
</p>
</TMPL_IF>
</div>
<!-- End of applications loop -->
</TMPL_LOOP>
</TMPL_IF>
</div>
<!-- End of sub categories loop -->
</TMPL_LOOP>
</TMPL_IF>
</div>
<!-- End of categories loop -->
</TMPL_IF>
</TMPL_LOOP>
</div>
</TMPL_IF>
<TMPL_IF NAME="ChangePassword">

View File

@ -88,7 +88,10 @@ sub displayModules {
$self->lmLog( "Evaluate condition $cond for module $module", 'debug' );
if ( $self->safe->reval($cond) ) {
push @$displayModules, { $module => 1 };
my $moduleHash = { $module => 1 };
$moduleHash->{'APPSLIST_LOOP'} = $self->appslist()
if ( $module eq 'Appslist' );
push @$displayModules, $moduleHash;
}
}
@ -96,7 +99,7 @@ sub displayModules {
}
## @method arrayref appslist()
# Returns categories and appplications list as HTML::Template loop
# Returns categories and applications list as HTML::Template loop
# @return categories and applications list
sub appslist {
my ($self) = splice @_;
@ -155,7 +158,7 @@ sub _buildCategoryHash {
my $categoryHash =
{ category => 1, catname => $catname, catlevel => $catlevel };
$categoryHash->{appplications} = $applications if $applications;
$categoryHash->{applications} = $applications if $applications;
$categoryHash->{categories} = $categories if $categories;
return $categoryHash;
}