mirror of
https://github.com/janeczku/calibre-web
synced 2024-11-10 01:13:33 +00:00
Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
092329c9e6
@ -107,8 +107,8 @@ Pre-built Docker images are available in the following Docker Hub repositories (
|
|||||||
|
|
||||||
Both the Calibre-Web and Calibre-Mod images are automatically rebuilt on new releases and updates.
|
Both the Calibre-Web and Calibre-Mod images are automatically rebuilt on new releases and updates.
|
||||||
|
|
||||||
- Set "path to convertertool" to `/usr/bin/ebook-convert`
|
- Set "Path to Calibre Binaries" to `/usr/bin`
|
||||||
- Set "path to unrar" to `/usr/bin/unrar`
|
- Set "Path to Unrar" to `/usr/bin/unrar`
|
||||||
|
|
||||||
## Contributor Recognition
|
## Contributor Recognition
|
||||||
|
|
||||||
|
@ -35,7 +35,7 @@ def clean_string(unsafe_text, book_id=0):
|
|||||||
try:
|
try:
|
||||||
if bleach:
|
if bleach:
|
||||||
allowed_tags = list(ALLOWED_TAGS)
|
allowed_tags = list(ALLOWED_TAGS)
|
||||||
allowed_tags.extend(['p', 'span', 'div', 'pre'])
|
allowed_tags.extend(["p", "span", "div", "pre", "br", "h1", "h2", "h3", "h4", "h5", "h6"])
|
||||||
safe_text = clean_html(unsafe_text, tags=set(allowed_tags))
|
safe_text = clean_html(unsafe_text, tags=set(allowed_tags))
|
||||||
else:
|
else:
|
||||||
safe_text = clean_html(unsafe_text)
|
safe_text = clean_html(unsafe_text)
|
||||||
|
@ -23,7 +23,7 @@
|
|||||||
import os
|
import os
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
import json
|
import json
|
||||||
from shutil import copyfile, move
|
from shutil import copyfile
|
||||||
from uuid import uuid4
|
from uuid import uuid4
|
||||||
from markupsafe import escape, Markup # dependency of flask
|
from markupsafe import escape, Markup # dependency of flask
|
||||||
from functools import wraps
|
from functools import wraps
|
||||||
|
@ -21,17 +21,17 @@ import os
|
|||||||
import shutil
|
import shutil
|
||||||
import zipfile
|
import zipfile
|
||||||
import mimetypes
|
import mimetypes
|
||||||
import copy
|
|
||||||
from io import BytesIO
|
from io import BytesIO
|
||||||
try:
|
|
||||||
import magic
|
|
||||||
except ImportError:
|
|
||||||
pass
|
|
||||||
|
|
||||||
from . import logger
|
from . import logger
|
||||||
|
|
||||||
log = logger.create()
|
log = logger.create()
|
||||||
|
|
||||||
|
try:
|
||||||
|
import magic
|
||||||
|
except ImportError as e:
|
||||||
|
log.error("Cannot import python-magic, checking uploaded file metadata will not work: %s", e)
|
||||||
|
|
||||||
|
|
||||||
def get_temp_dir():
|
def get_temp_dir():
|
||||||
tmp_dir = os.path.join(gettempdir(), 'calibre_web')
|
tmp_dir = os.path.join(gettempdir(), 'calibre_web')
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
from datetime import datetime
|
||||||
from gevent.pywsgi import WSGIHandler
|
from gevent.pywsgi import WSGIHandler
|
||||||
|
|
||||||
|
|
||||||
@ -27,4 +27,26 @@ class MyWSGIHandler(WSGIHandler):
|
|||||||
env['RAW_URI'] = path
|
env['RAW_URI'] = path
|
||||||
return env
|
return env
|
||||||
|
|
||||||
|
def format_request(self):
|
||||||
|
now = datetime.now().replace(microsecond=0)
|
||||||
|
length = self.response_length or '-'
|
||||||
|
if self.time_finish:
|
||||||
|
delta = '%.6f' % (self.time_finish - self.time_start)
|
||||||
|
else:
|
||||||
|
delta = '-'
|
||||||
|
forwarded = self.environ.get('HTTP_X_FORWARDED_FOR', None)
|
||||||
|
if forwarded:
|
||||||
|
client_address = forwarded
|
||||||
|
else:
|
||||||
|
client_address = self.client_address[0] if isinstance(self.client_address, tuple) else self.client_address
|
||||||
|
return '%s - - [%s] "%s" %s %s %s' % (
|
||||||
|
client_address or '-',
|
||||||
|
now,
|
||||||
|
self.requestline or '',
|
||||||
|
# Use the native string version of the status, saved so we don't have to
|
||||||
|
# decode. But fallback to the encoded 'status' in case of subclasses
|
||||||
|
# (Is that really necessary? At least there's no overhead.)
|
||||||
|
(self._orig_status or self.status or '000').split()[0],
|
||||||
|
length,
|
||||||
|
delta)
|
||||||
|
|
||||||
|
@ -137,7 +137,7 @@ class LubimyCzytac(Metadata):
|
|||||||
|
|
||||||
def _prepare_query(self, title: str) -> str:
|
def _prepare_query(self, title: str) -> str:
|
||||||
query = ""
|
query = ""
|
||||||
characters_to_remove = "\?()\/"
|
characters_to_remove = r"\?()\/"
|
||||||
pattern = "[" + characters_to_remove + "]"
|
pattern = "[" + characters_to_remove + "]"
|
||||||
title = re.sub(pattern, "", title)
|
title = re.sub(pattern, "", title)
|
||||||
title = title.replace("_", " ")
|
title = title.replace("_", " ")
|
||||||
|
@ -21,7 +21,6 @@ import os
|
|||||||
import errno
|
import errno
|
||||||
import signal
|
import signal
|
||||||
import socket
|
import socket
|
||||||
import asyncio
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from gevent.pywsgi import WSGIServer
|
from gevent.pywsgi import WSGIServer
|
||||||
|
@ -22,6 +22,7 @@ import tornado
|
|||||||
from tornado import escape
|
from tornado import escape
|
||||||
from tornado import httputil
|
from tornado import httputil
|
||||||
from tornado.ioloop import IOLoop
|
from tornado.ioloop import IOLoop
|
||||||
|
from tornado.log import access_log
|
||||||
|
|
||||||
from typing import List, Tuple, Optional, Callable, Any, Dict, Text
|
from typing import List, Tuple, Optional, Callable, Any, Dict, Text
|
||||||
from types import TracebackType
|
from types import TracebackType
|
||||||
@ -96,5 +97,26 @@ class MyWSGIContainer(WSGIContainer):
|
|||||||
except TypeError as e:
|
except TypeError as e:
|
||||||
environ = WSGIContainer.environ(request)
|
environ = WSGIContainer.environ(request)
|
||||||
environ['RAW_URI'] = request.path
|
environ['RAW_URI'] = request.path
|
||||||
|
self.env = environ
|
||||||
return environ
|
return environ
|
||||||
|
|
||||||
|
def _log(self, status_code: int, request: httputil.HTTPServerRequest) -> None:
|
||||||
|
if status_code < 400:
|
||||||
|
log_method = access_log.info
|
||||||
|
elif status_code < 500:
|
||||||
|
log_method = access_log.warning
|
||||||
|
else:
|
||||||
|
log_method = access_log.error
|
||||||
|
request_time = 1000.0 * request.request_time()
|
||||||
|
assert request.method is not None
|
||||||
|
assert request.uri is not None
|
||||||
|
ip = self.env.get("HTTP_FORWARD_FOR", None) or request.remote_ip
|
||||||
|
summary = (
|
||||||
|
request.method # type: ignore[operator]
|
||||||
|
+ " "
|
||||||
|
+ request.uri
|
||||||
|
+ " ("
|
||||||
|
+ ip
|
||||||
|
+ ")"
|
||||||
|
)
|
||||||
|
log_method("%d %s %.2fms", status_code, summary, request_time)
|
||||||
|
Loading…
Reference in New Issue
Block a user