7.7 KiB · text History 7a00c02
{% extends "root.html" %}
{% from "_macros.html" import rank_badge, cuisine_links, hours_badge %}

{% block content %}
<div class="space-y-4">
  <a href="/areas/{{ area.id }}" class="btn btn-ghost btn-sm">&larr; {{ area.name }}</a>

  <div class="grid grid-cols-1 md:grid-cols-2 gap-4">
    <div class="card bg-base-200 p-5 space-y-3">
      <div class="flex items-start justify-between gap-2">
        <h2 class="text-2xl font-bold">{{ restaurant.name }}</h2>
        {% if restaurant.archived %}<span class="badge badge-ghost">archived</span>{% endif %}
      </div>
      <dl class="text-sm space-y-1">
        {% if cuisines %}<div><dt class="inline opacity-70">Cuisine</dt> <dd class="inline">{{ cuisine_links(cuisines, area.id) }}</dd></div>{% endif %}
        {% if hours %}
        <div>
          <dt class="inline opacity-70">Hours</dt>
          <dd class="inline"><span class="font-mono text-xs">{{ hours.raw }}</span> {{ hours_badge(hours.at_lunch, "noon today") }}</dd>
        </div>
        {% endif %}
        {% if restaurant.address %}<div><dt class="inline opacity-70">Address</dt> <dd class="inline">{{ restaurant.address }}</dd></div>{% endif %}
        {% if restaurant.website %}<div><dt class="inline opacity-70">Web</dt> <dd class="inline"><a class="link" href="{{ restaurant.website }}" rel="noopener noreferrer" target="_blank">{{ restaurant.website }}</a></dd></div>{% endif %}
        {% if restaurant.osm_ref %}
        <div><dt class="inline opacity-70">OSM</dt>
          <dd class="inline">
            {% set kinds = {"N": "node", "W": "way", "R": "relation"} %}
            <a class="link font-mono" target="_blank" rel="noopener noreferrer"
               href="https://www.openstreetmap.org/{{ kinds[restaurant.osm_ref[0]] }}/{{ restaurant.osm_ref[1:] }}">{{ restaurant.osm_ref }}</a>
          </dd>
        </div>
        {% endif %}
      </dl>
      {% if restaurant.notes %}<p class="whitespace-pre-wrap text-base-content/80">{{ restaurant.notes }}</p>{% endif %}
      {% if added_by %}<p class="text-xs opacity-70"><i class="fas fa-user-pen"></i> Contributed by {{ added_by }}{% if restaurant.created_at %} on {{ restaurant.created_at[:10] }}{% endif %}</p>{% endif %}
      <div>
        <p class="text-xs opacity-70 mb-1">Your rank</p>
        {% with restaurant_id = restaurant.id %}{% include "restaurants/_rank.html" %}{% endwith %}
      </div>
    </div>
    <div class="h-72 md:h-auto min-h-64 rounded-box border border-base-300"
         data-map
         data-tiles="{{ map_config.tiles }}" data-lat="{{ restaurant.lat }}" data-lon="{{ restaurant.lon }}" data-zoom="17"
         data-markers='{{ [{"name": restaurant.name, "lat": restaurant.lat, "lon": restaurant.lon, "rank": my_rank}] | tojson }}'></div>
  </div>

  <div class="grid grid-cols-1 md:grid-cols-2 gap-4">
    <section class="card bg-base-200 p-5 space-y-2">
      <h3 class="font-semibold">Everyone's take</h3>
      <ul class="space-y-1">
        {% for p in everyone %}
        <li class="flex items-center justify-between gap-2 text-sm"><span>{{ p.username }}</span>{{ rank_badge(p.rank, p.since, p.tried) }}</li>
        {% endfor %}
      </ul>
    </section>

    <section class="card bg-base-200 p-5 space-y-3">
      <h3 class="font-semibold">Visits</h3>
      <form method="post" action="/lunches" class="join">
        <input type="hidden" name="restaurant_id" value="{{ restaurant.id }}"/>
        <input type="hidden" name="attendee" value="{{ user.id }}"/>
        <input class="input input-bordered input-sm join-item" type="date" name="went_on" value="{{ today }}" max="{{ today }}" required aria-label="Date"/>
        <button class="btn btn-sm join-item" type="submit"><i class="fas fa-check"></i> I went</button>
      </form>
      {% if visits | length == 0 %}
        <p class="text-sm opacity-70">Nobody's been yet.</p>
      {% else %}
      <ul class="text-sm space-y-1">
        {% for v in visits %}
        <li><span class="font-mono">{{ v.went_on }}</span> <span class="opacity-70">· {{ v.attendees | join(", ") }}</span></li>
        {% endfor %}
      </ul>
      {% endif %}
    </section>
  </div>

  <section class="card bg-base-200 p-5 space-y-3">
    <div class="flex flex-wrap items-center justify-between gap-2">
      <h3 class="font-semibold">Similar nearby</h3>
      {% if cuisines %}
      <div class="join">
        {% for r in [1500, 5000] %}
        <button type="button" class="btn btn-xs join-item"
                hx-get="/restaurants/{{ restaurant.id }}/similar?radius={{ r }}"
                hx-target="#similar" hx-select="#similar" hx-swap="outerHTML">
          <i class="fas fa-magnifying-glass-location"></i> {{ (r / 1000) | round(1) }} km
          <span class="loading loading-spinner loading-xs htmx-indicator"></span>
        </button>
        {% endfor %}
      </div>
      {% endif %}
    </div>
    <div id="similar">
      {% if cuisines %}
      <p class="text-sm opacity-70">Other {{ cuisines | join(" / ") }} places around {{ restaurant.name }}: pick a distance.</p>
      {% else %}
      <p class="text-sm opacity-70">Set a cuisine under Edit details to find similar places.</p>
      {% endif %}
    </div>
  </section>

  {% if role == "editor" or role == "admin" %}
  <details class="collapse collapse-arrow bg-base-200 border border-base-300">
    <summary class="collapse-title text-sm font-semibold">Edit details</summary>
    <div class="collapse-content space-y-3">
      <form method="post" action="/restaurants/{{ restaurant.id }}" class="grid grid-cols-1 sm:grid-cols-2 gap-3">
        <label class="form-control">
          <span class="label-text text-xs">Cuisine</span>
          <input class="input input-bordered input-sm" type="text" name="cuisine" value="{{ restaurant.cuisine or '' }}" maxlength="255"/>
        </label>
        <label class="form-control">
          <span class="label-text text-xs">Website</span>
          <input class="input input-bordered input-sm" type="url" name="website" value="{{ restaurant.website or '' }}" maxlength="512"/>
        </label>
        <label class="form-control sm:col-span-2">
          <span class="label-text text-xs">Opening hours <a class="link" href="https://wiki.openstreetmap.org/wiki/Key:opening_hours" target="_blank" rel="noopener noreferrer">(OSM syntax)</a></span>
          <input class="input input-bordered input-sm font-mono" type="text" name="opening_hours" value="{{ restaurant.opening_hours or '' }}" maxlength="512" placeholder="Mo-Fr 11:00-15:00"/>
        </label>
        <label class="form-control sm:col-span-2">
          <span class="label-text text-xs">Notes</span>
          <textarea class="textarea textarea-bordered" name="notes" rows="3">{{ restaurant.notes }}</textarea>
        </label>
        <div><button class="btn btn-sm" type="submit">Save</button></div>
      </form>
      {% if restaurant.osm_ref %}
      <form method="post" action="/restaurants/{{ restaurant.id }}/refresh" class="space-y-1">
        <button class="btn btn-sm btn-ghost" type="submit"><i class="fas fa-rotate"></i> Refresh from OSM</button>
        <p class="text-xs opacity-70">Replaces the hours with OSM's; fills cuisine, website and address only if blank.</p>
      </form>
      {% endif %}
      <form method="post" action="/restaurants/{{ restaurant.id }}/archive">
        {% if restaurant.archived %}
          <button class="btn btn-sm btn-ghost" type="submit"><i class="fas fa-box-open"></i> Put back in rotation</button>
        {% else %}
          <button class="btn btn-sm btn-ghost text-error" type="submit"
                  hx-confirm="Archive {{ restaurant.name }}? It stays in the history but won't be suggested.">
            <i class="fas fa-box-archive"></i> Archive (closed, or off the rotation)
          </button>
        {% endif %}
      </form>
    </div>
  </details>
  {% endif %}
</div>
{% endblock %}