diff options
author | Jannis M. Hoffmann <jannis@fehcom.de> | 2023-03-10 13:54:57 +0100 |
---|---|---|
committer | Jannis M. Hoffmann <jannis@fehcom.de> | 2023-03-10 13:54:57 +0100 |
commit | fcf5549584b69e62b6c2f0eb919f6799c7904211 (patch) | |
tree | e5f0e480af0f39f1c0f457ea0aca8d33f8fb4d0b /templates/displayheaders | |
parent | df59f9dec32d7f8f08706fd3eb5b784deaa0abfc (diff) |
Proper recursive rendering of mails to html
1. Added raw mode to model
2. Added raw route
3. Moved readmail view parts to RenderMail plugin
4. Renamed displayheaders partial templates
Diffstat (limited to 'templates/displayheaders')
-rw-r--r-- | templates/displayheaders/_bot_nav.html.ep | 36 | ||||
-rw-r--r-- | templates/displayheaders/_folders.html.ep | 29 | ||||
-rw-r--r-- | templates/displayheaders/_main_table.html.ep | 112 | ||||
-rw-r--r-- | templates/displayheaders/_pagination1.html.ep | 7 | ||||
-rw-r--r-- | templates/displayheaders/_pagination2.html.ep | 37 | ||||
-rw-r--r-- | templates/displayheaders/_top_nav.html.ep | 35 |
6 files changed, 256 insertions, 0 deletions
diff --git a/templates/displayheaders/_bot_nav.html.ep b/templates/displayheaders/_bot_nav.html.ep new file mode 100644 index 0000000..3eb57d3 --- /dev/null +++ b/templates/displayheaders/_bot_nav.html.ep @@ -0,0 +1,36 @@ +<div class="pure-g jwm-nav"> + + <div class="pure-u-3-4 pure-u-md-1-4"> + %= include 'displayheaders/_pagination1' + </div> + + <div class="pure-u-1-4 pure-u-md-1-4"> + <label for=allbox><%= l 'check all' %></label> + <input name=allbox type=checkbox onclick="check_all(this)"> + </div> + + <div class="pure-u-1 pure-u-md-1-2"> + % if (grep {$_ ne $folder} @$mail_folders) { + %= form_for move => (id => 'move-mail') => (class => 'pure-form') => begin + <fieldset> + %= label_for 'select-folder' => l('move to') + %= select_field folder => [map { $_ ? $_ : l 'Home' } grep {$_ ne $folder} @$mail_folders] => (id => 'select-folder') + %= csrf_field + %= submit_button l('move') => (class => 'pure-button') + </fieldset> + % end + % } + </div> + +</div> + +<script type="text/javascript"> +function check_all(box) { + const setTo = box.checked; + const mails = document.getElementById('mail-headers').tBodies[0].rows; + + for (const m of mails) { + m.lastElementChild.children[0].checked = setTo; + } +} +</script> diff --git a/templates/displayheaders/_folders.html.ep b/templates/displayheaders/_folders.html.ep new file mode 100644 index 0000000..be5bdd9 --- /dev/null +++ b/templates/displayheaders/_folders.html.ep @@ -0,0 +1,29 @@ +<div id=display-folders class="pure-g jwm-nav"> + + <div class="pure-u-1-1 pure-u-md-1-2"> + <nav class="pure-menu pure-menu-horizontal"> + + <strong class="pure-menu-heading"> + %= l($folder || '_mailbox_root') + </strong> + + <ul class="pure-menu-list"> +% for (grep {$_ ne $folder} @$mail_folders) { + <li class="pure-menu-item"> + %= link_to '' => {folder => $_} => (class => 'bright') => begin + %= l($_ || '_mailbox_root') + % end + </li> +% } + </ul> + + </nav> + </div> + + <p class="pure-u-1-1 pure-u-md-1-2"> + <%= l('[_1] of [_2] messages', $pgn->{this_page}[1] - $pgn->{this_page}[0], $pgn->{total_items}) %>\ + <%= l(', [_1] new', $total_new_mails) if $total_new_mails > 0 =%> + <%= l(' - mailbox size: [_1]', print_sizes10 $total_size) if $total_size %> + </p> + +</div> diff --git a/templates/displayheaders/_main_table.html.ep b/templates/displayheaders/_main_table.html.ep new file mode 100644 index 0000000..5430c15 --- /dev/null +++ b/templates/displayheaders/_main_table.html.ep @@ -0,0 +1,112 @@ +% my $sort_param = begin + % my $param = shift; + + %= 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; + % end + +% end + +<table id=mail-headers class="pure-table pure-table-horizontal"> + + <thead> + <tr id=sort> + <th class="hide-small"> + # + </th> + + <th> + <div class="pure-g"> + + %# $sort_param->('status'); + + <div class="pure-u-1 pure-u-md-4-24"> + %= $sort_param->('date'); + </div> + +% if ($folder ne "SENT") { + <div class="pure-u-1 pure-u-md-8-24"> + %= $sort_param->('sender'); + </div> +% } +% else { + <th class=sort-param> + %= 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> +% } + + <div class="pure-u-1 pure-u-md-12-24"> + %= $sort_param->('subject'); + </div> + + </div> + </th> + + <th class="hide-small"> + %= $sort_param->('size'); + </th> + + <th> + <input type=checkbox checked=1 disabled=1> + </th> + </tr> + </thead> + + <tbody> + % foreach my $msgnum ($pgn->{first_item} .. $pgn->{last_item}) { + % my $msg = $msgs->[$msgnum - $pgn->{first_item}]; + + %= tag tr => (class => $msg->{unread} ? 'new-mail' : '') => (id => $msg->{message_handle}) => begin + <td class="hide-small" style="text-align: right"> + %= $msgnum + 1 + </td> + + <td> + <div class="pure-g"> + + <!-- + <div class="pure-u-1-4"> + %# ucfirst($msg->{head}{mime}{content_maintype} eq 'multipart' ? l('yes') : l('no')); + </div> + --> + + <div class="pure-u-1 pure-u-md-4-24"> + % my $date = parse_iso_date $msg->{head}{date}; + %= join('/', $date->{mday}, $date->{month}, $date->{year}) . " $date->{hour}:$date->{min}"; + </div> + + <div class="pure-u-1 pure-u-md-8-24"> + <%= $msg->{head}{sender}[0]{display_name} || $msg->{head}{sender}[0]{address} || + $msg->{head}{from}[0]{display_name} || $msg->{head}{from}[0]{address}; %> + </div> + + <div class="pure-u-1 pure-u-md-12-24"> + %= link_to $msg->{head}{subject} || '_' => read => {id => $msg->{message_handle}} + </div> + + </div> + </td> + + <td class="hide-small" style="text-align: right; white-space: nowrap"> + %= print_sizes10 $msg->{byte_size}; + </td> + + <td> + %= check_box mail => $msg->{message_handle} => (form => 'move-mail') + </td> + % end + + % } + </tbody> + +</table> diff --git a/templates/displayheaders/_pagination1.html.ep b/templates/displayheaders/_pagination1.html.ep new file mode 100644 index 0000000..798f79f --- /dev/null +++ b/templates/displayheaders/_pagination1.html.ep @@ -0,0 +1,7 @@ +<div> + <a href="<%= url_with->query({start => $pgn->{prev_page}[0]}) %>"> ← </a> + <a href="<%= url_with->query({start => $pgn->{first_page}[0]}) %>"> ↞ </a> + [<%= l('page [_1] of [_2]', $pgn->{current_page}+1, $pgn->{total_pages}) %>] + <a href="<%= url_with->query({start => $pgn->{last_page}[0]}) %>"> ↠ </a> + <a href="<%= url_with->query({start => $pgn->{next_page}[0]}) %>"> → </a> +</div> diff --git a/templates/displayheaders/_pagination2.html.ep b/templates/displayheaders/_pagination2.html.ep new file mode 100644 index 0000000..8bff0bf --- /dev/null +++ b/templates/displayheaders/_pagination2.html.ep @@ -0,0 +1,37 @@ +%= form_for '' => (class => 'pure-form') => begin + <a href="<%= url_with->query({start => $pgn->{first_page}[0]}) %>"> + <img src="/first.gif" alt="<%= l('first') . ' ' . l 'page' %>"> + </a> + <a href="<%= url_with->query({start => $pgn->{prev_page}[0]}) %>"> + <img src="/left.gif" alt="<%= l('previous') . ' ' . l 'page' %>"> + </a> + + <div style="white-space: nowrap"> + [ +%= label_for custompage => ucfirst l('page') => (style => 'display: inline') + <%= number_field start + => (id => 'custompage') + => (size => 3) + => (placeholder => $pgn->{current_page}+1) + => (min => 1) + => (max => $pgn->{total_pages} + => (style => 'display: inline')) %> +%= l 'of' +%= $pgn->{total_pages} + ] + </div> + +% my $h = $c->req->query_params->to_hash; +% while (my ($k, $v) = each %$h) { +% if ($k ne 'start') { +%= hidden_field $k => $v +% } +% } + + <a href="<%= url_with->query({start => $pgn->{next_page}[0]}) %>"> + <img src="/right.gif" alt="<%= l('next') . ' ' . l 'page' %>"> + </a> + <a href="<%= url_with->query({start => $pgn->{last_page}[0]}) %>"> + <img src="/last.gif" alt="<%= l('last') . ' ' . l('page') %>"> + </a> +% end diff --git a/templates/displayheaders/_top_nav.html.ep b/templates/displayheaders/_top_nav.html.ep new file mode 100644 index 0000000..fd6bae6 --- /dev/null +++ b/templates/displayheaders/_top_nav.html.ep @@ -0,0 +1,35 @@ +<div class="pure-g"> + + <div class="pure-u-1 pure-u-md-1-4"> + <div class="pure-menu pure-menu-horizontal"> + <ul class="pure-menu-list"> + %# <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 class="pure-menu-item"> + %= link_to ucfirst(l 'logout') => 'logout' + </li> + <li class="pure-menu-item"> + %= link_to ucfirst(l 'compose') => 'write' + </li> + </ul> + </div> + </div> + + <div class="pure-u-1 pure-u-md-1-4"> + %= form_for '' => (class => 'pure-form') => begin + %= label_for search => ucfirst(l 'search') + %= search_field search => (size => 8) + % end + </div> + + <div class="pure-u-1-1 pure-u-md-1-2"> + %= include 'displayheaders/_pagination2'; + </div> + + <!-- delete button + <td> + %# <form action="<%= url_for('delete_msg') %>" name=Formdel onsubmit="return confirm('<%= TXT q(js_confirm_delete) %>')" > </form> + </td> + --> + +</div> |