<%def name="row(tile, event, avatars=True, preview=True)">
    <%
    from adhocracy.lib.event import formatting
    event_html = formatting.as_html(event)
    %>
    <li class="${event.event.code}">
        %if avatars and h.config.get_bool('adhocracy.use_avatars'):
        %if event.user.is_deleted():
        <img class="avatar" src="/img/icons/user.png"/>
        %else:
        <img class="avatar" src="${h.logo_url(event.user, 32, x=32)}"/>
        %endif
        %endif
        <div class="time">${h.datetime_tag(event.time)|n}</div>
        <div class="action">
            <a href="${h.entity_url(event.user)}">${event.user.name}</a>
            ${tiles.badge.badges(event.user.get_badges(event.instance))}
            ${event_html|n}
        </div>

        %if preview:
            %if event.event.code in [u't_proposal_create', u't_proposal_edit'] and event.proposal.description.head is not None:
            ${row_text(h.entity_url(event.proposal), _(u'Show full proposal'), event.proposal.description.head.render())}

            %elif event.event.code in [u't_amendment_create', u't_amendment_edit'] and event.proposal.description.head is not None:
            ${row_text(h.entity_url(event.proposal), _(u'Show full amendment'), event.proposal.description.head.render())}

            %elif event.event.code in [u't_comment_create', u't_comment_edit'] and event.comment.__class__.__name__=='Comment':
            ${row_text(h.entity_url(event.comment), _(u'Show full comment'), h.render(event.comment.latest.text))}

            %endif
        %endif
    </li>
</%def>


<%def name="profile_row(tile, event)">
    ${row(tile, event, avatars=False)}
</%def>


<%def name="sidebar_row(tile, event)">
    ${row(tile, event, avatars=False, preview=False)}
</%def>


<%def name="row_text(url, link_text, text)">
    <% short = h.text.truncate_html(text, 30, u'&hellip;') %>
    <blockquote class="preview">${short|n}
        <a href="${url}" class="more_link">${link_text}</a>
    </blockquote>
</%def>
