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
8ababf9f
Commit
8ababf9f
authored
Jan 27, 2019
by
Ozzieisaacs
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'simple_shelf/shelf-down' into Develop
parents
59711946
9b4ca222
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
113 additions
and
0 deletions
+113
-0
shelf.html
cps/templates/shelf.html
+3
-0
shelfdown.html
cps/templates/shelfdown.html
+82
-0
web.py
cps/web.py
+28
-0
No files found.
cps/templates/shelf.html
View file @
8ababf9f
...
...
@@ -2,6 +2,9 @@
{% block body %}
<div
class=
"discover"
>
<h2>
{{title}}
</h2>
{% if g.user.role_download() %}
<a
id=
"shelf_down"
href=
"{{ url_for('show_shelf_down', shelf_id=shelf.id) }}"
class=
"btn btn-primary"
>
{{ _('Download') }}
</a>
{% endif %}
{% if g.user.is_authenticated %}
{% if (g.user.role_edit_shelfs() and shelf.is_public ) or not shelf.is_public %}
<div
id=
"delete_shelf"
data-toggle=
"modal"
data-target=
"#DeleteShelfDialog"
class=
"btn btn-danger"
>
{{ _('Delete this Shelf') }}
</div>
...
...
cps/templates/shelfdown.html
0 → 100644
View file @
8ababf9f
<!DOCTYPE html>
<html
lang=
"{{ g.user.locale }}"
>
<head>
<title>
{{instance}} | {{title}}
</title>
<meta
charset=
"utf-8"
>
<meta
name=
"viewport"
content=
"width=device-width, initial-scale=1.0"
>
<meta
http-equiv=
"X-UA-Compatible"
content=
"IE=edge,chrome=1"
>
<meta
name=
"apple-mobile-web-app-capable"
content=
"yes"
>
<!-- Bootstrap -->
<link
rel=
"apple-touch-icon"
sizes=
"140x140"
href=
"{{ url_for('static', filename='favicon.ico') }}"
>
<link
rel=
"shortcut icon"
href=
"{{ url_for('static', filename='favicon.ico') }}"
>
<link
href=
"{{ url_for('static', filename='css/libs/bootstrap.min.css') }}"
rel=
"stylesheet"
media=
"screen"
>
<link
href=
"{{ url_for('static', filename='css/style.css') }}"
rel=
"stylesheet"
media=
"screen"
>
{% if g.user.get_theme == 1 %}
<link
href=
"{{ url_for('static', filename='css/caliBlur-style.css') }}"
rel=
"stylesheet"
media=
"screen"
>
{% endif %}
<!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
<script src="https://oss.maxcdn.com/libs/respond.js/1.3.0/respond.min.js"></script>
<![endif]-->
{% block header %}{% endblock %}
</head>
<body
class=
"{{ page }}"
>
{% block body %}
<div
class=
"discover"
>
<h2>
{{title}}
</h2>
<div
class=
"row"
>
{% for entry in entries %}
<div
class=
"col-sm-3 col-lg-2 col-xs-6 book"
>
<div
class=
"meta"
>
<p
class=
"title"
>
{{entry.title|shortentitle}}
</p>
<p
class=
"author"
>
{% for author in entry.authors %}
<a
href=
"{{url_for('author', book_id=author.id) }}"
>
{{author.name.replace('|',',')}}
</a>
{% if not loop.last %}
&
{% endif %}
{% endfor %}
</p>
</div>
<div
class=
"btn-group"
role=
"group"
aria-label=
"Download, send to Kindle, reading"
>
{% if g.user.role_download() %}
{% if entry.data|length %}
<div
class=
"btn-group"
role=
"group"
>
{% if entry.data|length
<
2
%}
{%
for
format
in
entry
.
data
%}
<
a
href=
"{{ url_for('get_download_link_ext', book_id=entry.id, book_format=format.format|lower, anyname=entry.id|string+'.'+format.format|lower) }}"
id=
"btnGroupDrop1{{format.format|lower}}"
class=
"btn btn-primary"
role=
"button"
>
<span
class=
"glyphicon glyphicon-download"
></span>
{{format.format}} ({{ format.uncompressed_size|filesizeformat }})
</a>
{% endfor %}
{% else %}
<button
id=
"btnGroupDrop1"
type=
"button"
class=
"btn btn-primary dropdown-toggle"
data-toggle=
"dropdown"
aria-haspopup=
"true"
aria-expanded=
"false"
>
<span
class=
"glyphicon glyphicon-download"
></span>
{{_('Download')}}
<span
class=
"caret"
></span>
</button>
<ul
class=
"dropdown-menu"
aria-labelledby=
"btnGroupDrop1"
>
{% for format in entry.data %}
<li><a
href=
"{{ url_for('get_download_link_ext', book_id=entry.id, book_format=format.format|lower, anyname=entry.id|string+'.'+format.format|lower) }}"
>
{{format.format}} ({{ format.uncompressed_size|filesizeformat }})
</a></li>
{% endfor %}
</ul>
{% endif %}
</div>
{% endif %}
{% endif %}
</div>
</div>
{% endfor %}
</div>
</div>
{% endblock %}
</body>
</html>
\ No newline at end of file
cps/web.py
View file @
8ababf9f
...
...
@@ -2675,6 +2675,34 @@ def show_shelf(shelf_id):
return
redirect
(
url_for
(
"index"
))
@
app
.
route
(
"/shelfdown/<int:shelf_id>"
)
def
show_shelf_down
(
shelf_id
):
if
current_user
.
is_anonymous
:
shelf
=
ub
.
session
.
query
(
ub
.
Shelf
)
.
filter
(
ub
.
Shelf
.
is_public
==
1
,
ub
.
Shelf
.
id
==
shelf_id
)
.
first
()
else
:
shelf
=
ub
.
session
.
query
(
ub
.
Shelf
)
.
filter
(
ub
.
or_
(
ub
.
and_
(
ub
.
Shelf
.
user_id
==
int
(
current_user
.
id
),
ub
.
Shelf
.
id
==
shelf_id
),
ub
.
and_
(
ub
.
Shelf
.
is_public
==
1
,
ub
.
Shelf
.
id
==
shelf_id
)))
.
first
()
result
=
list
()
# user is allowed to access shelf
if
shelf
:
books_in_shelf
=
ub
.
session
.
query
(
ub
.
BookShelf
)
.
filter
(
ub
.
BookShelf
.
shelf
==
shelf_id
)
.
order_by
(
ub
.
BookShelf
.
order
.
asc
())
.
all
()
for
book
in
books_in_shelf
:
cur_book
=
db
.
session
.
query
(
db
.
Books
)
.
filter
(
db
.
Books
.
id
==
book
.
book_id
)
.
first
()
if
cur_book
:
result
.
append
(
cur_book
)
else
:
app
.
logger
.
info
(
'Not existing book
%
s in shelf
%
s deleted'
%
(
book
.
book_id
,
shelf
.
id
))
ub
.
session
.
query
(
ub
.
BookShelf
)
.
filter
(
ub
.
BookShelf
.
book_id
==
book
.
book_id
)
.
delete
()
ub
.
session
.
commit
()
return
render_title_template
(
'shelfdown.html'
,
entries
=
result
,
title
=
_
(
u"Shelf: '
%(name)
s'"
,
name
=
shelf
.
name
),
shelf
=
shelf
,
page
=
"shelf"
)
else
:
flash
(
_
(
u"Error opening shelf. Shelf does not exist or is not accessible"
),
category
=
"error"
)
return
redirect
(
url_for
(
"index"
))
@
app
.
route
(
"/shelf/order/<int:shelf_id>"
,
methods
=
[
"GET"
,
"POST"
])
@
login_required
def
order_shelf
(
shelf_id
):
...
...
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