Files
website-v2/templates/libraries/flat_list.html
daveoconnor 50559609e9 fixed issues with libraries navigation, refactors (#1213) (#1250)
There's a good amount of refactoring in this, so this is going to look
like a much bigger change than it is. In reality it makes the dispatch
code simpler.

Fixes: 
1. Resolved the issue with the libraries pages not redirecting correctly
2. Resolved an issue around categories not being preserved moving from
page to page.

The issue with the redirects was there was a tug of war on arriving on
/library between the various ways of determining where the user should
end up.
I added a `/libraries/grid/` url and now `/libraries/` determines which
list page the user should end up on based on 1) url 2) cookie, 3) the
default, same for version preference. We can probably get rid of
dispatch() later. This has the added bonus of allowing reliable linking
to a specific list view (e.g. for users to bookmark one type)

Refactors:
1. Separated the navigation on the three library pages into a standalone
template.
2. Moved some constants to constants.py
3. Moved a lot of the views methods which were only used by the
dispatch() call to utils.py .
4. At that stage there were circular imports so I moved the docs
generation functions which were only used in constants.py to
constants_utils.py. utils.py is more general.
2024-09-19 12:06:36 -07:00

73 lines
2.5 KiB
HTML

{% extends "base.html" %}
{% load i18n %}
{% load static %}
{% block title %}{% trans "Boost Libraries by Name" %}{% endblock %}
{% block description %}{% trans "Explore the Boost C++ Libraries and discover tools for multithreading, image processing, testing, and more." %}{% endblock %}
{% block content %}
<main class="content">
<div class="py-1 px-0 mt-0 mb-0 w-full md:mb-2 flex flex-row flex-nowrap items-center md:block">
{% comment %}
<div class="flex-auto mb-2 w-full md:block md:w-auto md:mb-0">
<div>
<span class="text-xl md:text-3xl lg:text-4xl">Libraries by Name</span>
</div>
</div>
<div class="flex-shrink md:hidden">
<form action="." method="get">
<div>
<select onchange="this.form.submit()"
name="version"
class="dropdown"
id="id_version">
{% for v in versions %}
<option value="{{ v.slug }}" {% if version == v %}selected="selected"{% endif %}>{{ v.display_name }}</option>
{% endfor %}
</select>
</div>
</form>
</div>
{% endcomment %}
</div>
{% include "libraries/includes/library_preferences.html" %}
{# alert for non-current Boost versions #}
{% include "libraries/includes/version_alert.html" %}
{# Libraries list #}
<div class="relative content-between p-3 w-full bg-white md:rounded-lg md:shadow-lg md:p-5 dark:bg-charcoal">
{% if category %}
<h5 class="pb-2 text-xl md:text-2xl leading-tight text-orange border-b border-gray-300 dark:border-slate">{{ category }}</h5>
{% endif %}
<table class="table-auto w-full">
<tbody>
{% for library in library_list %}
{% include "libraries/_library_flat_list_item.html" %}
{% endfor %}
</tbody>
</table>
</div>
{# end libraries list #}
{% if page_obj.paginator %}
{# Pagination #}
<div class="space-x-3 text-center">
{% if page_obj.has_previous %}
<a href="?page=1" class="text-orange"><small> &lt;&lt; First</small></a>
<a href="?page={{ page_obj.previous_page_number }}" class="text-orange"><small> &lt; Previous</small> </a>
{% endif %}
{% if page_obj.has_next %}
<a href="?page={{ page_obj.next_page_number }}" class="text-orange"><small>Next <small> &gt; </small></a>
<a href="?page={{ page_obj.paginator.num_pages }}" class="text-orange">Last <small> &gt;&gt;</small></a>
{% endif %}
</div>
{# end pagination #}
{% endif %}
</main>
{% endblock %}