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
a66873a9
Commit
a66873a9
authored
Mar 11, 2019
by
Ozzieisaacs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added file formats view
parent
4a332785
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
40 additions
and
5 deletions
+40
-5
list.html
cps/templates/list.html
+6
-2
ub.py
cps/ub.py
+6
-1
web.py
cps/web.py
+28
-2
No files found.
cps/templates/list.html
View file @
a66873a9
...
@@ -19,7 +19,7 @@
...
@@ -19,7 +19,7 @@
{% for entry in entries %}
{% for entry in entries %}
<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=
"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-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 )}
}"
>
<div
class=
"col-xs-10 col-sm-10 col-md-11"
><a
id=
"list_{{loop.index0}}"
href=
"{
% if entry.format %}{{url_for(folder, book_id=entry.format )}}{% else %}{{url_for(folder, book_id=entry[0].id )}}{% endif %
}"
>
{% if entry.name %}
{% if entry.name %}
<div
class=
"rating"
>
<div
class=
"rating"
>
{% for number in range(entry.name) %}
{% for number in range(entry.name) %}
...
@@ -31,7 +31,11 @@
...
@@ -31,7 +31,11 @@
{% endif %}
{% endif %}
{% endfor %}
{% endfor %}
</div>
</div>
{% else %} {{entry[0].name}}{% endif %}
</a></div>
{% else %}
{% if entry.format %}
{{entry.format}}
{% else %}
{{entry[0].name}}{% endif %}{% endif %}
</a></div>
</div>
</div>
{% endfor %}
{% endfor %}
</div>
</div>
...
...
cps/ub.py
View file @
a66873a9
...
@@ -71,6 +71,7 @@ SIDEBAR_SORTED = 1024
...
@@ -71,6 +71,7 @@ SIDEBAR_SORTED = 1024
MATURE_CONTENT
=
2048
MATURE_CONTENT
=
2048
SIDEBAR_PUBLISHER
=
4096
SIDEBAR_PUBLISHER
=
4096
SIDEBAR_RATING
=
8192
SIDEBAR_RATING
=
8192
SIDEBAR_FORMAT
=
16384
UPDATE_STABLE
=
0
UPDATE_STABLE
=
0
AUTO_UPDATE_STABLE
=
1
AUTO_UPDATE_STABLE
=
1
...
@@ -143,9 +144,13 @@ def get_sidebar_config(kwargs=[]):
...
@@ -143,9 +144,13 @@ def get_sidebar_config(kwargs=[]):
sidebar
.
append
({
"glyph"
:
"glyphicon-star-empty"
,
"text"
:
_
(
'Ratings'
),
"link"
:
'web.ratings_list'
,
"id"
:
"rate"
,
sidebar
.
append
({
"glyph"
:
"glyphicon-star-empty"
,
"text"
:
_
(
'Ratings'
),
"link"
:
'web.ratings_list'
,
"id"
:
"rate"
,
"visibility"
:
SIDEBAR_RATING
,
'public'
:
True
,
"visibility"
:
SIDEBAR_RATING
,
'public'
:
True
,
"page"
:
"rating"
,
"show_text"
:
_
(
'Show ratings selection'
),
"config_show"
:
True
})
"page"
:
"rating"
,
"show_text"
:
_
(
'Show ratings selection'
),
"config_show"
:
True
})
sidebar
.
append
({
"glyph"
:
"glyphicon-file"
,
"text"
:
_
(
'File formats'
),
"link"
:
'web.formats_list'
,
"id"
:
"format"
,
"visibility"
:
SIDEBAR_FORMAT
,
'public'
:
True
,
"page"
:
"format"
,
"show_text"
:
_
(
'Show file formats selection'
),
"config_show"
:
True
})
return
sidebar
return
sidebar
class
UserBase
:
class
UserBase
:
@
property
@
property
...
@@ -847,7 +852,7 @@ def create_admin_user():
...
@@ -847,7 +852,7 @@ def create_admin_user():
user
.
role
=
ROLE_USER
+
ROLE_ADMIN
+
ROLE_DOWNLOAD
+
ROLE_UPLOAD
+
ROLE_EDIT
+
ROLE_DELETE_BOOKS
+
ROLE_PASSWD
user
.
role
=
ROLE_USER
+
ROLE_ADMIN
+
ROLE_DOWNLOAD
+
ROLE_UPLOAD
+
ROLE_EDIT
+
ROLE_DELETE_BOOKS
+
ROLE_PASSWD
user
.
sidebar_view
=
DETAIL_RANDOM
+
SIDEBAR_LANGUAGE
+
SIDEBAR_SERIES
+
SIDEBAR_CATEGORY
+
SIDEBAR_HOT
+
\
user
.
sidebar_view
=
DETAIL_RANDOM
+
SIDEBAR_LANGUAGE
+
SIDEBAR_SERIES
+
SIDEBAR_CATEGORY
+
SIDEBAR_HOT
+
\
SIDEBAR_RANDOM
+
SIDEBAR_AUTHOR
+
SIDEBAR_BEST_RATED
+
SIDEBAR_READ_AND_UNREAD
+
SIDEBAR_RECENT
+
\
SIDEBAR_RANDOM
+
SIDEBAR_AUTHOR
+
SIDEBAR_BEST_RATED
+
SIDEBAR_READ_AND_UNREAD
+
SIDEBAR_RECENT
+
\
SIDEBAR_SORTED
+
+
MATURE_CONTENT
+
SIDEBAR_PUBLISHER
+
SIDEBAR_RATING
SIDEBAR_SORTED
+
MATURE_CONTENT
+
SIDEBAR_PUBLISHER
+
SIDEBAR_RATING
+
SIDEBAR_FORMAT
user
.
password
=
generate_password_hash
(
DEFAULT_PASS
)
user
.
password
=
generate_password_hash
(
DEFAULT_PASS
)
...
...
cps/web.py
View file @
a66873a9
...
@@ -722,7 +722,6 @@ def series(book_id, page):
...
@@ -722,7 +722,6 @@ def series(book_id, page):
abort
(
404
)
abort
(
404
)
# (cast(db.Ratings.rating/2, SQLString)).label('name'))\
@
web
.
route
(
"/ratings"
)
@
web
.
route
(
"/ratings"
)
@
login_required_if_no_ano
@
login_required_if_no_ano
def
ratings_list
():
def
ratings_list
():
...
@@ -746,7 +745,34 @@ def ratings(book_id, page):
...
@@ -746,7 +745,34 @@ def ratings(book_id, page):
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
()])
[
db
.
Books
.
timestamp
.
desc
()])
return
render_title_template
(
'index.html'
,
random
=
random
,
pagination
=
pagination
,
entries
=
entries
,
return
render_title_template
(
'index.html'
,
random
=
random
,
pagination
=
pagination
,
entries
=
entries
,
title
=
_
(
u"Ratings:
%(rating)
s stars"
,
rating
=
(
name
.
rating
/
2
)),
page
=
"ratings"
)
title
=
_
(
u"Rating:
%(rating)
s stars"
,
rating
=
int
(
name
.
rating
/
2
)),
page
=
"ratings"
)
else
:
abort
(
404
)
@
web
.
route
(
"/formats"
)
@
login_required_if_no_ano
def
formats_list
():
if
current_user
.
check_visibility
(
ub
.
SIDEBAR_FORMAT
):
entries
=
db
.
session
.
query
(
db
.
Data
,
func
.
count
(
'data.book'
)
.
label
(
'count'
),
db
.
Data
.
format
.
label
(
'format'
))
\
.
join
(
db
.
Books
)
.
filter
(
common_filters
())
\
.
group_by
(
db
.
Data
.
format
)
.
order_by
(
db
.
Data
.
format
)
.
all
()
return
render_title_template
(
'list.html'
,
entries
=
entries
,
folder
=
'web.formats'
,
charlist
=
list
(),
title
=
_
(
u"File formats list"
),
page
=
"formatslist"
)
else
:
abort
(
404
)
@
web
.
route
(
"/formats/<book_id>/"
,
defaults
=
{
'page'
:
1
})
@
web
.
route
(
"/formats/<book_id>/<int:page>"
)
@
login_required_if_no_ano
def
formats
(
book_id
,
page
):
name
=
db
.
session
.
query
(
db
.
Data
)
.
filter
(
db
.
Data
.
format
==
book_id
.
upper
())
.
first
()
if
name
:
entries
,
random
,
pagination
=
fill_indexpage
(
page
,
db
.
Books
,
db
.
Books
.
data
.
any
(
db
.
Data
.
format
==
book_id
.
upper
()),
[
db
.
Books
.
timestamp
.
desc
()])
return
render_title_template
(
'index.html'
,
random
=
random
,
pagination
=
pagination
,
entries
=
entries
,
title
=
_
(
u"File format:
%(format)
s"
,
format
=
name
.
format
),
page
=
"formats"
)
else
:
else
:
abort
(
404
)
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