From 7fa312026a6caba28550339fc29edfd790e78fda Mon Sep 17 00:00:00 2001 From: Buchan Milne Date: Tue, 2 Nov 2010 20:29:21 +0000 Subject: Add some CSS themeing, and refactor some template stuff using preprocess Add missing tempaltes --- catdap.yml | 3 + lib/CatDap/Controller/user.pm | 34 +++++- lib/CatDap/View/TT.pm | 2 + root/index.tt | 11 -- root/register/complete.tt | 11 -- root/template/footer | 3 + root/template/header | 16 +++ root/template/html | 13 +++ root/template/layout | 40 +++++++ root/template/pre | 3 + root/template/wrapper | 11 ++ root/ttsite.css | 252 ++++++++++++++++++++++++++++++++++++++++++ root/user/firstlogin.tt | 18 +++ root/user/index.tt | 32 ++++++ root/user/password.tt | 22 ++++ 15 files changed, 447 insertions(+), 24 deletions(-) create mode 100644 root/template/footer create mode 100644 root/template/header create mode 100644 root/template/html create mode 100644 root/template/layout create mode 100644 root/template/pre create mode 100644 root/template/wrapper create mode 100644 root/ttsite.css create mode 100644 root/user/firstlogin.tt create mode 100644 root/user/index.tt create mode 100644 root/user/password.tt diff --git a/catdap.yml b/catdap.yml index 3a62e3a..3e12daa 100644 --- a/catdap.yml +++ b/catdap.yml @@ -10,6 +10,9 @@ name: CatDap default_view: TT +organisation: Mageia +apptitle: Mageia Identity Management + Model::Proxy: base: ou=People,dc=mageia,dc=org dn: cn=catdap,ou=System Accounts,dc=mageia,dc=org diff --git a/lib/CatDap/Controller/user.pm b/lib/CatDap/Controller/user.pm index 0603217..90dbb0e 100644 --- a/lib/CatDap/Controller/user.pm +++ b/lib/CatDap/Controller/user.pm @@ -53,8 +53,8 @@ sub auto : Private { #TODO: ppolicy .... $c->stash(errors => ['Incorrect username or password']); $c->stash(template => 'index.tt'); - $c->forward('/index'); - $c->detach; + #$c->forward('/index'); + $c->detach('/user/login'); } else { #if (defined $c->user->pwdReset) { # $c->res->redirect('/user'); @@ -65,6 +65,7 @@ sub auto : Private { -cipher => 'Blowfish' ) or die $!; $c->session->{enc_password} = $cipher->encrypt($c->req->param('password') || $c->req->param('key')); + $c->stash(pages => roles2pages($c->user->roles)); $c->session->{dn} = $c->user->ldap_entry->dn; $c->session->{user} = $c->req->param('username'); $password = $c->req->param('password') || $c->req->param('key'); @@ -78,6 +79,8 @@ sub auto : Private { $password = $cipher->decrypt($c->session->{enc_password}); $c->log->info("Re-authenticating user " . $c->session->{user}); $c->authenticate({username => $c->session->{user},password => $password}); + + $c->stash(pages => roles2pages($c->user->roles)); $c->log->info($@) if $@; return 1; } @@ -186,6 +189,7 @@ sub index :Path :Args(0) { may => \@may, must => \@must, }); + $c->stash(subpages => gensubpages()); } sub add : Local { @@ -223,8 +227,10 @@ sub delete : Local : Args(2) { sub password : Local { my ( $self, $c) = @_; my ($mesg,$newpass,$cipher); + $c->stash(subpages => gensubpages()); if ( not defined $c->req->param('password') or not defined $c->req->param('newpassword1') or not defined $c->req->param('newpassword2')) { #if ( not defined $c->req->param('newpassword1') or not defined $c->req->param('newpassword2')) { + $c->detach; } if ($c->req->param('newpassword1') eq $c->req->param('newpassword2')) { @@ -318,6 +324,30 @@ sub logout : Local { $c->res->redirect('/'); } +sub roles2pages : Private { + my @roles = @_; + my @pages; + foreach my $role (sort @roles) { + if ($role =~ /^(\w+) ?(\w*) (Admin)s$/) { + my $page = lc("/$3/$1$2"); + push @pages,{ page => lc("/$3/$1$2"), title => "$1 $2 $3"}; + } + } + return \@pages; +} + +sub gensubpages : Private { + my ($type) = @_; + my @subpagenames; + @subpagenames = ( + { page => './', title => "Edit"}, + { page => 'password', title => "Change password"}, + ); + return \@subpagenames; +} + + + =head1 AUTHOR Buchan Milne diff --git a/lib/CatDap/View/TT.pm b/lib/CatDap/View/TT.pm index 0cd6acb..f63d775 100644 --- a/lib/CatDap/View/TT.pm +++ b/lib/CatDap/View/TT.pm @@ -8,6 +8,8 @@ use base 'Catalyst::View::TT'; __PACKAGE__->config( TEMPLATE_EXTENSION => '.tt', render_die => 1, + WRAPPER => 'template/wrapper', + PRE_PROCESS => 'template/pre', ); =head1 NAME diff --git a/root/index.tt b/root/index.tt index 3b43806..73f890a 100644 --- a/root/index.tt +++ b/root/index.tt @@ -1,16 +1,5 @@ -[% MACRO l(text, args) BLOCK; - c.localize(text, args); -END; %] - -

[% l('Login') %]

- -[% FOREACH error IN errors %] -[% error %]
-[% END %] -
-
diff --git a/root/register/complete.tt b/root/register/complete.tt index a4f07e2..0ffaa8c 100644 --- a/root/register/complete.tt +++ b/root/register/complete.tt @@ -1,16 +1,5 @@ -[% MACRO l(text, args) BLOCK; - c.localize(text, args); -END; %] - -

[% l('Registration completed') %]

- -[% FOREACH error IN errors %] -[% error %]
-[% END %] -
-

[% l('Registration was successful.') %] [% l('Check your mail for activation instructions') %] diff --git a/root/template/footer b/root/template/footer new file mode 100644 index 0000000..78203d5 --- /dev/null +++ b/root/template/footer @@ -0,0 +1,3 @@ + + + diff --git a/root/template/header b/root/template/header new file mode 100644 index 0000000..11ca573 --- /dev/null +++ b/root/template/header @@ -0,0 +1,16 @@ + +

+

[% c.config.apptitle %]

+
+
+ + +
+ diff --git a/root/template/html b/root/template/html new file mode 100644 index 0000000..c23fcfb --- /dev/null +++ b/root/template/html @@ -0,0 +1,13 @@ + + + + [% template.title or site.title %] + + + + + + +[% content %] + + diff --git a/root/template/layout b/root/template/layout new file mode 100644 index 0000000..8a6b601 --- /dev/null +++ b/root/template/layout @@ -0,0 +1,40 @@ + + + + +
+
+
+
+ +
+
+
+ +
+ +
+
+ [% IF errros %] + + [% FOREACH error IN errors %] + [% error %]
+ [% END %] +
+ [% END %] +
+ [% content %] +
+
+
+
+
+
+ +
+ + diff --git a/root/template/pre b/root/template/pre new file mode 100644 index 0000000..581baf7 --- /dev/null +++ b/root/template/pre @@ -0,0 +1,3 @@ +[% MACRO l(text, args) BLOCK; + c.localize(text, args); +END; %] diff --git a/root/template/wrapper b/root/template/wrapper new file mode 100644 index 0000000..8bfee46 --- /dev/null +++ b/root/template/wrapper @@ -0,0 +1,11 @@ +[% MACRO l(text, args) BLOCK; + c.localize(text, args); +END; %] +[% IF template.name.match('\.(css|js|txt)'); + debug("Passing page through as text: $template.name"); + content; + ELSE; + debug("Applying HTML page layout wrappers to $template.name\n"); + content WRAPPER template/html + template/layout; + END; +-%] diff --git a/root/ttsite.css b/root/ttsite.css new file mode 100644 index 0000000..520bb5b --- /dev/null +++ b/root/ttsite.css @@ -0,0 +1,252 @@ + +html { + height: 100%; + margin: 0; +} + +body { + /*background-color: #ccc;*/ + color: #000; + margin: 0; + padding: 0px; + height: 100%; +} + +#header { + background-color: #eee; + border-bottom: 0px solid #fff; +} + +#footer { + background-color: #ccc; + text-align: center; + /*border-top: 1px solid #000;*/ + position: absolute; + /*top: 99%;*/ + float: bottom; + left: 0px; + width: 100%; + height: 1em; + padding: 0px; + padding-bottom: 2px; + top: 100%; +} + +#content { + padding: 10px; + vertical-align: top; +} + +h1.title { + padding: 4px; + margin: 0px; +} + +.message { + color: #000; +} + +.error { + color: #f00; +} + + +/* Some stuff from skidoo_too.css */ +#outerColumnContainer +{ + /* reserves space for the left and right columns. you can use either + * padding, margins, or borders, depending on your needs. however you + * can use the border method to create a background color for both left + * and right columns + */ + /*height: 98%;*/ + border-left: solid 12em #eee; + border-right: solid 0em #eee; + /*border-bottom: solid 1em #fff;*/ +} +#innerColumnContainer +{ + border: solid 0px #000; + border-width: 0 0px; + margin: 0 -1px; /* compensate for the borders because of + 100% width declaration */ + width: 100%; + /*height: 90%;*/ + /*z-index: 1;*/ + background-color: #fff; + float: right; +} +#leftColumn, #middleColumn, #rightColumn, * html #SOWrap +{ + overflow: visible; /* fix for IE italics bug */ + position: relative; /* fix some rendering issues */ +} +#SOWrap +{ + float: left; + margin: 0 -1px 0 0; + width: 100%; + /*z-index: 3;*/ +} +#middleColumn +{ + float: right; + margin: 0 0 0 -1px; + width: 100%; + /*z-index: 5;*/ +} +#leftColumn +{ + float: left; + margin: 0 1px 0 -12em; + width: 12em; + /*z-index: 4;*/ + height: 100%; + background-color: #eee; +} +#rightColumn +{ + float: right; + width: 14em; + margin: 0 -14em 0 1px; + /*z-index: 2;*/ +} + +/* vertical navigation stuff. mostly exactly as seen in the vnav.css styleheet + * in the original skidoo layout. + */ +.vnav +{ + margin: 0em 0; +} +.vnav ul, .vnav ul li +{ + margin: 0; + padding: 0; + list-style-type: none; + display: block; +} +.vnav ul +{ + border: solid 0px #fff; + border-bottom-width: 0; +} +.vnav ul li +{ + border-bottom: solid 0px #fff; +} +.vnav ul li, .vnav ul li a +{ + margin: 0; + display: block; + padding: 0; + line-height: normal; +} +.vnav ul li a +{ + display: block; + padding: 2px 5px 3px 5px; +} +.vnav ul li a, .vnav ul li a:link, .vnav ul li a:visited, .vnav ul li a:active, .vnav ul li a:hover +{ + text-decoration: none; + cursor: pointer; + background-color: #eee; + color: #000; +} + +.vnav ul li a:hover +{ + text-decoration: none; + background-color: #ccc; +} + + +.vnav h3 +{ + margin-bottom: 0; + padding-bottom: 0; + font-size: 126%; +} +* html .vnav ul li a/* hide from IE5.0/Win & IE5/Mac */ +{ + height: 0.01%; +} +* html .vnav ul +{ + position: relative; /* IE needs this to fix a rendering problem */ +} + +/* horizontal navigation elements. create a DIV element with the class hnav + * and stick one unordered list inside it to generate a horizontal menu. + */ +.hnav +{ + border-bottom: solid 0px #fff; + text-align: center; +} +.hnav, .hnav ul li a +{ + /* need to middor veritcal padding on .hnav and child anchor elements + * because the anchors are _not_ block elements. since they are not + * block elements web browsers will not expand .hnav to contain them + * even with the extra padding. by applying the same padding to both + * the parent .hnav _looks_ like its containing the child anchor + * elements. + */ + padding-top: 3px; + padding-bottom: 4px; +} +.hnav ul, .hnav ul li +{ + display: inline; + list-style-type: none; + margin: 0; + padding: 0; +} +.hnav ul li a +{ + margin: 0 -1px 0 0; + padding-left: 10px; + padding-right: 10px; /* short-hand padding attribute would overwrite + top/bottom padding set in a previous rule */ + border-left: solid 0px #000; + border-right: solid 0px #000; + white-space: nowrap; +} +.hnav ul li a:link, .hnav ul li a:visited, .hnav ul li a:active, .hnav ul li a:hover +{ + text-decoration: none; + color: #7f899a; +} +.hnav ul li a:hover +{ + text-decoration: none; + background-color: #ccc; +} +.hnav ul li span.divider +{ + display: none; +} +* html .hnav ul li, * html .hnav ul li a +{ + width: 1%; /* IE/Mac needs this */ + display: inline-block; /* IE/Mac needs this */ + /* \*/ + width: auto; + display: inline; + /* reset above hack */ +} +* html .hnav, * html .hnav ul a +{ + /* \*/ height: 0.01%; /* hasLayout hack to fix render bugs in IE/Win. + IE/Mac will ignore this rule. */ +} +* html .HNAV +{ + padding: 0; /* IE5/Win will resize #hnav to fit the heights of its + inline children that have vertical padding. So this + incorrect case selector hack will be applied only by + IE 5.x/Win */ +} + diff --git a/root/user/firstlogin.tt b/root/user/firstlogin.tt new file mode 100644 index 0000000..33d0e60 --- /dev/null +++ b/root/user/firstlogin.tt @@ -0,0 +1,18 @@ + + +
+ + + + + + + + + + + + +
New Password
Repeat New Password
+
+ diff --git a/root/user/index.tt b/root/user/index.tt new file mode 100644 index 0000000..3147cd9 --- /dev/null +++ b/root/user/index.tt @@ -0,0 +1,32 @@ +
+ + +[% FOREACH attr IN values %] + + + + +[% END %] + +
AttributeValue
[% attr.name %][% FOREACH val IN attr.values %][% IF attr.editable %][% ELSE %][% val %]
[% END %] +[% IF attr.addable AND attr.editable %]Add[% END %] +[% IF attr.removable AND attr.editable %]Delete[% END %] + [% END %]
+
+ +
+ + + + + + +
+ + + + +
+
diff --git a/root/user/password.tt b/root/user/password.tt new file mode 100644 index 0000000..ade4e11 --- /dev/null +++ b/root/user/password.tt @@ -0,0 +1,22 @@ + +
+ + + + + + + + + + + + + + + + + +
Current password
New Password
Repeat New Password
+
+ -- cgit v1.2.1