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
d5e1dba0
Commit
d5e1dba0
authored
Aug 27, 2017
by
OzzieIsaacs
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'adv/goodreads-more-by'
parents
193605df
a682c95e
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
73 additions
and
17 deletions
+73
-17
style.css
cps/static/css/style.css
+2
-1
author.html
cps/templates/author.html
+47
-4
web.py
cps/web.py
+24
-12
No files found.
cps/static/css/style.css
View file @
d5e1dba0
...
...
@@ -77,7 +77,8 @@ input.pill:not(:checked) + label .glyphicon {
}
.author-bio
img
{
margin
:
0
1em
1em
0
;}
.author-link
img
{
display
:
inline-block
;
max-width
:
100px
;}
.author-link
{
display
:
inline-block
;
margin-top
:
10px
;
width
:
100px
;}
.author-link
img
{
display
:
block
;
height
:
100%
;}
#remove-from-shelves
.btn
,
#shelf-action-errors
{
...
...
cps/templates/author.html
View file @
d5e1dba0
...
...
@@ -11,16 +11,15 @@
{%if author.about is not none %}
<p>
{{author.about|safe}}
</p>
{% endif %}
</section>
<a
href=
"{{author.link}}"
class=
"author-link"
target=
"_blank"
>
<img
src=
"{{ url_for('static', filename='img/goodreads.svg') }}"
alt=
"Goodreads"
>
</a>
- {{_("via")}}
<a
href=
"{{author.link}}"
class=
"author-link"
target=
"_blank"
rel=
"noopener"
>
Goodreads
</a>
</section>
<div
class=
"clearfix"
></div>
{% endif %}
<div
class=
"discover load-more"
>
<h3>
{{_("In Library")}}
</h3>
<div
class=
"row"
>
{% if entries[0] %}
{% for entry in entries %}
...
...
@@ -62,4 +61,48 @@
{% endif %}
</div>
</div>
{% if other_books is not none %}
<div
class=
"discover"
>
<h3>
{{_("More by")}} {{ author.name|safe }}
</h3>
<div
class=
"row"
>
{% for entry in other_books %}
<div
class=
"col-sm-3 col-lg-2 col-xs-6 book"
>
<div
class=
"cover"
>
<a
href=
"https://www.goodreads.com/book/show/{{ entry.gid['#text'] }}"
target=
"_blank"
rel=
"noopener"
>
<img
src=
"{{ entry.image_url }}"
/>
</a>
</div>
<div
class=
"meta"
>
<p
class=
"title"
>
{{entry.title|shortentitle}}
</p>
<p
class=
"author"
>
{% for author in entry.authors %}
<a
href=
"https://www.goodreads.com/author/show/{{ author.gid }}"
target=
"_blank"
rel=
"noopener"
>
{{author.name}}
</a>
{% if not loop.last %}
&
{% endif %}
{% endfor %}
</p>
<div
class=
"rating"
>
{% for number in range((entry.average_rating)|float|round|int(2)) %}
<span
class=
"glyphicon glyphicon-star good"
></span>
{% if loop.last and loop.index
<
5
%}
{%
for
numer
in
range
(
5
-
loop
.
index
)
%}
<
span
class=
"glyphicon glyphicon-star"
></span>
{% endfor %}
{% endif %}
{% endfor %}
</div>
</div>
</div>
{% endfor %}
</div>
<a
href=
"{{author.link}}"
class=
"author-link"
target=
"_blank"
rel=
"noopener"
>
<img
src=
"{{ url_for('static', filename='img/goodreads.svg') }}"
alt=
"Goodreads"
>
</a>
</div>
{% endif %}
{% endblock %}
cps/web.py
View file @
d5e1dba0
...
...
@@ -8,11 +8,16 @@ except ImportError:
gdrive_support
=
False
try
:
from
goodreads
import
client
as
gr_c
lient
from
goodreads
.client
import
GoodreadsC
lient
goodreads_support
=
True
except
ImportError
:
goodreads_support
=
False
try
:
from
functools
import
reduce
except
ImportError
:
pass
# We're not using Python 3
import
mimetypes
import
logging
from
logging.handlers
import
RotatingFileHandler
...
...
@@ -1169,20 +1174,27 @@ def author_list():
def
author
(
book_id
,
page
):
entries
,
random
,
pagination
=
fill_indexpage
(
page
,
db
.
Books
,
db
.
Books
.
authors
.
any
(
db
.
Authors
.
id
==
book_id
),
db
.
Books
.
timestamp
.
desc
())
if
entries
:
name
=
db
.
session
.
query
(
db
.
Authors
)
.
filter
(
db
.
Authors
.
id
==
book_id
)
.
first
()
.
name
author_info
=
None
if
goodreads_support
and
config
.
config_use_goodreads
:
gc
=
gr_client
.
GoodreadsClient
(
config
.
config_goodreads_api_key
,
config
.
config_goodreads_api_secret
)
author_info
=
gc
.
find_author
(
author_name
=
name
)
return
render_title_template
(
'author.html'
,
entries
=
entries
,
pagination
=
pagination
,
title
=
name
,
author
=
author_info
)
else
:
if
entries
is
None
:
flash
(
_
(
u"Error opening eBook. File does not exist or file is not accessible:"
),
category
=
"error"
)
return
redirect
(
url_for
(
"index"
))
name
=
db
.
session
.
query
(
db
.
Authors
)
.
filter
(
db
.
Authors
.
id
==
book_id
)
.
first
()
.
name
author_info
=
None
other_books
=
None
if
goodreads_support
and
config
.
config_use_goodreads
:
gc
=
GoodreadsClient
(
config
.
config_goodreads_api_key
,
config
.
config_goodreads_api_secret
)
author_info
=
gc
.
find_author
(
author_name
=
name
)
# Get all identifiers (ISBN, Goodreads, etc) and filter author's books by that list so we show fewer duplicates
# Note: Not all images will be shown, even though they're available on Goodreads.com.
# See https://www.goodreads.com/topic/show/18213769-goodreads-book-images
identifiers
=
reduce
(
lambda
acc
,
book
:
acc
+
map
(
lambda
identifier
:
identifier
.
val
,
book
.
identifiers
),
entries
.
all
(),
[])
other_books
=
filter
(
lambda
book
:
book
.
isbn
not
in
identifiers
and
book
.
gid
[
"#text"
]
not
in
identifiers
,
author_info
.
books
)
return
render_title_template
(
'author.html'
,
entries
=
entries
,
pagination
=
pagination
,
title
=
name
,
author
=
author_info
,
other_books
=
other_books
)
@
app
.
route
(
"/series"
)
@
login_required_if_no_ano
...
...
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