discussion-message-preview.html 2.12 KB
{% load i18n tz highlight %}

{% if result.fullname or result.modified or result.modified_by %}
  <div class="quiet">
    {% if result.modified %}
      <span class="pull-left">{{ result.modified|localtime|timesince }} {% trans "ago" %} - </span>
    {% endif %}

    {% if result.modified_by %}
      <span class="pull-left">{% trans "by" %}
        {% if result.modified_by_url %}
          <a href="{{ result.modified_by_url }}">
        {% else %}
          <span>
        {% endif %}

        {% if query %}
          {% highlight result.modified_by with query %}
        {% else %}
          {{ result.modified_by }}
        {% endif %}

        {% if result.modified_by_url %}
          </a>
        {% else %}
          </span>
        {% endif %}
      </span>
    {% else %}
      <span class="pull-left">{% trans "by" %} {% trans "Anonymous" %}</span>
    {% endif %}
  </div>
{% endif %}

{% if result.title %}
  <a href="{{ result.url }}
   {% if result.type == 'thread' and result.latest_message_pk %}
        #msg-{{ result.latest_message_pk }}
   {% elif result.type == 'thread' and result.pk %}
        #msg-{{ result.pk }}
   {% endif %}" 

   {% if result.latest_description %}
     title="{{ result.latest_description|escape|truncatechars:150 }}"
   {% elif result.description %}
     title="{{ result.description|escape|truncatechars:150 }}"
   {% endif %}>
    <span class="subject">
      <!-- a striptags filter was raising an error here because using with highlight -->
      {% if query %}
        {% highlight result.title with query max_length "1000" %}
      {% else %}
        {{ result.title }}
      {% endif %}
    </span>
  </a>
{% endif %}

{% if result.description %}
  <!-- a striptags filter was raising an error here because using with highlight -->
  <span class="quiet"> - {% if query %}
    {% highlight result.description with query max_length "110" %}
  {% else %}
    {% if result.latest_description %}
      {{ result.latest_description|striptags|escape|truncatechars:110 }}
    {% elif result.description %}
      {{ result.description|striptags|escape|truncatechars:110 }}
    {% endif %}
  {% endif %}
  </span>
{% endif %}