- Fix migration of shelf order
- fix show random books in detail view for authors and series
pull/102/head
OzzieIsaacs 8 years ago
parent f21c65ac50
commit 176c7dce70

@ -15,7 +15,7 @@
<h2>{{entry.title}}</h2> <h2>{{entry.title}}</h2>
<p class="author"> <p class="author">
{% for author in entry.authors %} {% for author in entry.authors %}
<a href="{{url_for('author', name=author.name) }}">{{author.name}}</a> <a href="{{url_for('author', name=author.name | urlencode) }}">{{author.name}}</a>
{% if not loop.last %} {% if not loop.last %}
&amp; &amp;
{% endif %} {% endif %}
@ -65,7 +65,7 @@
<span class="glyphicon glyphicon-tags"></span> <span class="glyphicon glyphicon-tags"></span>
{% for tag in entry.tags %} {% for tag in entry.tags %}
<a href="{{ url_for('category', name=tag.name) }}" class="btn btn-xs btn-info" role="button">{{tag.name}}</a> <a href="{{ url_for('category', name=tag.name | urlencode) }}" class="btn btn-xs btn-info" role="button">{{tag.name}}</a>
{%endfor%} {%endfor%}
</div> </div>

@ -9,13 +9,13 @@
<div class="cover"> <div class="cover">
{% if entry.has_cover is defined %} {% if entry.has_cover is defined %}
<a href="{{ url_for('show_book', id=entry.id) }}"> <a href="{{ url_for('show_book', id=entry.id) }}">
<img src="{{ url_for('get_cover', cover_path=entry.path) }}" /> <img src="{{ url_for('get_cover', cover_path=entry.path.replace('\\','/')) }}" />
</a> </a>
{% endif %} {% endif %}
</div> </div>
<div class="meta"> <div class="meta">
<p class="title">{{entry.title|shortentitle}}</p> <p class="title">{{entry.title|shortentitle}}</p>
<p class="author"><a href="{{url_for('author', name=entry.authors[0].name) }}">{{entry.authors[0].name}}</a></p> <p class="author"><a href="{{url_for('author', name=entry.authors[0].name | urlencode) }}">{{entry.authors[0].name}}</a></p>
{% if entry.ratings.__len__() > 0 %} {% if entry.ratings.__len__() > 0 %}
<div class="rating"> <div class="rating">
{% for number in range((entry.ratings[0].rating/2)|int(2)) %} {% for number in range((entry.ratings[0].rating/2)|int(2)) %}

@ -55,7 +55,7 @@
<p class="title">{{entry.title|shortentitle}}</p> <p class="title">{{entry.title|shortentitle}}</p>
<p class="author"> <p class="author">
{% for author in entry.authors %} {% for author in entry.authors %}
<a href="{{url_for('author', name=author.name) }}">{{author.name}}</a> <a href="{{url_for('author', name=author.name | urlencode) }}">{{author.name}}</a>
{% if not loop.last %} {% if not loop.last %}
&amp; &amp;
{% endif %} {% endif %}

@ -5,7 +5,7 @@
{% for entry in entries %} {% for entry in entries %}
<div class="row"> <div class="row">
<div class="col-xs-1" align="left"><span class="badge">{{entry.count}}</span></div> <div class="col-xs-1" align="left"><span class="badge">{{entry.count}}</span></div>
<div class="col-xs-6"><a href="{{url_for(folder, name=entry[0].name)}}">{{entry[0].name}}</a></div> <div class="col-xs-6"><a href="{{url_for(folder, name=entry[0].name | urlencode)}}">{{entry[0].name}}</a></div>
</div> </div>
{% endfor %} {% endfor %}
</div> </div>

@ -16,7 +16,7 @@
<div class="cover"> <div class="cover">
{% if entry.has_cover is defined %} {% if entry.has_cover is defined %}
<a href="{{ url_for('show_book', id=entry.id) }}"> <a href="{{ url_for('show_book', id=entry.id) }}">
<img src="{{ url_for('get_cover', cover_path=entry.path) }}" /> <img src="{{ url_for('get_cover', cover_path=entry.path.replace('\\','/')) }}" />
</a> </a>
{% endif %} {% endif %}
</div> </div>
@ -24,7 +24,7 @@
<p class="title">{{entry.title|shortentitle}}</p> <p class="title">{{entry.title|shortentitle}}</p>
<p class="author"> <p class="author">
{% for author in entry.authors %} {% for author in entry.authors %}
<a href="{{url_for('author', name=author.name) }}">{{author.name}}</a> <a href="{{url_for('author', name=author.name | urlencode) }}">{{author.name}}</a>
{% if not loop.last %} {% if not loop.last %}
&amp; &amp;
{% endif %} {% endif %}

