Translation of UI (german and english)
Bugfix for feeds
- removed categories related and up
- load new books now working
- category random now working
login page is free of non accessible elements
boolean custom column is vivible in UI
books with only with certain languages can be shown
book shelfs can be deleted from UI
Anonymous user view is more resticted
Added browse of series in sidebar
Dependencys in vendor folder are updated to newer versions (licencs files are now present)
Bugfix editing Authors names
Made upload on windows working
This commit is contained in:
Vendored
+78
-30
@@ -5,7 +5,7 @@
|
||||
|
||||
This module provides various traceback related utility functions.
|
||||
|
||||
:copyright: (c) 2013 by the Werkzeug Team, see AUTHORS for more details.
|
||||
:copyright: (c) 2014 by the Werkzeug Team, see AUTHORS for more details.
|
||||
:license: BSD.
|
||||
"""
|
||||
import re
|
||||
@@ -20,13 +20,15 @@ from tokenize import TokenError
|
||||
|
||||
from werkzeug.utils import cached_property, escape
|
||||
from werkzeug.debug.console import Console
|
||||
from werkzeug._compat import range_type, PY2, text_type, string_types
|
||||
from werkzeug._compat import range_type, PY2, text_type, string_types, \
|
||||
to_native, to_unicode
|
||||
from werkzeug.filesystem import get_filesystem_encoding
|
||||
|
||||
|
||||
_coding_re = re.compile(r'coding[:=]\s*([-\w.]+)')
|
||||
_line_re = re.compile(r'^(.*?)$(?m)')
|
||||
_coding_re = re.compile(br'coding[:=]\s*([-\w.]+)')
|
||||
_line_re = re.compile(br'^(.*?)$(?m)')
|
||||
_funcdef_re = re.compile(r'^(\s*def\s)|(.*(?<!\w)lambda(:|\s))|^(\s*@)')
|
||||
UTF8_COOKIE = '\xef\xbb\xbf'
|
||||
UTF8_COOKIE = b'\xef\xbb\xbf'
|
||||
|
||||
system_exceptions = (SystemExit, KeyboardInterrupt)
|
||||
try:
|
||||
@@ -41,17 +43,20 @@ HEADER = u'''\
|
||||
<html>
|
||||
<head>
|
||||
<title>%(title)s // Werkzeug Debugger</title>
|
||||
<link rel="stylesheet" href="?__debugger__=yes&cmd=resource&f=style.css" type="text/css">
|
||||
<!-- We need to make sure this has a favicon so that the debugger does not by
|
||||
accident trigger a request to /favicon.ico which might change the application
|
||||
state. -->
|
||||
<link rel="shortcut icon" href="?__debugger__=yes&cmd=resource&f=console.png">
|
||||
<script type="text/javascript" src="?__debugger__=yes&cmd=resource&f=jquery.js"></script>
|
||||
<script type="text/javascript" src="?__debugger__=yes&cmd=resource&f=debugger.js"></script>
|
||||
<link rel="stylesheet" href="?__debugger__=yes&cmd=resource&f=style.css"
|
||||
type="text/css">
|
||||
<!-- We need to make sure this has a favicon so that the debugger does
|
||||
not by accident trigger a request to /favicon.ico which might
|
||||
change the application state. -->
|
||||
<link rel="shortcut icon"
|
||||
href="?__debugger__=yes&cmd=resource&f=console.png">
|
||||
<script src="?__debugger__=yes&cmd=resource&f=jquery.js"></script>
|
||||
<script src="?__debugger__=yes&cmd=resource&f=debugger.js"></script>
|
||||
<script type="text/javascript">
|
||||
var TRACEBACK = %(traceback_id)d,
|
||||
CONSOLE_MODE = %(console)s,
|
||||
EVALEX = %(evalex)s,
|
||||
EVALEX_TRUSTED = %(evalex_trusted)s,
|
||||
SECRET = "%(secret)s";
|
||||
</script>
|
||||
</head>
|
||||
@@ -64,6 +69,21 @@ FOOTER = u'''\
|
||||
friendly Werkzeug powered traceback interpreter.
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="pin-prompt">
|
||||
<div class="inner">
|
||||
<h3>Console Locked</h3>
|
||||
<p>
|
||||
The console is locked and needs to be unlocked by entering the PIN.
|
||||
You can find the PIN printed out on the standard output of your
|
||||
shell that runs the server.
|
||||
<form>
|
||||
<p>PIN:
|
||||
<input type=text name=pin size=14>
|
||||
<input type=submit name=btn value="Confirm Pin">
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
'''
|
||||
@@ -124,12 +144,10 @@ FRAME_HTML = u'''\
|
||||
<h4>File <cite class="filename">"%(filename)s"</cite>,
|
||||
line <em class="line">%(lineno)s</em>,
|
||||
in <code class="function">%(function_name)s</code></h4>
|
||||
<pre>%(current_line)s</pre>
|
||||
<div class="source">%(lines)s</div>
|
||||
</div>
|
||||
'''
|
||||
|
||||
SOURCE_TABLE_HTML = u'<table class=source>%s</table>'
|
||||
|
||||
SOURCE_LINE_HTML = u'''\
|
||||
<tr class="%(classes)s">
|
||||
<td class=lineno>%(lineno)s</td>
|
||||
@@ -138,13 +156,14 @@ SOURCE_LINE_HTML = u'''\
|
||||
'''
|
||||
|
||||
|
||||
def render_console_html(secret):
|
||||
def render_console_html(secret, evalex_trusted=True):
|
||||
return CONSOLE_HTML % {
|
||||
'evalex': 'true',
|
||||
'evalex_trusted': evalex_trusted and 'true' or 'false',
|
||||
'console': 'true',
|
||||
'title': 'Console',
|
||||
'secret': secret,
|
||||
'traceback_id': -1
|
||||
'traceback_id': -1
|
||||
}
|
||||
|
||||
|
||||
@@ -269,7 +288,7 @@ class Traceback(object):
|
||||
logfile = sys.stderr
|
||||
tb = self.plaintext.rstrip() + u'\n'
|
||||
if PY2:
|
||||
tb.encode('utf-8', 'replace')
|
||||
tb = tb.encode('utf-8', 'replace')
|
||||
logfile.write(tb)
|
||||
|
||||
def paste(self):
|
||||
@@ -327,17 +346,19 @@ class Traceback(object):
|
||||
'description': description_wrapper % escape(self.exception)
|
||||
}
|
||||
|
||||
def render_full(self, evalex=False, secret=None):
|
||||
def render_full(self, evalex=False, secret=None,
|
||||
evalex_trusted=True):
|
||||
"""Render the Full HTML page with the traceback info."""
|
||||
exc = escape(self.exception)
|
||||
return PAGE_HTML % {
|
||||
'evalex': evalex and 'true' or 'false',
|
||||
'evalex_trusted': evalex_trusted and 'true' or 'false',
|
||||
'console': 'false',
|
||||
'title': exc,
|
||||
'exception': exc,
|
||||
'exception_type': escape(self.exception_type),
|
||||
'summary': self.render_summary(include_title=False),
|
||||
'plaintext': self.plaintext,
|
||||
'plaintext': escape(self.plaintext),
|
||||
'plaintext_cs': re.sub('-{2,}', '-', self.plaintext),
|
||||
'traceback_id': self.id,
|
||||
'secret': secret
|
||||
@@ -363,6 +384,7 @@ class Traceback(object):
|
||||
|
||||
|
||||
class Frame(object):
|
||||
|
||||
"""A single frame in a traceback."""
|
||||
|
||||
def __init__(self, exc_type, exc_value, tb):
|
||||
@@ -377,7 +399,7 @@ class Frame(object):
|
||||
# if it's a file on the file system resolve the real filename.
|
||||
if os.path.isfile(fn):
|
||||
fn = os.path.realpath(fn)
|
||||
self.filename = fn
|
||||
self.filename = to_unicode(fn, get_filesystem_encoding())
|
||||
self.module = self.globals.get('__name__')
|
||||
self.loader = self.globals.get('__loader__')
|
||||
self.code = tb.tb_frame.f_code
|
||||
@@ -399,9 +421,29 @@ class Frame(object):
|
||||
'filename': escape(self.filename),
|
||||
'lineno': self.lineno,
|
||||
'function_name': escape(self.function_name),
|
||||
'current_line': escape(self.current_line.strip())
|
||||
'lines': self.render_line_context(),
|
||||
}
|
||||
|
||||
def render_line_context(self):
|
||||
before, current, after = self.get_context_lines()
|
||||
rv = []
|
||||
|
||||
def render_line(line, cls):
|
||||
line = line.expandtabs().rstrip()
|
||||
stripped_line = line.strip()
|
||||
prefix = len(line) - len(stripped_line)
|
||||
rv.append(
|
||||
'<pre class="line %s"><span class="ws">%s</span>%s</pre>' % (
|
||||
cls, ' ' * prefix, escape(stripped_line) or ' '))
|
||||
|
||||
for line in before:
|
||||
render_line(line, 'before')
|
||||
render_line(current, 'current')
|
||||
for line in after:
|
||||
render_line(line, 'after')
|
||||
|
||||
return '\n'.join(rv)
|
||||
|
||||
def get_annotated_lines(self):
|
||||
"""Helper function that returns lines with extra information."""
|
||||
lines = [Line(idx + 1, x) for idx, x in enumerate(self.sourcelines)]
|
||||
@@ -429,15 +471,10 @@ class Frame(object):
|
||||
|
||||
return lines
|
||||
|
||||
def render_source(self):
|
||||
"""Render the sourcecode."""
|
||||
return SOURCE_TABLE_HTML % u'\n'.join(line.render() for line in
|
||||
self.get_annotated_lines())
|
||||
|
||||
def eval(self, code, mode='single'):
|
||||
"""Evaluate code in the context of the frame."""
|
||||
if isinstance(code, string_types):
|
||||
if PY2 and isinstance(code, unicode):
|
||||
if PY2 and isinstance(code, unicode): # noqa
|
||||
code = UTF8_COOKIE + code.encode('utf-8')
|
||||
code = compile(code, '<interactive>', mode)
|
||||
return eval(code, self.globals, self.locals)
|
||||
@@ -460,7 +497,8 @@ class Frame(object):
|
||||
|
||||
if source is None:
|
||||
try:
|
||||
f = open(self.filename)
|
||||
f = open(to_native(self.filename, get_filesystem_encoding()),
|
||||
mode='rb')
|
||||
except IOError:
|
||||
return []
|
||||
try:
|
||||
@@ -479,7 +517,7 @@ class Frame(object):
|
||||
source = source[3:]
|
||||
else:
|
||||
for idx, match in enumerate(_line_re.finditer(source)):
|
||||
match = _line_re.search(match.group())
|
||||
match = _coding_re.search(match.group())
|
||||
if match is not None:
|
||||
charset = match.group(1)
|
||||
break
|
||||
@@ -487,6 +525,7 @@ class Frame(object):
|
||||
break
|
||||
|
||||
# on broken cookies we fall back to utf-8 too
|
||||
charset = to_native(charset)
|
||||
try:
|
||||
codecs.lookup(charset)
|
||||
except LookupError:
|
||||
@@ -494,6 +533,15 @@ class Frame(object):
|
||||
|
||||
return source.decode(charset, 'replace').splitlines()
|
||||
|
||||
def get_context_lines(self, context=5):
|
||||
before = self.sourcelines[self.lineno - context - 1:self.lineno - 1]
|
||||
past = self.sourcelines[self.lineno:self.lineno + context]
|
||||
return (
|
||||
before,
|
||||
self.current_line,
|
||||
past,
|
||||
)
|
||||
|
||||
@property
|
||||
def current_line(self):
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user