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
e5593d9a
Commit
e5593d9a
authored
Mar 16, 2019
by
Ozzieisaacs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Integrated author in sorting functions
parent
3f2a9c8b
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
70 additions
and
53 deletions
+70
-53
author.html
cps/templates/author.html
+14
-2
detail.html
cps/templates/detail.html
+1
-1
discover.html
cps/templates/discover.html
+2
-2
index.html
cps/templates/index.html
+4
-4
list.html
cps/templates/list.html
+1
-1
search.html
cps/templates/search.html
+2
-2
shelf.html
cps/templates/shelf.html
+2
-2
shelfdown.html
cps/templates/shelfdown.html
+1
-1
web.py
cps/web.py
+43
-38
No files found.
cps/templates/author.html
View file @
e5593d9a
...
...
@@ -22,6 +22,18 @@
{% if author is not none %}
<h3>
{{_("In Library")}}
</h3>
{% endif %}
<div
class=
"filterheader hidden-xs hidden-sm"
>
<a
id=
"new"
class=
"btn btn-primary"
href=
"{{url_for('web.books_list', data='author', sort='new')}}"
><span
class=
"glyphicon glyphicon-sort-by-order"
></span></a>
<a
id=
"old"
class=
"btn btn-primary"
href=
"{{url_for('web.books_list', data='author', sort='old')}}"
><span
class=
"glyphicon glyphicon-sort-by-order-alt"
></span></a>
<a
id=
"asc"
class=
"btn btn-primary"
href=
"{{url_for('web.books_list', data='author', sort='abc')}}"
><span
class=
"glyphicon glyphicon-font"
></span><span
class=
"glyphicon glyphicon-sort-by-alphabet"
></span></a>
<a
id=
"desc"
class=
"btn btn-primary"
href=
"{{url_for('web.books_list', data='author', sort='zyx')}}"
><span
class=
"glyphicon glyphicon-font"
></span><span
class=
"glyphicon glyphicon-sort-by-alphabet-alt"
></span></a>
<a
id=
"pub_new"
class=
"btn btn-primary"
href=
"{{url_for('web.books_list', data='author', sort='pubnew')}}"
><span
class=
"glyphicon glyphicon-calendar"
></span><span
class=
"glyphicon glyphicon-sort-by-order"
></span></a>
<a
id=
"pub_old"
class=
"btn btn-primary"
href=
"{{url_for('web.books_list', data='author', sort='pubold')}}"
><span
class=
"glyphicon glyphicon-calendar"
></span><span
class=
"glyphicon glyphicon-sort-by-order-alt"
></span></a>
<div
class=
"btn-group character"
role=
"group"
>
<a
id=
"no_shelf"
class=
"btn btn-primary"
href=
"{{url_for('web.books_list', data='author', sort='pubold')}}"
><span
class=
"glyphicon glyphicon-list"
></span><b>
?
</b></a>
<div
id=
"all"
class=
"btn btn-primary"
>
{{_('All')}}
</div>
</div>
</div>
<div
class=
"row"
>
{% if entries[0] %}
{% for entry in entries %}
...
...
@@ -45,7 +57,7 @@
{% if not loop.first %}
<span
class=
"author-hidden-divider"
>
&
</span>
{% endif %}
<a
class=
"author-name author-hidden"
href=
"{{url_for('web.
author
', book_id=author.id) }}"
>
{{author.name.replace('|',',')|shortentitle(30)}}
</a>
<a
class=
"author-name author-hidden"
href=
"{{url_for('web.
books_list', data='author', sort='new
', book_id=author.id) }}"
>
{{author.name.replace('|',',')|shortentitle(30)}}
</a>
{% if loop.last %}
<a
href=
"#"
class=
"author-expand"
data-authors-max=
"{{g.config_authors_max}}"
data-collapse-caption=
"({{_('reduce')}})"
>
(...)
</a>
{% endif %}
...
...
@@ -53,7 +65,7 @@
{% if not loop.first %}
<span>
&
</span>
{% endif %}
<a
class=
"author-name"
href=
"{{url_for('web.
author
', book_id=author.id) }}"
>
{{author.name.replace('|',',')|shortentitle(30)}}
</a>
<a
class=
"author-name"
href=
"{{url_for('web.
books_list', data='author', sort='new
', book_id=author.id) }}"
>
{{author.name.replace('|',',')|shortentitle(30)}}
</a>
{% endif %}
{% endfor %}
</p>
...
...
cps/templates/detail.html
View file @
e5593d9a
...
...
@@ -99,7 +99,7 @@
<h2
id=
"title"
>
{{entry.title|shortentitle(40)}}
</h2>
<p
class=
"author"
>
{% for author in entry.authors %}
<a
href=
"{{url_for('web.
author
', book_id=author.id ) }}"
>
{{author.name.replace('|',',')}}
</a>
<a
href=
"{{url_for('web.
books_list', data='author', sort='new
', book_id=author.id ) }}"
>
{{author.name.replace('|',',')}}
</a>
{% if not loop.last %}
&
{% endif %}
...
...
cps/templates/discover.html
View file @
e5593d9a
...
...
@@ -22,7 +22,7 @@
{% if not loop.first %}
<span
class=
"author-hidden-divider"
>
&
</span>
{% endif %}
<a
class=
"author-name author-hidden"
href=
"{{url_for('web.
author
', book_id=author.id) }}"
>
{{author.name.replace('|',',')|shortentitle(30)}}
</a>
<a
class=
"author-name author-hidden"
href=
"{{url_for('web.
books_list', data='author', sort='new
', book_id=author.id) }}"
>
{{author.name.replace('|',',')|shortentitle(30)}}
</a>
{% if loop.last %}
<a
href=
"#"
class=
"author-expand"
data-authors-max=
"{{g.config_authors_max}}"
data-collapse-caption=
"({{_('reduce')}})"
>
(...)
</a>
{% endif %}
...
...
@@ -30,7 +30,7 @@
{% if not loop.first %}
<span>
&
</span>
{% endif %}
<a
class=
"author-name"
href=
"{{url_for('web.
author
', book_id=author.id) }}"
>
{{author.name.replace('|',',')|shortentitle(30)}}
</a>
<a
class=
"author-name"
href=
"{{url_for('web.
books_list', data='author', sort='new
', book_id=author.id) }}"
>
{{author.name.replace('|',',')|shortentitle(30)}}
</a>
{% endif %}
{% endfor %}
</p>
...
...
cps/templates/index.html
View file @
e5593d9a
...
...
@@ -25,7 +25,7 @@ web. {% for entry in random %}
{% if not loop.first %}
<span
class=
"author-hidden-divider"
>
&
</span>
{% endif %}
<a
class=
"author-name author-hidden"
href=
"{{url_for('web.
author
', book_id=author.id) }}"
>
{{author.name.replace('|',',')|shortentitle(30)}}
</a>
<a
class=
"author-name author-hidden"
href=
"{{url_for('web.
books_list', data='author', sort='new
', book_id=author.id) }}"
>
{{author.name.replace('|',',')|shortentitle(30)}}
</a>
{% if loop.last %}
<a
href=
"#"
class=
"author-expand"
data-authors-max=
"{{g.config_authors_max}}"
data-collapse-caption=
"({{_('reduce')}})"
>
(...)
</a>
{% endif %}
...
...
@@ -33,7 +33,7 @@ web. {% for entry in random %}
{% if not loop.first %}
<span>
&
</span>
{% endif %}
<a
class=
"author-name"
href=
"{{url_for('web.
author
', book_id=author.id) }}"
>
{{author.name.replace('|',',')|shortentitle(30)}}
</a>
<a
class=
"author-name"
href=
"{{url_for('web.
books_list', data='author', sort='new
', book_id=author.id) }}"
>
{{author.name.replace('|',',')|shortentitle(30)}}
</a>
{% endif %}
{% endfor %}
</p>
...
...
@@ -92,7 +92,7 @@ web. {% for entry in random %}
{% if not loop.first %}
<span
class=
"author-hidden-divider"
>
&
</span>
{% endif %}
<a
class=
"author-name author-hidden"
href=
"{{url_for('web.
author', book_id=author.id
) }}"
>
{{author.name.replace('|',',')|shortentitle(30)}}
</a>
<a
class=
"author-name author-hidden"
href=
"{{url_for('web.
books_list', data='author', book_id=author.id, sort='new'
) }}"
>
{{author.name.replace('|',',')|shortentitle(30)}}
</a>
{% if loop.last %}
<a
href=
"#"
class=
"author-expand"
data-authors-max=
"{{g.config_authors_max}}"
data-collapse-caption=
"({{_('reduce')}})"
>
(...)
</a>
{% endif %}
...
...
@@ -100,7 +100,7 @@ web. {% for entry in random %}
{% if not loop.first %}
<span>
&
</span>
{% endif %}
<a
class=
"author-name"
href=
"{{url_for('web.
author', book_id=author.id
) }}"
>
{{author.name.replace('|',',')|shortentitle(30)}}
</a>
<a
class=
"author-name"
href=
"{{url_for('web.
books_list', data='author', book_id=author.id, sort='new'
) }}"
>
{{author.name.replace('|',',')|shortentitle(30)}}
</a>
{% endif %}
{% endfor %}
{% for format in entry.data %}
...
...
cps/templates/list.html
View file @
e5593d9a
...
...
@@ -19,7 +19,7 @@
{% for entry in entries %}
<div
class=
"row"
data-id=
"{% if entry[0].sort %}{{entry[0].sort}}{% else %}{% if entry.name %}{{entry.name}}{% else %}{{entry[0].name}}{% endif %}{% endif %}"
>
<div
class=
"col-xs-2 col-sm-2 col-md-1"
align=
"left"
><span
class=
"badge"
>
{{entry.count}}
</span></div>
<div
class=
"col-xs-10 col-sm-10 col-md-11"
><a
id=
"list_{{loop.index0}}"
href=
"{% if entry.format %}{{url_for(folder,
book_id=entry.format )}}{% else %}{{url_for(folder
, book_id=entry[0].id )}}{% endif %}"
>
<div
class=
"col-xs-10 col-sm-10 col-md-11"
><a
id=
"list_{{loop.index0}}"
href=
"{% if entry.format %}{{url_for(folder,
data=data, sort='new', book_id=entry.format )}}{% else %}{{url_for(folder, data=data, sort='new'
, book_id=entry[0].id )}}{% endif %}"
>
{% if entry.name %}
<div
class=
"rating"
>
{% for number in range(entry.name) %}
...
...
cps/templates/search.html
View file @
e5593d9a
...
...
@@ -50,7 +50,7 @@
{% if not loop.first %}
<span
class=
"author-hidden-divider"
>
&
</span>
{% endif %}
<a
class=
"author-name author-hidden"
href=
"{{url_for('web.
author
', book_id=author.id) }}"
>
{{author.name.replace('|',',')|shortentitle(30)}}
</a>
<a
class=
"author-name author-hidden"
href=
"{{url_for('web.
books_list', data='author', sort='new
', book_id=author.id) }}"
>
{{author.name.replace('|',',')|shortentitle(30)}}
</a>
{% if loop.last %}
<a
href=
"#"
class=
"author-expand"
data-authors-max=
"{{g.config_authors_max}}"
data-collapse-caption=
"({{_('reduce')}})"
>
(...)
</a>
{% endif %}
...
...
@@ -58,7 +58,7 @@
{% if not loop.first %}
<span>
&
</span>
{% endif %}
<a
class=
"author-name"
href=
"{{url_for('web.
author
', book_id=author.id) }}"
>
{{author.name.replace('|',',')|shortentitle(30)}}
</a>
<a
class=
"author-name"
href=
"{{url_for('web.
books_list', data='author', sort='new
', book_id=author.id) }}"
>
{{author.name.replace('|',',')|shortentitle(30)}}
</a>
{% endif %}
{% endfor %}
</p>
...
...
cps/templates/shelf.html
View file @
e5593d9a
...
...
@@ -35,7 +35,7 @@
{% if not loop.first %}
<span
class=
"author-hidden-divider"
>
&
</span>
{% endif %}
<a
class=
"author-name author-hidden"
href=
"{{url_for('web.
author
', book_id=author.id) }}"
>
{{author.name.replace('|',',')|shortentitle(30)}}
</a>
<a
class=
"author-name author-hidden"
href=
"{{url_for('web.
books_list', data='author', sort='new
', book_id=author.id) }}"
>
{{author.name.replace('|',',')|shortentitle(30)}}
</a>
{% if loop.last %}
<a
href=
"#"
class=
"author-expand"
data-authors-max=
"{{g.config_authors_max}}"
data-collapse-caption=
"({{_('reduce')}})"
>
(...)
</a>
{% endif %}
...
...
@@ -43,7 +43,7 @@
{% if not loop.first %}
<span>
&
</span>
{% endif %}
<a
class=
"author-name"
href=
"{{url_for('web.
author
', book_id=author.id) }}"
>
{{author.name.replace('|',',')|shortentitle(30)}}
</a>
<a
class=
"author-name"
href=
"{{url_for('web.
books_list', data='author', sort='new
', book_id=author.id) }}"
>
{{author.name.replace('|',',')|shortentitle(30)}}
</a>
{% endif %}
{% endfor %}
</p>
...
...
cps/templates/shelfdown.html
View file @
e5593d9a
...
...
@@ -37,7 +37,7 @@
<p
class=
"title"
>
{{entry.title|shortentitle}}
</p>
<p
class=
"author"
>
{% for author in entry.authors %}
<a
href=
"{{url_for('web.
author
', book_id=author.id) }}"
>
{{author.name.replace('|',',')}}
</a>
<a
href=
"{{url_for('web.
books_list', data='author', sort='new
', book_id=author.id) }}"
>
{{author.name.replace('|',',')}}
</a>
{% if not loop.last %}
&
{% endif %}
...
...
cps/web.py
View file @
e5593d9a
...
...
@@ -464,19 +464,20 @@ def index(page):
title
=
_
(
u"Recently Added Books"
),
page
=
"root"
)
@
web
.
route
(
'/<data>/<sort>'
,
defaults
=
{
'page'
:
1
})
@
web
.
route
(
'/<data>/<sort>/<int:page>'
)
@
web
.
route
(
'/<data>/<sort>'
,
defaults
=
{
'page'
:
1
,
'book_id'
:
1
})
@
web
.
route
(
'/<data>/<sort>/<int:book_id>'
,
defaults
=
{
'page'
:
1
})
@
web
.
route
(
'/<data>/<sort>/<int:book_id>/<int:page>'
)
@
login_required_if_no_ano
def
books_list
(
data
,
sort
,
page
):
def
books_list
(
data
,
sort
,
book_id
,
page
):
order
=
[
db
.
Books
.
timestamp
.
desc
()]
if
sort
==
'pubnew'
:
order
=
[
db
.
Books
.
pubdate
.
desc
()]
if
sort
==
'pubold'
:
order
=
[
db
.
Books
.
pubdate
]
if
sort
==
'abc'
:
[
db
.
Books
.
sort
]
order
=
[
db
.
Books
.
sort
]
if
sort
==
'zyx'
:
[
db
.
Books
.
sort
.
desc
()]
order
=
[
db
.
Books
.
sort
.
desc
()]
if
sort
==
'new'
:
order
=
[
db
.
Books
.
timestamp
.
desc
()]
if
sort
==
'old'
:
...
...
@@ -503,38 +504,44 @@ def books_list(data,sort, page):
elif
data
==
"read"
:
return
render_read_books
(
page
,
True
,
order
=
order
)
elif
data
==
"hot"
:
if
current_user
.
check_visibility
(
ub
.
SIDEBAR_HOT
):
if
current_user
.
show_detail_random
():
random
=
db
.
session
.
query
(
db
.
Books
)
.
filter
(
common_filters
())
\
.
order_by
(
func
.
random
())
.
limit
(
config
.
config_random_books
)
else
:
random
=
false
()
off
=
int
(
int
(
config
.
config_books_per_page
)
*
(
page
-
1
))
all_books
=
ub
.
session
.
query
(
ub
.
Downloads
,
ub
.
func
.
count
(
ub
.
Downloads
.
book_id
))
.
order_by
(
ub
.
func
.
count
(
ub
.
Downloads
.
book_id
)
.
desc
())
.
group_by
(
ub
.
Downloads
.
book_id
)
hot_books
=
all_books
.
offset
(
off
)
.
limit
(
config
.
config_books_per_page
)
entries
=
list
()
for
book
in
hot_books
:
downloadBook
=
db
.
session
.
query
(
db
.
Books
)
.
filter
(
common_filters
())
.
filter
(
db
.
Books
.
id
==
book
.
Downloads
.
book_id
)
.
first
()
if
downloadBook
:
entries
.
append
(
downloadBook
)
else
:
ub
.
delete_download
(
book
.
Downloads
.
book_id
)
# ub.session.query(ub.Downloads).filter(book.Downloads.book_id == ub.Downloads.book_id).delete()
# ub.session.commit()
numBooks
=
entries
.
__len__
()
pagination
=
Pagination
(
page
,
config
.
config_books_per_page
,
numBooks
)
return
render_title_template
(
'index.html'
,
random
=
random
,
entries
=
entries
,
pagination
=
pagination
,
title
=
_
(
u"Hot Books (most downloaded)"
),
page
=
"hot"
)
else
:
abort
(
404
)
return
render_hot_books
(
page
)
elif
data
==
"author"
:
return
render_author_books
(
page
,
book_id
,
order
)
else
:
entries
,
random
,
pagination
=
fill_indexpage
(
page
,
db
.
Books
,
True
,
order
)
return
render_title_template
(
'index.html'
,
random
=
random
,
entries
=
entries
,
pagination
=
pagination
,
title
=
_
(
u"Books"
),
page
=
"newest"
)
def
render_hot_books
(
page
):
if
current_user
.
check_visibility
(
ub
.
SIDEBAR_HOT
):
if
current_user
.
show_detail_random
():
random
=
db
.
session
.
query
(
db
.
Books
)
.
filter
(
common_filters
())
\
.
order_by
(
func
.
random
())
.
limit
(
config
.
config_random_books
)
else
:
random
=
false
()
off
=
int
(
int
(
config
.
config_books_per_page
)
*
(
page
-
1
))
all_books
=
ub
.
session
.
query
(
ub
.
Downloads
,
ub
.
func
.
count
(
ub
.
Downloads
.
book_id
))
.
order_by
(
ub
.
func
.
count
(
ub
.
Downloads
.
book_id
)
.
desc
())
.
group_by
(
ub
.
Downloads
.
book_id
)
hot_books
=
all_books
.
offset
(
off
)
.
limit
(
config
.
config_books_per_page
)
entries
=
list
()
for
book
in
hot_books
:
downloadBook
=
db
.
session
.
query
(
db
.
Books
)
.
filter
(
common_filters
())
.
filter
(
db
.
Books
.
id
==
book
.
Downloads
.
book_id
)
.
first
()
if
downloadBook
:
entries
.
append
(
downloadBook
)
else
:
ub
.
delete_download
(
book
.
Downloads
.
book_id
)
# ub.session.query(ub.Downloads).filter(book.Downloads.book_id == ub.Downloads.book_id).delete()
# ub.session.commit()
numBooks
=
entries
.
__len__
()
pagination
=
Pagination
(
page
,
config
.
config_books_per_page
,
numBooks
)
return
render_title_template
(
'index.html'
,
random
=
random
,
entries
=
entries
,
pagination
=
pagination
,
title
=
_
(
u"Hot Books (most downloaded)"
),
page
=
"hot"
)
else
:
abort
(
404
)
@
web
.
route
(
"/author"
)
@
login_required_if_no_ano
def
author_list
():
...
...
@@ -547,18 +554,16 @@ def author_list():
.
group_by
(
func
.
upper
(
func
.
substr
(
db
.
Authors
.
sort
,
1
,
1
)))
.
all
()
for
entry
in
entries
:
entry
.
Authors
.
name
=
entry
.
Authors
.
name
.
replace
(
'|'
,
','
)
return
render_title_template
(
'list.html'
,
entries
=
entries
,
folder
=
'web.
author
'
,
charlist
=
charlist
,
title
=
u"Author list"
,
page
=
"authorlist"
)
return
render_title_template
(
'list.html'
,
entries
=
entries
,
folder
=
'web.
books_list
'
,
charlist
=
charlist
,
title
=
u"Author list"
,
page
=
"authorlist"
,
data
=
'author'
)
else
:
abort
(
404
)
@
web
.
route
(
"/author/<int:book_id>"
,
defaults
=
{
'page'
:
1
})
@
web
.
route
(
"/author/<int:book_id>/<int:page>"
)
@
login_required_if_no_ano
def
author
(
book_id
,
page
):
# ToDo wrong order function
def
render_author_books
(
page
,
book_id
,
order
):
entries
,
__
,
pagination
=
fill_indexpage
(
page
,
db
.
Books
,
db
.
Books
.
authors
.
any
(
db
.
Authors
.
id
==
book_id
),
[
db
.
Series
.
name
,
db
.
Books
.
series_index
],
db
.
books_series_link
,
db
.
Series
)
[
order
[
0
],
db
.
Series
.
name
,
db
.
Books
.
series_index
],
db
.
books_series_link
,
db
.
Series
)
if
entries
is
None
:
flash
(
_
(
u"Error opening eBook. File does not exist or file is not accessible:"
),
category
=
"error"
)
return
redirect
(
url_for
(
"web.index"
))
...
...
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