This is a gentle fork from https://framagit.org/marienfressinaud/photos.marienfressinaud.fr with a responsive and optimized mindset. https://media.larlet.fr/
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

media.html.j2 7.6KB

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