Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
D
douban-api-proxy
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
captainwong
douban-api-proxy
Commits
361a1243
Commit
361a1243
authored
Feb 27, 2019
by
Ozzieisaacs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improvements #828
parent
fad62a09
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
63 additions
and
66 deletions
+63
-66
uploadprogress.js
cps/static/js/uploadprogress.js
+2
-2
layout.html
cps/templates/layout.html
+2
-1
messages.mo
cps/translations/de/LC_MESSAGES/messages.mo
+0
-0
messages.po
cps/translations/de/LC_MESSAGES/messages.po
+52
-52
web.py
cps/web.py
+7
-11
No files found.
cps/static/js/uploadprogress.js
View file @
361a1243
...
@@ -132,8 +132,8 @@
...
@@ -132,8 +132,8 @@
// Replace the contents of the form, with the returned html
// Replace the contents of the form, with the returned html
if
(
xhr
.
status
===
422
)
{
if
(
xhr
.
status
===
422
)
{
var
newHtml
=
$
.
parseHTML
(
xhr
.
responseText
);
var
newHtml
=
$
.
parseHTML
(
xhr
.
responseText
);
this
.
replace_form
(
newHtml
);
this
.
$modalBar
.
text
(
newHtml
[
0
].
data
);
this
.
$modal
.
modal
(
"hide"
);
//
this.$modal.modal("hide");
}
}
// Write the error response to the document.
// Write the error response to the document.
else
{
else
{
...
...
cps/templates/layout.html
View file @
361a1243
...
@@ -62,7 +62,8 @@
...
@@ -62,7 +62,8 @@
<li>
<li>
<form
id=
"form-upload"
class=
"navbar-form"
action=
"{{ url_for('upload') }}"
method=
"post"
enctype=
"multipart/form-data"
>
<form
id=
"form-upload"
class=
"navbar-form"
action=
"{{ url_for('upload') }}"
method=
"post"
enctype=
"multipart/form-data"
>
<div
class=
"form-group"
>
<div
class=
"form-group"
>
<span
class=
"btn btn-default btn-file"
>
{{_('Upload')}}
<input
id=
"btn-upload"
name=
"btn-upload"
type=
"file"
multiple
></span>
<span
class=
"btn btn-default btn-file"
>
{{_('Upload')}}
<input
id=
"btn-upload"
name=
"btn-upload"
type=
"file"
accept=
"{% for format in accept %}.{{format}}{{ ',' if not loop.last }}{% endfor %}"
multiple
></span>
</div>
</div>
</form>
</form>
</li>
</li>
...
...
cps/translations/de/LC_MESSAGES/messages.mo
View file @
361a1243
No preview for this file type
cps/translations/de/LC_MESSAGES/messages.po
View file @
361a1243
This diff is collapsed.
Click to expand it.
cps/web.py
View file @
361a1243
...
@@ -698,7 +698,7 @@ def render_xml_template(*args, **kwargs):
...
@@ -698,7 +698,7 @@ def render_xml_template(*args, **kwargs):
# Returns the template for redering and includes the instance name
# Returns the template for redering and includes the instance name
def
render_title_template
(
*
args
,
**
kwargs
):
def
render_title_template
(
*
args
,
**
kwargs
):
return
render_template
(
instance
=
config
.
config_calibre_web_title
,
*
args
,
**
kwargs
)
return
render_template
(
instance
=
config
.
config_calibre_web_title
,
accept
=
EXTENSIONS_UPLOAD
,
*
args
,
**
kwargs
)
@
app
.
before_request
@
app
.
before_request
...
@@ -3733,13 +3733,10 @@ def upload():
...
@@ -3733,13 +3733,10 @@ def upload():
if
'.'
in
requested_file
.
filename
:
if
'.'
in
requested_file
.
filename
:
file_ext
=
requested_file
.
filename
.
rsplit
(
'.'
,
1
)[
-
1
]
.
lower
()
file_ext
=
requested_file
.
filename
.
rsplit
(
'.'
,
1
)[
-
1
]
.
lower
()
if
file_ext
not
in
EXTENSIONS_UPLOAD
:
if
file_ext
not
in
EXTENSIONS_UPLOAD
:
flash
(
return
Response
(
_
(
"File extension '
%(ext)
s' is not allowed to be uploaded to this server"
,
_
(
"File extension '
%(ext)
s' is not allowed to be uploaded to this server"
,
ext
=
file_ext
)),
422
ext
=
file_ext
),
category
=
"error"
)
return
redirect
(
url_for
(
'index'
))
else
:
else
:
flash
(
_
(
'File to be uploaded must have an extension'
),
category
=
"error"
)
return
Response
(
_
(
'File to be uploaded must have an extension'
)),
422
return
redirect
(
url_for
(
'index'
))
# extract metadata from file
# extract metadata from file
meta
=
uploader
.
upload
(
requested_file
)
meta
=
uploader
.
upload
(
requested_file
)
...
@@ -3758,13 +3755,12 @@ def upload():
...
@@ -3758,13 +3755,12 @@ def upload():
try
:
try
:
os
.
makedirs
(
filepath
)
os
.
makedirs
(
filepath
)
except
OSError
:
except
OSError
:
flash
(
_
(
u"Failed to create path
%(path)
s (Permission denied)."
,
path
=
filepath
),
category
=
"error"
)
return
Response
(
_
(
u"Failed to create path
%(path)
s (Permission denied)."
,
path
=
filepath
)),
422
return
redirect
(
url_for
(
'index'
))
try
:
try
:
copyfile
(
meta
.
file_path
,
saved_filename
)
copyfile
(
meta
.
file_path
,
saved_filename
)
except
OSError
:
except
OSError
:
flash
(
_
(
u"Failed to store file
%(file)
s (Permission denied)."
,
file
=
saved_filename
),
category
=
"error"
)
return
Response
(
_
(
u"Failed to store file
%(file)
s (Permission denied)."
,
file
=
saved_filename
)),
422
return
redirect
(
url_for
(
'index'
))
try
:
try
:
os
.
unlink
(
meta
.
file_path
)
os
.
unlink
(
meta
.
file_path
)
except
OSError
:
except
OSError
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment