<!--
  ~ Copyright (C) 2024 usbharu
  ~
  ~ Licensed under the Apache License, Version 2.0 (the "License");
  ~ you may not use this file except in compliance with the License.
  ~ You may obtain a copy of the License at
  ~
  ~      http://www.apache.org/licenses/LICENSE-2.0
  ~
  ~ Unless required by applicable law or agreed to in writing, software
  ~ distributed under the License is distributed on an "AS IS" BASIS,
  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  ~ See the License for the specific language governing permissions and
  ~ limitations under the License.
  -->

<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>


<article class="post" th:fragment="single-simple-post(post)">
    <!--/*@thymesVar id="post" type="dev.usbharu.hideout.core.application.model.PostDetail"*/-->
    <img alt="" height="80px" src="" th:src="${post.actor.iconUrl}" width="80px">
    <div style="display: inline-block">
        <a th:href="${post.actor.remoteUrl}"
           th:text="${post.actor.screenName}+'(@'+${post.actor.name}+'@'+${post.actor.host}+')'"></a>
    </div>

    <div th:utext="${post.content}">

    </div>
    <div th:each=" media : ${post.mediaDetailList} ">
        <th:block th:switch="${media.type}">
            <picture th:case="Image">
                <source media="(min-width: 600px)" th:srcset="${media.url}">
                <img alt="" src="" th:alt="${media.description}" th:src="${media.thumbnailUrl}" width="260">
            </picture>
            <video controls loop preload="metadata" th:case="Video" th:poster="${media.thumbnailUrl}"
                   th:src="${media.url}"
                   th:text="#{common.video-download-link}"
                   width="260">
                <a th:href="${media.url}" th:text="#{common.video}">Video</a>
                <a th:href="${media.thumbnailUrl}" th:text="#{common.thumbnail}">Thumbnail</a>
            </video>
            <audio controls preload="metadata" th:case="Audio" th:src="${media.url}"
                   th:text="#{common.audio-download-link}">
                <a th:href="${media.url}" th:text="#{common.audio}">Audio</a>
            </audio>
            <th:block th:case="*">
                <p th:text="#{common.unknwon-file-type}">Unknown filetype</p>
            </th:block>
        </th:block>
        <a href="" th:href="${media.url}" th:text="#{common.media-original-link}"></a>
    </div>
</article>

<div class="post-controller" th:fragment="single-post-controller(post)">
    <!--/*@thymesVar id="post" type="dev.usbharu.hideout.core.application.model.PostDetail"*/-->
    <th:block th:if="${post.favourited}">
        <form method="post" th:action="@{/users/a/posts/{id}/unfavourite(id=${post.id})}">
            <a th:href="${'/publish?reply_to=' + post.id}">Reply</a>
            <input type="submit" value="[❤]">
            <a th:href="${post.apId}">
                <time th:datetime="${post.createdAt}"
                      th:text="${#temporals.format(post.createdAt, 'yyyy-MM-dd HH:mm')}"></time>
            </a>
        </form>
    </th:block>
    <th:block th:unless="${post.favourited}">
        <form method="post" th:action="@{/users/a/posts/{id}/favourite(id=${post.id})}">
            <a th:href="${'/publish?reply_to=' + post.id}">Reply</a>
            <input type="submit" value="❤">
            <a th:href="${post.apId}">
                <time th:datetime="${post.createdAt}"
                      th:text="${#temporals.format(post.createdAt, 'yyyy-MM-dd HH:mm')}"></time>
            </a>
        </form>
    </th:block>

</div>


</body>
</html>