{% macro list_to_html_multiline(possible_list) %}
{% autoescape false %}
{%- if possible_list is string -%}
{{ possible_list }}
{%- else -%}
{%- for el in possible_list -%}
{%- if el is string -%}
{{el}}
{% else %}
{{el[1]}}
{%- endif -%}
{%- endfor -%}
{%- endif -%}
{% endautoescape %}
{% endmacro %}
{#
render_book_search_table - Format Gutenberg Book Search results into a table for display
results - whoosh search results (format differ from typical sqlite results)
offset - the index into the total result sets of the first result on this page.
fn_author_to_query - function that accepts an author string an returns a query value that searches for the author
class - css class for the table
#}
{% macro render_book_search_table(results, offset, fn_author_to_query, class='', files_exist=None) %}
# | {% trans %}Title{% endtrans %} | {% trans %}Author{% endtrans %} | {% trans %}Language{% endtrans %} |
{{ loop.index + offset }} | {{ list_to_html_multiline(result['title']) }} {% if files_exist != None and not files_exist(result['textId']) -%} ({% trans %}Not Available{% endtrans %}) {% endif -%} |
{%- for k,v in result['creator'] -%}
{{ v }} {%- endfor -%} {%- for k,v in result['contributor'] -%} {{ v }} {%- endfor -%} |
{{ list_to_html_multiline(result['language']) }} |
# | {% trans %}Title{% endtrans %} | {% trans %}Author{% endtrans %} | {% trans %}Language{% endtrans %} |
{{ loop.index + offset }} | {{ book.title }} |
{% for c in book.gutenberg_creators -%}
{{ c.creator }} {%- endfor %} {% for c in book.gutenberg_contributors -%} {{ c.contributor }} {%- endfor %} |
{% for c in book.gutenberg_languages -%} {{ c.language }} {%- endfor %} |
# | {% trans %}Author{% endtrans %} |
{{ loop.index + offset }} | {{ author.creator }} |
{{ label }} | {{ record[key] }} |
---|---|
{{ label }} | {{ val[aux_key] }} |
{% trans %}Name{% endtrans %} | {% trans %}Format{% endtrans %} | {% set index = 0 %} {% for f in record['gutenberg_files'] %}
---|---|
{{ f['file'] }} | {{ f['format'] }} |