<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"
      xmlns:tal="http://xml.zope.org/namespaces/tal"
      xmlns:metal="http://xml.zope.org/namespaces/metal"
      xmlns:i18n="http://xml.zope.org/namespaces/i18n"
      lang="en"
      metal:use-macro="context/main_template/macros/master"
      i18n:domain="xmldirector.plonecore">
<body>


<metal:main fill-slot="content-core">
    <metal:content-core define-macro="content-core">

        <style type="text/css">
            div.row {
                margin-bottom: 1em;
            }
            div.row label {
                display: inline-block;
                width: 100px;
            }
            div.row label.format {
                width: 40px;
                display: inline;
                margin-right: 1em;
            }
            div.row input[type="submit"] {
                padding: 0.5em;
                font-weight: bold;
            }
            div.row input[type="text"] {
                width: 500px !important;
            }

            legend {
                font-size: 1.4em !important;
                font-weight: bold;
            }

            img.preview {
                max-width: 150px;
            } 


            .left {
                float: left;
                width: 50%;
            }

            .right {
                float: right;
                width: 40%;
                padding-left: 1em;
                padding-top: 1em;
           }

           .clear {
               clear: both;
               margin-bottom: 2em;
           }



        </style>

        <h2 i18n:translate="">Bookalope</h2>

        <form method="post" class="left" tal:attributes="action string:${context/absolute_url}/bookalope-upload-source" enctype="multipart/form-data">
            <fieldset>
                <legend i18n:translate="">Source document upload (DOCX/ICML)</legend>
                <div class="row">
                    <input type="file" name="source" size="60"/>
                </div>
                <div class="row">
                    <input type="submit" value="Upload" i18n:attributes="value"/>
                </div>
            </fieldset>
        </form>

        <div class="right">
            <label i18n:translate="">Source files</label>
            <a tal:attributes="href string:${context/absolute_url}/@@bookalope-cleanup-sources"
                i18n:translate="">
                Cleanup source files
            </a>
            <ul>
                <li tal:repeat="name view/get_source_files">
                    <a tal:content="name"
                        tal:attributes="href string:${context/absolute_url}/@@view/$name"/>
                </li>
            </ul>
        </div>

        <div class="clear"></div>

        <form method="post" class="left" tal:attributes="action string:${context/absolute_url}/bookalope-upload-cover" enctype="multipart/form-data">
            <fieldset>
                <legend i18n:translate="">Cover upload (PNG/JPG/GIF)</legend>
                <div class="row">
                    <input type="file" name="source" size="60"/>
                </div>
                <div class="row">
                    <input type="submit" value="Upload" i18n:attributes="value"/>
                </div>
            </fieldset>
        </form>

        <div class="right">    
            <label i18n:translate="">Cover files</label>
            <a tal:attributes="href string:${context/absolute_url}/@@bookalope-cleanup-covers"
                i18n:translate="">
                Cleanup cover files
            </a>
            <ul>
                <li tal:repeat="name view/get_cover_files">
                    <a tal:attributes="href string:${context/absolute_url}/@@view/$name">
                        <img class="preview" tal:attributes="src string:${context/absolute_url}/@@view/$name" />
                        <br/>
                        <span tal:content="name"/>
                    </a>
                </li>
            </ul>
        </div>

        <div class="clear"></div>

        <form method="post" class="left" tal:attributes="action string:${context/absolute_url}/bookalope-convert">
            <fieldset>
                <legend i18n:translate="">Convert using bookalope.net web service</legend>
                <div class="row">
                    <label i18n.translate="" for="title">Title</label>
                    <input type="text" name="title" id="title" size="60" tal:attributes="value context/Title | nothing"/>
                </div>
                <div class="row">
                    <label i18n.translate="" for="author">Author</label>
                    <input type="text" name="author" id="author" size="60"/>
                </div>
                <div class="row">
                    <label i18n.translate="" for="author">Source</label>
                    <select name="source">
                        <option tal:repeat="name view/get_source_files"
                            tal:attributes="value name"
                            tal:content="name"
                            />
                    </select>
                </div>
                <div class="row">
                    <label i18n.translate="" for="author">Cover</label>
                    <select name="cover">
                        <option tal:repeat="name view/get_cover_files"
                            tal:attributes="value name"
                            tal:content="name"
                            />
                    </select>
                </div>
                <div class="row">
                    <label i18n:translate="" for="formats">Formats</label>
                    <input type="checkbox" name="formats:list" value="epub" checked="checked"/>
                    <label class="format">EPUB</label>
                    <input type="checkbox" name="formats:list" value="epub3"/>
                    <label class="format">EPUB3</label>
                    <input type="checkbox" name="formats:list" value="mobi"/>
                    <label class="format">Mobi</label>
                    <input type="checkbox" name="formats:list" value="pdf"/>
                    <label class="format">PDF</label>
                    <input type="checkbox" name="formats:list" value="icml"/>
                    <label class="format">ICML</label>
                    <input type="checkbox" name="formats:list" value="docx"/>
                    <label class="format">DOCX</label>
                </div>
                <div class="row">
                    <input type="submit" value="Convert" i18n:attributes="value"/>
                </div>
            </fieldset>
        </form>

        <div class="right">
            <label i18n:translate="">Generated files</label>
            <a tal:attributes="href string:${context/absolute_url}/@@bookalope-cleanup"
                i18n:translate="">
                Cleanup generated files
            </a>
            <ul>
                <li tal:repeat="name view/get_generated_files">
                    <a tal:content="name"
                        tal:attributes="href string:${context/absolute_url}/@@view/$name"/>
                </li>
            </ul>

        </div>

  </metal:content-core>
</metal:main>

</body>
</html>

