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
4a332785
Commit
4a332785
authored
Mar 10, 2019
by
Ozzieisaacs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update ratings
parent
6d2270d9
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
48 additions
and
33 deletions
+48
-33
author.html
cps/templates/author.html
+4
-4
discover.html
cps/templates/discover.html
+2
-2
index.html
cps/templates/index.html
+4
-4
list.html
cps/templates/list.html
+16
-2
search.html
cps/templates/search.html
+2
-2
shelf.html
cps/templates/shelf.html
+2
-2
web.py
cps/web.py
+18
-17
No files found.
cps/templates/author.html
View file @
4a332785
...
...
@@ -41,13 +41,13 @@
</a>
<p
class=
"author"
>
{% for author in entry.authors %}
{% if loop.index >
config_authors_max and
config_authors_max != 0 %}
{% if loop.index >
g.config_authors_max and g.
config_authors_max != 0 %}
{% 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>
{% if loop.last %}
<a
href=
"#"
class=
"author-expand"
data-authors-max=
"{{config_authors_max}}"
data-collapse-caption=
"({{_('reduce')}})"
>
(...)
</a>
<a
href=
"#"
class=
"author-expand"
data-authors-max=
"{{
g.
config_authors_max}}"
data-collapse-caption=
"({{_('reduce')}})"
>
(...)
</a>
{% endif %}
{% else %}
{% if not loop.first %}
...
...
@@ -91,10 +91,10 @@
<p
class=
"title"
>
{{entry.title|shortentitle}}
</p>
<p
class=
"author"
>
{% for author in entry.authors %}
{% if loop.index >
config_authors_max and
config_authors_max != 0 %}
{% if loop.index >
g.config_authors_max and g.
config_authors_max != 0 %}
<a
class=
"author-name author-hidden"
href=
"https://www.goodreads.com/author/show/{{ author.gid }}"
target=
"_blank"
rel=
"noopener"
>
{{author.name.replace('|',',')}}
</a>
{% if loop.last %}
<a
href=
"#"
class=
"author-expand"
data-authors-max=
"{{config_authors_max}}"
data-collapse-caption=
"({{_('reduce')}})"
>
(...)
</a>
<a
href=
"#"
class=
"author-expand"
data-authors-max=
"{{
g.
config_authors_max}}"
data-collapse-caption=
"({{_('reduce')}})"
>
(...)
</a>
{% endif %}
{% else %}
<a
class=
"author-name"
href=
"https://www.goodreads.com/author/show/{{ author.gid }}"
target=
"_blank"
rel=
"noopener"
>
{{author.name.replace('|',',')}}
</a>
...
...
cps/templates/discover.html
View file @
4a332785
...
...
@@ -19,13 +19,13 @@
</a>
<p
class=
"author"
>
{% for author in entry.authors %}
{% if loop.index >
config_authors_max and
config_authors_max != 0 %}
{% if loop.index >
g.config_authors_max and g.
config_authors_max != 0 %}
{% 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>
{% if loop.last %}
<a
href=
"#"
class=
"author-expand"
data-authors-max=
"{{config_authors_max}}"
data-collapse-caption=
"({{_('reduce')}})"
>
(...)
</a>
<a
href=
"#"
class=
"author-expand"
data-authors-max=
"{{
g.
config_authors_max}}"
data-collapse-caption=
"({{_('reduce')}})"
>
(...)
</a>
{% endif %}
{% else %}
{% if not loop.first %}
...
...
cps/templates/index.html
View file @
4a332785
...
...
@@ -21,13 +21,13 @@ web. {% for entry in random %}
</a>
<p
class=
"author"
>
{% for author in entry.authors %}
{% if loop.index >
config_authors_max and
config_authors_max != 0 %}
{% if loop.index >
g.config_authors_max and g.
config_authors_max != 0 %}
{% 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>
{% if loop.last %}
<a
href=
"#"
class=
"author-expand"
data-authors-max=
"{{config_authors_max}}"
data-collapse-caption=
"({{_('reduce')}})"
>
(...)
</a>
<a
href=
"#"
class=
"author-expand"
data-authors-max=
"{{
g.
config_authors_max}}"
data-collapse-caption=
"({{_('reduce')}})"
>
(...)
</a>
{% endif %}
{% else %}
{% if not loop.first %}
...
...
@@ -88,13 +88,13 @@ web. {% for entry in random %}
</a>
<p
class=
"author"
>
{% for author in entry.authors %}
{% if loop.index >
config_authors_max and
config_authors_max != 0 %}
{% if loop.index >
g.config_authors_max and g.
config_authors_max != 0 %}
{% 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>
{% if loop.last %}
<a
href=
"#"
class=
"author-expand"
data-authors-max=
"{{config_authors_max}}"
data-collapse-caption=
"({{_('reduce')}})"
>
(...)
</a>
<a
href=
"#"
class=
"author-expand"
data-authors-max=
"{{
g.
config_authors_max}}"
data-collapse-caption=
"({{_('reduce')}})"
>
(...)
</a>
{% endif %}
{% else %}
{% if not loop.first %}
...
...
cps/templates/list.html
View file @
4a332785
...
...
@@ -5,7 +5,9 @@
<div
class=
"filterheader hidden-xs hidden-sm"
>
<button
id=
"desc"
class=
"btn btn-success"
><span
class=
"glyphicon glyphicon-sort-by-alphabet"
></span></button>
<button
id=
"asc"
class=
"btn btn-success"
><span
class=
"glyphicon glyphicon-sort-by-alphabet-alt"
></span></button>
{% if charlist|length %}
<button
id=
"all"
class=
"btn btn-success"
>
{{_('All')}}
</button>
{% endif %}
<div
class=
"btn-group character"
role=
"group"
>
{% for char in charlist%}
<button
class=
"btn btn-success char"
>
{{char.char}}
</button>
...
...
@@ -15,9 +17,21 @@
<div
class=
"container"
>
<div
id=
"list"
class=
"col-xs-12 col-sm-6"
>
{% for entry in entries %}
<div
class=
"row"
data-id=
"{% if entry[0].sort %}{{entry[0].sort}}{% else %}{
{entry[0].name}
}{% endif %}"
>
<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=
"{{url_for(folder, book_id=entry[0].id )}}"
>
{{entry[0].name}}
</a></div>
<div
class=
"col-xs-10 col-sm-10 col-md-11"
><a
id=
"list_{{loop.index0}}"
href=
"{{url_for(folder, book_id=entry[0].id )}}"
>
{% if entry.name %}
<div
class=
"rating"
>
{% for number in range(entry.name) %}
<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>
{% else %} {{entry[0].name}}{% endif %}
</a></div>
</div>
{% endfor %}
</div>
...
...
cps/templates/search.html
View file @
4a332785
...
...
@@ -46,13 +46,13 @@
</a>
<p
class=
"author"
>
{% for author in entry.authors %}
{% if loop.index >
config_authors_max and
config_authors_max != 0 %}
{% if loop.index >
g.config_authors_max and g.
config_authors_max != 0 %}
{% 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>
{% if loop.last %}
<a
href=
"#"
class=
"author-expand"
data-authors-max=
"{{config_authors_max}}"
data-collapse-caption=
"({{_('reduce')}})"
>
(...)
</a>
<a
href=
"#"
class=
"author-expand"
data-authors-max=
"{{
g.
config_authors_max}}"
data-collapse-caption=
"({{_('reduce')}})"
>
(...)
</a>
{% endif %}
{% else %}
{% if not loop.first %}
...
...
cps/templates/shelf.html
View file @
4a332785
...
...
@@ -31,13 +31,13 @@
</a>
<p
class=
"author"
>
{% for author in entry.authors %}
{% if loop.index >
config_authors_max and
config_authors_max != 0 %}
{% if loop.index >
g.config_authors_max and g.
config_authors_max != 0 %}
{% 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>
{% if loop.last %}
<a
href=
"#"
class=
"author-expand"
data-authors-max=
"{{config_authors_max}}"
data-collapse-caption=
"({{_('reduce')}})"
>
(...)
</a>
<a
href=
"#"
class=
"author-expand"
data-authors-max=
"{{
g.
config_authors_max}}"
data-collapse-caption=
"({{_('reduce')}})"
>
(...)
</a>
{% endif %}
{% else %}
{% if not loop.first %}
...
...
cps/web.py
View file @
4a332785
...
...
@@ -36,7 +36,9 @@ from babel import Locale as LC
from
babel.dates
import
format_date
from
babel.core
import
UnknownLocaleError
import
base64
from
sqlalchemy.sql
import
*
# from sqlalchemy.sql import *
from
sqlalchemy
import
String
as
SQLString
from
sqlalchemy.sql.expression
import
text
,
func
,
cast
,
true
,
and_
,
false
import
json
import
datetime
from
iso639
import
languages
as
isoLanguages
...
...
@@ -45,7 +47,7 @@ import gdriveutils
from
redirect
import
redirect_back
from
cps
import
lm
,
babel
,
ub
,
config
,
get_locale
,
language_table
,
app
,
db
from
pagination
import
Pagination
from
sqlalchemy.sql.expression
import
text
feature_support
=
dict
()
try
:
...
...
@@ -335,6 +337,7 @@ def before_request():
g
.
allow_registration
=
config
.
config_public_reg
g
.
allow_upload
=
config
.
config_uploading
g
.
current_theme
=
config
.
config_theme
g
.
config_authors_max
=
config
.
config_authors_max
g
.
public_shelfes
=
ub
.
session
.
query
(
ub
.
Shelf
)
.
filter
(
ub
.
Shelf
.
is_public
==
1
)
.
order_by
(
ub
.
Shelf
.
name
)
.
all
()
if
not
config
.
db_configured
and
request
.
endpoint
not
in
(
'admin.basic_configuration'
,
'login'
)
and
'/static/'
not
in
request
.
path
:
return
redirect
(
url_for
(
'admin.basic_configuration'
))
...
...
@@ -494,7 +497,7 @@ def get_matching_tags():
def
index
(
page
):
entries
,
random
,
pagination
=
fill_indexpage
(
page
,
db
.
Books
,
True
,
[
db
.
Books
.
timestamp
.
desc
()])
return
render_title_template
(
'index.html'
,
random
=
random
,
entries
=
entries
,
pagination
=
pagination
,
title
=
_
(
u"Recently Added Books"
),
page
=
"root"
,
config_authors_max
=
config
.
config_authors_max
)
title
=
_
(
u"Recently Added Books"
),
page
=
"root"
)
@
web
.
route
(
'/books/newest'
,
defaults
=
{
'page'
:
1
})
...
...
@@ -632,8 +635,7 @@ def author(book_id, page):
app
.
logger
.
error
(
'Goodreads website is down/inaccessible'
)
return
render_title_template
(
'author.html'
,
entries
=
entries
,
pagination
=
pagination
,
title
=
name
,
author
=
author_info
,
other_books
=
other_books
,
page
=
"author"
,
config_authors_max
=
config
.
config_authors_max
)
title
=
name
,
author
=
author_info
,
other_books
=
other_books
,
page
=
"author"
)
@
web
.
route
(
"/publisher"
)
...
...
@@ -720,17 +722,16 @@ def series(book_id, page):
abort
(
404
)
# (cast(db.Ratings.rating/2, SQLString)).label('name'))\
@
web
.
route
(
"/ratings"
)
@
login_required_if_no_ano
def
ratings_list
():
if
current_user
.
check_visibility
(
ub
.
SIDEBAR_RATING
):
entries
=
db
.
session
.
query
(
db
.
Series
,
func
.
count
(
'books_series_link.book'
)
.
label
(
'count'
))
\
.
join
(
db
.
books_series_link
)
.
join
(
db
.
Books
)
.
filter
(
common_filters
())
\
.
group_by
(
text
(
'books_series_link.series'
))
.
order_by
(
db
.
Series
.
sort
)
.
all
()
charlist
=
db
.
session
.
query
(
func
.
upper
(
func
.
substr
(
db
.
Series
.
sort
,
1
,
1
))
.
label
(
'char'
))
\
.
join
(
db
.
books_series_link
)
.
join
(
db
.
Books
)
.
filter
(
common_filters
())
\
.
group_by
(
func
.
upper
(
func
.
substr
(
db
.
Series
.
sort
,
1
,
1
)))
.
all
()
return
render_title_template
(
'list.html'
,
entries
=
entries
,
folder
=
'web.series'
,
charlist
=
charlist
,
entries
=
db
.
session
.
query
(
db
.
Ratings
,
func
.
count
(
'books_ratings_link.book'
)
.
label
(
'count'
),
(
db
.
Ratings
.
rating
/
2
)
.
label
(
'name'
))
\
.
join
(
db
.
books_ratings_link
)
.
join
(
db
.
Books
)
.
filter
(
common_filters
())
\
.
group_by
(
text
(
'books_ratings_link.rating'
))
.
order_by
(
db
.
Ratings
.
rating
)
.
all
()
return
render_title_template
(
'list.html'
,
entries
=
entries
,
folder
=
'web.ratings'
,
charlist
=
list
(),
title
=
_
(
u"Ratings list"
),
page
=
"ratingslist"
)
else
:
abort
(
404
)
...
...
@@ -740,12 +741,12 @@ def ratings_list():
@
web
.
route
(
"/ratings/<int:book_id>/<int:page>"
)
@
login_required_if_no_ano
def
ratings
(
book_id
,
page
):
name
=
db
.
session
.
query
(
db
.
Series
)
.
filter
(
db
.
Series
.
id
==
book_id
)
.
first
()
if
name
:
entries
,
random
,
pagination
=
fill_indexpage
(
page
,
db
.
Books
,
db
.
Books
.
series
.
any
(
db
.
Serie
s
.
id
==
book_id
),
[
db
.
Books
.
series_index
])
if
book_id
<=
5
:
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
.
Rating
s
.
id
==
book_id
),
[
db
.
Books
.
timestamp
.
desc
()
])
return
render_title_template
(
'index.html'
,
random
=
random
,
pagination
=
pagination
,
entries
=
entries
,
title
=
_
(
u"Ratings:
%(
serie)
s"
,
serie
=
name
.
name
),
page
=
"ratings"
)
title
=
_
(
u"Ratings:
%(
rating)
s stars"
,
rating
=
(
name
.
rating
/
2
)
),
page
=
"ratings"
)
else
:
abort
(
404
)
...
...
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