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.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  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. <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>
  61. <p><a href="https://vimeo.com/580086949/0833bc929c">Évasion (lire sur Vimeo)</a></p>
  62. <hr>
  63. <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>
  64. <p><a href="https://vimeo.com/540447287/323e810be3">Contemplation (lire sur Vimeo)</a></p>
  65. <hr>
  66. <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>
  67. <p><a href="https://vimeo.com/516515235/45826baa92">Précipitation (lire sur Vimeo)</a></p>
  68. <hr>
  69. <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>
  70. <p><a href="https://vimeo.com/492686199/31ac11260c">Arrakice (lire sur Vimeo)</a></p>
  71. <hr>
  72. <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>
  73. <p><a href="https://vimeo.com/473661570/46af2e921e">Chaos (lire sur Vimeo)</a></p>
  74. </div>
  75. {% endif %}
  76. <div class="gallery">
  77. {% for gallery_photo in gallery.photos %}
  78. {% if not gallery_photo.url == photo.url %}
  79. <div class="photo{% if gallery_photo.narrow %} narrow{% endif %}{% if gallery_photo.wide %} wide{% endif %}">
  80. <a href="{{ gallery_photo.page_url }}">
  81. <picture>
  82. <source
  83. srcset="
  84. {%- for size in sizes %}
  85. {{ gallery_photo.gallery_slug }}/webp/{{ gallery_photo.name }}_{{ size.0 }}x{{ size.1 }}.webp {{ size.0 }}w{% if not loop.last%},{% endif %}
  86. {%- endfor -%}
  87. "
  88. sizes="{% if gallery_photo.narrow %}150px{% else %}310px{% endif %}"
  89. type="image/webp">
  90. <img
  91. src="{{ gallery_photo.gallery_slug }}/jpg/{{ gallery_photo.name }}_{{ sizes.0.0 }}x{{ sizes.0.1 }}.jpg"
  92. width="{{ gallery_photo.width }}" height="{{ gallery_photo.height }}"
  93. srcset="
  94. {%- for size in sizes %}
  95. {{ gallery_photo.gallery_slug }}/jpg/{{ gallery_photo.name }}_{{ size.0 }}x{{ size.1 }}.jpg {{ size.0 }}w{% if not loop.last%},{% endif %}
  96. {%- endfor -%}
  97. "
  98. sizes="{% if gallery_photo.narrow %}150px{% else %}310px{% endif %}"
  99. alt="TODO" loading="lazy" decoding="async">
  100. </picture>
  101. </a>
  102. </div>
  103. {% endif %}
  104. {% endfor %}
  105. </div>
  106. <nav>
  107. <p class="u-center"
  108. data-controller="navigation"
  109. data-action="keydown@window->navigation#navigate"
  110. >
  111. {% if previous %}
  112. <a href="{{ previous.page_url }}"
  113. title="Photo précédente, vous pouvez utiliser la flèche du clavier ←"
  114. rel="prev"
  115. data-navigation-target="previous"
  116. >← Photo précédente</a>
  117. {% endif %}
  118. <a href="/"
  119. title="Retour à l’accueil, vous pouvez utiliser la flèche du clavier ↑"
  120. data-navigation-target="up"
  121. >↑ Retour aux albums{% if gallery.private %} publics{% endif %}</a>
  122. {% if next %}
  123. <a href="{{ next.page_url }}"
  124. title="Photo suivante, vous pouvez utiliser la flèche du clavier →"
  125. rel="next"
  126. data-navigation-target="next"
  127. >Photo suivante →</a>
  128. {% endif %}
  129. </p>
  130. </nav>
  131. {% endblock %}
  132. {% block extra_bottom %}
  133. <script type="module">
  134. import { Application, Controller } from "/scripts/stimulus-3.0.1.js"
  135. window.Stimulus = Application.start()
  136. // window.Stimulus.debug = true
  137. Stimulus.register("navigation", class extends Controller {
  138. static targets = [ "previous", "next", "up" ]
  139. navigate(event) {
  140. const key = event.key
  141. if (key === "ArrowLeft" && this.hasPreviousTarget) {
  142. this.previousTarget.click()
  143. }
  144. if (key === "ArrowRight" && this.hasNextTarget) {
  145. this.nextTarget.click()
  146. }
  147. if (key === "ArrowUp" && this.hasUpTarget) {
  148. this.upTarget.click()
  149. }
  150. }
  151. })
  152. </script>
  153. {% endblock %}