util.html 4.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. {% macro render_thumbnail(parent, thumbnail_size=None, no_external_references=False) -%}
  2. {% set thumb = parent.thumbnail(thumbnail_size) %}
  3. {% if not no_external_references and thumb %}
  4. <a href="{{parent.link}}">
  5. <img class="preview" src="{{thumb.src}}"
  6. {% if thumb.width %}width="{{thumb.width}}"{% endif %}
  7. {% if thumb.height %} height="{{thumb.height}}"{% endif %} />
  8. </a>
  9. {% else %}
  10. <!-- no preview available -->
  11. {% endif %}
  12. {%- endmacro %}
  13. {% macro render_message(message, preview_size=None, no_external_references=False) -%}
  14. <div class="message-container{%if message.subtype %} {{message.subtype}}{%endif%}">
  15. <div id="{{ message.id }}">
  16. {% if not no_external_references %}
  17. {% if message.img %}<img src="{{ message.img }}" class="user_icon" />{%else%}<div class="user_icon"></div>{%endif%}
  18. {% endif %}
  19. <div class="message">
  20. <div class="username">{{ message.username }}
  21. {%if message.user.email%} <span class="print-only user-email">({{message.user.email}})</span>{%endif%}
  22. </div>
  23. <a href="#{{ message.id}}"><div class="time">{{ message.time }}</div></a>
  24. <div class="msg">
  25. {{ message.msg|safe }}
  26. {% for attachment in message.attachments -%}
  27. <div class="message-attachment"
  28. {%if attachment.color %}style="border-color: #{{attachment.color}}"{%endif%}>
  29. {%if attachment.service_name %}<div class="service-name">{{ attachment.service_name }}</div>{%endif%}
  30. {%if attachment.author_name%}
  31. <div class="attachment-author">
  32. {% if not no_external_references %}
  33. <img src="{{attachment.author_icon}}" class="icon">
  34. {% endif %}}
  35. {%if attachment.author_link%}<a href="{{attachment.author_link}}">{%endif%}
  36. {{attachment.author_name}}
  37. {%if attachment.author_link%}</a><span class="print-only">({{attachment.author_link}})</span>{%endif%}
  38. </div>
  39. {%endif%}
  40. {% if not no_external_references %}
  41. {%if attachment.pretext %}<div class="pre-text">{{attachment.pretext}}</div>{%endif%}
  42. <div class="link-title"><a href="{{ attachment.title_link }}">{{ attachment.title }}</a></div>
  43. <div class="link-text">
  44. {{attachment.text}}
  45. </div>
  46. {%for field in attachment.fields %}
  47. <div class="attachment-field">
  48. {%if field.title %}<div class="field-title">{{field.title}}</div>{%endif%}
  49. {{field.value}}
  50. </div>
  51. {%endfor%}
  52. {{ render_thumbnail(attachment, preview_size) }}
  53. {% if attachment.original_url %}
  54. <div class="print-only">Original URL: {{attachment.original_url}}</div>
  55. {% endif %}
  56. {%if attachment.footer%}
  57. <div class="attachment-footer">
  58. <img src="{{attachment.footer_icon}}" class="icon" />
  59. {{attachment.footer}}
  60. </div>
  61. {%endif%}
  62. {%endif%}
  63. </div>
  64. {% endfor %}
  65. {% for file in message.files -%}
  66. <div class="message-upload">
  67. <div class="link-title"><a href="{{ file.link }}">{{ file.title }}</a></div>
  68. {% if not no_external_references %}
  69. {{ render_thumbnail(file, preview_size) }}
  70. {%endif%}
  71. </div>
  72. {% endfor %}
  73. {% for reaction in message.reactions %}
  74. <div class="message-reaction">
  75. {{ reaction.name }} {{ reaction.usernames|join(', ') }}
  76. </div>
  77. {% endfor %}
  78. </div>
  79. </div>
  80. </div>
  81. </div>
  82. {%- endmacro %}