Simplify navigation...

Put all the links at the top, unconditionally.  Make the search forms
look slightly nicer.
This commit is contained in:
barnold 2022-09-29 14:14:43 +01:00
parent 76df89a970
commit 85dde076e4
5 changed files with 49 additions and 21 deletions

View File

@ -82,13 +82,10 @@ sub startup ($self) {
# Set routes.
my $r = $self->routes;
# Home gets an explicit name, else its name is an empty string. A
# route's default name seems to come from '/path' with the leading
# '/' removed.
$r->get('/<page_number:num>')->to('book#books', page_number => 1)->name('home');
$r->get('/<page_number:num>')->to('book#books')->name('books');
$r->get('/<page_number:num>')->to('book#books', page_number => 1)->name('books');
$r->get('/about')->to('book#about');
$r->get('/authors/<page_number:num>')->to('book#authors')->name('authors');
$r->get('/authors/<page_number:num>')
->to('book#authors', page_number => 1)->name('authors');
$r->get('/author/<id:num>/<page_number:num>')->to('book#author')->name('author');
$r->post('/set_rpp')->to('book#set_rpp')->name('set_rpp');
}

View File

@ -1,3 +1,18 @@
form > span {
margin-right: 1em;
}
ul.top {
margin: 0;
padding-left: 0;
}
ul.top > li {
display: inline-block;
padding-right: 1em;
min-width: 10ch;
}
div.verbiage {
max-width: 40em;
}

View File

@ -2,16 +2,17 @@
% title 'Authors';
<h1><%= title %></h1>
<a href="/about#search-help">Search help</a>
<p/>
<%# On a new search, reset the page number to 1. %>
%= form_for authors => { page_number => 1 } => begin
<span>
%= label_for name_like => 'Name like'
%= text_field name_like => flash('name_like')
</span>
<span>
%= label_for minimum_book_count => 'Wrote at least'
<%= number_field minimum_book_count => 0,
min => 0, maxlength => 4, size => 4 %> books.
min => 0, maxlength => 4, size => 4 %> books
</span>
%= submit_button "Search"
%= end

View File

@ -2,15 +2,16 @@
% title 'Books';
<h1><%= title %></h1>
<a href="/about#search-help">Search help</a>
<p/>
<%# On a new search, reset the page number to 1. %>
%= form_for books => { page_number => 1 } => begin
<span>
%= label_for title_like => 'Title like'
%= text_field title_like => flash('title_like')
</span>
<span>
%= label_for author_like => 'Author like'
%= text_field author_like => flash('author_like')
</span>
%= submit_button "Search"
%= end

View File

@ -5,21 +5,35 @@
<link rel="stylesheet" href="/default.css">
</head>
<body>
<div>
<%# Provide a link to the home page, unless we're on it. %>
<%# I gave the home page route a name, else it's an empty string. %>
<% if ('home' ne current_route) { %>
<%= link_to("Home" => 'home') %>
<% } %>
<ul class="top">
<li>
<%= link_to("About" => 'about') %>
</li>
<li>
<%= link_to("Authors" => 'authors') %>
</li>
<li>
<%= link_to("Books" => 'books') %>
</li>
<li>
<a href="/about#search-help">Search help</a>
</li>
<li>
%= form_for set_rpp => begin
<%= hidden_field target_url => url_with('current') %>
%= label_for rows_per_page => 'Rows per page'
<%= number_field rows_per_page => $c->rpp,
min => 1, max => max_rpp, maxlength => 4, size => 4 %>
rows per page
%= submit_button "Update"
% end
</div>
</li>
</ul>
<hr/>
<div>
<%= content %>