2.8 KiB · text History 3d2ee7c
{# "Find similar nearby" results. Swapped in whole, so the root keeps the
   target's id. #}
{% from "_macros.html" import rank_badge, cuisine_links %}
<div id="similar" class="space-y-4">
  {% if not cuisines %}
    <p class="text-sm opacity-70">No cuisine set for {{ restaurant.name }}, so there's nothing to match on. Add one under Edit details.</p>
  {% else %}
  <div>
    <h4 class="text-sm font-semibold mb-1">Already in this area</h4>
    {% if in_area %}
    <ul class="text-sm space-y-1">
      {% for r in in_area %}
      <li class="flex flex-wrap items-center gap-2">
        <a class="link link-hover font-semibold" href="/restaurants/{{ r.restaurant.id }}">{{ r.restaurant.name }}</a>
        <span class="text-xs opacity-70">{{ cuisine_links(r.cuisines, restaurant.area_id) }} · {{ r.distance_m }} m</span>
        {{ rank_badge(r.my_rank) }}
      </li>
      {% endfor %}
    </ul>
    {% else %}
    <p class="text-xs opacity-70">Nothing else tagged {{ cuisines | join(" or ") }} here yet.</p>
    {% endif %}
  </div>

  <div>
    <h4 class="text-sm font-semibold mb-1">Nearby on OpenStreetMap, within {{ (radius / 1000) | round(1) }} km</h4>
    {% if nearby %}
    <ul class="text-sm space-y-1">
      {% for p in nearby %}
      <li class="flex flex-wrap items-center gap-2">
        <span class="font-semibold">{{ p.name }}</span>
        <span class="text-xs opacity-70">{{ [p.cuisine, p.address] | select | join(" · ") }} · {{ p.distance_m }} m</span>
        {% if p.website %}<a class="link text-xs" href="{{ p.website }}" target="_blank" rel="noopener noreferrer"><i class="fas fa-globe"></i></a>{% endif %}
        {% if can_add %}
        <form method="post" action="/restaurants" class="inline">
          <input type="hidden" name="area_id" value="{{ restaurant.area_id }}"/>
          <input type="hidden" name="name" value="{{ p.name }}"/>
          <input type="hidden" name="osm_ref" value="{{ p.osm_ref or '' }}"/>
          <input type="hidden" name="lat" value="{{ p.lat }}"/>
          <input type="hidden" name="lon" value="{{ p.lon }}"/>
          <input type="hidden" name="cuisine" value="{{ p.cuisine or '' }}"/>
          <input type="hidden" name="address" value="{{ p.address or '' }}"/>
          <input type="hidden" name="website" value="{{ p.website or '' }}"/>
          <input type="hidden" name="opening_hours" value="{{ p.opening_hours or '' }}"/>
          <button class="btn btn-xs btn-outline" type="submit"><i class="fas fa-plus"></i> Add</button>
        </form>
        {% endif %}
      </li>
      {% endfor %}
    </ul>
    {% else %}
    <p class="text-xs opacity-70">Nothing else tagged {{ cuisines | join(" or ") }} within {{ (radius / 1000) | round(1) }} km{% if radius < 5000 %}; try further out{% endif %}.</p>
    {% endif %}
  </div>
  {% endif %}
</div>