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
6dfa171b
Commit
6dfa171b
authored
Sep 27, 2020
by
Ozzieisaacs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added id's for testing
moved downloaded books section
parent
b1400739
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
94 additions
and
32 deletions
+94
-32
constants.py
cps/constants.py
+2
-1
grid.html
cps/templates/grid.html
+1
-1
list.html
cps/templates/list.html
+1
-1
user_edit.html
cps/templates/user_edit.html
+20
-7
ub.py
cps/ub.py
+3
-0
web.py
cps/web.py
+67
-22
No files found.
cps/constants.py
View file @
6dfa171b
...
...
@@ -81,7 +81,8 @@ SIDEBAR_PUBLISHER = 1 << 12
SIDEBAR_RATING
=
1
<<
13
SIDEBAR_FORMAT
=
1
<<
14
SIDEBAR_ARCHIVED
=
1
<<
15
SIDEBAR_LIST
=
1
<<
16
SIDEBAR_DOWNLOAD
=
1
<<
16
SIDEBAR_LIST
=
1
<<
17
ADMIN_USER_ROLES
=
sum
(
r
for
r
in
ALL_ROLES
.
values
())
&
~
ROLE_ANONYMOUS
ADMIN_USER_SIDEBAR
=
(
SIDEBAR_LIST
<<
1
)
-
1
...
...
cps/templates/grid.html
View file @
6dfa171b
...
...
@@ -19,7 +19,7 @@
{% endfor %}
</div>
<button
class=
"update-view btn btn-primary"
href=
"#"
data-target=
"series_view"
data-view=
"list"
>
List
</button>
<button
class=
"update-view btn btn-primary"
href=
"#"
data-target=
"series_view"
id=
'list-button'
data-view=
"list"
>
List
</button>
</div>
{% if entries[0] %}
...
...
cps/templates/list.html
View file @
6dfa171b
...
...
@@ -20,7 +20,7 @@
</div>
{% if data == "series" %}
<button
class=
"update-view btn btn-primary"
href=
"#"
data-target=
"series_view"
data-view=
"grid"
>
Grid
</button>
<button
class=
"update-view btn btn-primary"
href=
"#"
data-target=
"series_view"
id=
'grid-button'
data-view=
"grid"
>
Grid
</button>
{% endif %}
</div>
<div
class=
"container"
>
...
...
cps/templates/user_edit.html
View file @
6dfa171b
...
...
@@ -140,20 +140,32 @@
{% endif %}
</div>
</form>
</div>
{% if downloads %}
<div
class=
"col-sm-12"
>
<div
class=
"col-md-12 col-lg-12"
>
<div
class=
"discover1 load-more1"
>
<h2>
{{_('Recent Downloads')}}
</h2>
<div
class=
"row"
>
{% for entry in downloads %}
<div
class=
"col-sm-2"
>
<a
class=
"pull-left"
href=
"{{ url_for('web.show_book', book_id=entry.id) }}"
>
<img
class=
"media-object cover-small"
src=
"{{ url_for('web.get_cover', book_id=entry.id) }}"
alt=
"..."
>
<div
class=
"col-sm-3 col-lg-2 col-xs-6 book"
id=
"books"
>
<div
class=
"cover"
>
<a
href=
"{{ url_for('web.show_book', book_id=entry.id) }}"
data-toggle=
"modal"
data-target=
"#bookDetailsModal"
data-remote=
"false"
>
<img
src=
"{{ url_for('web.get_cover', book_id=entry.id) }}"
alt=
"{{ entry.title }}"
/>
</a>
</div>
<div
class=
"meta"
>
<a
href=
"{{ url_for('web.show_book', book_id=entry.id) }}"
data-toggle=
"modal"
data-target=
"#bookDetailsModal"
data-remote=
"false"
>
<p
class=
"title"
>
{{entry.title|shortentitle}}
</p>
</a>
</div>
{% endfor %}
</div>
{% endif %}
{% endfor %}
</div>
</div>
</div>
{% endif %}
<div
class=
"modal fade"
id=
"modal_kobo_token"
tabindex=
"-1"
role=
"dialog"
aria-labelledby=
"kobo_tokenModalLabel"
>
<div
class=
"modal-dialog modal-lg"
role=
"document"
>
<div
class=
"modal-content"
>
...
...
@@ -192,4 +204,5 @@
<script
src=
"{{ url_for('static', filename='js/libs/bootstrap-table/bootstrap-table-editable.min.js') }}"
></script>
<script
src=
"{{ url_for('static', filename='js/libs/bootstrap-table/bootstrap-editable.min.js') }}"
></script>
<script
src=
"{{ url_for('static', filename='js/table.js') }}"
></script>
<script
src=
"{{ url_for('static', filename='js/libs/plugins.js') }}"
></script>
{% endblock %}
cps/ub.py
View file @
6dfa171b
...
...
@@ -70,6 +70,9 @@ def get_sidebar_config(kwargs=None):
sidebar
.
append
({
"glyph"
:
"glyphicon-fire"
,
"text"
:
_
(
'Hot Books'
),
"link"
:
'web.books_list'
,
"id"
:
"hot"
,
"visibility"
:
constants
.
SIDEBAR_HOT
,
'public'
:
True
,
"page"
:
"hot"
,
"show_text"
:
_
(
'Show Hot Books'
),
"config_show"
:
True
})
sidebar
.
append
({
"glyph"
:
"glyphicon-download"
,
"text"
:
_
(
'Downloaded Books'
),
"link"
:
'web.books_list'
,
"id"
:
"download"
,
"visibility"
:
constants
.
SIDEBAR_DOWNLOAD
,
'public'
:
True
,
"page"
:
"download"
,
"show_text"
:
_
(
'Show Downloaded Books'
),
"config_show"
:
True
})
sidebar
.
append
(
{
"glyph"
:
"glyphicon-star"
,
"text"
:
_
(
'Top Rated Books'
),
"link"
:
'web.books_list'
,
"id"
:
"rated"
,
"visibility"
:
constants
.
SIDEBAR_BEST_RATED
,
'public'
:
True
,
"page"
:
"rated"
,
...
...
cps/web.py
View file @
6dfa171b
...
...
@@ -659,6 +659,8 @@ def render_books_list(data, sort, book_id, page):
return
render_read_books
(
page
,
True
,
order
=
order
)
elif
data
==
"hot"
:
return
render_hot_books
(
page
)
elif
data
==
"download"
:
return
render_downloaded_books
(
page
,
order
)
elif
data
==
"author"
:
return
render_author_books
(
page
,
book_id
,
order
)
elif
data
==
"publisher"
:
...
...
@@ -718,6 +720,42 @@ def render_hot_books(page):
abort
(
404
)
def
render_downloaded_books
(
page
,
order
):
if
current_user
.
check_visibility
(
constants
.
SIDEBAR_DOWNLOAD
):
# order = order or []
if
current_user
.
show_detail_random
():
random
=
calibre_db
.
session
.
query
(
db
.
Books
)
.
filter
(
calibre_db
.
common_filters
())
\
.
order_by
(
func
.
random
())
.
limit
(
config
.
config_random_books
)
else
:
random
=
false
()
# off = int(int(config.config_books_per_page) * (page - 1))
'''entries, random, pagination = calibre_db.fill_indexpage(page, 0,
db.Books,
db_filter,
order,
ub.ReadBook, db.Books.id==ub.ReadBook.book_id)'''
entries
,
__
,
pagination
=
calibre_db
.
fill_indexpage
(
page
,
0
,
db
.
Books
,
ub
.
Downloads
.
user_id
==
int
(
current_user
.
id
),
order
,
ub
.
Downloads
,
db
.
Books
.
id
==
ub
.
Downloads
.
book_id
)
for
book
in
entries
:
if
not
calibre_db
.
session
.
query
(
db
.
Books
)
.
filter
(
calibre_db
.
common_filters
())
\
.
filter
(
db
.
Books
.
id
==
book
.
id
)
.
first
():
ub
.
delete_download
(
book
.
id
)
return
render_title_template
(
'index.html'
,
random
=
random
,
entries
=
entries
,
pagination
=
pagination
,
title
=
_
(
u"Downloaded books by
%(user)
s"
,
user
=
current_user
.
nickname
),
page
=
"download"
)
else
:
abort
(
404
)
def
render_author_books
(
page
,
author_id
,
order
):
entries
,
__
,
pagination
=
calibre_db
.
fill_indexpage
(
page
,
0
,
db
.
Books
,
...
...
@@ -765,7 +803,7 @@ def render_series_books(page, book_id, order):
entries
,
random
,
pagination
=
calibre_db
.
fill_indexpage
(
page
,
0
,
db
.
Books
,
db
.
Books
.
series
.
any
(
db
.
Series
.
id
==
book_id
),
[
db
.
Books
.
series_index
,
order
[
0
]])
[
order
[
0
]])
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"
)
else
:
...
...
@@ -994,7 +1032,6 @@ def list_books():
isoLanguages
.
get
(
part3
=
entry
.
languages
[
index
]
.
lang_code
)
.
name
)
table_entries
=
{
'totalNotFiltered'
:
total_count
,
'total'
:
filtered_count
,
"rows"
:
entries
}
js_list
=
json
.
dumps
(
table_entries
,
cls
=
db
.
AlchemyEncoder
)
#js_list = json.dumps(entries, cls=db.AlchemyEncoder)
response
=
make_response
(
js_list
)
response
.
headers
[
"Content-Type"
]
=
"application/json; charset=utf-8"
...
...
@@ -1664,7 +1701,7 @@ def token_verified():
@
web
.
route
(
"/me"
,
methods
=
[
"GET"
,
"POST"
])
@
login_required
def
profile
():
downloads
=
list
()
#
downloads = list()
languages
=
calibre_db
.
speaking_language
()
translations
=
babel
.
list_translations
()
+
[
LC
(
'en'
)]
kobo_support
=
feature_support
[
'kobo'
]
and
config
.
config_kobo_sync
...
...
@@ -1675,12 +1712,13 @@ def profile():
oauth_status
=
None
local_oauth_check
=
{}
for
book
in
current_user
.
downloads
:
downloadBook
=
calibre_db
.
get_book
(
book
.
book_id
)
if
downloadBook
:
downloads
.
append
(
downloadBook
)
else
:
ub
.
delete_download
(
book
.
book_id
)
'''entries, __, pagination = calibre_db.fill_indexpage(page,
0,
db.Books,
ub.Downloads.user_id == int(current_user.id), # True,
[],
ub.Downloads, db.Books.id == ub.Downloads.book_id)'''
if
request
.
method
==
"POST"
:
to_save
=
request
.
form
.
to_dict
()
current_user
.
random_books
=
0
...
...
@@ -1694,7 +1732,7 @@ def profile():
if
"email"
in
to_save
and
to_save
[
"email"
]
!=
current_user
.
email
:
if
config
.
config_public_reg
and
not
check_valid_domain
(
to_save
[
"email"
]):
flash
(
_
(
u"E-mail is not from valid domain"
),
category
=
"error"
)
return
render_title_template
(
"user_edit.html"
,
content
=
current_user
,
downloads
=
downloads
,
return
render_title_template
(
"user_edit.html"
,
content
=
current_user
,
title
=
_
(
u"
%(name)
s's profile"
,
name
=
current_user
.
nickname
),
page
=
"me"
,
kobo_support
=
kobo_support
,
registered_oauth
=
local_oauth_check
,
oauth_status
=
oauth_status
)
...
...
@@ -1710,7 +1748,6 @@ def profile():
languages
=
languages
,
kobo_support
=
kobo_support
,
new_user
=
0
,
content
=
current_user
,
downloads
=
downloads
,
registered_oauth
=
local_oauth_check
,
title
=
_
(
u"Edit User
%(nick)
s"
,
nick
=
current_user
.
nickname
),
...
...
@@ -1730,24 +1767,32 @@ def profile():
if
"Show_detail_random"
in
to_save
:
current_user
.
sidebar_view
+=
constants
.
DETAIL_RANDOM
# current_user.mature_content = "Show_mature_content" in to_save
try
:
ub
.
session
.
commit
()
flash
(
_
(
u"Profile updated"
),
category
=
"success"
)
log
.
debug
(
u"Profile updated"
)
except
IntegrityError
:
ub
.
session
.
rollback
()
flash
(
_
(
u"Found an existing account for this e-mail address."
),
category
=
"error"
)
log
.
debug
(
u"Found an existing account for this e-mail address."
)
return
render_title_template
(
"user_edit.html"
,
content
=
current_user
,
downloads
=
downloads
,
translations
=
translations
,
kobo_support
=
kobo_support
,
title
=
_
(
u"
%(name)
s's profile"
,
name
=
current_user
.
nickname
),
page
=
"me"
,
registered_oauth
=
local_oauth_check
,
oauth_status
=
oauth_status
)
flash
(
_
(
u"Profile updated"
),
category
=
"success"
)
log
.
debug
(
u"Profile updated"
)
return
render_title_template
(
"user_edit.html"
,
translations
=
translations
,
profile
=
1
,
languages
=
languages
,
content
=
current_user
,
downloads
=
downloads
,
kobo_support
=
kobo_support
,
'''return render_title_template("user_edit.html",
content=current_user,
translations=translations,
kobo_support=kobo_support,
title=_(u"
%(name)
s's profile", name=current_user.nickname),
page="me",
registered_oauth=local_oauth_check,
oauth_status=oauth_status)'''
return
render_title_template
(
"user_edit.html"
,
translations
=
translations
,
profile
=
1
,
languages
=
languages
,
content
=
current_user
,
kobo_support
=
kobo_support
,
title
=
_
(
u"
%(name)
s's profile"
,
name
=
current_user
.
nickname
),
page
=
"me"
,
registered_oauth
=
local_oauth_check
,
oauth_status
=
oauth_status
)
page
=
"me"
,
registered_oauth
=
local_oauth_check
,
oauth_status
=
oauth_status
)
# ###################################Show single book ##################################################################
...
...
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