source-file.html 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. <!--
  2. Copyright (c) 2016-2023 Martin Donath <martin.donath@squidfunk.com>
  3. Permission is hereby granted, free of charge, to any person obtaining a copy
  4. of this software and associated documentation files (the "Software"), to
  5. deal in the Software without restriction, including without limitation the
  6. rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  7. sell copies of the Software, and to permit persons to whom the Software is
  8. furnished to do so, subject to the following conditions:
  9. The above copyright notice and this permission notice shall be included in
  10. all copies or substantial portions of the Software.
  11. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  12. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  13. FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
  14. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  15. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  16. FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
  17. IN THE SOFTWARE.
  18. -->
  19. <!-- Render date of last update -->
  20. {% macro render_updated(date) %}
  21. <span class="md-source-file__fact">
  22. <span class="md-icon" title="{{ lang.t('source.file.date.updated') }}">
  23. {% include ".icons/material/clock-edit-outline.svg" %}
  24. </span>
  25. {{ date }}
  26. </span>
  27. {% endmacro %}
  28. <!-- Render date of creation -->
  29. {% macro render_created(date) %}
  30. <span class="md-source-file__fact">
  31. <span class="md-icon" title="{{ lang.t('source.file.date.created') }}">
  32. {% include ".icons/material/clock-plus-outline.svg" %}
  33. </span>
  34. {{ date }}
  35. </span>
  36. {% endmacro %}
  37. <!-- ---------------------------------------------------------------------- -->
  38. <!-- Render authors -->
  39. {% macro render_authors(authors) %}
  40. {% set git_authors = config.plugins.get("git-authors") %}
  41. <span class="md-source-file__fact">
  42. <span class="md-icon" title="{{ lang.t('source.file.contributors') }}">
  43. {% if authors | length == 1 %}
  44. {% include ".icons/material/account.svg" %}
  45. {% else %}
  46. {% include ".icons/material/account-group.svg" %}
  47. {% endif %}
  48. </span>
  49. <nav>
  50. {% for author in authors %}
  51. {%- if git_authors.config.show_email_address %}
  52. <a href="mailto:{{ author.email }}">
  53. {{- author.name -}}
  54. </a>
  55. {%- else -%}
  56. {{- author.name -}}
  57. {% endif -%}
  58. {%- if loop.revindex > 1 %}, {% endif -%}
  59. {% endfor %}
  60. </nav>
  61. </span>
  62. {% endmacro %}
  63. <!-- ---------------------------------------------------------------------- -->
  64. <!-- Render committers from GitHub -->
  65. {% macro render_committers_github(title) %}
  66. <span class="md-icon" title="{{ lang.t('source.file.contributors') }}">
  67. {% include ".icons/material/github.svg" %}
  68. </span>
  69. <span>{{ title }}</span>
  70. {% endmacro %}
  71. <!-- Render committers from GitLab -->
  72. {% macro render_committers_gitlab(title) %}
  73. <span class="md-icon" title="{{ lang.t('source.file.contributors') }}">
  74. {% include ".icons/material/gitlab.svg" %}
  75. </span>
  76. <span>{{ title }}</span>
  77. {% endmacro %}
  78. <!-- Render committers -->
  79. {% macro render_committers(authors) %}
  80. <span class="md-source-file__fact">
  81. {% if committers_source == "gitlab" %}
  82. {{ render_committers_gitlab("GitLab") }}
  83. {% else %}
  84. {{ render_committers_github("GitHub") }}
  85. {% endif %}
  86. <nav>
  87. {% for author in authors[:4] %}
  88. <a
  89. href="{{ author.url }}"
  90. class="md-author"
  91. title="@{{ author.login }}"
  92. >
  93. {% set separator = "&" if "?" in author.avatar else "?" %}
  94. <img
  95. src="{{ author.avatar }}{{ separator }}size=72"
  96. alt="{{ author.name or 'GitHub user' }}"
  97. />
  98. </a>
  99. {% endfor %}
  100. <!-- More authors -->
  101. {% set more = authors[4:] | length %}
  102. {% if more > 0 %}
  103. {% if page.edit_url %}
  104. <a
  105. href="{{ page.edit_url | replace('edit', 'blob') }}"
  106. class="md-author md-author--more"
  107. >
  108. +{{ more }}
  109. </a>
  110. {% else %}
  111. <span class="md-author md-author--more">
  112. +{{ more }}
  113. </span>
  114. {% endif %}
  115. {% endif %}
  116. </nav>
  117. </span>
  118. {% endmacro %}
  119. <!-- ---------------------------------------------------------------------- -->
  120. <!-- Determine date of last update -->
  121. {% if page.meta %}
  122. {% if page.meta.git_revision_date_localized %}
  123. {% set updated = page.meta.git_revision_date_localized %}
  124. {% elif page.meta.revision_date %}
  125. {% set updated = page.meta.revision_date %}
  126. {% endif %}
  127. <!-- Determine date of creation -->
  128. {% if page.meta.git_creation_date_localized %}
  129. {% set created = page.meta.git_creation_date_localized %}
  130. {% endif %}
  131. {% endif %}
  132. <!-- Source file information -->
  133. {% if updated or created or git_info or committers %}
  134. <aside class="md-source-file">
  135. <!-- Date of last update -->
  136. {% if updated %}
  137. {{ render_updated(updated) }}
  138. {% endif %}
  139. <!-- Date of creation -->
  140. {% if created %}
  141. {{ render_created(created) }}
  142. {% endif %}
  143. <!-- Authors (git-authors plugin) -->
  144. {% if git_info %}
  145. {{ render_authors(git_info.get("page_authors")) }}
  146. {% endif %}
  147. <!-- Authors (git-committers plugin) -->
  148. {% if committers %}
  149. {{ render_committers(committers) }}
  150. {% endif %}
  151. </aside>
  152. {% endif %}