|
@@ -2,43 +2,44 @@
|
|
|
# -*- coding: UTF-8 -*-
|
|
|
# fmt: off
|
|
|
# flake8: noqa
|
|
|
-
|
|
|
+import logging
|
|
|
import os
|
|
|
|
|
|
settings = {
|
|
|
- 'installed' : False,
|
|
|
- "autoreload" : True,
|
|
|
- "xsrf_cookies" : False,
|
|
|
- "static_host" : "",
|
|
|
- "nuxt_env_path" : os.path.join(os.path.dirname(__file__), "../app/.env"),
|
|
|
- "html_path" : os.path.join(os.path.dirname(__file__), "../app/dist"),
|
|
|
- "i18n_path" : os.path.join(os.path.dirname(__file__), "i18n"),
|
|
|
- "static_path" : os.path.join(os.path.dirname(__file__), "resources"),
|
|
|
- "resource_path" : os.path.join(os.path.dirname(__file__), "resources"),
|
|
|
- "settings_path" : "/data/books/settings/",
|
|
|
- "progress_path" : "/data/books/progress/",
|
|
|
- "convert_path" : "/data/books/convert/",
|
|
|
- "upload_path" : "/data/books/upload/",
|
|
|
- "scan_upload_path" : "/data/books/imports/",
|
|
|
- "extract_path" : "/data/books/extract/",
|
|
|
- "with_library" : "/data/books/library/",
|
|
|
- "cookie_secret" : "cookie_secret",
|
|
|
- "cookie_expire" : 7*86400,
|
|
|
- "login_url" : "/login",
|
|
|
- "user_database" : 'sqlite:////data/books/calibre-webserver.db',
|
|
|
- "site_title" : u"奇异书屋",
|
|
|
- "ssl_crt_file" : "/data/books/ssl/ssl.crt",
|
|
|
- "ssl_key_file" : "/data/books/ssl/ssl.key",
|
|
|
-
|
|
|
+ 'installed': False,
|
|
|
+ "autoreload": True,
|
|
|
+ "xsrf_cookies": False,
|
|
|
+ "static_host": "",
|
|
|
+ "nuxt_env_path": os.path.join(os.path.dirname(__file__), "../app/.env"),
|
|
|
+ "html_path": os.path.join(os.path.dirname(__file__), "../app/dist"),
|
|
|
+ "i18n_path": os.path.join(os.path.dirname(__file__), "i18n"),
|
|
|
+ "static_path": os.path.join(os.path.dirname(__file__), "resources"),
|
|
|
+ "resource_path": os.path.join(os.path.dirname(__file__), "resources"),
|
|
|
+ "settings_path": "/data/books/settings/",
|
|
|
+ "progress_path": "/data/books/progress/",
|
|
|
+ "convert_path": "/data/books/convert/",
|
|
|
+ "upload_path": "/data/books/upload/",
|
|
|
+ "scan_upload_path": "/data/books/imports/",
|
|
|
+ "extract_path": "/data/books/extract/",
|
|
|
+ "with_library": "/data/books/library/",
|
|
|
+ "cookie_secret": "cookie_secret",
|
|
|
+ "cookie_expire": 7 * 86400,
|
|
|
+ "login_url": "/login",
|
|
|
+ "user_database": 'sqlite:////data/books/calibre-webserver.db',
|
|
|
+ "site_title": u"奇异书屋",
|
|
|
+ "ssl_crt_file": "/data/books/ssl/ssl.crt",
|
|
|
+ "ssl_key_file": "/data/books/ssl/ssl.key",
|
|
|
+ 'custom_scripts': '',
|
|
|
+ 'scripts_compiled': True,
|
|
|
# https://analytics.google.com/
|
|
|
- "google_analytics_id" : "G-LLF01B5ZZ8",
|
|
|
+ "google_analytics_id": "G-LLF01B5ZZ8",
|
|
|
|
|
|
- "opds_will_display" : ["*"],
|
|
|
- "opds_wont_display" : [],
|
|
|
- "opds_max_tags_shown" : 10240,
|
|
|
- "opds_max_items" : 50,
|
|
|
- "opds_max_ungrouped_items" : 100,
|
|
|
- "opds_url_prefix" : "",
|
|
|
+ "opds_will_display": ["*"],
|
|
|
+ "opds_wont_display": [],
|
|
|
+ "opds_max_tags_shown": 10240,
|
|
|
+ "opds_max_items": 50,
|
|
|
+ "opds_max_ungrouped_items": 100,
|
|
|
+ "opds_url_prefix": "",
|
|
|
|
|
|
"downloads_count_per_ip_limitation": 0,
|
|
|
"db_engine_args": {
|
|
@@ -50,10 +51,10 @@ settings = {
|
|
|
|
|
|
"PDF_VIEWER": "/static/pdfjs/web/viewer.html?file=%(pdf_url)s",
|
|
|
|
|
|
- "SOCIAL_AUTH_LOGIN_URL" : '/',
|
|
|
- "SOCIAL_AUTH_LOGIN_REDIRECT_URL" : '/api/done/',
|
|
|
- "SOCIAL_AUTH_USER_MODEL" : 'webserver.models.Reader',
|
|
|
- "SOCIAL_AUTH_AUTHENTICATION_BACKENDS" : (
|
|
|
+ "SOCIAL_AUTH_LOGIN_URL": '/',
|
|
|
+ "SOCIAL_AUTH_LOGIN_REDIRECT_URL": '/api/done/',
|
|
|
+ "SOCIAL_AUTH_USER_MODEL": 'webserver.models.Reader',
|
|
|
+ "SOCIAL_AUTH_AUTHENTICATION_BACKENDS": (
|
|
|
'social_core.backends.qq.QQOAuth2',
|
|
|
'social_core.backends.weibo.WeiboOAuth2',
|
|
|
'social_core.backends.amazon.AmazonOAuth2',
|
|
@@ -61,48 +62,48 @@ settings = {
|
|
|
),
|
|
|
|
|
|
# See: http://open.weibo.com/developers
|
|
|
- 'SOCIAL_AUTH_WEIBO_KEY' : '',
|
|
|
- 'SOCIAL_AUTH_WEIBO_SECRET' : '',
|
|
|
+ 'SOCIAL_AUTH_WEIBO_KEY': '',
|
|
|
+ 'SOCIAL_AUTH_WEIBO_SECRET': '',
|
|
|
|
|
|
# See: https://connect.qq.com/
|
|
|
- 'SOCIAL_AUTH_QQ_KEY' : '',
|
|
|
- 'SOCIAL_AUTH_QQ_SECRET' : '',
|
|
|
+ 'SOCIAL_AUTH_QQ_KEY': '',
|
|
|
+ 'SOCIAL_AUTH_QQ_SECRET': '',
|
|
|
|
|
|
# See: https://github.com/settings/applications/new
|
|
|
- 'SOCIAL_AUTH_GITHUB_KEY' : '',
|
|
|
- 'SOCIAL_AUTH_GITHUB_SECRET' : '',
|
|
|
+ 'SOCIAL_AUTH_GITHUB_KEY': '',
|
|
|
+ 'SOCIAL_AUTH_GITHUB_SECRET': '',
|
|
|
|
|
|
# See: http://service.mail.qq.com/cgi-bin/help?subtype=1&&no=1001256&&id=28
|
|
|
- 'smtp_server' : "smtp.talebook.org",
|
|
|
- 'smtp_username' : "sender@talebook.org",
|
|
|
- 'smtp_password' : "password",
|
|
|
- 'douban_apikey' : "0df993c66c0c636e29ecbb5344252a4a",
|
|
|
- 'douban_baseurl' : "https://api.douban.com",
|
|
|
- 'douban_max_count' : 2,
|
|
|
+ 'smtp_server': "smtp.talebook.org",
|
|
|
+ 'smtp_username': "sender@talebook.org",
|
|
|
+ 'smtp_password': "password",
|
|
|
+ 'douban_apikey': "0df993c66c0c636e29ecbb5344252a4a",
|
|
|
+ 'douban_baseurl': "https://api.douban.com",
|
|
|
+ 'douban_max_count': 2,
|
|
|
|
|
|
- 'avatar_service' : "https://cravatar.cn",
|
|
|
+ 'avatar_service': "https://cravatar.cn",
|
|
|
|
|
|
'BOOK_NAMES_FORMAT': 'en',
|
|
|
|
|
|
- 'INVITE_MODE' : False,
|
|
|
- 'INVITE_CODE' : 'love',
|
|
|
+ 'INVITE_MODE': False,
|
|
|
+ 'INVITE_CODE': 'love',
|
|
|
'INVITE_MESSAGE': u'''本站为私人图书馆,需输入密码才可进行访问''',
|
|
|
|
|
|
- 'ALLOW_GUEST_READ' : True,
|
|
|
- 'ALLOW_GUEST_PUSH' : True,
|
|
|
- 'ALLOW_GUEST_DOWNLOAD' : True,
|
|
|
+ 'ALLOW_GUEST_READ': True,
|
|
|
+ 'ALLOW_GUEST_PUSH': True,
|
|
|
+ 'ALLOW_GUEST_DOWNLOAD': True,
|
|
|
'RESTRICT_DOWNLOADS_COUNT_PER_IP': False,
|
|
|
- 'ALLOW_REGISTER' : False,
|
|
|
+ 'ALLOW_REGISTER': False,
|
|
|
|
|
|
'FOOTER': '本站基于Calibre构建,感谢开源的力量。所有资源来源于互联网免费资源库,如有侵权请邮件联系。',
|
|
|
|
|
|
'FRIENDS': [
|
|
|
- { "text": u"芒果读书", "href": "http://diumx.com/" },
|
|
|
- { "text": u"鸠摩搜索", "href": "https://www.jiumodiary.com/" },
|
|
|
- { "text": u"文渊阁", "href": "https://wenyuange.org/" },
|
|
|
- { "text": u"阅读链", "href": "https://www.yuedu.pro/" },
|
|
|
- { "text": u"苦瓜书盘", "href": "https://www.kgbook.com" },
|
|
|
- { "text": u"三秋书屋", "href": "https://www.sanqiu.cc/" },
|
|
|
+ {"text": u"芒果读书", "href": "http://diumx.com/"},
|
|
|
+ {"text": u"鸠摩搜索", "href": "https://www.jiumodiary.com/"},
|
|
|
+ {"text": u"文渊阁", "href": "https://wenyuange.org/"},
|
|
|
+ {"text": u"阅读链", "href": "https://www.yuedu.pro/"},
|
|
|
+ {"text": u"苦瓜书盘", "href": "https://www.kgbook.com"},
|
|
|
+ {"text": u"三秋书屋", "href": "https://www.sanqiu.cc/"},
|
|
|
],
|
|
|
'SOCIALS': [
|
|
|
],
|
|
@@ -123,3 +124,73 @@ Hi, %(username)s!
|
|
|
''',
|
|
|
|
|
|
}
|
|
|
+
|
|
|
+KEYS = [
|
|
|
+ "ALLOW_GUEST_DOWNLOAD",
|
|
|
+ "ALLOW_GUEST_PUSH",
|
|
|
+ "ALLOW_GUEST_READ",
|
|
|
+ "ALLOW_REGISTER",
|
|
|
+ "BOOK_NAMES_FORMAT",
|
|
|
+ "FRIENDS",
|
|
|
+ "FOOTER",
|
|
|
+ "INVITE_CODE",
|
|
|
+ "INVITE_MESSAGE",
|
|
|
+ "INVITE_MODE",
|
|
|
+ "MAX_UPLOAD_SIZE",
|
|
|
+ "RESET_MAIL_CONTENT",
|
|
|
+ "RESET_MAIL_TITLE",
|
|
|
+ "SIGNUP_MAIL_CONTENT",
|
|
|
+ "SIGNUP_MAIL_TITLE",
|
|
|
+ "SOCIALS",
|
|
|
+ "autoreload",
|
|
|
+ "cookie_secret",
|
|
|
+ "scan_upload_path",
|
|
|
+ "RESTRICT_DOWNLOADS_COUNT_PER_IP",
|
|
|
+ "downloads_count_per_ip_limitation",
|
|
|
+ "douban_apikey",
|
|
|
+ "douban_baseurl",
|
|
|
+ "douban_max_count",
|
|
|
+ "site_title",
|
|
|
+ "smtp_password",
|
|
|
+ "smtp_server",
|
|
|
+ "smtp_username",
|
|
|
+ "static_host",
|
|
|
+ "xsrf_cookies",
|
|
|
+ "settings_path",
|
|
|
+ "avatar_service",
|
|
|
+ "google_analytics_id",
|
|
|
+ "custom_scripts",
|
|
|
+ "scripts_compiled",
|
|
|
+]
|
|
|
+
|
|
|
+cust_scripts_start = "<!-- Custom Scripts Start -->"
|
|
|
+cust_scripts_end = "<!-- Custom Scripts End -->"
|
|
|
+
|
|
|
+
|
|
|
+def replace_scripts(html_file, custom_scripts):
|
|
|
+ tmp_file = html_file + ".tmp"
|
|
|
+ with open(tmp_file, "w") as f:
|
|
|
+ curr_file = open(html_file, "rt")
|
|
|
+ if not curr_file:
|
|
|
+ logging.error("html文件打开失败: %s" % html_file)
|
|
|
+ return
|
|
|
+
|
|
|
+ skip = False
|
|
|
+ while True:
|
|
|
+ line = curr_file.readline()
|
|
|
+ if not line:
|
|
|
+ break
|
|
|
+
|
|
|
+ if skip:
|
|
|
+ if cust_scripts_end in line:
|
|
|
+ skip = False
|
|
|
+ continue
|
|
|
+
|
|
|
+ if cust_scripts_start in line:
|
|
|
+ line = "%s\n%s\n%s\n" % (cust_scripts_start, custom_scripts, cust_scripts_end)
|
|
|
+ skip = True
|
|
|
+ f.write(line)
|
|
|
+ f.close()
|
|
|
+ curr_file.close()
|
|
|
+ os.replace(tmp_file, html_file)
|
|
|
+ logging.info("set custom scripts to %s successfully." % html_file)
|