{% macro feed_link(feed) -%} {%- if feed.link %}{%- endif -%} {{ feed_title(feed) }} {%- if feed.link %}{% endif -%} {%- endmacro %} {% macro feed_title(feed) %} {%- if feed.user_title and feed.user_title.strip() -%} {{ feed.user_title }} {%- elif feed.title and feed.title.strip() -%} {{ feed.title }} {%- else -%} {{ feed.url }} {%- endif -%} {% endmacro %} {% macro feed_title_secondary(feed) %} {%- if feed.user_title and feed.user_title.strip() and feed.title and feed.title.strip() -%} {{ feed.title }} {%- endif -%} {% endmacro %} {% macro entry_content(entry) %} {%- set content = ( ( entry.content | selectattr('type', 'equalto', 'text/html') | first ) or ( entry.content | selectattr('type', 'equalto', 'text/xhtml') | first ) or ( entry.content | selectattr('type', 'equalto', 'text/plain') | first ) ) -%} {%- if content -%} {%- if content.type == 'text/plain' -%}
{{ content.value }}
{%- else -%} {{ content.value | safe }} {%- endif -%} {%- endif -%} {% endmacro %} {% macro entry_enclosures(entry) %} {% if entry.enclosures %} {% endif %} {% endmacro %} {# https://github.com/lemon24/reader/issues/93 has some notes for refactoring the *_button macros #} {% macro text_input_button(form_view, action, label, name, placeholder, leave_disabled=false, next=none, context=none, js_enabled=True, value=none) -%}
  • {{ label }} {% if next is not none %}{% endif %} {% for name, value in (context or {}) | dictsort -%} {% endfor %}
    {%- endmacro %} {# TODO: unify with text_input_button somehow (likely by using js_enabled=False) #} {% macro text_input_button_get(form_view, label, name, placeholder, value, input_type='text', context=none, autocomplete=false) -%}
  • {{ label }} {% for name, value in (context or {}) | dictsort -%} {% endfor %}
    {%- endmacro %} {% macro text_confirm_button(form_view, action, label, name, placeholder, id=none, leave_disabled=false, next=none, context=none, js_enabled=True, value=none) -%}
  • {{ label }} {% if next is not none %}{% endif %} {% for name, value in (context or {}) | dictsort -%} {% endfor %}
    {%- endmacro %} {% macro confirm_button(form_view, action, label, id=none, leave_disabled=false, next=none, context=none, js_enabled=True) -%}
  • {{ label }} {% if next is not none %}{% endif %} {% for name, value in (context or {}) | dictsort -%} {% endfor %}
    {%- endmacro %} {% macro simple_button(form_view, action, label, leave_disabled=false, next=none, context=none, js_enabled=True, title=none) -%}
  • {% if next is not none %}{% endif %} {% for name, value in (context or {}) | dictsort -%} {% endfor %}
    {%- endmacro %} {% macro radio_links(name, options, default, endpoint, label=none, drop_args=()) -%}
  • {% if label %}{{ label }}: {% endif %} {% set current_option = request.args.get(name, default) -%} {%- for option, option_label in options -%} {%- set option_label = option_label or option -%} {%- set args = request.args.copy() -%} {%- for arg in drop_args -%} {%- set _ = args.poplist(arg) -%} {%- endfor -%} {%- if option is none -%} {%- set _ = args.poplist(name) -%} {%- else -%} {%- set _ = args.setlist(name, [option]) -%} {%- endif -%} {%- if option != current_option %}{% endif -%} {{- option_label -}} {%- if option != current_option %} {% endif %} {% endfor %} {%- endmacro %} {% macro toggle_link(name, options, default, endpoint) %} {%- set (yes_option, yes_label), (no_option, no_label) = options -%} {%- set args = request.args.copy() -%} {%- set current_option = args.get(name, default) -%} {%- set option, option_label = options[ current_option == yes_option ] %} {% if option == default %} {%- set _ = args.poplist(name) -%} {% else %} {%- set _ = args.setlist(name, [option]) -%} {% endif %}
  • {{ option_label or option }} {% endmacro %} {% macro entry_counts(counts, url=none) %} {% set blocks = {0: ' ' | safe, 1: '▁', 2: '▂', 3: '▃', 4: '▄', 5: '▅', 6: '▆', 7: '▇'} %} {{ counts.total }} {% if url %}{% endif %} entries {% if url %}{% endif %} {%- for avg in counts.averages -%} {{- blocks.get((avg | log_scale(2) * 8) | int, blocks[7]) -}} {%- endfor -%} {% endmacro %}