From f6cc48e682f824e707751b35926bb9dda9eee786 Mon Sep 17 00:00:00 2001 From: Akhyar Amarullah Date: Sat, 7 Jan 2017 21:15:47 +0700 Subject: [PATCH] Make DEFAULT_PASS configurable --- config.ini.example | 1 + cps/config.py | 4 +++- cps/ub.py | 3 +-- readme.md | 51 +++++++++++++++++++++++++++------------------- 4 files changed, 35 insertions(+), 24 deletions(-) diff --git a/config.ini.example b/config.ini.example index 02a57541..4d355527 100644 --- a/config.ini.example +++ b/config.ini.example @@ -5,6 +5,7 @@ MAIN_DIR = LOG_DIR = PORT = 8083 NEWEST_BOOKS = 60 +DEFAULT_PASS = admin123 [Advanced] TITLE_REGEX = ^(A|The|An|Der|Die|Das|Den|Ein|Eine|Einen|Dem|Des|Einem|Eines)\s+ DEVELOPMENT = 0 diff --git a/cps/config.py b/cps/config.py index 11dffae5..6b00434a 100755 --- a/cps/config.py +++ b/cps/config.py @@ -55,8 +55,9 @@ APP_DB_ROOT = check_setting_str(CFG, 'General', 'APP_DB_ROOT', os.getcwd()) MAIN_DIR = check_setting_str(CFG, 'General', 'MAIN_DIR', os.getcwd()) LOG_DIR = check_setting_str(CFG, 'General', 'LOG_DIR', os.getcwd()) PORT = check_setting_int(CFG, 'General', 'PORT', 8083) -NEWEST_BOOKS = check_setting_str(CFG, 'General', 'NEWEST_BOOKS', 60) +NEWEST_BOOKS = check_setting_int(CFG, 'General', 'NEWEST_BOOKS', 60) RANDOM_BOOKS = check_setting_int(CFG, 'General', 'RANDOM_BOOKS', 4) +DEFAULT_PASS = check_setting_str(CFG, 'General', 'DEFAULT_PASS', 'admin123') # override from environment variables, if any DB_ROOT = env.get('DB_ROOT', DB_ROOT) APP_DB_ROOT = env.get('APP_DB_ROOT', APP_DB_ROOT) @@ -65,6 +66,7 @@ LOG_DIR = env.get('LOG_DIR', LOG_DIR) PORT = int(env.get('PORT', PORT)) NEWEST_BOOKS = int(env.get('NEWEST_BOOKS', NEWEST_BOOKS)) RANDOM_BOOKS = int(env.get('RANDOM_BOOKS', RANDOM_BOOKS)) +DEFAULT_PASS = env.get('DEFAULT_PASS', DEFAULT_PASS) CheckSection('Advanced') diff --git a/cps/ub.py b/cps/ub.py index 19961960..b24366d0 100644 --- a/cps/ub.py +++ b/cps/ub.py @@ -7,7 +7,6 @@ from sqlalchemy.ext.declarative import declarative_base from sqlalchemy.orm import * import os import config -from os import environ as env from werkzeug.security import generate_password_hash dbpath = os.path.join(config.APP_DB_ROOT, "app.db") @@ -20,7 +19,7 @@ ROLE_DOWNLOAD = 2 ROLE_UPLOAD = 4 ROLE_EDIT = 8 ROLE_PASSWD = 16 -DEFAULT_PASS = env.get("DEFAULT_PASS", "admin123") +DEFAULT_PASS = config.DEFAULT_PASS class User(Base): diff --git a/readme.md b/readme.md index 84530a92..21c84e57 100755 --- a/readme.md +++ b/readme.md @@ -1,4 +1,4 @@ -##About +## About Calibre Web is a web app providing a clean interface for browsing, reading and downloading eBooks using an existing [Calibre](https://calibre-ebook.com) database. @@ -6,12 +6,13 @@ Calibre Web is a web app providing a clean interface for browsing, reading and d ![screenshot](https://raw.githubusercontent.com/janeczku/docker-calibre-web/master/screenshot.png) -##Features +## Features + - Bootstrap 3 HTML5 interface - User management - Admin interface - User Interface in english, german and french -- OPDS feed for eBook reader apps +- OPDS feed for eBook reader apps - Filter and search by titles, authors, tags, series and language - Create custom book collection (shelves) - Support for editing eBook metadata @@ -28,28 +29,35 @@ Calibre Web is a web app providing a clean interface for browsing, reading and d 1. Rename `config.ini.example` to `config.ini` and set `DB_ROOT` to the path of the folder where your Calibre library (metadata.db) lives 2. Execute the command: `python cps.py` -3. Point your browser to `http://localhost:8083` or `http://localhost:8083/opds` for the OPDS catalog +3. Point your browser to `http://localhost:8083` or `http://localhost:8083/opds` for the OPDS catalog -**Default admin login:** -*Username:* admin +**Default admin login:** +*Username:* admin *Password:* admin123 -## Runtime Configuration Options +## Configuration Options + +`PUBLIC_REG` +Set to 1 to enable public user registration. + +`ANON_BROWSE` +Set to 1 to allow not logged in users to browse the catalog. + +`UPLOADING` +Set to 1 to enable PDF uploading. This requires the imagemagick library to be installed. -`PUBLIC_REG` -Set to 1 to enable public user registration. -`ANON_BROWSE` -Set to 1 to allow not logged in users to browse the catalog. -`UPLOADING` -Set to 1 to enable PDF uploading. This requires the imagemagick library to be installed. +`DEFAULT_PASS` +Default password for user `admin` + +> See `config.ini.example` for all available options. You can also use environment variables to override them. ## Requirements Python 2.7+ - -Optionally, to enable on-the-fly conversion from EPUB to MOBI when using the send-to-kindle feature: -[Download](http://www.amazon.com/gp/feature.html?docId=1000765211) Amazon's KindleGen tool for your platform and place the binary named as `kindlegen` in the `vendor` folder. +Optionally, to enable on-the-fly conversion from EPUB to MOBI when using the send-to-kindle feature: + +[Download](http://www.amazon.com/gp/feature.html?docId=1000765211) Amazon's KindleGen tool for your platform and place the binary named as `kindlegen` in the `vendor` folder. ## Docker image @@ -82,6 +90,7 @@ http { Apache 2.4 configuration for a local server listening on port 443, mapping calibre web to /calibre-web: The following modules have to be activated: headers, proxy, proxy_html, proxy_http, rewrite, xml2enc. + ``` Listen 443 @@ -91,13 +100,13 @@ Listen 443 SSLCipherSuite ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP:+eNULL SSLCertificateFile "C:\Apache24\conf\ssl\test.crt" SSLCertificateKeyFile "C:\Apache24\conf\ssl\test.key" - - + + ProxyHTMLEnable On ProxyPass http://127.0.0.1:8083/ - ProxyPassReverse http://127.0.0.1:8083/ + ProxyPassReverse http://127.0.0.1:8083/ Header edit Location "^http://(.*?)/" "https://$1/calibre-web/" - ProxyHTMLURLMap / /calibre-web/ + ProxyHTMLURLMap / /calibre-web/ ``` @@ -122,4 +131,4 @@ Replace the user and ExecStart with your user and foldernames. `sudo systemctl enable cps.service` -enables the service. +enables the service.