Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
D
douban-api-proxy
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
captainwong
douban-api-proxy
Commits
a6b6700a
Commit
a6b6700a
authored
Nov 01, 2016
by
OzzieIsaacs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Removed non working search from epub viewer
parent
313116dc
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
43 additions
and
47 deletions
+43
-47
search.js
cps/static/js/plugins/search.js
+1
-1
read.html
cps/templates/read.html
+3
-7
web.py
cps/web.py
+39
-39
No files found.
cps/static/js/plugins/search.js
View file @
a6b6700a
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
({
...
...
cps/templates/read.html
View file @
a6b6700a
...
...
@@ -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>
...
...
cps/web.py
View file @
a6b6700a
...
...
@@ -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
))
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment