Removed non working search from epub viewer

This commit is contained in:
OzzieIsaacs 2016-11-01 18:49:47 +01:00
parent 313116dca7
commit a6b6700a73
3 changed files with 43 additions and 47 deletions

View File

@ -1,7 +1,7 @@
EPUBJS.reader.search = {};
// Search Server -- https://github.com/futurepress/epubjs-search
EPUBJS.reader.search.SERVER = "https://pacific-cliffs-3579.herokuapp.com";
EPUBJS.reader.search.SERVER = "";
EPUBJS.reader.search.request = function(q, callback) {
var fetch = $.ajax({

View File

@ -73,19 +73,15 @@
<!-- Plugins -->
<!-- <script src="js/plugins/search.js"></script> -->
<script src="{{ url_for('static', filename='js/plugins/search.js') }}"></script>
<!-- Highlights -->
<!-- <script src="js/libs/jquery.highlight.js"></script> -->
<!-- <script src="js/hooks/extensions/highlight.js"></script> -->
<!--script src="{{ url_for('static', filename='js/plugins/search.js') }}"></script-->
</head>
<body>
<div id="sidebar">
<div id="panels">
<input id="searchBox" placeholder="search" type="search">
<!--input id="searchBox" placeholder="search" type="search"-->
<a id="show-Search" class="show_view icon-search" data-view="Search">Search</a>
<!--a id="show-Search" class="show_view icon-search" data-view="Search">Search</a-->
<a id="show-Toc" class="show_view icon-list-1 active" data-view="Toc">TOC</a>
<a id="show-Bookmarks" class="show_view icon-bookmark" data-view="Bookmarks">Bookmarks</a>
<a id="show-Notes" class="show_view icon-edit" data-view="Notes">Notes</a>

View File

@ -548,45 +548,45 @@ def read_book(book_id,format):
book_dir = os.path.join(config.MAIN_DIR, "cps","static", str(book_id))
if not os.path.exists(book_dir):
os.mkdir(book_dir)
if format.lower() == "epub":
#check if mimetype file is exists
mime_file = str(book_id) +"/mimetype"
if os.path.exists(mime_file) == False:
epub_file = os.path.join(config.DB_ROOT, book.path, book.data[0].name) + ".epub"
if not os.path.isfile(epub_file):
raise ValueError('Error opening eBook. File does not exist: ', epub_file)
zfile = zipfile.ZipFile(epub_file)
for name in zfile.namelist():
(dirName, fileName) = os.path.split(name)
newDir = os.path.join(book_dir, dirName)
if not os.path.exists(newDir):
try:
os.makedirs(newDir)
except OSError as exception:
if exception.errno == errno.EEXIST:
pass
else:
raise
if fileName:
fd = open(os.path.join(newDir, fileName), "wb")
fd.write(zfile.read(name))
fd.close()
zfile.close()
return render_template('read.html', bookid=book_id, title="Read a Book")
elif format.lower() == "pdf":
all_name = str(book_id) +"/"+ urllib.quote(book.data[0].name) +".pdf"
tmp_file = os.path.join(book_dir,urllib.quote(book.data[0].name)) + ".pdf"
if os.path.exists(tmp_file) == False:
pdf_file = os.path.join(config.DB_ROOT, book.path, book.data[0].name) + ".pdf"
copyfile(pdf_file,tmp_file)
return render_template('readpdf.html', pdffile=all_name, title="Read a Book")
elif format.lower() == "txt":
all_name = str(book_id) +"/"+ urllib.quote(book.data[0].name) +".txt"
tmp_file = os.path.join(book_dir,urllib.quote(book.data[0].name)) + ".txt"
if os.path.exists(all_name) == False:
txt_file = os.path.join(config.DB_ROOT, book.path, book.data[0].name) + ".txt"
copyfile(txt_file,tmp_file)
return render_template('readtxt.html', txtfile=all_name, title="Read a Book")
if format.lower() == "epub":
#check if mimetype file is exists
mime_file = str(book_id) +"/mimetype"
if os.path.exists(mime_file) == False:
epub_file = os.path.join(config.DB_ROOT, book.path, book.data[0].name) + ".epub"
if not os.path.isfile(epub_file):
raise ValueError('Error opening eBook. File does not exist: ', epub_file)
zfile = zipfile.ZipFile(epub_file)
for name in zfile.namelist():
(dirName, fileName) = os.path.split(name)
newDir = os.path.join(book_dir, dirName)
if not os.path.exists(newDir):
try:
os.makedirs(newDir)
except OSError as exception:
if exception.errno == errno.EEXIST:
pass
else:
raise
if fileName:
fd = open(os.path.join(newDir, fileName), "wb")
fd.write(zfile.read(name))
fd.close()
zfile.close()
return render_template('read.html', bookid=book_id, title="Read a Book")
elif format.lower() == "pdf":
all_name = str(book_id) +"/"+ urllib.quote(book.data[0].name) +".pdf"
tmp_file = os.path.join(book_dir,urllib.quote(book.data[0].name)) + ".pdf"
if os.path.exists(tmp_file) == False:
pdf_file = os.path.join(config.DB_ROOT, book.path, book.data[0].name) + ".pdf"
copyfile(pdf_file,tmp_file)
return render_template('readpdf.html', pdffile=all_name, title="Read a Book")
elif format.lower() == "txt":
all_name = str(book_id) +"/"+ urllib.quote(book.data[0].name) +".txt"
tmp_file = os.path.join(book_dir,urllib.quote(book.data[0].name)) + ".txt"
if os.path.exists(all_name) == False:
txt_file = os.path.join(config.DB_ROOT, book.path, book.data[0].name) + ".txt"
copyfile(txt_file,tmp_file)
return render_template('readtxt.html', txtfile=all_name, title="Read a Book")
else :
flash("Error opening eBook. File does not exist or file is not accessible:", category="error")
return redirect('/' or url_for("index", _external=True))