mirror of
https://github.com/simonw/datasette.git
synced 2025-12-10 16:51:24 +01:00
Datasette previously only supported one type of faceting: exact column value counting. With this change, faceting logic is extracted out into one or more separate classes which can implement other patterns of faceting - this is discussed in #427, but potential upcoming facet types include facet-by-date, facet-by-JSON-array, facet-by-many-2-many and more. A new plugin hook, register_facet_classes, can be used by plugins to add in additional facet classes. Each class must implement two methods: suggest(), which scans columns in the table to decide if they might be worth suggesting for faceting, and facet_results(), which executes the facet operation and returns results ready to be displayed in the UI.
This commit is contained in:
parent
efc93b8ab5
commit
ea66c45df9
10 changed files with 600 additions and 132 deletions
|
|
@ -110,7 +110,7 @@
|
|||
|
||||
{% if suggested_facets %}
|
||||
<p class="suggested-facets">
|
||||
Suggested facets: {% for facet in suggested_facets %}<a href="{{ facet.toggle_url }}#facet-{{ facet.name|to_css_class }}">{{ facet.name }}</a>{% if not loop.last %}, {% endif %}{% endfor %}
|
||||
Suggested facets: {% for facet in suggested_facets %}<a href="{{ facet.toggle_url }}#facet-{{ facet.name|to_css_class }}">{{ facet.name }}</a>{% if facet.type %} ({{ facet.type }}){% endif %}{% if not loop.last %}, {% endif %}{% endfor %}
|
||||
</p>
|
||||
{% endif %}
|
||||
|
||||
|
|
@ -123,9 +123,9 @@
|
|||
{% for facet_info in sorted_facet_results %}
|
||||
<div class="facet-info facet-{{ database|to_css_class }}-{{ table|to_css_class }}-{{ facet_info.name|to_css_class }}" id="facet-{{ facet_info.name|to_css_class }}">
|
||||
<p class="facet-info-name">
|
||||
<strong>{{ facet_info.name }}</strong>
|
||||
{% if facet_hideable(facet_info.name) %}
|
||||
<a href="{{ path_with_removed_args(request, {'_facet': facet_info['name']}) }}" class="cross">✖</a>
|
||||
<strong>{{ facet_info.name }}{% if facet_info.type != "column" %} ({{ facet_info.type }}){% endif %}</strong>
|
||||
{% if facet_info.hideable %}
|
||||
<a href="{{ facet_info.toggle_url }}" class="cross">✖</a>
|
||||
{% endif %}
|
||||
</p>
|
||||
<ul>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue