{% extends "base.html" %}
{% block title %}
{{ _("Suggest an app") }}
{% endblock %}
{% block main %}
<div class="mt-5 text-center px-3 sm:px-0">
    <h1 class="text-2xl font-bold text-gray-900">
        {{ _("Suggest an application to be added to YunoHost's catalog") }}
    </h1>
</div>


<div class="overflow-x-auto max-w-md mx-auto pt-5 px-3 sm:px-0">

    {% if successmsg %}
    <div role="alert" class="rounded-md border-s-4 border-green-500 bg-green-50 p-4 my-5">
      <p class="mt-2 text-sm text-green-700 font-bold">
        <i class="fa fa-thumbs-up fa-fw" aria-hidden="true"></i>
        {{ successmsg | safe }}
      </p>
    </div>
    {% else %}


    {% if not user %}
    <div role="alert" class="rounded-md border-s-4 border-orange-500 bg-orange-50 p-4 mb-5">
      <p class="mt-2 text-sm text-orange-700 font-bold">
        <i class="fa fa-exclamation-triangle fa-fw" aria-hidden="true"></i>
          {{ _("You must first login to be allowed to submit an app to the wishlist") }}
          <br/><br/>
      </p>
      <p class="mt-2 text-sm text-orange-700">
          {{ _("Note that, due to various abuses, we restricted login on the app store to 'trust level 1' users.<br/><br/>'Trust level 1' is obtained after interacting a minimum with the forum, and more specifically: entering at least 5 topics, reading at least 30 posts, and spending at least 10 minutes reading posts.") }}
      </p>
    </div>
    {% else %}
    <div role="alert" class="rounded-md border-s-4 border-orange-500 bg-orange-50 p-4 mb-5">
      <p class="mt-2 text-sm text-orange-700 font-bold">
        <i class="fa fa-exclamation-triangle fa-fw" aria-hidden="true"></i>
          {{ _("Due to abuses, only one proposal every 15 days per user is allowed.") }}
      </p>
      <p class="mt-2 text-sm text-orange-700">
          {{ _("Reviewing those proposals is tiring for volunteers, please don't yolo-send every random nerdy stuff you find on the Internet.") }}
      </p>
    </div>
    {% endif %}

    {% if errormsg %}
    <div role="alert" class="rounded-md border-s-4 border-red-500 bg-red-50 p-4 my-5">
      <p class="mt-2 text-sm text-red-700 font-bold">
        <i class="fa fa-exclamation-triangle fa-fw" aria-hidden="true"></i>
        {{ errormsg | safe }}
      </p>
    </div>
    {% endif %}

    <form method="POST" action="{{ url_for('add_to_wishlist') }}" class="my-8" >

      <input name="csrf_token" type="text" class="hidden" value="{{ csrf_token }}" >

      <label for="name" class="mt-5 block font-bold text-gray-700">{{ _("Name") }}</label>
      <input name="name" type="text" class="w-full mt-1 rounded-md border-gray-200 text-gray-700 shadow-sm" maxlength="30" required onkeyup="this.value = this.value.replace(/[^a-zA-Z0-9.-\\(\\)\\ ]/, '')" >

      <label for="description" class="mt-5 block font-bold text-gray-700">{{ _("App's description") }}</label>
      <textarea name="description" type="text" class="w-full mt-1 rounded-md border-gray-200 text-gray-700 shadow-sm" required rows='3' maxlength='100'></textarea>
      <span class="text-xs text-gray-600"><span class="font-bold">{{ _("Please be concise and focus on what the app does.") }}</span> {{ _("No need to repeat '[App] is …'. No need to state that it is free/open-source or self-hosted (otherwise it wouldn't be packaged for YunoHost). Avoid marketing stuff like 'the most', or vague properties like 'easy', 'simple', 'lightweight'.") }}</span>

      <label for="upstream" class="mt-5 block font-bold text-gray-700">{{ _("Project code repository") }}</label>
      <input name="upstream" type="url" class="w-full mt-1 rounded-md border-gray-200 text-gray-700 shadow-sm"  maxlength="150" required >

      <label for="license" class="mt-5 block font-bold text-gray-700">{{ _("Link to the project's LICENSE") }}</label>
      <input name="license" type="url" class="w-full mt-1 rounded-md border-gray-200 text-gray-700 shadow-sm" required maxlength="250"></input>
  <span class="text-xs text-gray-600 font-bold">{{ _("The YunoHost project will only package free/open-source software (with possible case-by-case exceptions for apps which are not-totally-free)") }}</span>

      <label for="website" class="mt-5 block font-bold text-gray-700">{{ _("Project website") }}</label>
      <input name="website" type="url" class="w-full mt-1 rounded-md border-gray-200 text-gray-700 shadow-sm"  maxlength="150" >
      <span class="text-xs text-gray-600">{{ _("Please *do not* just copy-paste the code repository URL. If the project has no proper website, then leave the field empty.") }}</span>

      <button
        type="submit"
        class="block mx-auto btn btn-primary mt-5 {% if user %}hover:bg-blue-700{% endif %}"
        {% if not user %}disabled{% endif %}
      >
          {{ _("Submit") }}
      </button>

    </form>
    {% endif %}
</div>

{% endblock %}
