fix some error

Fix TypeError: 'bool' object is not callable
pull/34/head
wuqi 8 years ago
parent 3a54ff0eb4
commit b846cc11d8

1
.gitignore vendored

@ -18,3 +18,4 @@ eggs/
*.log *.log
config.ini config.ini
*.bak

@ -1,4 +1,2 @@
@import url(http://fonts.googleapis.com/css?family=Lato:100,300,400,700); @font-face{font-family:Lato;font-style:normal;font-weight:100;src:local('Lato Hairline'),local('Lato-Hairline'),url(../fonts/Lato-Hairline.ttf) format('truetype')}@font-face{font-family:Lato;font-style:normal;font-weight:300;src:local('Lato Light'),local('Lato-Light'),url(../fonts/Lato-Light.ttf) format('truetype')}@font-face{font-family:Lato;font-style:normal;font-weight:400;src:local('Lato Regular'),local('Lato-Regular'),url(../fonts/Lato-Regular.ttf) format('truetype')}@font-face{font-family:Lato;font-style:normal;font-weight:700;src:local('Lato Bold'),local('Lato-Bold'),url(../fonts/Lato-Bold.ttf) format('truetype')}@font-face{font-family:Montserrat;font-style:normal;font-weight:400;src:local('Montserrat-Regular'),url(../fonts/Montserrat-Regular.ttf) format('truetype')}@font-face{font-family:Montserrat;font-style:normal;font-weight:700;src:local('Montserrat-Bold'),url(../fonts/Montserrat-Bold.ttf) format('truetype')}@font-face{font-family:Lobster;font-style:normal;font-weight:400;src:local('Lobster'),local('Lobster-Regular'),url(../fonts/Lobster.ttf) format('truetype')}
@import url(http://fonts.googleapis.com/css?family=Montserrat:400,700);
@import url(http://fonts.googleapis.com/css?family=Lobster:400,700);
@font-face{font-family:'Gotham-Light';src:url('../fonts/itc/Gotham-Light.eot');src:url('../fonts/itc/Gotham-Light.woff') format('woff'),url('../fonts/itc/Gotham-Light.svg#Gotham-Light') format('svg')}@font-face{font-family:'Gotham-Medium';src:url('../fonts/itc/Gotham-Medium.eot');src:url('../fonts/itc/Gotham-Medium.woff') format('woff'),url('../fonts/itc/Gotham-Medium.svg#Gotham-Medium') format('svg')}@font-face{font-family:'Gotham-Book';src:url('../fonts/itc/Gotham-Book.eot');src:url('../fonts/itc/Gotham-Book.woff') format('woff'),url('../fonts/itc/Gotham-Book.svg#Gotham-Book') format('svg')} @font-face{font-family:'Gotham-Light';src:url('../fonts/itc/Gotham-Light.eot');src:url('../fonts/itc/Gotham-Light.woff') format('woff'),url('../fonts/itc/Gotham-Light.svg#Gotham-Light') format('svg')}@font-face{font-family:'Gotham-Medium';src:url('../fonts/itc/Gotham-Medium.eot');src:url('../fonts/itc/Gotham-Medium.woff') format('woff'),url('../fonts/itc/Gotham-Medium.svg#Gotham-Medium') format('svg')}@font-face{font-family:'Gotham-Book';src:url('../fonts/itc/Gotham-Book.eot');src:url('../fonts/itc/Gotham-Book.woff') format('woff'),url('../fonts/itc/Gotham-Book.svg#Gotham-Book') format('svg')}

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

@ -85,7 +85,7 @@
{{entry.comments[0].text|safe}} {{entry.comments[0].text|safe}}
{% endif %} {% endif %}
{% if g.user.is_authenticated() %} {% if g.user.is_authenticated %}
<div class="more-stuff"> <div class="more-stuff">
<div class="btn-toolbar" role="toolbar"> <div class="btn-toolbar" role="toolbar">
@ -104,8 +104,6 @@
{% if g.user.kindle_mail %} {% if g.user.kindle_mail %}
<a href="{{url_for('send_to_kindle', book_id=entry.id)}}" id="sendbtn" class="btn btn-primary" role="button"><span class="glyphicon glyphicon-send"></span> Send to Kindle</a> <a href="{{url_for('send_to_kindle', book_id=entry.id)}}" id="sendbtn" class="btn btn-primary" role="button"><span class="glyphicon glyphicon-send"></span> Send to Kindle</a>
{% endif %} {% endif %}
{% for format in entry.data %}
{%if format.format|lower == 'epub' or format.format|lower == 'txt' or format.format|lower == 'pdf' %}
<div class="btn-group" role="group"> <div class="btn-group" role="group">
<button id="btnGroupDrop2" type="button" class="btn btn-primary dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"> <button id="btnGroupDrop2" type="button" class="btn btn-primary dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<span class="glyphicon glyphicon-eye-open"></span>Read in browser <span class="glyphicon glyphicon-eye-open"></span>Read in browser
@ -119,11 +117,6 @@
{%endfor%} {%endfor%}
</ul> </ul>
</div> </div>
{% break %}
{% endif %}
{%endfor%}
</div> </div>
</div> </div>
</br> </br>

@ -63,7 +63,7 @@
<li><a href="{{url_for('advanced_search')}}"><span class="glyphicon glyphicon-search"></span> Advanced Search</a></li> <li><a href="{{url_for('advanced_search')}}"><span class="glyphicon glyphicon-search"></span> Advanced Search</a></li>
</ul> </ul>
<ul class="nav navbar-nav navbar-right" id="main-nav"> <ul class="nav navbar-nav navbar-right" id="main-nav">
{% if g.user.is_authenticated() %} {% if g.user.is_authenticated %}
{% if g.user.role_upload() or g.user.role_admin()%} {% if g.user.role_upload() or g.user.role_admin()%}
{% if g.allow_upload %} {% if g.allow_upload %}
<li> <li>
@ -119,7 +119,7 @@
<li><a href="{{url_for('category_list')}}"><span class="glyphicon glyphicon-inbox"></span> Categories</a></li> <li><a href="{{url_for('category_list')}}"><span class="glyphicon glyphicon-inbox"></span> Categories</a></li>
<li><a href="{{url_for('author_list')}}"><span class="glyphicon glyphicon-user"></span> Authors</a></li> <li><a href="{{url_for('author_list')}}"><span class="glyphicon glyphicon-user"></span> Authors</a></li>
{% if g.user.is_authenticated() %} {% if g.user.is_authenticated %}
<li class="nav-head hidden-xs">Public Shelves</li> <li class="nav-head hidden-xs">Public Shelves</li>
{% for shelf in g.public_shelfes %} {% for shelf in g.public_shelfes %}
<li><a href="{{url_for('show_shelf', shelf_id=shelf.id)}}"><span class="glyphicon glyphicon-list"></span> {{shelf.name}}</a></li> <li><a href="{{url_for('show_shelf', shelf_id=shelf.id)}}"><span class="glyphicon glyphicon-list"></span> {{shelf.name}}</a></li>

@ -97,9 +97,9 @@
</head> </head>
<body> <body>
<div id="main"> <div id="main">
<div id="prev" class="arrow" onclick="prevPage();"></div> <div id="prev" class="arrow" ></div>
<div id="area"><pre id="content" class="content"></pre></div> <div id="area"><pre id="content" class="content"></pre></div>
<div id="next" class="arrow" onclick="nextPage();"></div> <div id="next" class="arrow"></div>
</div> </div>
<script> <script>
@ -122,9 +122,22 @@
nextPage(); nextPage();
} }
}); });
//click
$( "#prev" ).click(function() {
prevPage();
});
$( "#next" ).click(function() {
nextPage();
});
//bind mouse //bind mouse
$(window).bind('mousewheel', function(event) { $(window).bind('DOMMouseScroll mousewheel', function(event) {
if (event.originalEvent.wheelDelta >= 0) { var delta = 0;
if (event.originalEvent.wheelDelta) {
delta = event.originalEvent.wheelDelta;
}else if (event.originalEvent.detail) {
delta = event.originalEvent.detail*-1;
}
if (delta >= 0) {
prevPage(); prevPage();
} }
else { else {

@ -540,7 +540,10 @@ def read_book(book_id,format):
book_dir = os.path.join(config.MAIN_DIR, "cps","static", str(book_id)) book_dir = os.path.join(config.MAIN_DIR, "cps","static", str(book_id))
if not os.path.exists(book_dir): if not os.path.exists(book_dir):
os.mkdir(book_dir) os.mkdir(book_dir)
if format.lower() == "epub": 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" epub_file = os.path.join(config.DB_ROOT, book.path, book.data[0].name) + ".epub"
if not os.path.isfile(epub_file): if not os.path.isfile(epub_file):
raise ValueError('Error opening eBook. File does not exist: ', epub_file) raise ValueError('Error opening eBook. File does not exist: ', epub_file)
@ -561,37 +564,21 @@ def read_book(book_id,format):
fd.write(zfile.read(name)) fd.write(zfile.read(name))
fd.close() fd.close()
zfile.close() zfile.close()
return render_template('read.html', bookid=book_id, title="Read a Book") return render_template('read.html', bookid=book_id, title="Read a Book")
elif format.lower() == "pdf": 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" pdf_file = os.path.join(config.DB_ROOT, book.path, book.data[0].name) + ".pdf"
tmp_file = os.path.join(book_dir,urllib.quote(book.data[0].name)) + ".pdf"
copyfile(pdf_file,tmp_file) copyfile(pdf_file,tmp_file)
all_name = str(book_id) +"/"+ urllib.quote(book.data[0].name) +".pdf" return render_template('readpdf.html', pdffile=all_name, title="Read a Book")
return render_template('readpdf.html', pdffile=all_name, title="Read a Book") elif format.lower() == "txt":
elif format.lower() == "txt": all_name = str(book_id) +"/"+ urllib.quote(book.data[0].name) +".txt"
#change txt to epub 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" txt_file = os.path.join(config.DB_ROOT, book.path, book.data[0].name) + ".txt"
tmp_file = os.path.join(book_dir,urllib.quote(book.data[0].name)) + ".txt"
copyfile(txt_file,tmp_file) copyfile(txt_file,tmp_file)
all_name = str(book_id) +"/"+ urllib.quote(book.data[0].name) +".txt" return render_template('readtxt.html', txtfile=all_name, title="Read a Book")
return render_template('readtxt.html', txtfile=all_name, title="Read a Book")
else:
if format.lower() == "epub":
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")
@app.route("/download/<int:book_id>/<format>") @app.route("/download/<int:book_id>/<format>")
@login_required @login_required
@ -621,7 +608,7 @@ def register():
error = None error = None
if not config.PUBLIC_REG: if not config.PUBLIC_REG:
abort(404) abort(404)
if current_user is not None and current_user.is_authenticated(): if current_user is not None and current_user.is_authenticated:
return redirect(url_for('index', _external=True)) return redirect(url_for('index', _external=True))
if request.method == "POST": if request.method == "POST":
@ -657,7 +644,7 @@ def register():
def login(): def login():
error = None error = None
if current_user is not None and current_user.is_authenticated(): if current_user is not None and current_user.is_authenticated:
return redirect(url_for('index', _external=True)) return redirect(url_for('index', _external=True))
if request.method == "POST": if request.method == "POST":
@ -676,7 +663,7 @@ def login():
@app.route('/logout') @app.route('/logout')
@login_required @login_required
def logout(): def logout():
if current_user is not None and current_user.is_authenticated(): if current_user is not None and current_user.is_authenticated:
logout_user() logout_user()
return redirect(request.args.get("next") or url_for("index", _external=True)) return redirect(request.args.get("next") or url_for("index", _external=True))

Loading…
Cancel
Save