{% extends 'main_base.html' %}

{% block title %}
  Publish
{% endblock %}

{% block extra_head %}
  <link rel="stylesheet" href="/static/css/files/publish.css" />
  <script type="text/javascript">
$(function() {
  $('.createCopy').click(function(e) {
    e.preventDefault();
    var $this = $(this);
    var articleId = $(this).parents('li').attr("data-id");
    var articleTitle = prompt("Give your new article a name:");
//    alert(articleId);
    var url = "/edit/create_article/";
    if (articleTitle) {
      $.post(url, {
        'article_id': articleId,
        'article_name': articleTitle
        }, function(url) {
        window.location = url;
  //      $this.attr("href", url);
  //      $this.unbind("click");
      });
    }
  });
});

  </script>
{% endblock %}

{% block pageTitle %}
Publish
{% endblock %}

{% block content %}

    <div id="publishWrapper">
        <div id="publishBlockleft">
    
        <p>
Welcome to the publishing area of edgwareroad.org, and to our printing tool.
To use the tool, you have to be logged in. To test-run the tool, use the login:guest and password:guest.
        </p> <br/>
        <p>
Since the tool uses Html5 and features standard only in newer browsers, please note that the tool will only work in Firefox 3.5+, Google Chrome, and Safari. 
        </p><br/>
        <p>
If you are a participant looking to open a new account, please write to contact@edgwareroad.org.  A basic introduction to its features are found in our first publication, Instructions for Printing, here.
        </p>
        </div>
        <div id="publishBlockright">
        <h4 class="listHeader">Edit your own articles:</h4>
  <ul id="ownList">
    {% for o in own_list %}
      <li data-id="{{ o.id }}">
        <span class="articleTitle">{{ o.title }}</span> 
        {% if o.is_locked %} locked {% else %} <a href="{{ o.edit_url }}" title="Edit Article" target="_blank">edit</a> {% endif %}
        <a href="{{ o.web_url }}" title="View as Webpage" target="_blank">web</a> 
        <a href="#" class="createCopy">copy</a>
      </li>
    {% endfor %}
  </ul>
    <h4 class="listHeader">Create New Article - Pick a template and click 'copy':</h4>
    <ul id="templateList">
      {% for t in tmpl_list %}
      <li data-id="{{ t.id }}">
        <span class="articleTitle">{{ t.title }}</span> 
        {% if o.is_locked %} {% else %} <a href="{{ t.edit_url }}" title="Edit Article" target="_blank">edit</a> {% endif %}
        <a href="{{ t.web_url }}" title="View as Webpage" target="_blank">web</a> 
        <a href="#" class="createCopy">copy</a>
      </li>
      {% endfor %}
    </ul>
  
    <h4 class="listHeader">Create a copy of any existing published article:</h4>
    <ul id="publishedList">
      {% for p in pub_list %}
      <li data-id="{{ p.id }}">
        <span class="articleTitle">{{ p.title }}</span>
        <a href="{{ p.web_url }}" title="View as Webpage" target="_blank">web</a> 
        <a href="#" class="createCopy">copy</a>
      </li>
      {% endfor %}
    </ul>
 
        <br/>
        </div>    

    </div> 
  

{% endblock %}
