closed_fragments, open_fragments = html.extract_fragments(book.html_file.path)
book_themes = []
for fragment in closed_fragments.values():
- new_fragment = Fragment(html=fragment.to_string(), short_html=fragment.to_string(),
- anchor=fragment.id, book=book)
+ new_fragment = Fragment(html=fragment.to_string(), anchor=fragment.id, book=book)
theme_names = [s.strip() for s in fragment.themes.split(',')]
themes = []
class Fragment(models.Model):
html = models.TextField()
- short_html = models.TextField()
+ _short_html = models.TextField(editable=False)
anchor = models.IntegerField()
book = models.ForeignKey(Book, related_name='fragments')
-
+
objects = managers.ModelTaggedItemManager(Tag)
tags = managers.TagDescriptor(Tag)
+ def short_html(self):
+ if len(self._short_html):
+ return mark_safe(self._short_html)
+ else:
+ book_authors = [u'<a href="%s">%s</a>' % (tag.get_absolute_url(), tag.name)
+ for tag in self.book.tags if tag.category == 'author']
+
+ self._short_html = render_to_string('catalogue/fragment_short.html',
+ {'fragment': self, 'book': self.book, 'book_authors': book_authors})
+ self.save()
+ return mark_safe(self._short_html)
+
class Meta:
ordering = ('book', 'anchor',)
verbose_name = _('fragment')
return tagged_object_list(
request,
tag_model=models.Tag,
- queryset_or_model=models.Book,
+ queryset_or_model=model,
tags=tags,
template_name='catalogue/tagged_book_list.html',
extra_context = {'categories': categories },
$('#login-form').show();
});
+ $('.fragment-text').toggle(
+ function() { $(this).addClass('fragment-text-full').removeClass('fragment-text'); },
+ function() { $(this).addClass('fragment-text').removeClass('fragment-text-full'); }
+ ).hover(
+ function() { $(this).css({background: '#F3F3F3', cursor: 'pointer'}); },
+ function() { $(this).css({background: '#FFF'}); }
+ )
+
$('#registration-form').ajaxForm({
dataType: 'json',
beforeSubmit: function() {
# CSS and JS files to compress
COMPRESS_CSS = {
'all': {
- 'source_filenames': ('css/master.css', 'css/jquery.autocomplete.css',),
+ 'source_filenames': ('css/master.css', 'css/jquery.autocomplete.css', 'css/master.plain.css',),
'output_filename': 'css/all.min.css',
}
}
<h1>{{ book.title }}, {{ categories.author|join:", " }}</h1>
<form action="{% url main_page %}" method="get" accept-charset="utf-8" id="search-form">
<ol>
- {% for tag in tags %}
- <li class="category"><a href="{% catalogue_url tag %}">{{ tag }}</a> | <a href="{% catalogue_url tags -tag %}">x</a></li>
- {% endfor %}
- <li class="book-title">{{ book.title }} | <a href="{% catalogue_url tags %}">x</a></li>
+ {# {% for tag in tags %} #}
+ {# <li class="category"><a href="{% catalogue_url tag %}">{{ tag }}</a> | <a href="{% catalogue_url tags -tag %}">x</a></li> #}
+ {# {% endfor %} #}
+ <li class="book-title">{{ book.title }} | <a href="{% url main_page %}">x</a></li>
</ol>
</form>