<tal:archive_state define="
                     plone_view view/plone_view;
                     ws_class_name request/superspace | string:workspaces;
                     absolute_url here/absolute_url;
                     can_view view/can_view;
                     can_add view/workspaces_view/can_add;
                     userid request/userid|nothing;
                     link_class here/link_class|string:link;
                     tags here/item/Subject|here/Subject;
                     proto nocall: here/@@proto;
                     tag_classes python:proto.get_tag_classes(tags);
                     hero_image_url view/hero_image_url;
                   "
                   i18n:domain="ploneintranet"
>
  <tal:workspace condition="not:view/is_expandable">
    <div class="tile tile-${ws_class_name} workspace four columns ${view/get_css_classes} ${tag_classes}">
      <a class="${link_class}"
         href="${here/absolute_url}?_authenticator=${here/@@authenticator/token}#${here/url_fragment|string:app-space}"
         data-pat-inject="history: record"
         data-pat-modal="${python: 'class: medium' if (link_class and 'pat-modal' in link_class) else None}"
         data-pat-switch="selector: #app-space; remove: state-*; add: state-on"
      >
        <h3>${python:view.shorten(here.title, 80)}</h3>
        <img class="hero-image"
             src="${hero_image_url}"
             tal:condition="hero_image_url"
        />

        <p class="description"
           tal:condition="here/description"
           tal:attributes="title here/description"
          >${python:view.shorten(here.description, 100)}
        </p>
        <p class="tags tag-cloud" tal:condition="tags">
          <span class="tag" tal:repeat="tag tags"><tal:comment condition="nothing"># followed directly by $ upsets i18ndude, so we need to use a tal statement here:</tal:comment><tal:tag replace="tag"/></span>
        </p>
        <p class="workspace-state"
           tal:condition="here/is_archived|nothing"
        >
          <time class="icon-archive archived">
            <tal:archived_on i18n:translate="">Archived on</tal:archived_on>
            ${python:plone_view.toLocalizedTime(here.archival_date, long_format=0)}
          </time>
        </p>
      </a>
      <tal:bookmark condition="can_view"
                    replace="structure here/@@bookmark-link-iconified"
      />
    </div>
  </tal:workspace>

  <tal:superspace condition="view/is_expandable">
    <div class="tile workspace tile-${ws_class_name} state- four columns ${view/get_css_classes}"
         id="workspace-tile-${tile_uid}"
         tal:define="
           tile_uid view/tile_uid;
         "
    >
      <div class="link">
        <a class="pat-inject pat-switch"
           href="${view/superspace_overview_url}"
           data-pat-inject="source: #workspaces > .tiles; target: #subspaces-tile-${tile_uid}"
           data-pat-switch="selector: #workspace-tile-${tile_uid}; add: expanded"
        >
          <h3>${python:view.shorten(here.title, 80)}</h3>
          <p class="description"
             tal:condition="here/description"
             tal:attributes="title here/description"
             >${python:view.shorten(here.description, 100)}</p>
        </a>
        <a class="close iconified icon-minus-circle pat-switch"
           title="Close super space"
           data-pat-switch="selector: #workspace-tile-${tile_uid}; remove: expanded"
           i18n:attributes="title;"
           i18n:translate=""
        >Close</a>
        <a class="settings iconified icon-cog pat-tooltip"
           href="${here/absolute_url}#super-settings"
           title="Change the settings of this super space"
           data-pat-tooltip="source: ajax"
           tal:condition="python: can_view and not userid"
           i18n:attributes="title;"
           i18n:translate=""
        >Settings</a>
        <a class="icon iconified icon-plus-circle create pat-modal"
           href="${here/absolute_url}/../@@add_workspace?superspace=${here/UID}#document-content"
           title="Create a new workspace with this superspace as a parent"
           data-pat-modal="class: panel medium"
           i18n:attributes="title;"
           tal:condition="python: can_add and not userid"
           i18n:translate=""
        >Create workspace</a>
        <div class="row tiles workspaces pat-masonry"
             id="subspaces-tile-${tile_uid}"
             data-pat-masonry="column-width: .grid-sizer; gutter: 0; item-selector: #subspaces-tile-${tile_uid} > .tile;"
        ></div>
      </div>
    </div>
  </tal:superspace>
</tal:archive_state>
