{# Tables and views as a grid of cards, one per table. Shared by the homepage and the database page. {% call catalog_cards.list() %} {{ catalog_cards.card(item, show_database=True, count_text="1,204") }} {% endcall %} item is a dictionary: url, name, type ("table" or "view") and optionally title, private, hidden, description, database, color, count, columns (the ones shown to start with), more_columns (the rest, shown by the "+N more" button, which needs catalog-cards.js on the page), matched_columns, column_count, has_fts and linked_tables (names of tables in the same database, which needs database). count_text is the row count as it should be shown, e.g. "1,204" or ">10,000". Import it "with context": the linked tables use urls. #} {% macro list() -%} {%- endmacro %} {% macro card(item, show_database=false, count_text=none) -%}
  • {{ item.title or item.name }} {%- if item.private %} 🔒{% endif %} {% if item.type == "view" %}view{% endif %} {% if item.hidden %}hidden{% endif %} {% if count_text %}{{ count_text }} row{% if item.count != 1 %}s{% endif %}{% endif %}
    {% if item.description %}

    {{ item.description }}

    {% endif %} {% if item.columns %}

    {%- for column in item.columns %}{% if column in (item.matched_columns or []) %}{{ column }}{% else %}{{ column }}{% endif %}{% if not loop.last %}, {% endif %}{% endfor -%} {%- if item.more_columns %} {%- elif item.column_count and item.column_count > item.columns|length %} +{{ item.column_count - item.columns|length }} more{% endif -%}

    {% endif %} {% if show_database or item.has_fts or item.linked_tables or (item.title and item.title != item.name) %}

    {%- if show_database %}{{ item.database }}{% endif -%} {%- if item.title and item.title != item.name %}{{ item.name }}{% endif -%} {%- if item.has_fts %}full-text search{% endif -%} {%- if item.linked_tables %} 3 %} title="Linked by foreign keys to: {{ item.linked_tables|join(', ') }}"{% endif %}>links to {% for other in item.linked_tables[:3] %}{{ other }}{% if not loop.last %}, {% endif %}{% endfor %}{% if item.linked_tables|length > 3 %} and {{ item.linked_tables|length - 3 }} more{% endif %}{% endif -%}

    {% endif %}
  • {%- endmacro %}