<tal:comment condition="nothing">
  <!-- ploneintranet.prototype/_includes/post.html -->
</tal:comment>
<div class="tile">
  <div class="post item${python: ' user-inactive' if not is_user_enabled else ''}"
       id="post-${here/id}"
       tal:define="
         dummy view/portal/@@http-cache-headers;
         plone_view here/@@plone;
         portal_url view/portal_url;
         proto nocall: here/@@proto;
         is_slow proto/is_slow;
         userid here/userid;
         is_user_enabled view/is_user_enabled;
         in_workspace view/in_workspace;
         switch_target view/switch_target;
         injection_target view/injection_target;
       "
       i18n:domain="ploneintranet"
  >
    <div class="post-header">
      <a class="${python: 'pat-inject pat-switch' if is_user_enabled else None}"
         href="${python: '{}/author/{}#app-space'.format(portal_url, userid) if is_user_enabled else None}"
         data-pat-inject="${python: 'history: record' if is_user_enabled else None}"
         data-pat-switch="${python: '#app-space state-off state-on' if is_user_enabled else None}"
      >
        <img tal:replace="structure python:proto.get_avatar_tag(userid)" />
        <h4 class="name"
            title="${view/fullname_title}"
        >${view/fullname}</h4>
      </a>
      <p class="byline">
        <a class="action pat-inject"
           href="${context/absolute_url}"
           data-pat-inject="history: record;"
           i18n:comment="INFO: This is a dynamic translation message which is already translated elsewhere. Keep it as-is."
           i18n:translate=""
        >${context/action_verb}</a>
        <time class="pat-display-time"
              datetime="${context/date/ISO}"
              data-pat-display-time="from-now: ${view/use_relative_date}; locale: ${view/portal/plone_portal_state/language}"
        >${context/date/ISO}</time>
        <tal:location condition="context/microblog_context/Title|nothing">
          in
          <a class="pat-inject pat-switch"
             href="${context/microblog_context/absolute_url}?_authenticator=${context/@@authenticator/token}#app-space"
             data-pat-inject="history: record"
             data-pat-switch="#app-space state-off state-on"
          >${context/microblog_context/Title}</a>
        </tal:location>

        <tal:comment condition="nothing">
          <!-- XXX: This is not yet implemented -->
          <!--label class="visibility pat-select bare">
        |
          <select>
            <optgroup>
              <option>
                Everyone
              </option>
              <option>
                Trusted users
              </option>
            </optgroup>
            <optgroup>
              <option>
                Workspace so and so
              </option>
              <option>
                Baggage handling regulations
              </option>
              <option>
                Human resources
              </option>
            </optgroup>
          </select>
         </label-->
        </tal:comment>
        <br />
        <a class="iconified icon-ellipsis pat-tooltip"
           href="${view/traverse}/post-menu.html#content"
           data-pat-tooltip="source: ajax"
           tal:condition="view/actions"
        >Options</a>
      </p>
    </div>

    <section class="post-content"
             tal:define="
               decorated_text view/decorated_text;
             "
    >
      <p tal:condition="decorated_text">
        <span tal:replace="structure decorated_text">Comment text</span>
        <a class="edited-toggle"
           id="edited-toggle-${context/id}"
           tal:condition="context/original_text"
        >
          (<span tal:omit-tag=""
                i18n:translate=""
          >Edited</span>
          <time class="pat-display-time"
                datetime="${context/edited/ISO}"
                data-pat-display-time="from-now: true; locale: ${view/portal/plone_portal_state/language}"
          >${context/edited/ISO}</time>)
        </a>
      </p>

      <section class="original-text pat-collapsible closed"
               data-pat-collapsible="trigger: #edited-toggle-${context/id}"
               tal:condition="context/original_text"
      >
        <p>
          <strong i18n:translate="">Original text:</strong>
          ${context/original_text}
        </p>
      </section>

    </section>

    <tal:document_preview switch="view/post_type">
      <tal:streamonly case="string:stream">
        <tal:image_attachments define="
                                 attachments view/image_attachments;
                               ">
          <tal:def define="
                     nr_images python:len(attachments);
                   ">
            <tal:attachment condition="nr_images">
              <section class="type-image document-preview"
                       tal:define="
                         attachment python:attachments[0];
                         has_preview attachment/img_src|nothing;
                       "
                       tal:condition="has_preview"
              >
                <figure>
                  <span class="pat-gallery">
                    <a href="${attachment/link}"
                       title="${view/label_image_preview}"
                    >
                      <img alt=""
                           src="${attachment/img_src}"
                           tal:condition="not:is_slow"
                      />
                    </a>
                    <a hidden="hidden"
                       href="${next_attachment/link}"
                       tal:repeat="next_attachment python:attachments[1:]"
                    >Image</a>
                  </span>
                  <tal:title condition="is_slow">${attachment/title}</tal:title>
                </figure>
                <p class="${python: not is_slow and 'overlay' or None}">
                  <tal:comment condition="nothing">
                    <!-- XXX images zip download not implemented yet -->
                  </tal:comment>
                  <a class="icon iconified icon-download"
                     href="${attachment/link}/@@download"
                     title="Download this image"
                     tal:condition="python:nr_images==1"
                     i18n:attributes="title"
                     i18n:translate=""
                  >Download</a>
                  <span class="pat-gallery">
                    <a href="${attachment/link}"
                       title="${view/label_image_preview}"
                    >
                      <span class="icon iconified icon-eye"
                            i18n:translate="label_preview"
                      >
                        Preview
                      </span>
                      <em class="icon page-counter"
                          tal:condition="python:nr_images&gt;1"
                      >${nr_images}x</em>
                    </a>
                    <a hidden="hidden"
                       href="${next_attachment/link}"
                       tal:repeat="next_attachment python:attachments[1:]"
                    >Image</a>
                  </span>
                </p>
              </section>
            </tal:attachment>
          </tal:def>
        </tal:image_attachments>

        <tal:file_attachments repeat="attachment view/file_attachments">
          <tal:def define="
                     has_preview attachment/img_src|nothing;
                     render_id string:render-${here/id}-${repeat/attachment/number};
                   ">
            <section class="document document-preview ${python: 'not-possible' if (is_slow or not has_preview) else ''}">
              <figure>
                <a class="pat-forward"
                   href="#${render_id}"
                   title="View"
                   data-pat-forward="selector: #${render_id}"
                   tal:condition="has_preview"
                   i18n:attributes="title"
                >
                  <img alt="${attachment/title}"
                       src="${attachment/img_src}"
                       title="${attachment/title}"
                       tal:condition="python:not is_slow and has_preview"
                  />
                </a>
                <figcaption>
                  <strong class="title">
                    <a class="pat-forward"
                       href="#${render_id}"
                       title="View"
                       data-pat-forward="selector: #${render_id}"
                       tal:condition="has_preview"
                       i18n:attributes="title"
                    >
                      ${attachment/title}
                    </a>
                    <a href="${attachment/link}/@@download"
                       title="Download this file"
                       tal:condition="not:has_preview"
                       i18n:attributes="title"
                    >
                      ${attachment/title}
                    </a>
                    <tal:comment condition="nothing">
                      <!-- This needs exposure of all generated thumbs. We can do that and have them accessible, it is just not added here yet. -->
                      <!--span class="page-counter icon-docs">3x</span-->
                    </tal:comment>
                    <span class="functions">
                      <a class="icon iconified icon-download"
                         href="${attachment/link}/@@download"
                         title="Download this file"
                         i18n:attributes="title"
                      >Download</a>
                      <nav class="pat-gallery pat-navigation"
                           tal:condition="has_preview"
                      >
                        <a class="icon iconified icon-eye"
                           id="${render_id}"
                           href="${attachment/img_src}"
                           title="View"
                           i18n:attributes="title"
                        >View</a>
                      </nav>
                    </span>
                  </strong>
                  <tal:comment condition="nothing">
                    <!-- no description byline for status attachments -->
                  </tal:comment>

                </figcaption>
              </figure>
            </section>
          </tal:def>
        </tal:file_attachments>
      </tal:streamonly>

      <tal:content_default define="
                             content_context nocall:context/content_context;
                             post_inner nocall:content_context/@@post_inner|nothing;
                           "
                           case="default"
      >
        <tal:post_inner condition="nocall:post_inner"
                        replace="structure post_inner"
        />
        <section class="${view/content_preview_status_css} ${python:is_slow and 'not-possible' or ''}"
                 tal:define="
                   content_context nocall:context/content_context;
                   content_update_type view/content_update_type;
                 "
                 tal:switch="content_update_type"
                 tal:condition="python: not post_inner"
        >

          <tal:image case="string:type-image">
            <figure>
              <a class="pat-inject ${python: 'pat-switch' if switch_target else None}"
                 alt="${content_context/Title}"
                 href="${content_context/absolute_url}/view?show_sidebar=1"
                 data-pat-inject="${injection_target}; history:record"
                 data-pat-switch="${switch_target}"
              >
                <img alt="${content_context/Title}"
                     src="${content_context/absolute_url}/@@images/image/3col"
                     tal:condition="not:is_slow"
                />
                <tal:title condition="is_slow">${content_context/Title}</tal:title>
              </a>
            </figure>
          </tal:image>

          <tal:audio case="string:type-audio">
            <figure>
              <figcaption tal:define="
                            description content_context/Description;
                          ">
                <h3 class="title">
                  <a class="pat-inject pat-switch"
                     href="${content_context/absolute_url}/view?show_sidebar=1#app-space"
                     data-pat-inject="${injection_target}; history:record"
                     data-pat-switch="${switch_target}"
                  >${content_context/Title}</a>
                </h3>
                <p class="byline"
                   tal:condition="description"
                >${description}</p>
              </figcaption>
              <audio controls>
                <source src="${python:view.get_video_source(content_context)}"
                        type="${python: view.context_content_type if view.context_content_type.startswith('audio/') else None}"
                />
              </audio>
            </figure>
          </tal:audio>

          <tal:video case="string:type-video">
            <figure>
              <figcaption tal:define="
                            description content_context/Description;
                          ">
                <h3 class="title">
                  <a class="pat-inject pat-switch"
                     href="${content_context/absolute_url}/view?show_sidebar=1#app-space"
                     data-pat-inject="${injection_target}; history:record"
                     data-pat-switch="${switch_target}"
                  >${content_context/Title}</a>
                </h3>
                <p class="byline"
                   tal:condition="description"
                >${description}</p>
              </figcaption>
              <video controls
                     poster="${poster}"
                     preload="${preload}"
                     tal:define="
                       poster python: view.get_video_poster(content_context) or None;
                       preload python: 'none' if poster else 'metadata';
                     "
              >
                <source src="${python:view.get_video_source(content_context)}"
                        type="${python: view.context_content_type if view.context_content_type.startswith('video/') else None}"
                />
              </video>
            </figure>
          </tal:video>

          <tal:youtube case="string:type-youtube">
            <figure>
              <figcaption tal:define="
                            description content_context/Description;
                          ">
                <h3 class="title">
                  <a class="pat-inject pat-switch"
                     href="${content_context/absolute_url}/view?show_sidebar=1#app-space"
                     data-pat-inject="${injection_target}; history:record"
                     data-pat-switch="${switch_target}"
                  >${content_context/Title}</a>
                </h3>
                <p class="byline"
                   tal:condition="description"
                >${description}</p>
              </figcaption>
              <div class="youtube-player">
                <img class="placeholder-image"
                     alt=""
                     src="${portal_url}/++theme++ploneintranet.theme/generated/assets/quaive/placeholders/placeholder-youtube.png"
                />
                <iframe allowfullscreen="true"
                        frameborder="0"
                        src="${content_context/@@previews/youtube_url}"
                        type="text/html"
                ></iframe>
              </div>
            </figure>
          </tal:youtube>

          <tal:default case="default">
            <figure tal:define="
                      preview_urls view/content_preview_urls;
                      gallery_urls python:view.content_preview_urls(small=False);
                      nr_images python:len(preview_urls);
                    ">
              <a class="pat-inject ${python: 'pat-switch' if switch_target else None}"
                 alt="${content_context/Title}"
                 href="${view/content_url}?show_sidebar=1"
                 data-pat-inject="${injection_target}; history: record"
                 data-pat-switch="${switch_target}"
                 tal:condition="view/content_has_previews"
              >
                <img alt=""
                     src="${python:preview_urls[0]}"
                     tal:condition="python:not is_slow"
                />

              </a>
              <a class="pat-inject ${python: 'pat-switch' if switch_target else None} document-preview-image-link"
                 alt="${content_context/Title}"
                 href="${view/content_url}?show_sidebar=1"
                 data-pat-inject="${injection_target}; history: record"
                 data-pat-switch="${switch_target}"
                 tal:condition="python:view.content_has_leadimage and content_context.image"
              >
                <img alt=""
                     src="${content_context/absolute_url}/@@images/image/preview"
                     tal:condition="python:not is_slow"
                />
              </a>
              <figcaption>
                <strong class="title">
                  <a class="pat-inject ${python: 'pat-switch' if switch_target else None}"
                     alt="${content_context/Title}"
                     href="${view/content_url}?show_sidebar=1"
                     data-pat-inject="${injection_target}; history: record"
                     data-pat-switch="${switch_target}"
                  >${content_context/Title}</a>
                  <span class="page-counter icon-docs"
                        tal:condition="python:nr_images&gt;1"
                  >${nr_images}x</span>
                  <span class="functions">
                    <a class="icon iconified icon-download"
                       href="${content_context/absolute_url}/@@download"
                       title="Download this file"
                       tal:condition="view/is_content_downloadable"
                       i18n:attributes="title"
                    >Download</a>
                    <nav class="pat-gallery pat-navigation"
                         tal:condition="view/content_has_previews"
                    >
                      <a class="icon iconified icon-eye"
                         href="${python:gallery_urls[0]}"
                         title="View"
                         i18n:attributes="title"
                      >View</a>
                      <a hidden="hidden"
                         href="${next_attachment_link}"
                         tal:repeat="next_attachment_link python:gallery_urls[1:]"
                      >Image</a>
                    </nav>
                  </span>
                </strong>
                <a class="pat-inject ${python: 'pat-switch' if switch_target else None}"
                   alt="${content_context/Title}"
                   href="${view/content_url}?show_sidebar=1"
                   data-pat-inject="${injection_target}; history: record"
                   data-pat-switch="${switch_target}"
                   tal:define="
                     description content_context/Description;
                   "
                >
                  <span class="byline">
                    ${python:plone_view.cropText(description, 340, u'&hellip;')}
                    <em class="read-more"
                        i18n:translate="label_read_more"
                    >Read more&hellip;</em>
                  </span>
                </a>
              </figcaption>
            </figure>
          </tal:default>

          <p class="${python: not is_slow and 'overlay' or None}"
             tal:condition="python: view.content_update_type == 'type-image'"
          >
            <tal:comment condition="nothing">
              <!-- XXX images zip download not implemented yet -->
            </tal:comment>
            <a href="${view/content_url}"
               title="View this image"
               i18n:attributes="title"
            >
            </a>
            <a href="${content_context/absolute_url}/@@download"
               title="Download this image"
               i18n:attributes="title"
            >
              <span class="icon iconified icon-download">Download</span>
            </a>
            <span class="pat-gallery">
              <a href="${content_context/absolute_url}"
                 title="${view/label_image_preview}"
              >
                <span class="icon iconified icon-eye">
                  ${view/label_image_preview}
                </span>
              </a>
            </span>
          </p>

        </section>
      </tal:content_default>
    </tal:document_preview>

    <div class="functions">
      <tal:comment condition="nothing">
        <!-- XXX: This is not yet implemented -->
        <!--a href="#" class="share pat-modal">Share <sup class="counter">(8)</sup></a-->
      </tal:comment>
      <tal:like condition="exists:view/portal/@@toggle_like_statusupdate"
                replace="structure view/toggle_like"
      />
    </div>

    <div class="comments"
         id="comments-${here/id}"
         tal:condition="python: not view.omit_comment_trail"
    >
      <div class="comment-trail"
           id="comment-trail-${here/id}"
      >

        <a class="pat-inject infinite-scrolling-trigger"
           href="${portal_url}/@@post-comments/${here/id}"
           data-pat-inject="trigger: autoload-visible; source: #comment-trail; target: self::element"
           tal:condition="view/replies"
           i18n:translate=""
        >
          Load more&hellip;
        </a>

        <tal:commentable condition="view/commentable">
          <div id="new-comment-${here/id}"></div>
          <tal:update replace="structure here/@@update-social.html" />
        </tal:commentable>
      </div>
      <a class="XXXpat-inject update-comments ${python: 'has-comments' if view.replies else ''}"
         id="update-comment-trail-${here/id}"
         href="#"
         data-xxx-pat-inject="source: #update-comment-trail-${here/id}; target: #update-comment-trail-${here/id}::after &amp;&amp; source: #comment-trail-mypost_1::element; target: #comment-trail-mypost_1::element; trigger: push; push-id: new_comments_for_${here/id}"
         i18n:translate=""
      >Update comment trail</a>
    </div>

  </div>
</div>
