view.html.twig 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  1. {% block note_actions %}
  2. {% if app.user or note_actions_hide is defined %}
  3. <menu class="note-actions note-info-end">
  4. <li class="note-actions-extra">
  5. <details class="note-actions-extra-details">
  6. <summary>
  7. {{ icon('kebab', 'icon icon-note-actions-extra') | raw }} {# button-container #}
  8. </summary>
  9. <ul>
  10. <li>
  11. <a href="{{ note.getUrl() }}">{{ 'Permalink' | trans }}</a>
  12. </li>
  13. <hr>
  14. {% for current_action in get_extra_note_actions(note) %}
  15. <li>
  16. <a class="{{ current_action["classes"] }}"
  17. href="{{ current_action["url"] }}">{{ current_action['title'] }}</a>
  18. </li>
  19. {% endfor %}
  20. </ul>
  21. </details>
  22. </li>
  23. <span class="note-actions-separator"></span>
  24. {% for current_action in get_note_actions(note) %}
  25. <li>
  26. <a title="{{ current_action["title"] | trans }}"
  27. class="{{ current_action["classes"] }}"
  28. href="{{ current_action["url"] }}"></a>
  29. </li>
  30. {% endfor %}
  31. </menu>
  32. {% endif %}
  33. {% endblock note_actions %}
  34. {% block note_replies %}
  35. {% if replies is defined and replies is not empty %}
  36. <div class="u-in-reply-to replies">
  37. <span class="note-replies-start"
  38. tabindex="0">{{ 'Replies to ' | trans }}{{ nickname }}{{ '\'s note' | trans }}</span>
  39. {% for conversation in replies %}
  40. {{ _self.macro_note(conversation['note'], conversation['replies']) }}
  41. <hr tabindex="0" title="{{ 'End of reply' | trans }}">
  42. {% endfor %}
  43. </div>
  44. {% endif %}
  45. {% endblock note_replies %}
  46. {% block note_attachments %}
  47. {% if hide_attachments is not defined %}
  48. {% if note.getAttachments() is not empty %}
  49. <section class="note-attachments" tabindex="0"
  50. title="{{ 'Note attachments.' | trans }}">
  51. {% for attachment in note.getAttachments() %}
  52. {% include '/cards/attachments/view.html.twig' with {'attachment': attachment, 'note': note, 'title': attachment.getBestTitle(note)} only %}
  53. {% endfor %}
  54. </section>
  55. {% endif %}
  56. {% endif %}
  57. {% endblock note_attachments %}
  58. {% block note_links %}
  59. {% if note.getLinks() is not empty %}
  60. <div class="note-links" title="{{ 'Shared links.' | trans }}">
  61. {% for link in note.getLinks() %}
  62. {% for block in handle_event('ViewLink', {'link': link, 'note': note}) %}
  63. {{ block | raw }}
  64. {% endfor %}
  65. {% endfor %}
  66. </div>
  67. {% endif %}
  68. {% endblock note_links %}
  69. {% block note_text %}
  70. <div class="note-text" tabindex="0"
  71. title="{{ 'Note text content.' | trans }}">
  72. {{ note.getRendered() | raw }}
  73. </div>
  74. {% endblock note_text %}
  75. {% block note_author %}
  76. {# Microformat's h-card properties indicates a face icon is a "u-logo" #}
  77. <a href="{{ actor_url }}">
  78. <header class="note-author-fullname" tabindex="0"
  79. title="{{ 'Begin a note by the user: ' | trans }} {{ nickname }}">
  80. {% if fullname is not null %}
  81. {{ fullname }}
  82. {% else %}
  83. {{ nickname }}
  84. {% endif %}
  85. </header>
  86. </a>
  87. <small class="note-author-nickname">
  88. <a href="{{ actor_uri }}"
  89. class="note-author-url u-url">{{ mention }}</a>
  90. </small>
  91. {% endblock note_author %}
  92. {% block note_sidebar %}
  93. <aside class="note-sidebar">
  94. {% set actor_avatar_dimensions = actor.getAvatarDimensions() %}
  95. <img class="u-logo avatar" src="{{ note.getActorAvatarUrl() }}"
  96. alt="{{ nickname }}'s avatar"
  97. width="{{ actor_avatar_dimensions['width'] }}"
  98. height="{{ actor_avatar_dimensions['height'] }}">
  99. </aside>
  100. {% endblock note_sidebar %}
  101. {% block note_info %}
  102. <div class="note-info-start">
  103. {{ block('note_author') }}
  104. <small class="note-conversation-info">
  105. <a href="{{ note.getConversationUrl() }}"
  106. class="note-conversation-url">{{ 'in conversation' | trans }}</a>
  107. <a href="{{ note.getUrl() }}"
  108. class="note-url">{{ note.getModified() | ago }}</a>
  109. </small>
  110. </div>
  111. {% endblock note_info %}
  112. {% block note_complementary_info %}
  113. {% for complementary_info in handle_event('AppendCardNote', {'note': note }) %}
  114. <aside title="{{ 'Note\'s complementary information' | trans }}"
  115. class="note-complementary">
  116. {% set actor_count = complementary_info['actors'] | length %}
  117. {% set counter = 0 %}
  118. {% for complementary_info_actor in complementary_info['actors'] %}
  119. {% if complementary_info_actor is defined %}
  120. <a href="{{ complementary_info_actor.getUrl() }}">{{ complementary_info_actor.getNickname() }}{% if actor_count > 1 and counter < actor_count - 2 %}{{ ', ' | trans }}{% endif %}</a>
  121. {% if counter == actor_count - 2 %}
  122. {{ ' and ' | trans }}
  123. {% endif %}
  124. {% endif %}
  125. {% set counter = counter + 1 %}
  126. {% endfor %}
  127. {% if complementary_info['action'] is defined and not null %}
  128. {% if counter > 1 %}
  129. {{ ' have ' | trans }}
  130. {% else %}
  131. {{ ' has ' | trans }}
  132. {% endif %}
  133. {{ complementary_info['action'] ~ ' this note' | trans }}
  134. {% endif %}
  135. </aside>
  136. {% endfor %}
  137. {% endblock note_complementary_info %}
  138. {% macro macro_note(note, replies) %}
  139. {% set actor = note.getActor() %}
  140. {% set nickname = actor.getNickname() %}
  141. {% set fullname = actor.getFullname() %}
  142. {% set actor_uri = actor.getUri() %}
  143. {% set actor_url = actor.getUrl() %}
  144. {% set mention = mention(actor) %}
  145. {% set note_language = note.getNoteLanguageShortDisplay() %}
  146. <article id="{{ 'note-anchor-' ~ note.getId() }}"
  147. class="h-entry hentry note" lang={{ note.getLanguageLocale() }}>
  148. {{ block('note_sidebar') }}
  149. <div class="note-wrapper">
  150. <header class="note-info">
  151. {{ block('note_info') }}
  152. {{ block('note_actions') }}
  153. </header>
  154. <section role="dialog" class="e-content entry-content note-content">
  155. {{ block('note_text') }}
  156. {{ block('note_attachments') }}
  157. {{ block('note_links') }}
  158. </section>
  159. {{ block('note_replies') }}
  160. {{ block('note_complementary_info') }}
  161. </div>
  162. </article>
  163. {% endmacro macro_note %}
  164. {% macro macro_note_minimal(note) %}
  165. {% set actor = note.getActor() %}
  166. {% set nickname = actor.getNickname() %}
  167. {% set fullname = actor.getFullname() %}
  168. {% set actor_uri = actor.getUri() %}
  169. {% set actor_url = actor.getUrl() %}
  170. {% set mention = mention(actor) %}
  171. <article class="h-entry hentry note" lang={{ note.getLanguageLocale() }}>
  172. {{ block('note_sidebar') }}
  173. <div class="note-wrapper">
  174. <header class="note-info">
  175. <div class="note-info-start">
  176. {{ block('note_author') }}
  177. </div>
  178. </header>
  179. <section role="dialog" class="e-content entry-content note-content">
  180. <small class="note-conversation-info">
  181. <a href="{{ note.getConversationUrl() }}"
  182. class="note-conversation-url">{{ 'in conversation' | trans }}</a>
  183. <a href="{{ note.getUrl() }}"
  184. class="note-url">{{ note.getModified() | ago }}</a>
  185. </small>
  186. <hr>
  187. {{ block('note_text') }}
  188. </section>
  189. </div>
  190. </article>
  191. {% endmacro macro_note_minimal %}