<form id=“post-form” action=“<%== @form_action %>” method=“post”>

<fieldset class="default">
  <div class="field">
    <label for="name">Name</label>
    <input type="text" name="name" id="name" class="name-post"
        maxlength="64" value="<%== @post ? @post.name : '' %>" />

    <% if @post; @post.errors.on_field(:name).each do |error| %>
      <p class="flash error"><%== error %></p>
    <% end; end %>
  </div>

  <div class="field">
    <label for="title">Title</label>
    <input type="text" name="title" id="title" class="title-post"
        maxlength="255" value="<%== @post ? @post.title : '' %>" />

    <% if @post; @post.errors.on_field(:title).each do |error| %>
      <p class="flash error"><%== error %></p>
    <% end; end %>
  </div>

  <div class="field">
    <label for="body">Body</label>
    <textarea name="body" id="body" rows="15" cols="60"><%== @post ? @post.body : '' %></textarea>

    <% if @post; @post.errors.on_field(:body).each do |error| %>
      <p class="flash error"><%== error %></p>
    <% end; end %>
  </div>

  <div class="field">
    <label for="tags">Tags</label>
    <input type="text" name="tags" id="tags" class="tags-input"
        maxlength="255" value="<%== @post ? @post.tags.collect{|i| i.name }.join(', ') : '' %>" />

    <% if @post; @post.errors.on_field(:tags).each do |error| %>
      <p class="flash error"><%== error %></p>
    <% end; end %>
  </div>

  <fieldset>
    <legend>Options</legend>

    <input type="checkbox" value="1" id="allow_comments" name="allow_comments" <%= !@post || @post.allow_comments ? 'checked="checked"' : '' %>/>
    <label for="allow_comments">Allow comments on this post</label>
  </fieldset>
</fieldset>

<p class="buttons">
  <input type="hidden" name="token" value="<%== form_token %>" />
  <% if !@post || @post.is_draft %>
    <input type="submit" name="action" value="Save &amp; Preview" />
  <% else %>
    <input type="submit" name="action" value="Preview" />
    <input type="submit" name="action" value="Unpublish &amp; Save as Draft">
  <% end %>
  <input type="submit" name="action" value="Publish" />
</p>

</form>

<h3>Hey, look! Tips!</h3>

<ul class=“tips”>

<li>
  Use
  <a href="http://redcloth.org/textile" target="_blank">Textile</a>
  or XHTML for formatting.
</li>
<li>
  Separate tags with commas, like this: <kbd>monkeys, pirates,
  pirate monkeys, ninjas</kbd>
</li>
<li>
  To link to another page on this site, use wiki-style links like
  <kbd>[[pagename]]</kbd> or <kbd>[[pagename|link text]]</kbd>.
</li>
<li>
  To link to a blog post, use a link like
  <kbd>[[@postname_or_id]]</kbd> or
  <kbd>[[@postname_or_id|link text]]</kbd>.
</li>

</ul>