f534cd6951fe6fbff5bff059323d68c8e1a90706
[redakcja.git] / src / documents / templates / documents / book_detail.html
1 {% extends "documents/base.html" %}
2 {% load book_list i18n %}
3 {% load bootstrap4 %}
4 {% load depot %}
5
6
7 {% block titleextra %}{{ book.title }}{% endblock %}
8
9
10 {% block content %}
11
12   <div class="card mt-4">
13     <div class="card-header">
14       <h1>{{ book.title }}</h1>
15     </div>
16     <div class="card-body">
17       <div class="row">
18         <div class="col-md-8">
19
20
21           {% if editable %}<form method='POST'>{% csrf_token %}{% endif %}
22             {% bootstrap_form form %}
23             {% if editable %}
24               {% buttons %}
25               <button type="submit" class="btn btn-primary">{% trans "Save" %}</button>
26         {% endbuttons %}
27             {% endif %}
28             {% if editable %}</form>{% endif %}
29
30             {% if editable %}
31               {% if book.gallery %}
32                 <p><a href="{% url 'documents_book_gallery' book.slug %}">{% trans "Edit gallery" %}</a></p>
33               {% endif %}
34
35               <p style="text-align:right"><a class="btn btn-sm btn-danger" href="{% url 'documents_book_append' book.slug %}">{% trans "Append to other book" %}</a></p>
36             {% endif %}
37
38
39         </div>
40         <div class="col-md-4">
41           {% with cbook=book.catalogue_book %}
42             {% if cbook %}
43               W katalogu:
44               <a href="{% url 'catalogue_book' cbook.slug %}">{{ cbook }}</a>
45             {% endif %}
46           {% endwith %}
47         </div>
48       </div>
49     </div>
50   </div>
51
52   <div class="card mt-4">
53     <div class="card-header">
54       <h2>{% trans "Chunks" %}</h2>
55     </div>
56     <div class="card-body">
57
58       <table class='single-book-list table'><tbody>
59         {% for chunk in book %}
60           {% include 'documents/book_list/chunk.html' %}
61         {% endfor %}
62       </tbody></table>
63     </div>
64   </div>
65
66
67
68
69   <div class='card mt-4'>
70
71     <div class="card-header">
72       <h2>{% trans "Publication" %}</h2>
73     </div>
74     <div class="card-body">
75       <div class="row">
76         <div class="col-lg-3">
77           <img class="cover-preview" src="{% url 'cover_preview' book.slug %}" />
78           {% if book.dc_cover_image %}
79             <a href="{{ book.dc_cover_image.get_absolute_url }}">{{ book.dc_cover_image }}</a>
80           {% endif %}
81           <br><br>
82
83           <form action="{% url 'cover_quick_import' book.pk %}" method="post">
84             {% csrf_token %}
85             <div class="input-group">
86               <input type="url" name="url" class="form-control" placeholder="URL okładki">
87               <button type="submit" class="btn btn-sm btn-info">Ustaw</button>
88             </div>
89           </form>
90
91
92           <br><br>
93           <form action="{% url 'cover_preview' book.slug %}">
94             <input type="hidden" name="download" value="1">
95             Pobierz okładkę:
96             <div class="input-group">
97               <select class="form-control" name='cover_class'>
98                 <option value="default">nowa</option>
99                 <option value="m-label">nowa + label</option>
100                 <option value="legacy">dawna</option>
101               </select><br>
102               <input class="form-control" name="width" type="number" required value="600" size="3" placeholder="szer.">
103               <input class="form-control" name="height" type="number" size="3" placeholder="wys.">
104               <button type="submit" class="btn btn-sm btn-primary">🡇</button>
105             </div>
106           </form>
107         </div>
108         <div class="col-lg-9">
109           <p>{% trans "Last published" %}:
110             {% if book.last_published %}
111               {{ book.last_published }}
112             {% else %}
113               &mdash;
114             {% endif %}
115           </p>
116
117           {% if publishable %}
118             <p>
119               <a href="{% url 'documents_book_xml' book.slug %}" rel="nofollow">{% trans "Full XML" %}</a><br/>
120               <a target="_blank" href="{% url 'documents_book_html' book.slug %}" rel="nofollow">{% trans "HTML version" %}</a><br/>
121               <a href="{% url 'documents_book_txt' book.slug %}" rel="nofollow">{% trans "TXT version" %}</a><br/>
122               <a href="{% url 'documents_book_pdf' book.slug %}" rel="nofollow">{% trans "PDF version" %}</a><br/>
123               <a href="{% url 'documents_book_pdf_mobile' book.slug %}" rel="nofollow">{% trans "PDF version for mobiles" %}</a><br/>
124               <a href="{% url 'documents_book_epub' book.slug %}" rel="nofollow">{% trans "EPUB version" %}</a><br/>
125               <a href="{% url 'documents_book_mobi' book.slug %}" rel="nofollow">{% trans "MOBI version" %}</a><br/>
126             </p>
127
128             {% if user.is_authenticated %}
129               <!--
130                    Angel photos:
131                    Angels in Ely Cathedral (http://www.flickr.com/photos/21804434@N02/4483220595/) /
132                    mira66 (http://www.flickr.com/photos/21804434@N02/) /
133                    CC BY 2.0 (http://creativecommons.org/licenses/by/2.0/)
134               -->
135               <form method="POST" action="{% url 'documents_publish' book.slug %}">{% csrf_token %}
136                 {{ publish_options_form.as_p }}
137                 <img src="{{ STATIC_URL }}img/angel-left.png" style="vertical-align: middle" />
138                 <button id="publish-button" type="submit">
139                   <span>{% trans "Publish" %}</span></button>
140                 <img src="{{ STATIC_URL }}img/angel-right.png" style="vertical-align: middle" />
141               </form>
142
143
144               {% if perms.depot.add_sitebookpublish %}
145                 {% depot_sites book as sites %}
146                 {% for site in sites %}
147                   <hr>
148                   <h3 class="mb-3">{{ site.name }}</h3>
149                   {% if not site.errors %}
150                     <form method="post" action="{% url 'depot_site_publish' site.site_id book.pk %}">
151                       {% csrf_token %}
152                       <button class="btn btn-primary mb-3" type="submit">
153                         Opublikuj na {{ site.name }}
154                       </button>
155                     </form>
156                     {% for info in site.info %}
157                       <div class="alert alert-info">
158                         {{ info }}
159                       </div>
160                     {% endfor %}
161                   {% else %}
162                     {% for error in site.errors %}
163                       <div class="alert alert-danger">
164                         {{ error }}
165                       </div>
166                     {% endfor %}
167                   {% endif %}
168                   {% for warning in site.warnings %}
169                     <div class="alert alert-warning">
170                       {{ warning }}
171                     </div>
172                   {% endfor %}
173                   {% if site.id %}
174                     id:{{ site.id }}
175                   {% endif %}
176                   {% with last=site.last %}
177                   {% if last %}
178                     {{ last.created_at }} &rarr;
179                     {{ last.started_at }} &rarr;
180                     {{ last.finished_at }}
181                     <span title="{{ last.error }}">
182                       ({{ last.get_status_display }})
183                     </span>
184                     <!-- {{ site.last.id }} -->
185                   {% endif %}
186                   {% endwith %}
187                 {% endfor %}
188               {% endif %}
189
190             {% else %}
191               <a href="{% url 'cas_ng_login' %}">{% trans "Log in to publish." %}</a>
192             {% endif %}
193           {% else %}
194             <p>{% trans "This book can't be published yet, because:" %}</p>
195             <ul><li>{{ publishable_error }}</li></ul>
196           {% endif %}
197         </div>
198       </div>
199     </div>
200   </div>
201
202
203   {% if stats %}
204     <div class="card mt-4">
205       <div class="card-header">
206         <h2>{% trans "Statistics" %}</h2>
207       </div>
208       <div class="card-body">
209         <table class="table">
210           <thead>
211             <tr>
212               <th>
213                 {% trans "book" %}
214               </th>
215               <th>{% trans "characters" %}</th>
216               <th>{% trans "characters (with footnotes)" %}</th>
217               <th>{% trans "words" %}</th>
218               <th>{% trans "words (with footnotes)" %}</th>
219               <th>{% trans "wiersze (+ inne znaki)" %}</th>
220               <th>{% trans "wiersze (+ inne znaki, z przypisami)" %}</th>
221             </tr>
222           </thead>
223           <tbody>
224             {% include 'documents/book_stats.html' with book=doc stats=stats depth=0 %}
225         </tbody>
226       </table>
227     </div>
228   </div>
229 {% endif %}
230 {% endblock content %}