This is a gentle fork from https://framagit.org/marienfressinaud/photos.marienfressinaud.fr with a responsive and optimized mindset. https://media.larlet.fr/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

media.html.j2 7.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. {% extends "base.html.j2" %}
  2. {% block title %}{{ gallery.name }}{% endblock %}
  3. {% block extra_head %}
  4. <!-- CanIHazMoreComplexityPlease? https://htmlhead.dev/ -->
  5. <meta
  6. name="twitter:image" property="og:image" itemprop="image"
  7. content="https://media.larlet.fr/{{ photo.gallery_slug }}/jpg/{{ photo.name }}_{{ sizes.0.0 }}x{{ sizes.0.1 }}.jpg"
  8. >
  9. {% endblock %}
  10. {% block container %}
  11. <div class="hero u-center">
  12. <picture>
  13. <source
  14. srcset="
  15. {%- for size in sizes %}
  16. {{ photo.gallery_slug }}/webp/{{ photo.name }}_{{ size.0 }}x{{ size.1 }}.webp {{ size.0 }}w{% if not loop.last%},{% endif %}
  17. {%- endfor -%}
  18. "
  19. sizes="min(100vw, calc(100vh * {{ photo.width }} / {{ photo.height }}))"
  20. type="image/webp">
  21. <!-- The <img> tag is a fallback image (required in the <picture> tag) -->
  22. <img
  23. src="{{ photo.gallery_slug }}/jpg/{{ photo.name }}_{{ sizes.0.0 }}x{{ sizes.0.1 }}.jpg"
  24. width="{{ photo.width }}" height="{{ photo.height }}"
  25. srcset="
  26. {%- for size in sizes %}
  27. {{ photo.gallery_slug }}/jpg/{{ photo.name }}_{{ size.0 }}x{{ size.1 }}.jpg {{ size.0 }}w{% if not loop.last%},{% endif %}
  28. {%- endfor -%}
  29. "
  30. sizes="min(100vw, calc(100vh * {{ photo.width }} / {{ photo.height }}))"
  31. fetchpriority="high"
  32. decoding="sync"
  33. alt="{{ photo.alt or 'TODO' }}">
  34. </picture>
  35. </div>
  36. <h1>{{ gallery.name }}{% if gallery.private %} (🔒 privé){% endif %}</h1>
  37. {% if photo.alt %}
  38. <h2>{{ photo.alt }}</h2>
  39. {% endif %}
  40. <nav>
  41. <p class="u-center">
  42. {% if previous %}
  43. <a href="{{ previous.page_url }}"
  44. title="Photo précédente, vous pouvez utiliser la flèche du clavier ←"
  45. >← Photo précédente</a>
  46. {% endif %}
  47. <a href="/"
  48. title="Retour à l’accueil, vous pouvez utiliser la flèche du clavier ↑"
  49. >↑ Retour aux albums{% if gallery.private %} publics{% endif %}</a>
  50. {% if next %}
  51. <a href="{{ next.page_url }}"
  52. title="Photo suivante, vous pouvez utiliser la flèche du clavier →"
  53. >Photo suivante →</a>
  54. {% endif %}
  55. </p>
  56. </nav>
  57. {# TODO: less manual! #}
  58. {% if gallery.type == "video" %}
  59. <div class="u-center">
  60. <script src="https://player.vimeo.com/api/player.js"></script>
  61. <div class="iframe-container"><iframe src="https://player.vimeo.com/video/580086949?h=0833bc929c" frameborder="0" allow="autoplay; fullscreen; picture-in-picture" allowfullscreen></iframe></div>
  62. <p><a href="https://vimeo.com/580086949/0833bc929c">Évasion (lire sur Vimeo)</a></p>
  63. <hr>
  64. <div class="iframe-container"><iframe src="https://player.vimeo.com/video/540447287?h=323e810be3" frameborder="0" allow="autoplay; fullscreen; picture-in-picture" allowfullscreen></iframe></div>
  65. <p><a href="https://vimeo.com/540447287/323e810be3">Contemplation (lire sur Vimeo)</a></p>
  66. <hr>
  67. <div class="iframe-container"><iframe src="https://player.vimeo.com/video/516515235?h=45826baa92" frameborder="0" allow="autoplay; fullscreen; picture-in-picture" allowfullscreen></iframe></div>
  68. <p><a href="https://vimeo.com/516515235/45826baa92">Précipitation (lire sur Vimeo)</a></p>
  69. <hr>
  70. <div class="iframe-container"><iframe src="https://player.vimeo.com/video/492686199?h=31ac11260c" frameborder="0" allow="autoplay; fullscreen; picture-in-picture" allowfullscreen></iframe></div>
  71. <p><a href="https://vimeo.com/492686199/31ac11260c">Arrakice (lire sur Vimeo)</a></p>
  72. <hr>
  73. <div class="iframe-container"><iframe src="https://player.vimeo.com/video/473661570?h=46af2e921e" frameborder="0" allow="autoplay; fullscreen; picture-in-picture" allowfullscreen></iframe></div>
  74. <p><a href="https://vimeo.com/473661570/46af2e921e">Chaos (lire sur Vimeo)</a></p>
  75. </div>
  76. {% endif %}
  77. <div class="gallery">
  78. {% for gallery_photo in gallery.photos %}
  79. {% if not gallery_photo.url == photo.url %}
  80. <div class="photo{% if gallery_photo.narrow %} narrow{% endif %}{% if gallery_photo.wide %} wide{% endif %}">
  81. <a href="{{ gallery_photo.page_url }}">
  82. <picture>
  83. <source
  84. srcset="
  85. {%- for size in sizes %}
  86. {{ gallery_photo.gallery_slug }}/webp/{{ gallery_photo.name }}_{{ size.0 }}x{{ size.1 }}.webp {{ size.0 }}w{% if not loop.last%},{% endif %}
  87. {%- endfor -%}
  88. "
  89. sizes="{% if gallery_photo.narrow %}150px{% else %}310px{% endif %}"
  90. type="image/webp">
  91. <img
  92. src="{{ gallery_photo.gallery_slug }}/jpg/{{ gallery_photo.name }}_{{ sizes.0.0 }}x{{ sizes.0.1 }}.jpg"
  93. width="{{ gallery_photo.width }}" height="{{ gallery_photo.height }}"
  94. srcset="
  95. {%- for size in sizes %}
  96. {{ gallery_photo.gallery_slug }}/jpg/{{ gallery_photo.name }}_{{ size.0 }}x{{ size.1 }}.jpg {{ size.0 }}w{% if not loop.last%},{% endif %}
  97. {%- endfor -%}
  98. "
  99. sizes="{% if gallery_photo.narrow %}150px{% else %}310px{% endif %}"
  100. alt="{{ gallery_photo.alt or 'TODO' }}" loading="lazy" decoding="async">
  101. </picture>
  102. </a>
  103. </div>
  104. {% endif %}
  105. {% endfor %}
  106. </div>
  107. <nav>
  108. <p class="u-center"
  109. data-controller="navigation"
  110. data-action="keydown@window->navigation#navigate"
  111. >
  112. {% if previous %}
  113. <a href="{{ previous.page_url }}"
  114. title="Photo précédente, vous pouvez utiliser la flèche du clavier ←"
  115. rel="prev"
  116. data-navigation-target="previous"
  117. >← Photo précédente</a>
  118. {% endif %}
  119. <a href="/"
  120. title="Retour à l’accueil, vous pouvez utiliser la flèche du clavier ↑"
  121. data-navigation-target="up"
  122. >↑ Retour aux albums{% if gallery.private %} publics{% endif %}</a>
  123. {% if next %}
  124. <a href="{{ next.page_url }}"
  125. title="Photo suivante, vous pouvez utiliser la flèche du clavier →"
  126. rel="next"
  127. data-navigation-target="next"
  128. >Photo suivante →</a>
  129. {% endif %}
  130. </p>
  131. </nav>
  132. {% endblock %}
  133. {% block extra_bottom %}
  134. <script type="module">
  135. import { Application, Controller } from "/scripts/stimulus-3.0.1.js"
  136. window.Stimulus = Application.start()
  137. // window.Stimulus.debug = true
  138. Stimulus.register("navigation", class extends Controller {
  139. static targets = [ "previous", "next", "up" ]
  140. navigate(event) {
  141. const key = event.key
  142. if (key === "ArrowLeft" && this.hasPreviousTarget) {
  143. this.previousTarget.click()
  144. }
  145. if (key === "ArrowRight" && this.hasNextTarget) {
  146. this.nextTarget.click()
  147. }
  148. if (key === "ArrowUp" && this.hasUpTarget) {
  149. this.upTarget.click()
  150. }
  151. }
  152. })
  153. </script>
  154. {% endblock %}