help='Don\'t build TXT file'),
make_option('-P', '--no-build-pdf', action='store_false', dest='build_pdf', default=True,
help='Don\'t build PDF file'),
+ make_option('-S', '--no-search-index', action='store_false', dest='search_index', default=True,
+ help='Don\'t build PDF file'),
make_option('-w', '--wait-until', dest='wait_until', metavar='TIME',
help='Wait until specified time (Y-M-D h:m:s)'),
)
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_mobi=options.get('build_mobi'),
+ search_index=options.get('search_index'))
files_imported += 1
if os.path.isfile(file_base + '.pdf'):
from sortify import sortify
from os import unlink
+import search
+
TAG_CATEGORIES = (
('author', _('author')),
('epoch', _('epoch')),
result = create_zip.delay(paths, self.slug)
return result.wait()
+ def search_index(self):
+ with search.Index() as idx:
+ idx.index_book(self)
+
@classmethod
def from_xml_file(cls, xml_file, **kwargs):
# use librarian to parse meta-data
@classmethod
def from_text_and_meta(cls, raw_file, book_info, overwrite=False,
- build_epub=True, build_txt=True, build_pdf=True, build_mobi=True):
+ build_epub=True, build_txt=True, build_pdf=True, build_mobi=True,
+ search_index=True):
import re
# check for parts before we do anything
if not settings.NO_BUILD_MOBI and build_mobi:
book.build_mobi()
+ if not settings.NO_SEARCH_INDEX and search_index:
+ book.search_index()
+
book_descendants = list(book.children.all())
# add l-tag to descendants and their fragments
# delete unnecessary EPUB files
# Example: "/home/media/media.lawrence.com/"
MEDIA_ROOT = path.join(PROJECT_DIR, '../media')
STATIC_ROOT = path.join(PROJECT_DIR, 'static')
+SEARCH_INDEX = path.join(MEDIA_ROOT, 'search')
# URL that handles the media served from MEDIA_ROOT. Make sure to use a
# trailing slash if there is a path component (optional in other cases).
'sponsors',
'stats',
'suggest',
+ 'search',
+
+ #
+ 'django_nose',
]
#CACHE_BACKEND = 'locmem:///?max_entries=3000'
NO_BUILD_TXT = False
NO_BUILD_PDF = False
NO_BUILD_MOBI = False
+NO_SEARCH_INDEX = False
ALL_EPUB_ZIP = 'wolnelektury_pl_epub'
ALL_PDF_ZIP = 'wolnelektury_pl_pdf'
BROKER_VHOST = "/"
+
# Load localsettings, if they exist
try:
from localsettings import *