{% extends request.base_template -%}

{% block title %}{{ the_title }} | {{ request.domain }}{%- endblock -%}
{% block content -%}

<h3>{{ the_title }}</h3>

<p>
Import comments and threads from WordPress, Disqus, or pre-formatted JSON exports using the
<a href="https://github.com/russellballestrini/blog-to-json" target="_blank" rel="nofollow">blog-to-json</a> tool.
</p>

<section class="well" style="text-align: left;">
<h4>How to Use</h4>

<ol>
<li><b>Export your comments:</b>
  <ul>
    <li>Install the blog-to-json tool: <code>pip install blog-to-json</code></li>
    <li>Use blog-to-json to convert your export file to JSON format</li>
    <li>See the <a href="https://github.com/russellballestrini/blog-to-json" target="_blank" rel="nofollow">tool documentation</a> for supported platforms and usage</li>
  </ul>
</li>
<li><b>Automatic user creation:</b>
  <ul>
    <li>Comments with email addresses will create or match existing users</li>
    <li>Comments without email addresses will create surrogate users (guest users specific to your namespace)</li>
    <li>All imported users will be tagged with a unique timestamp to identify them as imported from this session</li>
  </ul>
</li>
<li><b>Upload and import:</b> Select your JSON file and click "Import Comments".</li>
</ol>

<p><b>Note:</b> The import process will:
<ul>
  <li>Create threads for each unique URL in your export</li>
  <li>Create or find existing users by email address</li>
  <li>Import all comments with their timestamps and hierarchy</li>
  <li>Mark all imported comments as verified</li>
</ul>
</p>

<p><b>Get the tool:</b> <a href="https://github.com/russellballestrini/blog-to-json" target="_blank" rel="nofollow">https://github.com/russellballestrini/blog-to-json</a></p>
</section>

<br>

<form method="post" action="{{ request.link_prefix }}/ns/{{ request.namespace.name }}/import-comments" enctype="multipart/form-data" onsubmit="submit.disabled = true; submit.value = 'Importing...'; return true;">

<label>JSON File:</label>
<input type="file" name="json-file" id="json-file" accept=".json" required class="common-text-input"></input>
<br>
<small>Select the JSON file generated by blog-to-json</small>
<br>
<br>

<label for="group-prefix">Group Postfix (required):</label>
<input type="text" name="group-prefix" id="group-prefix" value="{{ default_prefix }}" class="common-text-input" placeholder="{{ default_prefix }}" minlength="2" maxlength="6" required {% if postfix_locked %}disabled{% endif %}></input>
<br>
{% if postfix_locked %}
<small><b>Locked:</b> This namespace is using the permanent postfix "<b>{{ default_prefix }}</b>". All imported users will be tagged with this postfix (e.g., "Anonymous-{{ default_prefix }}"). Re-uploading will reuse existing users with this postfix.</small>
{% else %}
<small>Short postfix (2-6 alphanumeric chars) to tag imported users. Auto-generated from your namespace domain, but you can customize it. <b>Once used, this postfix becomes permanent.</b> Re-uploading with the same postfix will reuse existing users.</small>
{% endif %}
<br>
<br>

{% include 'snippets/csrf.j2' %}

<br>

{% set submit_button_classes = 'button-right green-button' %}
{% set submit_button_value = 'Import Comments' %}
{% include 'snippets/submit.j2' %}

</form>

<br>
<br>

<a href="{{ request.link_prefix }}/ns/{{ request.namespace.name }}/settings">Back to Namespace Settings</a>

{%- endblock -%}
