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
76c7cdf4
Commit
76c7cdf4
authored
Apr 15, 2016
by
JanB
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add config option for upload feature
parent
952d389d
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
11 additions
and
1 deletion
+11
-1
config.ini
config.ini
+1
-0
config.py
cps/config.py
+3
-0
layout.html
cps/templates/layout.html
+2
-0
web.py
cps/web.py
+3
-0
readme.md
readme.md
+2
-1
No files found.
config.ini
View file @
76c7cdf4
...
@@ -9,3 +9,4 @@ NEWEST_BOOKS = 60
...
@@ -9,3 +9,4 @@ NEWEST_BOOKS = 60
TITLE_REGEX
=
^(A|The|An|Der|Die|Das|Den|Ein|Eine|Einen|Dem|Des|Einem|Eines)
\s
+
TITLE_REGEX
=
^(A|The|An|Der|Die|Das|Den|Ein|Eine|Einen|Dem|Des|Einem|Eines)
\s
+
DEVELOPMENT
=
0
DEVELOPMENT
=
0
PUBLIC_REG
=
0
PUBLIC_REG
=
0
UPLOADING
=
0
cps/config.py
View file @
76c7cdf4
...
@@ -59,6 +59,7 @@ CheckSection('Advanced')
...
@@ -59,6 +59,7 @@ CheckSection('Advanced')
TITLE_REGEX
=
check_setting_str
(
CFG
,
'Advanced'
,
'TITLE_REGEX'
,
'^(A|The|An|Der|Die|Das|Den|Ein|Eine|Einen|Dem|Des|Einem|Eines)
\
s+'
)
TITLE_REGEX
=
check_setting_str
(
CFG
,
'Advanced'
,
'TITLE_REGEX'
,
'^(A|The|An|Der|Die|Das|Den|Ein|Eine|Einen|Dem|Des|Einem|Eines)
\
s+'
)
DEVELOPMENT
=
bool
(
check_setting_int
(
CFG
,
'Advanced'
,
'DEVELOPMENT'
,
0
))
DEVELOPMENT
=
bool
(
check_setting_int
(
CFG
,
'Advanced'
,
'DEVELOPMENT'
,
0
))
PUBLIC_REG
=
bool
(
check_setting_int
(
CFG
,
'Advanced'
,
'PUBLIC_REG'
,
0
))
PUBLIC_REG
=
bool
(
check_setting_int
(
CFG
,
'Advanced'
,
'PUBLIC_REG'
,
0
))
UPLOADING
=
bool
(
check_setting_int
(
CFG
,
'Advanced'
,
'UPLOADING'
,
0
))
SYS_ENCODING
=
"UTF-8"
SYS_ENCODING
=
"UTF-8"
...
@@ -76,6 +77,7 @@ configval["NEWEST_BOOKS"] = NEWEST_BOOKS
...
@@ -76,6 +77,7 @@ configval["NEWEST_BOOKS"] = NEWEST_BOOKS
configval
[
"DEVELOPMENT"
]
=
DEVELOPMENT
configval
[
"DEVELOPMENT"
]
=
DEVELOPMENT
configval
[
"TITLE_REGEX"
]
=
TITLE_REGEX
configval
[
"TITLE_REGEX"
]
=
TITLE_REGEX
configval
[
"PUBLIC_REG"
]
=
PUBLIC_REG
configval
[
"PUBLIC_REG"
]
=
PUBLIC_REG
configval
[
"UPLOADING"
]
=
UPLOADING
def
save_config
(
configval
):
def
save_config
(
configval
):
new_config
=
ConfigObj
()
new_config
=
ConfigObj
()
...
@@ -91,6 +93,7 @@ def save_config(configval):
...
@@ -91,6 +93,7 @@ def save_config(configval):
new_config
[
'Advanced'
][
'TITLE_REGEX'
]
=
configval
[
"TITLE_REGEX"
]
new_config
[
'Advanced'
][
'TITLE_REGEX'
]
=
configval
[
"TITLE_REGEX"
]
new_config
[
'Advanced'
][
'DEVELOPMENT'
]
=
int
(
configval
[
"DEVELOPMENT"
])
new_config
[
'Advanced'
][
'DEVELOPMENT'
]
=
int
(
configval
[
"DEVELOPMENT"
])
new_config
[
'Advanced'
][
'PUBLIC_REG'
]
=
int
(
configval
[
"PUBLIC_REG"
])
new_config
[
'Advanced'
][
'PUBLIC_REG'
]
=
int
(
configval
[
"PUBLIC_REG"
])
new_config
[
'Advanced'
][
'UPLOADING'
]
=
int
(
configval
[
"UPLOADING"
])
new_config
.
write
()
new_config
.
write
()
return
"Saved"
return
"Saved"
...
...
cps/templates/layout.html
View file @
76c7cdf4
...
@@ -64,6 +64,7 @@
...
@@ -64,6 +64,7 @@
<ul
class=
"nav navbar-nav navbar-right"
id=
"main-nav"
>
<ul
class=
"nav navbar-nav navbar-right"
id=
"main-nav"
>
{% if g.user.is_authenticated() %}
{% if g.user.is_authenticated() %}
{% if g.user.role %}
{% if g.user.role %}
{% if g.allow_upload %}
<li>
<li>
<form
id=
"form-upload"
class=
"navbar-form"
action=
"{{ url_for('upload') }}"
method=
"post"
enctype=
"multipart/form-data"
>
<form
id=
"form-upload"
class=
"navbar-form"
action=
"{{ url_for('upload') }}"
method=
"post"
enctype=
"multipart/form-data"
>
<div
class=
"form-group"
>
<div
class=
"form-group"
>
...
@@ -72,6 +73,7 @@
...
@@ -72,6 +73,7 @@
</form>
</form>
</li>
</li>
{% endif %}
{% endif %}
{% endif %}
{% if g.user.role %}
{% if g.user.role %}
<li><a
href=
"{{url_for('user_list')}}"
><span
class=
"glyphicon glyphicon-dashboard"
></span>
Admin
</a></li>
<li><a
href=
"{{url_for('user_list')}}"
><span
class=
"glyphicon glyphicon-dashboard"
></span>
Admin
</a></li>
{% endif %}
{% endif %}
...
...
cps/web.py
View file @
76c7cdf4
...
@@ -157,6 +157,7 @@ def before_request():
...
@@ -157,6 +157,7 @@ def before_request():
g
.
user
=
current_user
g
.
user
=
current_user
g
.
public_shelfes
=
ub
.
session
.
query
(
ub
.
Shelf
)
.
filter
(
ub
.
Shelf
.
is_public
==
1
)
.
all
()
g
.
public_shelfes
=
ub
.
session
.
query
(
ub
.
Shelf
)
.
filter
(
ub
.
Shelf
.
is_public
==
1
)
.
all
()
g
.
allow_registration
=
config
.
PUBLIC_REG
g
.
allow_registration
=
config
.
PUBLIC_REG
g
.
allow_upload
=
config
.
UPLOADING
@
app
.
route
(
"/feed"
)
@
app
.
route
(
"/feed"
)
def
feed_index
():
def
feed_index
():
...
@@ -756,6 +757,8 @@ def edit_book(book_id):
...
@@ -756,6 +757,8 @@ def edit_book(book_id):
@
login_required
@
login_required
@
admin_required
@
admin_required
def
upload
():
def
upload
():
if
not
config
.
UPLOADING
:
abort
(
404
)
## create the function for sorting...
## create the function for sorting...
db
.
session
.
connection
()
.
connection
.
connection
.
create_function
(
"title_sort"
,
1
,
db
.
title_sort
)
db
.
session
.
connection
()
.
connection
.
connection
.
create_function
(
"title_sort"
,
1
,
db
.
title_sort
)
db
.
session
.
connection
()
.
connection
.
connection
.
create_function
(
'uuid4'
,
0
,
lambda
:
str
(
uuid4
()))
db
.
session
.
connection
()
.
connection
.
connection
.
create_function
(
'uuid4'
,
0
,
lambda
:
str
(
uuid4
()))
...
...
readme.md
View file @
76c7cdf4
...
@@ -26,7 +26,8 @@ Also available as [Docker image](https://registry.hub.docker.com/u/janeczku/cali
...
@@ -26,7 +26,8 @@ Also available as [Docker image](https://registry.hub.docker.com/u/janeczku/cali
## Quick start
## Quick start
1.
Open config.ini and set DB_ROOT to the path of the folder where your Calibre library (metadata.db) lives
1.
Open config.ini and set DB_ROOT to the path of the folder where your Calibre library (metadata.db) lives
3.
To enable public user registration set PUBLIC_REG to 1
2.
To enable public user registration set PUBLIC_REG to 1
3.
To enable uploading of PDF books set UPLOADING to 1
4.
Execute the command:
`python cps.py`
4.
Execute the command:
`python cps.py`
5.
Point your browser to
`http://localhost:8083`
or
`http://localhost:8083/feed`
for the OPDS catalog
5.
Point your browser to
`http://localhost:8083`
or
`http://localhost:8083/feed`
for the OPDS catalog
...
...
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