docs: def topic_quick_links(context, topic, latest, last_seen_time):
      """
      Creates topic listing page links for the given topic, with the given
      number of posts per page.
  
      Topics with between 2 and 5 pages will have page links displayed for
      each page.
  
      Topics with more than 5 pages will have page links displayed for the
      first page and the last 3 pages.
      """
      output_text = u''
  
      pages = topic.page_count
      if not pages or pages == 0:
          hits = topic.post_count - 1
          if hits < 1:
              hits = 1
          pages = hits // PAGINATE_BY + 1
  
      # determine if we need to show new link.
      if latest and latest.post_date_int > last_seen_time:
          output_text += '<a href="{0}#first-new-post" class="new">new</a>'.format(topic.last_url)
  
      # If only one post (or none) only return new link, if anything.
      if topic.post_count < 2:
          output_text += '1 post'
      else:
          # We have more than one post. Create last link
          if latest:
              last_link = '<a href="{0}#post-{1}" title="latest post">'.format(topic.last_url, latest.id)
          else:
              last_link = ''
  
          # if only one page, just show the number of posts wrapped in a link
          if pages < 2:
              output_text += '{0}{1} posts</a>'.format(last_link, topic.post_count)
  
          else:
              page_link = u'<a href="%spage%%s/">%%s</a>' % topic.get_short_url()
              if pages < 4:
                  page_links = u' '.join([page_link % (page, page) for page in range(1, pages + 1)])
              else:
                  page_links = u' '.join(
                      [page_link % (1, 1), u'<small>&hellip;</small>'] +
                      [page_link % (page, page) for page in range(pages - 1, pages + 1)]
                  )
              output_text += '{0}{1}&#9658;</a>'.format(page_links, last_link)
  
      return {
          'output_text': output_text,
          'topic': topic,
          'forum_slug': context['forum_slug'],
          'user': context['user'],
          'perms': context['perms']
      }