def gallery_url(self):
return gallery_url(self.slug)
+ def get_first_text(self):
+ if self.html_file:
+ return self
+ child = self.children.all().order_by('parent_number').first()
+ if child is not None:
+ return child.get_first_text()
+
+ def get_last_text(self):
+ if self.html_file:
+ return self
+ child = self.children.all().order_by('parent_number').last()
+ if child is not None:
+ return child.get_last_text()
+
+ def get_prev_text(self):
+ if not self.parent:
+ return None
+ sibling = self.parent.children.filter(parent_number__lt=self.parent_number).order_by('-parent_number').first()
+ if sibling is not None:
+ return sibling.get_last_text()
+ return self.parent.get_prev_text()
+
+ def get_next_text(self):
+ if not self.parent:
+ return None
+ sibling = self.parent.children.filter(parent_number__gt=self.parent_number).order_by('parent_number').first()
+ if sibling is not None:
+ return sibling.get_first_text()
+ return self.parent.get_next_text()
+
+ def get_siblings(self):
+ if not self.parent:
+ return []
+ return self.parent.children.all().order_by('parent_number')
+
@property
def name(self):
return self.title
{% endif %}
<li id="menu-toc">
- <a href="#" data-box="toc">
+ <a href="#" data-box="wltoc">
<span class="label">{% trans "Table of contents" %}</span>
</a>
</li>
{% block big-pane %}
<article id="main-text">
- {{ book_text|safe }}
+ {% with next=book.get_next_text prev=book.get_prev_text %}
+ {% if next %}
+ <a style="float:right; padding: 1em;" href="{% url 'book_text' next.slug %}">{{ next.title }} →</a>
+ {% endif %}
+ {% if prev %}
+ <a style="display:inline-block;padding: 1em;" href="{% url 'book_text' prev.slug %}">← {{ prev.title }}</a>
+ {% endif %}
+ {{ book_text|safe }}
+ {% endwith %}
</article>
+
+
<article id="other-text">
<a class="other-text-close" href="#">{% trans "Close" %}</a>
<div id="other-text-waiter">{% trans "Please wait..." %}</div>
</article>
{% endblock big-pane %}
-
{% block footer %}
+ <div id="wltoc" class="box">
+ {% if book.parent %}
+ {% for b in book.ancestor.all %}
+ {% if forloop.counter > 1 %}
+ <li>
+ {% endif %}
+ <a href="{{ b.get_absolute_url }}">{{ b.title }}</a>
+ <ol>
+ {% endfor %}
+ {% for b in book.get_siblings %}
+ <li>
+ {% if b == book %}
+ <strong>{{ b.title }}</strong>
+ <div id="heretoc"></div>
+ {% else %}
+ <a href="{% url 'book_text' b.slug %}">{{ b.title }}</a>
+ {% endif %}
+ </li>
+ {% endfor %}
+
+ {% for b in book.ancestor.all %}
+ </ol>
+ {% if not forloop.counter.last %}
+ </li>
+ {% endif %}
+ {% endfor %}
+ {% else %}
+ <strong>{{ book.title }}</strong>
+ <div id="heretoc"></div>
+ {% endif %}
+ </div>
+
<div id="info" class="box">
{% book_info book %}
</div>
def get_mp3_length(path):
from mutagen.mp3 import MP3
return int(MP3(path).info.length)
+
+
+def set_file_permissions(self, fieldfile):
+ if fieldfile.instance.preview:
+ fieldfile.set_readable(False)
+
}
-#toc, #themes, #nota_red, #info, #other-versions, #objects {
+#wltoc, #themes, #nota_red, #info, #other-versions, #objects {
position: fixed;
left: 0;
top: 1.5em;
z-index: 99;
}
-#toc ol, #themes ol, #objects ol {
+#wltoc ol, #themes ol, #objects ol {
list-style: none;
padding: 0;
margin: 0;
}
-#toc ol li {
+#wltoc ol li {
font-weight: bold;
}
-#toc ol ol {
+#wltoc ol ol {
padding: 0 0 1.5em 1.5em;
margin: 0;
}
-#toc ol ol li {
+#wltoc ol ol li {
font-weight: normal;
}
-#toc h2 {
+#wltoc h2 {
display: none;
}
-#toc .anchor {
+#wltoc .anchor {
float: none;
margin: 0;
color: blue;
/* ================================== */
/* = Header with logo and menu = */
/* ================================== */
-#toc ol, #themes ol, #objects ol {
+#wltoc ol, #themes ol, #objects ol {
list-style: none;
padding: 0;
margin: 0;
}
-
-#toc ol li {
- font-weight: bold;
+#wltoc ol {
+ padding-left: 1.5em;
}
-#toc ol ol {
+#wltoc ol ol {
padding: 0 0 1.5em 1.5em;
margin: 0;
}
-#toc ol ol li {
+#wltoc ol ol li {
font-weight: normal;
}
-#toc h2 {
+#wltoc h2 {
display: none;
}
-#toc .anchor {
+#wltoc .anchor {
float: none;
margin: 0;
color: blue;
}
$.highlightFade.defaults.speed = 3000;
- $('#toc').hide();
- if ($('#toc li').length == 0) {
- $('#menu li a[href="#toc"]').remove();
- }
if ($('#themes li').length == 0) {
$('#menu li a[href="#themes"]').remove();
}
(function($){$(function(){
+ if ($("#toc a").length > 0) {
+ $("#toc > ol").appendTo($("#heretoc"));
+ }
-if ($('#toc li').length > 0) {
- $('#menu-toc').show();
-}
+ if ($('#wltoc li').length > 0) {
+ $('#menu-toc').show();
+ }
+ if ($('#wltoc li a').length == 0) {
+ $('#menu li a[href="#wltoc"]').remove();
+ }
+
+ $("#toc").remove();
})})(jQuery);
top: 0;
right: 0;
+ box-sizing: border-box;
max-height: 100%;
- @include size(max-width, 380px);
+ @include size(max-width, 400px);
@include size(padding, 10px 10px 30px 10px);
margin: 0;
overflow-x: hidden;