Skip to content

Commit

Permalink
Show messages on the Bootstrap enabled pages
Browse files Browse the repository at this point in the history
  • Loading branch information
kimrutherford committed Apr 5, 2013
1 parent f1f20f6 commit 69f5094
Show file tree
Hide file tree
Showing 3 changed files with 88 additions and 75 deletions.
76 changes: 1 addition & 75 deletions root/autohandler
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -25,50 +25,7 @@ $is_admin_user
<& breadcrumbs.mhtml &> <& breadcrumbs.mhtml &>
<span id="curs-contact-page-link"><& contact.mhtml, link_text => 'Questions? Contact curators ...' &></span> <span id="curs-contact-page-link"><& contact.mhtml, link_text => 'Questions? Contact curators ...' &></span>


<div id="notice-list"> <& /err_mess_notice.mhtml, error => $error, message => $message, notice => $notice &>
% for my $notice (@notices) {
<div class="notice">
<strong>
<% $notice->{title} %>
</strong>
% if (exists $notice->{text}) {
<div>
<% $notice->{text} %>
</div>
% }
</div>
% }
</div>

<div id="error-list">
% for my $err (@errors) {
<div class="error">
<strong>
<% $err->{title} %>
</strong>
% if (exists $err->{text}) {
<div>
<% $err->{text} %>
</div>
% }
</div>
% }
</div>

<div id="message-list">
% for my $mess (@messages) {
<div class="message">
<strong>
<% $mess->{title} %>
</strong>
% if (exists $mess->{text}) {
<div>
<% $mess->{text} %>
</div>
% }
</div>
% }
</div>


% if ($show_title) { % if ($show_title) {
<h1 id="<% $page_description_id %>"> <h1 id="<% $page_description_id %>">
Expand Down Expand Up @@ -98,37 +55,6 @@ $is_admin_user


<%init> <%init>
my $st = $c->stash(); my $st = $c->stash();

my $tidy = sub {
my $arg = shift;

if (!defined $arg) {
return ();
}

if (ref $arg) {
if (ref $arg eq 'ARRAY') {
return @$arg;
} else {
if (ref $arg eq 'HASH' && exists $arg->{title}) {
return $arg;
} else {
use Data::Dumper;
$Data::Dumper::Maxdepth = 5;
warn "error in stash is not an array, hash or scalar: ", Dumper([$arg]);

return ( { title => 'Internal error',
text => 'The problem will be investigated' } );
}
}
} else {
return { title => $arg };
}
};

my @errors = $tidy->($error);
my @messages = $tidy->($message);
my @notices = $tidy->($notice);
</%init> </%init>


<%flags> <%flags>
Expand Down
4 changes: 4 additions & 0 deletions root/docs/autohandler
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
$title $title
$show_title => 1 $show_title => 1
$sub_title => undef $sub_title => undef
$error => undef
$message => undef
$notice => undef
</%args> </%args>


<!DOCTYPE HTML> <!DOCTYPE HTML>
Expand All @@ -18,6 +21,7 @@ $sub_title => undef
<div class="container-fluid" id="content"> <div class="container-fluid" id="content">
<span id="curs-contact-page-link"><& contact.mhtml, link_text => 'Questions? Contact curators ...' &></span> <span id="curs-contact-page-link"><& contact.mhtml, link_text => 'Questions? Contact curators ...' &></span>


<& /err_mess_notice.mhtml, error => $error, message => $message, notice => $notice &>


% if ($show_title) { % if ($show_title) {
<div id="canto-title-section"> <div id="canto-title-section">
Expand Down
83 changes: 83 additions & 0 deletions root/err_mess_notice.mhtml
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,83 @@
<%args>
$error => undef
$message => undef
$notice => undef
</%args>

<div id="notice-list">
% for my $notice (@notices) {
<div class="notice">
<strong>
<% $notice->{title} %>
</strong>
% if (exists $notice->{text}) {
<div>
<% $notice->{text} %>
</div>
% }
</div>
% }
</div>

<div id="error-list">
% for my $err (@errors) {
<div class="error">
<strong>
<% $err->{title} %>
</strong>
% if (exists $err->{text}) {
<div>
<% $err->{text} %>
</div>
% }
</div>
% }
</div>

<div id="message-list">
% for my $mess (@messages) {
<div class="message">
<strong>
<% $mess->{title} %>
</strong>
% if (exists $mess->{text}) {
<div>
<% $mess->{text} %>
</div>
% }
</div>
% }
</div>

<%init>
my $tidy = sub {
my $arg = shift;

if (!defined $arg) {
return ();
}

if (ref $arg) {
if (ref $arg eq 'ARRAY') {
return @$arg;
} else {
if (ref $arg eq 'HASH' && exists $arg->{title}) {
return $arg;
} else {
use Data::Dumper;
$Data::Dumper::Maxdepth = 5;
warn "error in stash is not an array, hash or scalar: ", Dumper([$arg]);

return ( { title => 'Internal error',
text => 'The problem will be investigated' } );
}
}
} else {
return { title => $arg };
}
};

my @errors = $tidy->($error);
my @messages = $tidy->($message);
my @notices = $tidy->($notice);
</%init>

0 comments on commit 69f5094

Please sign in to comment.