@ -15,13 +15,13 @@
<div class="cover"> <div class="cover">
{% if entry.has_cover is defined %} {% if entry.has_cover is defined %}
<a href="{{ url_for('show_book', id=entry.id) }}"> <a href="{{ url_for('show_book', id=entry.id) }}">
<img src="{{ url_for('get_cover', cover_path=entry.path) }}" /> <img src="{{ url_for('get_cover', cover_path=entry.path.replace('\\','/')) }}" />
</a> </a>
{% endif %} {% endif %}
</div> </div>
<div class="meta"> <div class="meta">
<p class="title">{{entry.title|shortentitle}}</p> <p class="title">{{entry.title|shortentitle}}</p>
<p class="author"><a href="{{url_for('author', name=entry.authors[0].name) }}">{{entry.authors[0].name}}</a></p> <p class="author"><a href="{{url_for('author', name=entry.authors[0].name | urlencode) }}">{{entry.authors[0].name}}</a></p>
{% if entry.ratings.__len__() > 0 %} {% if entry.ratings.__len__() > 0 %}
<div class="rating"> <div class="rating">
{% for number in range((entry.ratings[0].rating/2)|int(2)) %} {% for number in range((entry.ratings[0].rating/2)|int(2)) %}

@ -113,7 +113,7 @@
{% for entry in downloads %} {% for entry in downloads %}
<div class="col-sm-2"> <div class="col-sm-2">
<a class="pull-left" href="{{ url_for('show_book', id=entry.id) }}"> <a class="pull-left" href="{{ url_for('show_book', id=entry.id) }}">
<img class="media-object" width="100" src="{{ url_for('get_cover', cover_path=entry.path) }}" alt="..."> <img class="media-object" width="100" src="{{ url_for('get_cover', cover_path=entry.path.replace('\\','/')) }}" alt="...">
</a> </a>
</div> </div>
{% endfor %} {% endfor %}

@ -330,6 +330,13 @@ def migrate_Database():
conn.execute("ALTER TABLE Settings ADD column `config_anonbrowse` SmallInteger DEFAULT 0") conn.execute("ALTER TABLE Settings ADD column `config_anonbrowse` SmallInteger DEFAULT 0")
conn.execute("ALTER TABLE Settings ADD column `config_public_reg` SmallInteger DEFAULT 0") conn.execute("ALTER TABLE Settings ADD column `config_public_reg` SmallInteger DEFAULT 0")
session.commit() session.commit()
try:
session.query(exists().where(BookShelf.order)).scalar()
session.commit()
except exc.OperationalError: # Database is not compatible, some rows are missing
conn = engine.connect()
conn.execute("ALTER TABLE book_shelf_link ADD column 'order' INTEGER DEFAULT 1")
session.commit()
try: try:
create = False create = False
session.query(exists().where(User.sidebar_view)).scalar() session.query(exists().where(User.sidebar_view)).scalar()

@ -797,7 +797,7 @@ def hot_books(page):
filter = db.Books.languages.any(db.Languages.lang_code == current_user.filter_language()) filter = db.Books.languages.any(db.Languages.lang_code == current_user.filter_language())
else: else:
filter = True filter = True
if current_user.show_random_books(): if current_user.show_detail_random():
random = db.session.query(db.Books).filter(filter).order_by(func.random()).limit(config.config_random_books) random = db.session.query(db.Books).filter(filter).order_by(func.random()).limit(config.config_random_books)
else: else:
random = false random = false
@ -839,11 +839,12 @@ def author_list():
@app.route("/author/<name>") @app.route("/author/<name>")
@login_required_if_no_ano @login_required_if_no_ano
def author(name): def author(name):
name=requests.utils.unquote(name)
if current_user.filter_language() != "all": if current_user.filter_language() != "all":
filter = db.Books.languages.any(db.Languages.lang_code == current_user.filter_language()) filter = db.Books.languages.any(db.Languages.lang_code == current_user.filter_language())
else: else:
filter = True filter = True
if current_user.show_random_books(): if current_user.show_detail_random():
random = db.session.query(db.Books).filter(filter).order_by(func.random()).limit(config.config_random_books) random = db.session.query(db.Books).filter(filter).order_by(func.random()).limit(config.config_random_books)
else: else:
random = false random = false
@ -870,6 +871,7 @@ def series_list():
@app.route("/series/<name>/<int:page>'") @app.route("/series/<name>/<int:page>'")
@login_required_if_no_ano @login_required_if_no_ano
def series(name, page): def series(name, page):
name = requests.utils.unquote(name)
entries, random, pagination = fill_indexpage(page, db.Books, db.Books.series.any(db.Series.name == name), entries, random, pagination = fill_indexpage(page, db.Books, db.Books.series.any(db.Series.name == name),
db.Books.series_index) db.Books.series_index)
if entries: if entries:
@ -942,6 +944,7 @@ def category_list():
@app.route('/category/<name>/<int:page>') @app.route('/category/<name>/<int:page>')
@login_required_if_no_ano @login_required_if_no_ano
def category(name, page): def category(name, page):
name = requests.utils.unquote(name)
entries, random, pagination = fill_indexpage(page, db.Books, db.Books.tags.any(db.Tags.name == name), entries, random, pagination = fill_indexpage(page, db.Books, db.Books.tags.any(db.Tags.name == name),
db.Books.timestamp.desc()) db.Books.timestamp.desc())
return render_title_template('index.html', random=random, entries=entries, pagination=pagination, return render_title_template('index.html', random=random, entries=entries, pagination=pagination,

Loading…
Cancel
Save