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
ba54b9a3
Commit
ba54b9a3
authored
Nov 12, 2017
by
OzzieIsaacs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix #365
parent
fd39cbaa
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
141 additions
and
77 deletions
+141
-77
layout.html
cps/templates/layout.html
+4
-0
user_edit.html
cps/templates/user_edit.html
+8
-0
ub.py
cps/ub.py
+15
-5
web.py
cps/web.py
+114
-72
No files found.
cps/templates/layout.html
View file @
ba54b9a3
...
@@ -104,7 +104,10 @@
...
@@ -104,7 +104,10 @@
<nav
class=
"navigation"
>
<nav
class=
"navigation"
>
<ul
class=
"list-unstyled"
id=
"scnd-nav"
intent
in-standard-append=
"nav.navigation"
in-mobile-after=
"#main-nav"
in-mobile-class=
"nav navbar-nav"
>
<ul
class=
"list-unstyled"
id=
"scnd-nav"
intent
in-standard-append=
"nav.navigation"
in-mobile-after=
"#main-nav"
in-mobile-class=
"nav navbar-nav"
>
<li
class=
"nav-head hidden-xs"
>
{{_('Browse')}}
</li>
<li
class=
"nav-head hidden-xs"
>
{{_('Browse')}}
</li>
{% if g.user.show_recent() %}
<li
id=
"nav_new"
><a
href=
"{{url_for('index')}}"
><span
class=
"glyphicon glyphicon-book"
></span>
{{_('Recently Added')}}
</a></li>
<li
id=
"nav_new"
><a
href=
"{{url_for('index')}}"
><span
class=
"glyphicon glyphicon-book"
></span>
{{_('Recently Added')}}
</a></li>
{%endif%}
{% if g.user.show_sorted() %}
<li
class=
"dropdown"
>
<li
class=
"dropdown"
>
<a
href=
"#"
class=
"dropdown-toggle"
data-toggle=
"dropdown"
role=
"button"
aria-haspopup=
"true"
aria-expanded=
"false"
>
<a
href=
"#"
class=
"dropdown-toggle"
data-toggle=
"dropdown"
role=
"button"
aria-haspopup=
"true"
aria-expanded=
"false"
>
<span
class=
"glyphicon glyphicon-sort-by-attributes"
></span>
{{_('Sorted Books')}}
<span
class=
"glyphicon glyphicon-sort-by-attributes"
></span>
{{_('Sorted Books')}}
...
@@ -117,6 +120,7 @@
...
@@ -117,6 +120,7 @@
<li><a
href=
"{{url_for('titles_descending')}}"
>
{{_('Sort By')}} {{_('Title')}} ({{_('Descending')}})
</a></li>
<li><a
href=
"{{url_for('titles_descending')}}"
>
{{_('Sort By')}} {{_('Title')}} ({{_('Descending')}})
</a></li>
</ul>
</ul>
</li>
</li>
{%endif%}
{% if g.user.show_hot_books() %}
{% if g.user.show_hot_books() %}
<li
id=
"nav_hot"
><a
href=
"{{url_for('hot_books')}}"
><span
class=
"glyphicon glyphicon-fire"
></span>
{{_('Hot Books')}}
</a></li>
<li
id=
"nav_hot"
><a
href=
"{{url_for('hot_books')}}"
><span
class=
"glyphicon glyphicon-fire"
></span>
{{_('Hot Books')}}
</a></li>
{%endif%}
{%endif%}
...
...
cps/templates/user_edit.html
View file @
ba54b9a3
...
@@ -45,6 +45,14 @@
...
@@ -45,6 +45,14 @@
<input
type=
"checkbox"
name=
"show_random"
id=
"show_random"
{%
if
content
.
show_random_books
()
%}
checked
{%
endif
%}
>
<input
type=
"checkbox"
name=
"show_random"
id=
"show_random"
{%
if
content
.
show_random_books
()
%}
checked
{%
endif
%}
>
<label
for=
"show_random"
>
{{_('Show random books')}}
</label>
<label
for=
"show_random"
>
{{_('Show random books')}}
</label>
</div>
</div>
<div
class=
"form-group"
>
<input
type=
"checkbox"
name=
"show_recent"
id=
"show_recent"
{%
if
content
.
show_recent
()
%}
checked
{%
endif
%}
>
<label
for=
"show_recent"
>
{{_('Show recent books')}}
</label>
</div>
<div
class=
"form-group"
>
<input
type=
"checkbox"
name=
"show_sorted"
id=
"show_sorted"
{%
if
content
.
show_sorted
()
%}
checked
{%
endif
%}
>
<label
for=
"show_sorted"
>
{{_('Show sorted books')}}
</label>
</div>
<div
class=
"form-group"
>
<div
class=
"form-group"
>
<input
type=
"checkbox"
name=
"show_hot"
id=
"show_hot"
{%
if
content
.
show_hot_books
()
%}
checked
{%
endif
%}
>
<input
type=
"checkbox"
name=
"show_hot"
id=
"show_hot"
{%
if
content
.
show_hot_books
()
%}
checked
{%
endif
%}
>
<label
for=
"show_hot"
>
{{_('Show hot books')}}
</label>
<label
for=
"show_hot"
>
{{_('Show hot books')}}
</label>
...
...
cps/ub.py
View file @
ba54b9a3
...
@@ -39,6 +39,9 @@ SIDEBAR_RANDOM = 32
...
@@ -39,6 +39,9 @@ SIDEBAR_RANDOM = 32
SIDEBAR_AUTHOR
=
64
SIDEBAR_AUTHOR
=
64
SIDEBAR_BEST_RATED
=
128
SIDEBAR_BEST_RATED
=
128
SIDEBAR_READ_AND_UNREAD
=
256
SIDEBAR_READ_AND_UNREAD
=
256
SIDEBAR_RECENT
=
512
SIDEBAR_SORTED
=
1024
DEFAULT_PASS
=
"admin123"
DEFAULT_PASS
=
"admin123"
DEFAULT_PORT
=
int
(
os
.
environ
.
get
(
"CALIBRE_PORT"
,
8083
))
DEFAULT_PORT
=
int
(
os
.
environ
.
get
(
"CALIBRE_PORT"
,
8083
))
...
@@ -120,6 +123,12 @@ class UserBase:
...
@@ -120,6 +123,12 @@ class UserBase:
def
show_hot_books
(
self
):
def
show_hot_books
(
self
):
return
bool
((
self
.
sidebar_view
is
not
None
)
and
(
self
.
sidebar_view
&
SIDEBAR_HOT
==
SIDEBAR_HOT
))
return
bool
((
self
.
sidebar_view
is
not
None
)
and
(
self
.
sidebar_view
&
SIDEBAR_HOT
==
SIDEBAR_HOT
))
def
show_recent
(
self
):
return
bool
((
self
.
sidebar_view
is
not
None
)
and
(
self
.
sidebar_view
&
SIDEBAR_RECENT
==
SIDEBAR_RECENT
))
def
show_sorted
(
self
):
return
bool
((
self
.
sidebar_view
is
not
None
)
and
(
self
.
sidebar_view
&
SIDEBAR_SORTED
==
SIDEBAR_SORTED
))
def
show_series
(
self
):
def
show_series
(
self
):
return
bool
((
self
.
sidebar_view
is
not
None
)
and
(
self
.
sidebar_view
&
SIDEBAR_SERIES
==
SIDEBAR_SERIES
))
return
bool
((
self
.
sidebar_view
is
not
None
)
and
(
self
.
sidebar_view
&
SIDEBAR_SERIES
==
SIDEBAR_SERIES
))
...
@@ -496,9 +505,10 @@ def migrate_Database():
...
@@ -496,9 +505,10 @@ def migrate_Database():
conn
=
engine
.
connect
()
conn
=
engine
.
connect
()
conn
.
execute
(
"UPDATE user SET 'sidebar_view' = (random_books* :side_random + language_books * :side_lang "
conn
.
execute
(
"UPDATE user SET 'sidebar_view' = (random_books* :side_random + language_books * :side_lang "
"+ series_books * :side_series + category_books * :side_category + hot_books * "
"+ series_books * :side_series + category_books * :side_category + hot_books * "
":side_hot + :side_autor + :detail_random)"
,{
'side_random'
:
SIDEBAR_RANDOM
,
":side_hot + :side_autor + :detail_random)"
'side_lang'
:
SIDEBAR_LANGUAGE
,
'side_series'
:
SIDEBAR_SERIES
,
'side_category'
:
SIDEBAR_CATEGORY
,
,{
'side_random'
:
SIDEBAR_RANDOM
,
'side_lang'
:
SIDEBAR_LANGUAGE
,
'side_series'
:
SIDEBAR_SERIES
,
'side_hot'
:
SIDEBAR_HOT
,
'side_autor'
:
SIDEBAR_AUTHOR
,
'detail_random'
:
DETAIL_RANDOM
})
'side_category'
:
SIDEBAR_CATEGORY
,
'side_hot'
:
SIDEBAR_HOT
,
'side_autor'
:
SIDEBAR_AUTHOR
,
'detail_random'
:
DETAIL_RANDOM
})
session
.
commit
()
session
.
commit
()
try
:
try
:
session
.
query
(
exists
()
.
where
(
User
.
mature_content
))
.
scalar
()
session
.
query
(
exists
()
.
where
(
User
.
mature_content
))
.
scalar
()
...
@@ -582,8 +592,8 @@ def create_admin_user():
...
@@ -582,8 +592,8 @@ def create_admin_user():
user
.
nickname
=
"admin"
user
.
nickname
=
"admin"
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_RANDOM
+
SIDEBAR_AUTHOR
+
SIDEBAR_BEST_RATED
+
SIDEBAR_READ_AND_UNREAD
+
SIDEBAR_RECENT
+
\
SIDEBAR_SORTED
user
.
password
=
generate_password_hash
(
DEFAULT_PASS
)
user
.
password
=
generate_password_hash
(
DEFAULT_PASS
)
...
...
cps/web.py
View file @
ba54b9a3
This diff is collapsed.
Click to expand it.
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