{% extends "blogango/admin/base.html" %}
{% block title %}
    {% if entry %}
        Editing entry:: {{ entry_form.initial.title }}
    {% else %}
        New Entry
    {% endif %}
    &#8203;{{ title_suffix }}
{% endblock %}
{% block page_head %}
<link rel="stylesheet" type="text/css" href="{{STATIC_URL}}admin/css/base.css" />
<link rel="stylesheet" type="text/css" href="{{STATIC_URL}}admin/css/forms.css" />

<script type="text/javascript" src="/admin/jsi18n/"></script>
<script type="text/javascript" src="{{STATIC_URL}}admin/js/core.js"></script>
<script type="text/javascript" src="{{STATIC_URL}}admin/js/calendar.js"></script>
<script type="text/javascript" src="{{STATIC_URL}}admin/js/admin/DateTimeShortcuts.js"></script>
{% endblock %}
{% block extra_script %}
    <script>
        $(document).ready(function(){
            var tags_json = '{{tags_json|safe}}';
            var tag_list = JSON.parse(tags_json);
            $("#id_tags").autocomplete(tag_list, {
                multiple: true
            });
        });
    </script>
{% endblock %}
{% block subnavbar %}
    <ul class="ctxnavbar">
      <li{% if 'page' not in request.GET %} class="active"{% endif %}>
          <a href="{{ request.path }}">Entry</a>
      </li>
      <li{% if 'page' in request.GET %} class="active"{% endif %}>
          <a href="{{ request.path }}?page">Page</a>
      </li>
    </ul>
{% endblock %}
{% block contents %}
      <div class="notification-messages">      
	    {% if 'done' in request.GET %}
	        <div class="message message-info">Blog entry saved successfully</div>
	    {% endif %}
      </div>
    {% if entry %}
        <h1>
            {{ entry.title }} &mdash; &#8203; Edit Entry
            {% if entry.is_published %}
                <a href="{{ entry.get_absolute_url }}" class="preview">{{ _("View Entry") }}</a>
            {% else %}
                <a href="{{ entry.get_absolute_url }}?preview" class="preview" target="_blank">{{ _("Preview Entry") }}</a>
            {% endif %}
        </h1>
    {% endif %}
    {% if entry_form.errors %}
        Please correct the following errors:
        <ul class="errors">
            {% for field, error in entry_form.errors.iteritems %}
                <li>{{ field }} {{ error.as_text }}</li>
            {% endfor %}
        </ul>
    {% endif %}
    <form method="POST">
        {% csrf_token %}
		<div class="formbox formbox-title">
		      <h3><label for="id_title">Title</label></h3>
		      {{ entry_form.title }}
		</div>
		<div class="formbox">
		      <h3><label for="id_text">Text</label></h3>
		      {{ entry_form.text }}
		</div>
		<div class="formbox">
		      <h3><label for="id_text_markup_type">Markup Parser</label></h3>
		      {{ entry_form.text_markup_type }}
		</div>
		<div class="formbox">
		      <h3><label for="id_tags">Tags</label></h3>
		      {{ entry_form.tags }}
		</div>
		<div class="formbox toggleable collapsed">
		      <h3><label for="id_created_by">Author</label></h3>
		      {{ entry_form.created_by }}
		</div>	
		<div class="formbox">
		      <h3><label for="id_published_date">Publish date</label></h3>
              {{ entry_form.publish_date }}
		</div>
		<div class="formbox toggleable collapsed">
		      <h3><label for="id_meta_keywords">Keywords</label></h3>
		      {{ entry_form.meta_keywords }}
		</div>
		<div class="formbox toggleable collapsed">
		      <h3><label for="id_meta_description">Description</label></h3>
		      {{ entry_form.meta_description }}
		</div>
		<div class="formbox">
		      <h3><label for="id_comments_allowed">Allow Comments?</label></h3>
		      {{ entry_form.comments_allowed }}
		</div>
		{% if 'page' in request.GET %}
		    <input type="hidden" name="page" value="1" />
		{% endif %}
		<div class="secondary">
		  <div class="actions">
		    <input type="submit" value="{% if entry.is_published %}Unpublish{% else %}Save{% endif %}" name="save">
		    <input type="submit" value="Save and Publish" name="publish">
		    <input type="reset" value="Cancel" name="cancel">
		  </div>
		</div>
	</form>
{% endblock %}
