summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJannis M. Hoffmann <jannis.hoffmann@rwth-aachen.de>2022-05-01 22:06:03 +0200
committerJannis M. Hoffmann <jannis.hoffmann@rwth-aachen.de>2022-05-01 22:06:03 +0200
commit72ae9b3f63ddbe296f3e4e8f8db2d29303163d68 (patch)
treef0db960b784719df0c7318720880c73b5330b937
parent7c8bd21ccbca8a3166289ab0e5511cc82d2822aa (diff)
use more tag helpers in templates
-rw-r--r--public/style.css8
-rw-r--r--templates/_pagination2.html.ep19
-rw-r--r--templates/error.html.ep9
-rw-r--r--templates/headers/_display_bot_nav.html.ep32
-rw-r--r--templates/headers/_display_headers.html.ep37
-rw-r--r--templates/headers/_display_top_nav.html.ep13
-rw-r--r--templates/headers/_displayfolders.html.ep18
-rw-r--r--templates/layouts/mainlayout.html.ep19
-rw-r--r--templates/webmail/about.html.ep4
-rw-r--r--templates/webmail/noaction.html.ep10
-rw-r--r--templates/webmail/writemail.html.ep20
11 files changed, 103 insertions, 86 deletions
diff --git a/public/style.css b/public/style.css
index fd39792..23a7cbf 100644
--- a/public/style.css
+++ b/public/style.css
@@ -11,11 +11,12 @@
--color-head: #002266;
}
-
/* GENERAL */
+
body {
font-family: sans;
}
+
a:link {
text-decoration: none;
color: var(--color-link);
@@ -28,6 +29,7 @@ a:hover {
text-decoration: underline;
color: var(--color-link-hover);
}
+
footer {
margin-top: 50px;
text-align: center;
@@ -86,7 +88,7 @@ iframe.html-mail {
height: 400px;
}
-a.btn {
+form.link-btn input {
padding: 5px;
/* margin: 4px; */
/* border-width: 5px; */
@@ -101,7 +103,7 @@ a.btn {
cursor: pointer;
text-decoration: none;
}
-a.btn:hover {
+form.link-btn input:hover {
background-color: #0060a0;
/* border-color: black; */
}
diff --git a/templates/_pagination2.html.ep b/templates/_pagination2.html.ep
index f838841..e03dbb0 100644
--- a/templates/_pagination2.html.ep
+++ b/templates/_pagination2.html.ep
@@ -1,19 +1,22 @@
<a href="<%= url_with->query({start => $first_page->[0]-1}) %>"> <img src="/first.gif" alt="<%= l('first') . ' ' . l 'page' %>"></a>\
-<a href="<%= url_with->query({start => $prev_page->[0]-1}) %>"> <img src="/left.gif" alt="<%= l('previous') . ' ' . l 'page' %>"> </a>\
+<a href="<%= url_with->query({start => $prev_page->[0]-1}) %>"> <img src="/left.gif" alt="<%= l('previous') . ' ' . l 'page' %>"> </a>
-<form>
- [<label for=custompage><%= ucfirst l 'page' %></label>
- <input type=number name=start id=custompage placeholder="<%= $current_page %>" size=3 />
- <%= l 'of' %> <%= $total_pages %>]
+%= form_for '' => begin
+ [
+ %= label_for custompage => ucfirst l 'page'
+ %= number_field start => (id => 'custompage') => (size => 3) => (placeholder => $current_page)
+ %= l 'of'
+ %= $total_pages
+ ]
% my $h = $c->req->query_params->to_hash;
% while (my ($k, $v) = each %$h) {
% if ($k ne 'start') {
- <input type=hidden name="<%=$k%>" value="<%=$v%>" />
+ %= hidden_field $k => $v
% }
% }
-</form>\
+% end
<a href="<%= url_with->query({start => $next_page->[0]-1}) %>"> <img src="/right.gif" alt="<%= l('next') . ' ' . l 'page' %>"> </a>\
-<a href="<%= url_with->query({start => $last_page->[0]-1}) %>"> <img src="/last.gif" alt="<%= l('last') . ' ' . l('page') %>"> </a> \ No newline at end of file
+<a href="<%= url_with->query({start => $last_page->[0]-1}) %>"> <img src="/last.gif" alt="<%= l('last') . ' ' . l('page') %>"> </a>
diff --git a/templates/error.html.ep b/templates/error.html.ep
index 92391d6..d120e69 100644
--- a/templates/error.html.ep
+++ b/templates/error.html.ep
@@ -1,3 +1,4 @@
+<!DOCTYPE html>
<html>
<head>
@@ -8,20 +9,22 @@
<h1>Error</h1>
<p class=center>
% if (my $msg = stash 'error') {
-%= $msg
+ %= $msg
% }
% else {
Uwu :(
% }
</p>
+
% if (my $see_other = stash 'links') {
See:
<nav>
% for (@$see_other) {
- <a href="<%= $_ %>"> <%= $_ %> </a><br>
+ %= link_to $_ => $_
+ <br>
% }
</nav>
% }
</body>
-</html> \ No newline at end of file
+</html>
diff --git a/templates/headers/_display_bot_nav.html.ep b/templates/headers/_display_bot_nav.html.ep
index 107ac67..ea1ce3c 100644
--- a/templates/headers/_display_bot_nav.html.ep
+++ b/templates/headers/_display_bot_nav.html.ep
@@ -12,34 +12,30 @@
</td>
<td>
- <label for=allbox><%= l 'check_all' %>: </label>
- <input name=allbox type=checkbox onclick="check_all(this);">
+ <label for=allbox><%= l 'check_all' %></label>:
+ <input name=allbox type=checkbox onclick="check_all(this)">
</td>
<td>
- <form id=move-mail action="<%= url_for('move') %>" method=post>
- <label for=select-folder> <%= l('move') . ' ' . l('to') %> </label>
- <select name=folder id=select-folder>
- %== "<option value='$_'>$_</option>" for grep {$_ ne $folder} @$mail_folders;
- </select>
-
+ %= form_for move => (id => 'move-mail') => begin
+ %= label_for 'select-folder' => l('move') . ' ' . l('to')
+ %= select_field folder => [grep {$_ ne $folder} @$mail_folders] => (id => 'select-folder')
%= csrf_field
-
- <input type="submit" value="<%= l 'move' %>">
- </form>
+ %= submit_button l 'move'
+ % end
</td>
</tr>
</table>
-<script>
+<script type="text/javascript">
function check_all(box) {
- const setTo = box.checked;
- const mails = document.getElementById('mail-headers').tBodies[0].rows;
+ const setTo = box.checked;
+ const mails = document.getElementById('mail-headers').tBodies[0].rows;
- for (const m of mails) {
- m.lastElementChild.children[0].checked = setTo;
- }
+ for (const m of mails) {
+ m.lastElementChild.children[0].checked = setTo;
+ }
}
-</script> \ No newline at end of file
+</script>
diff --git a/templates/headers/_display_headers.html.ep b/templates/headers/_display_headers.html.ep
index d3f9457..c278a37 100644
--- a/templates/headers/_display_headers.html.ep
+++ b/templates/headers/_display_headers.html.ep
@@ -2,11 +2,11 @@
% my $param = shift;
<th class=sort-param>
- <a href="<%= url_with->query(sort => (param('sort') || '') eq $param ? '!' . $param : $param) %>">
+ %= link_to url_with->query(sort => $param eq (param('sort') || '') ? '!' . $param : $param) => begin
% no warnings qw(experimental::smartmatch);
%= do { given (param('sort')) { '↑' when ($param); '↓' when ('!' . $param) } }
%= ucfirst l $param;
- </a>
+ % end
</th>
% end
@@ -25,25 +25,28 @@
<thead>
<tr id=sort>
- <th> <%= ucfirst l 'nr' %> </th>
+ <th>
+ %= ucfirst l 'nr'
+ </th>
%= $sort_param->('status');
%= $sort_param->('date');
-
% if ($folder ne "SENT") {
%= $sort_param->('sender');
- % } else {
+ % }
+ % else {
<th class=sort-param>
- <a href="<%= url_with->query(sort => param('sort') ne '!sender' ? 'sender' : '!sender' ) %>">
- <%= ucfirst l 'recipient' %>
- % if (param('sort') eq "sender") {
- <IMG SRC="/down.gif" width="12" height="12" border="0" alt="v">
- % } elsif (param('sort') eq "recipient_rev") {
- <IMG SRC="/up.gif" width="12" height="12" border="0" alt="^">
- % }
- </a>
+ %= link_to url_with->query(sort => param('sort') ne '!sender' ? 'sender' : '!sender' ) => begin
+ %= ucfirst l 'recipient'
+ % if (param('sort') eq "sender") {
+ %= image '/down.gif' => (width => 12) => (height => 12) => (border => 0) => (alt => 'v')
+ % }
+ % elsif (param('sort') eq "recipient_rev") {
+ %= image '/up.gif' => (width => 12) => (height => 12) => (border => 0) => (alt => '^')
+ % }
+ % end
</th>
% }
@@ -63,7 +66,7 @@
% foreach my $msgnum ($first_item .. $last_item) {
% my $msg = $msgs->[$msgnum - $first_item];
- <tr class="<%= $msg->{new} ? 'new-mail' : '' %>" id="<%= $msg->{mid} %>" >
+ %= tag tr => (class => $msg->{new} ? 'new-mail' : '') => (id => $msg->{mid}) => begin
<td>
%= $msgnum
</td>
@@ -78,15 +81,15 @@
%= $msg->{head}{from}[0]{name} || $msg->{head}{from}[0]{email};
</td>
<td>
- <a href="<%= url_for('read', id => $msg->{mid}) %>"> <%= $msg->{head}{subject} || '_' %> </a>
+ %= link_to $msg->{head}{subject} || '_' => read => {id => $msg->{mid}}
</td>
<td>
%= print_sizes10 $msg->{size};
</td>
<td>
- <input type=checkbox name=mail value="<%= $msg->{mid} %>" form=move-mail>
+ %= check_box mail => $msg->{mid} => (form => 'move-mail')
</td>
- </tr>
+ % end
% }
</tbody>
diff --git a/templates/headers/_display_top_nav.html.ep b/templates/headers/_display_top_nav.html.ep
index 5888cb3..2b882af 100644
--- a/templates/headers/_display_top_nav.html.ep
+++ b/templates/headers/_display_top_nav.html.ep
@@ -6,18 +6,19 @@
%# <a href="<%= url_with($prefsurl) %>"><%= TXT 'userconfig' %></a>
%# <a href="<%=$prefsurl%>?action=editaddresses&folder=<%=$folder%>&sessionid=<%=$thissession%>&sort=<%=$sort%>&firstmessage=<%=$firstmessage+1%>&lang=<%=$lang%>" ><%= TXT 'addressbook' %></a>
<li>
- <a href="<%= url_for('logout') %>"><%= ucfirst l 'logout' %></a>
+ %= link_to ucfirst(l 'logout') => 'logout'
</li>
<li>
- <a href="<%= url_for('write') %>" ><%= ucfirst l 'compose' %></a>
+ %= link_to ucfirst(l 'compose') => 'write'
</li>
</ul>
</td>
<td>
- <form action="<%= url_for %>">
- <label for=search><%= ucfirst l 'search' %></label>: <input type=search name=search size=8>
- </form>
+ %= form_for '' => begin
+ %= label_for search => ucfirst(l 'search') . ': '
+ %= search_field search => (size => 8)
+ % end
</td>
<td id=pag2>
@@ -30,4 +31,4 @@
</td>
</tr>
-</table> \ No newline at end of file
+</table>
diff --git a/templates/headers/_displayfolders.html.ep b/templates/headers/_displayfolders.html.ep
index 8cff0ed..7bc5b12 100644
--- a/templates/headers/_displayfolders.html.ep
+++ b/templates/headers/_displayfolders.html.ep
@@ -2,25 +2,31 @@
<tr>
<td id=folder-list class=alter-font>
- <strong class=up> <%= l($folder) || $folder %> </strong>
+ <strong class=up>
+ %= l($folder) || $folder
+ </strong>
<ul class=line>
% for my $v (grep {$_ ne $folder} @$mail_folders) {
- <li><a href="<%= url_for(folder => $v) %>" class=bright> <%= $v ne '' ? (l($v) || $v) : l 'Home' %> </a></li>
+ <li>
+ %= link_to '' => {folder => $v} => (class => 'bright') => begin
+ %= $v ? (l($v) || $v) : l 'Home'
+ % end
+ </li>
% }
</ul>
</td>
<td>
<em class=msg-count>
- <%= $first_item %>-<%= $last_item %> <%= l 'of' %> <%= $total_items %> <%= l 'messages' %>\
- <%= ", $total_new_mails " . l('new') if $total_new_mails > 0; =%>
+ <%= "$first_item - $last_item " . l('of') . " $total_items " . l('messages') %>\
+ <%= ", $total_new_mails " . l('new') if $total_new_mails > 0 =%>
% if ($total_size) {
- - <%= ucfirst l('mbox_size') . ": " . print_sizes10 $total_size %>
+ - <%= ucfirst(l 'mbox_size') . ": " . print_sizes10 $total_size %>
% }
</em>
</td>
</tr>
-</table> \ No newline at end of file
+</table>
diff --git a/templates/layouts/mainlayout.html.ep b/templates/layouts/mainlayout.html.ep
index 782bcdd..9f36006 100644
--- a/templates/layouts/mainlayout.html.ep
+++ b/templates/layouts/mainlayout.html.ep
@@ -1,21 +1,24 @@
<!DOCTYPE html>
-
<html lang="<%= $lang %>">
<head>
<meta charset=UTF-8>
- <title> <%= stash('title') || 'JWebmail' %> </title>
- <link href="/style.css" rel=stylesheet>
+ <title>
+ %= stash('title') || 'JWebmail'
+ </title>
+ %= stylesheet '/style.css'
</head>
<body>
%= content
<footer>
- <a href="<%= url_for('about') %>">
- <%= ucfirst l 'about' %> JWebmail
- </a>
- <br/>
- <%= ucfirst l 'version' %> <%= $version %>
+ %= link_to about => begin
+ %= ucfirst l 'about'
+ JWebmail
+ % end
+ <br />
+ %= ucfirst l 'version'
+ %= $version
</footer>
</body>
</html>
diff --git a/templates/webmail/about.html.ep b/templates/webmail/about.html.ep
index 49ecc1a..60fe549 100644
--- a/templates/webmail/about.html.ep
+++ b/templates/webmail/about.html.ep
@@ -47,7 +47,7 @@
<li>Supported languages:
<p class=languages>
% foreach (@$languages) {
- <a href="<%= url_for(lang => $_) %>"><%= $_ %></a>
+ %= link_to $_ => {lang => $_}
% }
</p>
</li>
@@ -64,7 +64,7 @@
<tr>
<td>
<nav>
- <a href="<%= url_for('noaction') %>" class=btn>login</a>
+ %= button_to login => 'noaction' => (class => 'link-btn')
</nav>
</td>
</tr>
diff --git a/templates/webmail/noaction.html.ep b/templates/webmail/noaction.html.ep
index 54a8106..2608bda 100644
--- a/templates/webmail/noaction.html.ep
+++ b/templates/webmail/noaction.html.ep
@@ -18,12 +18,12 @@
<tr>
<td class=login-form>
- <form method=post name=login1 action="<%= url_for('login') %>">
+ %= form_for login => (name => 'login1') => begin
<table>
<tr>
<td class=label-cell>
- <label for=userid><%= ucfirst l 'userid' %></label>:
+ %= label_for userid => ucfirst l 'userid'
</td>
<td>
%= text_field 'userid'
@@ -31,7 +31,7 @@
</tr>
<tr>
<td class=label-cell>
- <label for=password><%= ucfirst l 'passwd' %></label>:
+ %= label_for password => ucfirst l 'passwd'
</td>
<td>
%= password_field 'password'
@@ -39,12 +39,12 @@
</tr>
<tr class=submit-row>
<td colspan=2>
- <input type=submit value="<%= l 'login' %>">
+ %= submit_button l 'login'
</td>
</tr>
</table>
- </form>
+ % end
</td>
</tr>
diff --git a/templates/webmail/writemail.html.ep b/templates/webmail/writemail.html.ep
index ca69994..8375bdf 100644
--- a/templates/webmail/writemail.html.ep
+++ b/templates/webmail/writemail.html.ep
@@ -8,40 +8,40 @@
<p class=warn> <%= $msg %> </p>
% }
-<form method=post enctype=multipart/form-data id=write-form>
+%= form_for '' => (method => 'post') => (enctype => 'multipart/form-data') => (id => 'write-form') => begin
- <label for=mail> <%= ucfirst l 'send_to' %> </label>
+ %= label_for mail => ucfirst l 'send_to'
%= email_field 'to', id => 'mail', multiple => '', required => ''
<br>
- <label for=subject> <%= ucfirst l 'subject' %> </label>
+ %= label_for subject => ucfirst l 'subject'
%= text_field 'subject', 'required' => ''
<br>
- <label for=cc>CC</label>
+ %= label_for cc => 'CC'
%= email_field 'cc', 'multiple' => ''
<br>
- <label for=bcc>BCC</label>
+ %= label_for bcc => 'BCC'
%= email_field 'bcc', 'multiple' => ''
<br>
- <label for=back_to> <%= ucfirst l 'answer_to' %> </label>
+ %= label_for back_to => ucfirst l 'answer_to'
%= email_field 'back_to'
<br>
- <label for=txt> <%= ucfirst l 'content' %> </label>
- %= text_area 'body', cols => 80, rows => 24, id => 'txt'
+ %= label_for txt => ucfirst l 'content'
+ %= text_area body => (cols => 80) => (rows => 24) => (id => 'txt')
<br>
%= file_field 'attach'
<br>
- <input type=submit value="send" />
+ %= submit_button l 'send'
%= csrf_field
-</form>
+% end
<nav>
%#<a href="<%= url_for('displayheaders') %>" class=btn> <%= l 'home' %> </a>