diff options
author | Birte Kristina Friesel <birte.friesel@uos.de> | 2024-08-24 07:42:20 +0200 |
---|---|---|
committer | Birte Kristina Friesel <birte.friesel@uos.de> | 2024-08-24 07:42:20 +0200 |
commit | 087536862b26619fbf63423d15469d46d70f2365 (patch) | |
tree | ef8eb68e09e7ccf203aea835f0bbee06a83f9e8e | |
parent | 520e6456001cf858d7e59606a77b1cf0ab115aa9 (diff) |
refactor backend details into sub-template
-rw-r--r-- | templates/_backend_line.html.ep | 25 | ||||
-rw-r--r-- | templates/select_backend.html.ep | 52 |
2 files changed, 27 insertions, 50 deletions
diff --git a/templates/_backend_line.html.ep b/templates/_backend_line.html.ep new file mode 100644 index 0000000..5f2bcf1 --- /dev/null +++ b/templates/_backend_line.html.ep @@ -0,0 +1,25 @@ +<div class="row"> + <div class="col s8 m6 l6 right-align"> + %= $backend->{longname} + % if ($backend->{id} == $user->{backend_id}) { + (aktuell ausgewählt) + % } + % if ($backend->{has_area}) { + <br/> + <a href="https://dbf.finalrewind.org/coverage/HAFAS/<%= $backend->{name} %>"><%= join(q{, }, @{$backend->{regions} // []}) || '[Karte]' %></a> + % } + % elsif ($backend->{regions}) { + <br/> + %= join(q{, }, @{$backend->{regions} // []}) + % } + % if ($backend->{homepage}) { + <br/> + <a href="<%= $backend->{homepage} %>"><%= $backend->{homepage} =~ s{ ^ http s? :// (?: www[.] )? (.*?) (?: / )? $ }{$1}xr %></a> + % } + </div> + <div class="col s4 m6 l6 left-align"> + <button class="btn waves-effect waves-light <%= $backend->{id} == $user->{backend_id} ? 'disabled' : q{} %>" style="min-width: 6em;" type="submit" name="backend" value="<%= $backend->{id} %>"> + <%= $backend->{name} %> + </button> + </div> +</div> diff --git a/templates/select_backend.html.ep b/templates/select_backend.html.ep index 55182f9..61df44d 100644 --- a/templates/select_backend.html.ep +++ b/templates/select_backend.html.ep @@ -21,31 +21,7 @@ </div> </div> % for my $backend (@{ stash('suggestions') // [] }) { - <div class="row"> - <div class="col s8 m6 l6 right-align"> - %= $backend->{longname} - % if ($backend->{id} == $user->{backend_id}) { - (aktuell ausgewählt) - % } - % if ($backend->{has_area}) { - <br/> - <a href="https://dbf.finalrewind.org/coverage/HAFAS/<%= $backend->{name} %>"><%= join(q{, }, @{$backend->{regions} // []}) || '[Karte]' %></a> - % } - % elsif ($backend->{regions}) { - <br/> - %= join(q{, }, @{$backend->{regions} // []}) - % } - % if ($backend->{homepage}) { - <br/> - <a href="<%= $backend->{homepage} %>"><%= $backend->{homepage} =~ s{ ^ http s? :// (?: www[.] )? (.*?) (?: / )? $ }{$1}xr %></a> - % } - </div> - <div class="col s4 m6 l6 left-align"> - <button class="btn waves-effect waves-light <%= $backend->{id} == $user->{backend_id} ? 'disabled' : q{} %>" style="min-width: 6em;" type="submit" name="backend" value="<%= $backend->{id} %>"> - <%= $backend->{name} %> - </button> - </div> - </div> + %= include '_backend_line', user => $user, backend => $backend % } % } <div class="row"> @@ -54,30 +30,6 @@ </div> </div> % for my $backend (@{ stash('backends') // [] }) { - <div class="row"> - <div class="col s8 m6 l6 right-align"> - %= $backend->{longname} - % if ($backend->{id} == $user->{backend_id}) { - (aktuell ausgewählt) - % } - % if ($backend->{has_area}) { - <br/> - <a href="https://dbf.finalrewind.org/coverage/HAFAS/<%= $backend->{name} %>"><%= join(q{, }, @{$backend->{regions} // []}) || '[Karte]' %></a> - % } - % elsif ($backend->{regions}) { - <br/> - %= join(q{, }, @{$backend->{regions} // []}) - % } - % if ($backend->{homepage}) { - <br/> - <a href="<%= $backend->{homepage} %>"><%= $backend->{homepage} =~ s{ ^ http s? :// (?: www[.] )? (.*?) (?: / )? $ }{$1}xr %></a> - % } - </div> - <div class="col s4 m6 l6 left-align"> - <button class="btn waves-effect waves-light <%= $backend->{id} == $user->{backend_id} ? 'disabled' : q{} %>" style="min-width: 6em;" type="submit" name="backend" value="<%= $backend->{id} %>"> - <%= $backend->{name} %> - </button> - </div> - </div> + %= include '_backend_line', user => $user, backend => $backend % } %= end |