couic/viregul/templates/stats.html.ep

87 lines
3.5 KiB
Plaintext

% # vim:set sw=4 ts=4 sts=4 ft=html.epl expandtab:
% title 'Lstu stats';
% use Mojo::Date;
<h2><%= l('Statistics') %></h2>
% if (defined(config('adminpwd')) || defined(config('hashed_adminpwd'))) {
% if (!flash('banned')) {
<form class="form" method="POST" action="<%== url_for 'stats' %>">
<fieldset>
% if (defined(stash('admin'))) {
<input type="hidden" value="logout" name="action">
<%= submit_button l('Logout from admin stats'), class => 'button' %>
% } else {
<label class="sr-only" for="adminpwd"><%= l('Admin password') %></label>
<input type="password" name="adminpwd" id="adminpwd" class="form-control" placeholder="<%= l('Admin password') %>" required>
<input type="hidden" value="0" name="page">
<%= submit_button l('Go!'), class => 'button' %>
% }
</fieldset>
</form>
% }
% if (defined(flash('msg'))) {
<h3 class="alert alert-danger"><%= flash('msg') %></h3>
% }
% }
% if (defined(flash('success_msg'))) {
<h3 class="alert alert-success"><%= flash('success_msg') %></h3>
% }
<form class="form" method="POST" action="<%== url_for 'import_cookie' %>" enctype="multipart/form-data">
<fieldset>
<label for="file"><%= l('Import URLs') %></label>
<input type="file" name="file" id="file" required>
</fieldset>
<%= submit_button l('Import URLs'), class => 'button' %>
<a href="<%= url_for 'export_cookie' %>" class="button button-outline"><%= l('Export your URLs') %></a>
</form>
<table class="table table-striped">
<tr>
<th>#</th>
<th><%= l('URL') %></th>
<th><%= l('Shortened URL') %></th>
<th><%= l('Counter') %></th>
<th><%= l('Created') %></th>
% if (defined(config('adminpwd')) || defined(config('hashed_adminpwd'))) {
% unless (defined(stash('admin'))) {
<th><%= l('QRCode') %></th>
% } else {
<th><%= l('Delete') %></th>
% }
% }
</tr>
% my $i = 1;
% if (defined(stash('page')) && stash('page') >= 0) {
% $i = 1 + config('page_offset') * stash('page');
% }
% my $j = $i;
% for my $url (@{$urls}) {
<tr>
<td><%= $i++ %></td>
<td><%= link_to $url->{url} => $url->{url} %></td>
<td><%= link_to $prefix.$url->{short} => $prefix.$url->{short} %></td>
<td><%= $url->{counter} %></td>
<td><%= Mojo::Date->new($url->{timestamp})->to_string %></td>
% if (defined(config('adminpwd')) || defined(config('hashed_adminpwd'))) {
% unless (defined(stash('admin'))) {
<td><img class="qrcode-stat" alt="QRCode" src="data:image/png;base64,<%= $url->{qrcode} %>"></td>
% } else {
<td><a href="<%= url_for('delete', {short => $url->{short}}) %>"><h5><span class="icon icon-trash"></span></h5></a></td>
% }
% }
</tr>
% }
</table>
% if (defined(config('adminpwd')) || defined(config('hashed_adminpwd'))) {
% if (defined(stash('admin'))) {
<nav>
<ul class="pager">
<li class="previous<%= (stash('first')) ? ' disabled' : '' %>"><%= link_to url_for->query(page => (stash('first')) ? 0 : stash('page') - 1) => begin %><span aria-hidden="true">&larr;</span> <%= l('Previous') %><% end %></li>
<li class="center"><%= $j.'-'.--$i.'/'.stash('total') %></li>
<li class="next<%= (stash('last')) ? ' disabled' : '' %>"><%= link_to url_for->query(page => (stash('last')) ? stash('page') : stash('page') + 1) => begin %><%= l('Next') %> <span aria-hidden="true">&rarr;</span><% end %></li>
</ul>
</nav>
% }
% }
%= link_to l('Home') => '/' => (class => 'button')