{% extends "admin/base.html" %}

{% block title %}Edit Note - StarPunk Admin{% endblock %}

{% block admin_content %}
<div class="note-editor">
  <h2>Edit Note</h2>
  <p class="note-meta">
    Slug: <code>{{ note.slug }}</code> |
    Created: {{ note.created_at.strftime('%B %d, %Y at %I:%M %p') }}
  </p>

  <form action="{{ url_for('admin.update_note_submit', note_id=note.id) }}" method="POST" class="note-form">
    <div class="form-group">
      <label for="content">Content (Markdown)</label>
      <textarea
        id="content"
        name="content"
        rows="20"
        required
        autofocus
      >{{ note.content }}</textarea>
      <small>Use Markdown syntax for formatting</small>
    </div>

    <div class="form-group form-checkbox">
      <input type="checkbox" id="published" name="published" {% if note.published %}checked{% endif %}>
      <label for="published">Published</label>
    </div>

    <div class="form-actions">
      <button type="submit" class="button button-primary">Update Note</button>
      <a href="{{ url_for('admin.dashboard') }}" class="button button-secondary">Cancel</a>
      <form action="{{ url_for('admin.delete_note_submit', note_id=note.id) }}" method="POST" class="delete-form" style="display: inline;" onsubmit="return confirm('Are you sure you want to delete this note? This cannot be undone.');">
        <input type="hidden" name="confirm" value="yes">
        <button type="submit" class="button button-danger">Delete Note</button>
      </form>
    </div>
  </form>
</div>
{% endblock %}

{% block head %}
{{ super() }}
<script src="https://cdn.jsdelivr.net/npm/marked/marked.min.js"></script>
<script src="{{ url_for('static', filename='js/preview.js') }}"></script>
{% endblock %}
