Merge branch 'pretty' of github.com:fnp/wolnelektury into pretty
authorRadek Czajka <radoslaw.czajka@nowoczesnapolska.org.pl>
Fri, 30 Dec 2011 08:45:20 +0000 (09:45 +0100)
committerRadek Czajka <radoslaw.czajka@nowoczesnapolska.org.pl>
Fri, 30 Dec 2011 08:45:20 +0000 (09:45 +0100)
Conflicts:
apps/catalogue/management/commands/importbooks.py
wolnelektury/templates/catalogue/book_detail.html
wolnelektury/templates/catalogue/book_short.html

1  2 
apps/catalogue/management/commands/importbooks.py
apps/catalogue/models.py
apps/catalogue/urls.py
wolnelektury/settings.py
wolnelektury/templates/catalogue/book_detail.html
wolnelektury/templates/catalogue/book_short.html

@@@ -42,10 -43,12 +43,11 @@@ class Command(BaseCommand)
          verbose = options.get('verbose')
          file_base, ext = os.path.splitext(file_path)
          book = Book.from_xml_file(file_path, overwrite=options.get('force'),
-                                   build_epub=options.get('build_epub'),
-                                   build_txt=options.get('build_txt'),
-                                   build_pdf=options.get('build_pdf'),
-                                   build_mobi=options.get('build_mobi'))
+                                                     build_epub=options.get('build_epub'),
+                                                     build_txt=options.get('build_txt'),
+                                                     build_pdf=options.get('build_pdf'),
+                                                     build_mobi=options.get('build_mobi'),
+                                                     search_index=options.get('search_index'))
 -        fileid = book.fileid()
          for ebook_format in Book.ebook_formats:
              if os.path.isfile(file_base + '.' + ebook_format):
                  getattr(book, '%s_file' % ebook_format).save(
@@@ -686,9 -724,22 +684,22 @@@ class Book(models.Model)
      def zip_audiobooks(self, format_):
          bm = BookMedia.objects.filter(book=self, type=format_)
          paths = map(lambda bm: (None, bm.file.path), bm)
 -        result = create_zip.delay(paths, "%s_%s" % (self.fileid(), format_))
 +        result = create_zip.delay(paths, "%s_%s" % (self.slug, format_))
          return result.wait()
  
+     def search_index(self, book_info=None):
+         if settings.CELERY_ALWAYS_EAGER:
+             idx = search.ReusableIndex()
+         else:
+             idx = search.Index()
+             
+         idx.open()
+         try:
+             idx.index_book(self, book_info)
+             idx.index_tags()
+         finally:
+             idx.close()
      @classmethod
      def from_xml_file(cls, xml_file, **kwargs):
          from django.core.files import File
Simple merge
Simple merge
@@@ -9,135 -9,8 +9,7 @@@
  {% block bodyid %}book-detail{% endblock %}
  
  {% block body %}
-     <h1>{% book_title book %}</h1>
  
-     <div id="books-list">
-         <div id='breadcrumbs'>
-             {% if categories.author %}
-                 {% for tag in categories.author %}
-                     <a href="{{ tag.get_absolute_url }}">{{ tag }}</a>{% if not forloop.last %}, {% endif %}
-                 {% endfor %}
-                 &#187; 
-             {% endif %}
-             {% for parent in parents %}
-                 <a href="{{ parent.get_absolute_url }}">{{ parent }}</a> &#187; 
-             {% endfor %}
-         </div>
+ {% book_wide book %}
  
-         {% if extra_info.license %}
-         <p>{% trans "Work is licensed under " %} <a href="{{ extra_info.license }}">{{ extra_info.license_description }}</a>.</p>
-         {% endif %}
-         <p>{% trans "Based on" %}: {{ extra_info.source_name }}</p>
-         {% if book.has_description %}
-             <div id="description">
-                 <div id='description-long'>{{ book.description|safe }}</div>
-                 <div id='description-short'>{{ book.description|safe|truncatewords_html:30 }}</div>
-             </div>
-             <div id="toggle-description"><p></p></div>
-         {% endif %}
-         <div id="formats">
-             <p class="change-sets">{% trans "Put a book" %} <span><a href="{% url catalogue.views.book_sets book.slug %}" class="jqm-trigger">{% trans "on the shelf!" %}</a></span></p>
-             <div class="clearboth"></div>
-             <div class="wrap">
-                 {% if book.has_html_file %}
-                     <a class="online" href="{% url book_text book.slug %}">{% trans "Read online" %}</a>
-                 {% endif %}
-                 <div class="download">
-                     {% if book.pdf_file %}
-                         <a href="{{ book.pdf_file.url }}"><img src="{{ STATIC_URL }}img/pdf.png" title="{% trans "Download PDF" %} &ndash; {% trans "for reading" %} {% trans "and printing using" %} Adobe Reader" %}" alt="{% trans "Download PDF" %}" /></a>
-                     {% endif %}
-                     {% if book.epub_file %}
-                         <a href="{{ book.epub_file.url }}"><img src="{{ STATIC_URL }}img/epub.png" title="{% trans "Download EPUB" %} &ndash; {% trans "for reading" %} {% trans "on mobile devices" %}" alt="{% trans "Download EPUB" %}" /></a>
-                     {% endif %}
-                     {% if book.mobi_file %}
-                         <a href="{{ book.mobi_file.url }}"><img src="{{ STATIC_URL }}img/mobi.png" title="{% trans "Download MOBI" %} &ndash; {% trans "for reading" %} {% trans "on mobile devices" %}" alt="{% trans "Download MOBI" %}" /></a>
-                     {% endif %}
-                     {% if book.txt_file %}
-                         <a href="{{ book.txt_file.url }}"><img src="{{ STATIC_URL }}img/txt.png" title="{% trans "Download TXT" %} &ndash; {% trans "for reading" %} {% trans "on small displays, for example mobile phones" %}" alt="{% trans "Download TXT" %}" /></a>
-                     {% endif %}
-                       
-                     {% if book.pdf_file %}
-                       <br/><a href="#" id="custom-pdf-link">{% trans "Dowload customized PDF" %}</a>.
-                   {% endif %}
-                       <div style="display: none" class="custom-pdf">
-                         <form action="{% url catalogue.views.download_custom_pdf book.slug %}" method="GET">
-                           {{custom_pdf_form.as_p}}
-                           <input type="submit" value="{% trans "Download" %}"/>
-                         </form>
-                       </div>
-                 </div>
-             </div>
-         </div>
-         {% if book_children %}
-         {% autopaginate book_children 10 %}
-         <div id="book-children">
-             <ol>
-             {% for book in book_children %}
-                 <li>{{ book.short_html }}</li>
-             {% endfor %}
-             </ol>
-         </div>
-         {% paginate %}
-         {% endif %}
-     </div>
--
-     <div id="tags-list">
-         <div id="book-info">
-             <h2>{% trans "Details" %}</h2>
-             <ul>
-                 <li>
-                     {% trans "Author" %}:
-                     {% for tag in categories.author %}
-                     <a href="{{ tag.get_absolute_url }}">{{ tag }}</a>{% if not forloop.last %}, {% endif %}
-                     {% endfor %}
-                 </li>
-                 <li>
-                     {% trans "Epoch" %}:
-                     {% for tag in categories.epoch %}
-                     <a href="{{ tag.get_absolute_url }}">{{ tag }}</a>{% if not forloop.last %}, {% endif %}
-                     {% endfor %}
-                 </li>
-                 <li>
-                     {% trans "Kind" %}:
-                     {% for tag in categories.kind %}
-                     <a href="{{ tag.get_absolute_url }}">{{ tag }}</a>{% if not forloop.last %}, {% endif %}
-                     {% endfor %}
-                 </li>
-                 <li>
-                     {% trans "Genre" %}:
-                     {% for tag in categories.genre %}
-                     <a href="{{ tag.get_absolute_url }}">{{ tag }}</a>{% if not forloop.last %}, {% endif %}
-                     {% endfor %}
-                 </li>              
-             </ul>
-             <h2>{% trans "Other resources" %}</h2>
-             <ul>
-                 {% if extra_info.source_url %}
-                 <li><a href="{{ extra_info.source_url }}">{% trans "Source of the book" %}</a></li>
-                 {% endif %}
-                 {% if extra_info.about and not hide_about %}
-                 <li><a href="{{ extra_info.about }}">{% trans "Book on the Editor's Platform" %}</a></li>
-                 {% endif %}
-                 {% if book.gazeta_link %}
-                 <li><a href="{{ book.gazeta_link }}">{% trans "Book description on Lektury.Gazeta.pl" %}</a></li>
-                 {% endif %}
-                 {% if book.wiki_link %}
-                 <li><a href="{{ book.wiki_link }}">{% trans "Book description on Wikipedia" %}</a></li>
-                 {% endif %}
-             </ul>
-             <p><a href="{{ book.xml_file.url }}">{% trans "View XML source" %}</a></p>
-             <p><a href="{% url poem_from_book book.slug %}">Miksuj ten utwór</a></p>
-         </div>
-         <div id="themes-list">
-             <h2>{% trans "Work's themes " %}</h2>
-             <ul>
-             {% for theme in book_themes %}
-                 <li><a href="{% url book_fragments book.slug theme.slug %}">{{ theme }} ({{ theme.count }})</a></li>
-             {% endfor %}
-             </ul>
-         </div>
-         <div class="clearboth"></div>
-     </div>
  {% endblock %}
@@@ -49,7 -51,7 +51,7 @@@
      <ul class="book-box-tools">
          <li class="book-box-read">
          {% if book.html_file %}
-             <a href="{% url book_text book.slug %}" class="mono">{% trans "Read online" %}</a>
 -            <a href="{% url book_text book.urlid %}" class="mono downarrow">{% trans "Read online" %}</a>
++            <a href="{% url book_text book.slug %}" class="mono downarrow">{% trans "Read online" %}</a>
          {% endif %}
          </li>
          <li class="book-box-download">