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
97a0dccd
Commit
97a0dccd
authored
Jul 22, 2019
by
Ozzieisaacs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix for display of format, series, category, ratings,
Fix for display of language (sorting not working yet)
parent
9f64a965
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
31 deletions
+32
-31
languages.html
cps/templates/languages.html
+2
-1
web.py
cps/web.py
+30
-30
No files found.
cps/templates/languages.html
View file @
97a0dccd
...
@@ -10,9 +10,10 @@
...
@@ -10,9 +10,10 @@
{% endif %}
{% endif %}
<div
class=
"row"
>
<div
class=
"row"
>
<div
class=
"col-xs-2 col-sm-2 col-md-1"
align=
"left"
><span
class=
"badge"
>
{{lang_counter[loop.index0].bookcount}}
</span></div>
<div
class=
"col-xs-2 col-sm-2 col-md-1"
align=
"left"
><span
class=
"badge"
>
{{lang_counter[loop.index0].bookcount}}
</span></div>
<div
class=
"col-xs-10 col-sm-10 col-md-11"
><a
id=
"list_{{loop.index0}}"
href=
"{{url_for('web.
language', name=lang.lang_code
)}}"
>
{{lang.name}}
</a></div>
<div
class=
"col-xs-10 col-sm-10 col-md-11"
><a
id=
"list_{{loop.index0}}"
href=
"{{url_for('web.
books_list', book_id=lang.lang_code, data=data, sort='new'
)}}"
>
{{lang.name}}
</a></div>
</div>
</div>
{% endfor %}
{% endfor %}
</div>
</div>
</div>
</div>
{% endblock %}
{% endblock %}
cps/web.py
View file @
97a0dccd
...
@@ -514,6 +514,8 @@ def books_list(data, sort, book_id, page):
...
@@ -514,6 +514,8 @@ def books_list(data, sort, book_id, page):
return
render_formats_books
(
page
,
book_id
,
order
)
return
render_formats_books
(
page
,
book_id
,
order
)
elif
data
==
"category"
:
elif
data
==
"category"
:
return
render_category_books
(
page
,
book_id
,
order
)
return
render_category_books
(
page
,
book_id
,
order
)
elif
data
==
"language"
:
return
render_language_books
(
page
,
book_id
,
order
)
else
:
else
:
entries
,
random
,
pagination
=
fill_indexpage
(
page
,
db
.
Books
,
True
,
order
)
entries
,
random
,
pagination
=
fill_indexpage
(
page
,
db
.
Books
,
True
,
order
)
return
render_title_template
(
'index.html'
,
random
=
random
,
entries
=
entries
,
pagination
=
pagination
,
return
render_title_template
(
'index.html'
,
random
=
random
,
entries
=
entries
,
pagination
=
pagination
,
...
@@ -568,8 +570,8 @@ def render_author_books(page, author_id, order):
...
@@ -568,8 +570,8 @@ def render_author_books(page, author_id, order):
other_books
=
services
.
goodreads
.
get_other_books
(
author_info
,
entries
)
other_books
=
services
.
goodreads
.
get_other_books
(
author_info
,
entries
)
return
render_title_template
(
'author.html'
,
entries
=
entries
,
pagination
=
pagination
,
id
=
author_id
,
return
render_title_template
(
'author.html'
,
entries
=
entries
,
pagination
=
pagination
,
id
=
author_id
,
title
=
_
(
u"Author:
%(name)
s"
,
name
=
author_name
),
author
=
author_info
,
other_books
=
other_books
,
title
=
_
(
u"Author:
%(name)
s"
,
name
=
author_name
),
author
=
author_info
,
page
=
"author"
)
other_books
=
other_books
,
page
=
"author"
)
def
render_publisher_books
(
page
,
book_id
,
order
):
def
render_publisher_books
(
page
,
book_id
,
order
):
...
@@ -590,19 +592,19 @@ def render_series_books(page, book_id, order):
...
@@ -590,19 +592,19 @@ def render_series_books(page, book_id, order):
if
name
:
if
name
:
entries
,
random
,
pagination
=
fill_indexpage
(
page
,
db
.
Books
,
db
.
Books
.
series
.
any
(
db
.
Series
.
id
==
book_id
),
entries
,
random
,
pagination
=
fill_indexpage
(
page
,
db
.
Books
,
db
.
Books
.
series
.
any
(
db
.
Series
.
id
==
book_id
),
[
db
.
Books
.
series_index
,
order
[
0
]])
[
db
.
Books
.
series_index
,
order
[
0
]])
return
render_title_template
(
'index.html'
,
random
=
random
,
pagination
=
pagination
,
entries
=
entries
,
return
render_title_template
(
'index.html'
,
random
=
random
,
pagination
=
pagination
,
entries
=
entries
,
id
=
book_id
,
title
=
_
(
u"Series:
%(serie)
s"
,
serie
=
name
.
name
),
page
=
"series"
)
title
=
_
(
u"Series:
%(serie)
s"
,
serie
=
name
.
name
),
page
=
"series"
)
else
:
else
:
abort
(
404
)
abort
(
404
)
def
render_ratings_books
(
page
,
book_id
,
order
):
def
render_ratings_books
(
page
,
book_id
,
order
):
if
book_id
<=
5
:
name
=
db
.
session
.
query
(
db
.
Ratings
)
.
filter
(
db
.
Ratings
.
id
==
book_id
)
.
first
()
name
=
db
.
session
.
query
(
db
.
Ratings
)
.
filter
(
db
.
Ratings
.
id
==
book_id
)
.
first
()
entries
,
random
,
pagination
=
fill_indexpage
(
page
,
db
.
Books
,
db
.
Books
.
ratings
.
any
(
db
.
Ratings
.
id
==
book_id
),
entries
,
random
,
pagination
=
fill_indexpage
(
page
,
db
.
Books
,
db
.
Books
.
ratings
.
any
(
db
.
Ratings
.
id
==
book_id
),
[
db
.
Books
.
timestamp
.
desc
(),
order
[
0
]])
[
db
.
Books
.
timestamp
.
desc
(),
order
[
0
]])
if
name
and
name
.
rating
<=
10
:
return
render_title_template
(
'index.html'
,
random
=
random
,
pagination
=
pagination
,
entries
=
entries
,
return
render_title_template
(
'index.html'
,
random
=
random
,
pagination
=
pagination
,
entries
=
entries
,
id
=
book_id
,
title
=
_
(
u"Rating:
%(rating)
s stars"
,
rating
=
int
(
name
.
rating
/
2
)),
page
=
"ratings"
)
title
=
_
(
u"Rating:
%(rating)
s stars"
,
rating
=
int
(
name
.
rating
/
2
)),
page
=
"ratings"
)
else
:
else
:
abort
(
404
)
abort
(
404
)
...
@@ -612,7 +614,7 @@ def render_formats_books(page, book_id, order):
...
@@ -612,7 +614,7 @@ def render_formats_books(page, book_id, order):
if
name
:
if
name
:
entries
,
random
,
pagination
=
fill_indexpage
(
page
,
db
.
Books
,
db
.
Books
.
data
.
any
(
db
.
Data
.
format
==
book_id
.
upper
()),
entries
,
random
,
pagination
=
fill_indexpage
(
page
,
db
.
Books
,
db
.
Books
.
data
.
any
(
db
.
Data
.
format
==
book_id
.
upper
()),
[
db
.
Books
.
timestamp
.
desc
(),
order
[
0
]])
[
db
.
Books
.
timestamp
.
desc
(),
order
[
0
]])
return
render_title_template
(
'index.html'
,
random
=
random
,
pagination
=
pagination
,
entries
=
entries
,
return
render_title_template
(
'index.html'
,
random
=
random
,
pagination
=
pagination
,
entries
=
entries
,
id
=
book_id
,
title
=
_
(
u"File format:
%(format)
s"
,
format
=
name
.
format
),
page
=
"formats"
)
title
=
_
(
u"File format:
%(format)
s"
,
format
=
name
.
format
),
page
=
"formats"
)
else
:
else
:
abort
(
404
)
abort
(
404
)
...
@@ -624,12 +626,27 @@ def render_category_books(page, book_id, order):
...
@@ -624,12 +626,27 @@ def render_category_books(page, book_id, order):
entries
,
random
,
pagination
=
fill_indexpage
(
page
,
db
.
Books
,
db
.
Books
.
tags
.
any
(
db
.
Tags
.
id
==
book_id
),
entries
,
random
,
pagination
=
fill_indexpage
(
page
,
db
.
Books
,
db
.
Books
.
tags
.
any
(
db
.
Tags
.
id
==
book_id
),
[
db
.
Series
.
name
,
db
.
Books
.
series_index
,
order
[
0
]],
[
db
.
Series
.
name
,
db
.
Books
.
series_index
,
order
[
0
]],
db
.
books_series_link
,
db
.
Series
)
db
.
books_series_link
,
db
.
Series
)
return
render_title_template
(
'index.html'
,
random
=
random
,
entries
=
entries
,
pagination
=
pagination
,
return
render_title_template
(
'index.html'
,
random
=
random
,
entries
=
entries
,
pagination
=
pagination
,
id
=
book_id
,
title
=
_
(
u"Category:
%(name)
s"
,
name
=
name
.
name
),
page
=
"category"
)
title
=
_
(
u"Category:
%(name)
s"
,
name
=
name
.
name
),
page
=
"category"
)
else
:
else
:
abort
(
404
)
abort
(
404
)
def
render_language_books
(
page
,
name
,
order
):
try
:
cur_l
=
LC
.
parse
(
name
)
lang_name
=
cur_l
.
get_language_name
(
get_locale
())
except
UnknownLocaleError
:
try
:
lang_name
=
_
(
isoLanguages
.
get
(
part3
=
name
)
.
name
)
except
KeyError
:
abort
(
404
)
entries
,
random
,
pagination
=
fill_indexpage
(
page
,
db
.
Books
,
db
.
Books
.
languages
.
any
(
db
.
Languages
.
lang_code
==
name
),
[
db
.
Books
.
timestamp
.
desc
(),
order
[
0
]])
return
render_title_template
(
'index.html'
,
random
=
random
,
entries
=
entries
,
pagination
=
pagination
,
id
=
name
,
title
=
_
(
u"Language:
%(name)
s"
,
name
=
lang_name
),
page
=
"language"
)
@
web
.
route
(
"/author"
)
@
web
.
route
(
"/author"
)
@
login_required_if_no_ano
@
login_required_if_no_ano
def
author_list
():
def
author_list
():
...
@@ -730,29 +747,12 @@ def language_overview():
...
@@ -730,29 +747,12 @@ def language_overview():
func
.
count
(
'books_languages_link.book'
)
.
label
(
'bookcount'
))
.
group_by
(
func
.
count
(
'books_languages_link.book'
)
.
label
(
'bookcount'
))
.
group_by
(
text
(
'books_languages_link.lang_code'
))
.
all
()
text
(
'books_languages_link.lang_code'
))
.
all
()
return
render_title_template
(
'languages.html'
,
languages
=
languages
,
lang_counter
=
lang_counter
,
return
render_title_template
(
'languages.html'
,
languages
=
languages
,
lang_counter
=
lang_counter
,
charlist
=
charlist
,
title
=
_
(
u"Available languages"
),
page
=
"langlist"
,
data
=
"language"
)
charlist
=
charlist
,
title
=
_
(
u"Available languages"
),
page
=
"langlist"
,
data
=
"language"
)
else
:
else
:
abort
(
404
)
abort
(
404
)
@
web
.
route
(
"/language/<name>"
,
defaults
=
{
'page'
:
1
})
@
web
.
route
(
'/language/<name>/page/<int:page>'
)
@
login_required_if_no_ano
def
language
(
name
,
page
):
try
:
cur_l
=
LC
.
parse
(
name
)
lang_name
=
cur_l
.
get_language_name
(
get_locale
())
except
UnknownLocaleError
:
try
:
lang_name
=
_
(
isoLanguages
.
get
(
part3
=
name
)
.
name
)
except
KeyError
:
abort
(
404
)
entries
,
random
,
pagination
=
fill_indexpage
(
page
,
db
.
Books
,
db
.
Books
.
languages
.
any
(
db
.
Languages
.
lang_code
==
name
),
[
db
.
Books
.
timestamp
.
desc
()])
return
render_title_template
(
'index.html'
,
random
=
random
,
entries
=
entries
,
pagination
=
pagination
,
title
=
_
(
u"Language:
%(name)
s"
,
name
=
lang_name
),
page
=
"language"
)
@
web
.
route
(
"/category"
)
@
web
.
route
(
"/category"
)
@
login_required_if_no_ano
@
login_required_if_no_ano
def
category_list
():
def
category_list
():
...
...
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