1
0
mirror of https://github.com/janeczku/calibre-web synced 2024-11-28 04:19:59 +00:00

Add config option for upload feature

This commit is contained in:
JanB 2016-04-15 19:39:25 +02:00
parent 952d389dc5
commit 76c7cdf465
5 changed files with 11 additions and 1 deletions

View File

@ -9,3 +9,4 @@ NEWEST_BOOKS = 60
TITLE_REGEX = ^(A|The|An|Der|Die|Das|Den|Ein|Eine|Einen|Dem|Des|Einem|Eines)\s+
DEVELOPMENT = 0
PUBLIC_REG = 0
UPLOADING = 0

View File

@ -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+')
DEVELOPMENT = bool(check_setting_int(CFG, 'Advanced', 'DEVELOPMENT', 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"
@ -76,6 +77,7 @@ configval["NEWEST_BOOKS"] = NEWEST_BOOKS
configval["DEVELOPMENT"] = DEVELOPMENT
configval["TITLE_REGEX"] = TITLE_REGEX
configval["PUBLIC_REG"] = PUBLIC_REG
configval["UPLOADING"] = UPLOADING
def save_config(configval):
new_config = ConfigObj()
@ -91,6 +93,7 @@ def save_config(configval):
new_config['Advanced']['TITLE_REGEX'] = configval["TITLE_REGEX"]
new_config['Advanced']['DEVELOPMENT'] = int(configval["DEVELOPMENT"])
new_config['Advanced']['PUBLIC_REG'] = int(configval["PUBLIC_REG"])
new_config['Advanced']['UPLOADING'] = int(configval["UPLOADING"])
new_config.write()
return "Saved"

View File

@ -64,6 +64,7 @@
<ul class="nav navbar-nav navbar-right" id="main-nav">
{% if g.user.is_authenticated() %}
{% if g.user.role %}
{% if g.allow_upload %}
<li>
<form id="form-upload" class="navbar-form" action="{{ url_for('upload') }}" method="post" enctype="multipart/form-data">
<div class="form-group">
@ -72,6 +73,7 @@
</form>
</li>
{% endif %}
{% endif %}
{% if g.user.role %}
<li><a href="{{url_for('user_list')}}"><span class="glyphicon glyphicon-dashboard"></span> Admin</a></li>
{% endif %}

View File

@ -157,6 +157,7 @@ def before_request():
g.user = current_user
g.public_shelfes = ub.session.query(ub.Shelf).filter(ub.Shelf.is_public == 1).all()
g.allow_registration = config.PUBLIC_REG
g.allow_upload = config.UPLOADING
@app.route("/feed")
def feed_index():
@ -756,6 +757,8 @@ def edit_book(book_id):
@login_required
@admin_required
def upload():
if not config.UPLOADING:
abort(404)
## 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('uuid4', 0, lambda : str(uuid4()))

View File

@ -26,7 +26,8 @@ Also available as [Docker image](https://registry.hub.docker.com/u/janeczku/cali
## Quick start
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`
5. Point your browser to `http://localhost:8083` or `http://localhost:8083/feed` for the OPDS catalog