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
82931940
Commit
82931940
authored
Feb 20, 2017
by
idalin
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'janeczku-master'
parents
42eea356
3cadde65
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
66 additions
and
39 deletions
+66
-39
helper.py
cps/helper.py
+4
-4
style.css
cps/static/css/style.css
+2
-0
layout.html
cps/templates/layout.html
+13
-11
web.py
cps/web.py
+1
-1
api.py
vendor/wand/api.py
+4
-4
drawing.py
vendor/wand/drawing.py
+1
-1
exceptions.py
vendor/wand/exceptions.py
+21
-9
image.py
vendor/wand/image.py
+11
-0
version.py
vendor/wand/version.py
+9
-9
No files found.
cps/helper.py
View file @
82931940
...
@@ -222,14 +222,14 @@ def get_valid_filename(value, replace_whitespace=True):
...
@@ -222,14 +222,14 @@ def get_valid_filename(value, replace_whitespace=True):
if
use_unidecode
:
if
use_unidecode
:
value
=
(
unidecode
.
unidecode
(
value
))
.
strip
()
value
=
(
unidecode
.
unidecode
(
value
))
.
strip
()
else
:
else
:
value
=
value
.
replace
(
'§'
,
'SS'
)
value
=
value
.
replace
(
u'§'
,
u
'SS'
)
value
=
value
.
replace
(
'ß'
,
'ss'
)
value
=
value
.
replace
(
u'ß'
,
u
'ss'
)
value
=
unicodedata
.
normalize
(
'NFKD'
,
value
)
value
=
unicodedata
.
normalize
(
'NFKD'
,
value
)
re_slugify
=
re
.
compile
(
'[
\
W
\
s-]'
,
re
.
UNICODE
)
re_slugify
=
re
.
compile
(
'[
\
W
\
s-]'
,
re
.
UNICODE
)
value
=
unicode
(
re_slugify
.
sub
(
''
,
value
)
.
strip
())
value
=
unicode
(
re_slugify
.
sub
(
''
,
value
)
.
strip
())
if
replace_whitespace
:
if
replace_whitespace
:
#*+:\"/<>? werden durch _ ersetzt
#*+:\"/<>? werden durch _ ersetzt
value
=
re
.
sub
(
'[
\
*
\
+:
\\\"
/<>
\
?]+'
,
'_'
,
value
,
flags
=
re
.
U
)
value
=
re
.
sub
(
'[
\
*
\
+:
\\\"
/<>
\
?]+'
,
u
'_'
,
value
,
flags
=
re
.
U
)
value
=
value
[:
128
]
value
=
value
[:
128
]
return
value
return
value
...
@@ -263,7 +263,7 @@ def update_dir_stucture(book_id, calibrepath):
...
@@ -263,7 +263,7 @@ def update_dir_stucture(book_id, calibrepath):
if
authordir
!=
new_authordir
:
if
authordir
!=
new_authordir
:
new_author_path
=
os
.
path
.
join
(
os
.
path
.
join
(
calibrepath
,
new_authordir
),
os
.
path
.
basename
(
path
))
new_author_path
=
os
.
path
.
join
(
os
.
path
.
join
(
calibrepath
,
new_authordir
),
os
.
path
.
basename
(
path
))
os
.
rename
(
path
,
new_author_path
)
os
.
rename
s
(
path
,
new_author_path
)
book
.
path
=
new_authordir
+
'/'
+
book
.
path
.
split
(
'/'
)[
1
]
book
.
path
=
new_authordir
+
'/'
+
book
.
path
.
split
(
'/'
)[
1
]
db
.
session
.
commit
()
db
.
session
.
commit
()
...
...
cps/static/css/style.css
View file @
82931940
...
@@ -36,6 +36,8 @@ span.glyphicon.glyphicon-tags {padding-right: 5px;color: #999;vertical-align: te
...
@@ -36,6 +36,8 @@ span.glyphicon.glyphicon-tags {padding-right: 5px;color: #999;vertical-align: te
-moz-box-shadow
:
0
5px
8px
-6px
#777
;
-moz-box-shadow
:
0
5px
8px
-6px
#777
;
box-shadow
:
0
5px
8px
-6px
#777
;
box-shadow
:
0
5px
8px
-6px
#777
;
}
}
.navbar-default
.navbar-toggle
.icon-bar
{
background-color
:
#000
;}
.navbar-default
.navbar-toggle
{
border-color
:
#000
;}
.btn-file
{
position
:
relative
;
overflow
:
hidden
;}
.btn-file
{
position
:
relative
;
overflow
:
hidden
;}
.btn-file
input
[
type
=
file
]
{
position
:
absolute
;
top
:
0
;
right
:
0
;
min-width
:
100%
;
min-height
:
100%
;
font-size
:
100px
;
text-align
:
right
;
filter
:
alpha
(
opacity
=
0
);
opacity
:
0
;
outline
:
none
;
background
:
white
;
cursor
:
inherit
;
display
:
block
;}
.btn-file
input
[
type
=
file
]
{
position
:
absolute
;
top
:
0
;
right
:
0
;
min-width
:
100%
;
min-height
:
100%
;
font-size
:
100px
;
text-align
:
right
;
filter
:
alpha
(
opacity
=
0
);
opacity
:
0
;
outline
:
none
;
background
:
white
;
cursor
:
inherit
;
display
:
block
;}
...
...
cps/templates/layout.html
View file @
82931940
...
@@ -52,17 +52,19 @@
...
@@ -52,17 +52,19 @@
</button>
</button>
<a
class=
"navbar-brand"
href=
"{{url_for('index')}}"
>
Calibre Web
</a>
<a
class=
"navbar-brand"
href=
"{{url_for('index')}}"
>
Calibre Web
</a>
</div>
</div>
{% if g.user.is_authenticated or g.user.is_anonymous() %}
<form
class=
"navbar-form navbar-left"
role=
"search"
action=
"{{url_for('search')}}"
method=
"GET"
>
<div
class=
"form-group input-group input-group-sm"
>
<input
type=
"text"
class=
"form-control"
name=
"query"
placeholder=
"{{_('Search')}}"
>
<span
class=
"input-group-btn"
>
<button
type=
"submit"
class=
"btn btn-default"
>
{{_('Go!')}}
</button>
</span>
</div>
</form>
{% endif %}
<div
class=
"navbar-collapse collapse"
>
<div
class=
"navbar-collapse collapse"
>
{% if g.user.is_authenticated or g.user.is_anonymous() %}
{% if g.user.is_authenticated or g.user.is_anonymous() %}
<ul
class=
"nav navbar-nav "
>
<ul
class=
"nav navbar-nav "
>
<li>
<form
class=
"navbar-form navbar-left"
role=
"search"
action=
"{{url_for('search')}}"
method=
"GET"
>
<div
class=
"form-group"
>
<input
type=
"text"
class=
"form-control"
name=
"query"
placeholder=
"{{_('Search')}}"
>
</div>
<button
type=
"submit"
class=
"btn btn-default"
>
{{_('Go!')}}
</button>
</form>
</li>
<li><a
href=
"{{url_for('advanced_search')}}"
><span
class=
"glyphicon glyphicon-search"
></span>
{{_('Advanced Search')}}
</a></li>
<li><a
href=
"{{url_for('advanced_search')}}"
><span
class=
"glyphicon glyphicon-search"
></span>
{{_('Advanced Search')}}
</a></li>
</ul>
</ul>
{% endif %}
{% endif %}
...
@@ -80,11 +82,11 @@
...
@@ -80,11 +82,11 @@
{% endif %}
{% endif %}
{% endif %}
{% endif %}
{% if g.user.role_admin() %}
{% if g.user.role_admin() %}
<li><a
id=
"top_admin"
href=
"{{url_for('admin')}}"
><span
class=
"glyphicon glyphicon-dashboard"
></span>
{{_('Admin')}}
</a></li>
<li><a
id=
"top_admin"
href=
"{{url_for('admin')}}"
><span
class=
"glyphicon glyphicon-dashboard"
></span>
<span
class=
"hidden-sm"
>
{{_('Admin')}}
</span>
</a></li>
{% endif %}
{% endif %}
<li><a
id=
"top_user"
href=
"{{url_for('profile')}}"
><span
class=
"glyphicon glyphicon-user"
></span>
{{g.user.nickname}}
</a></li>
<li><a
id=
"top_user"
href=
"{{url_for('profile')}}"
><span
class=
"glyphicon glyphicon-user"
></span>
<span
class=
"hidden-sm"
>
{{g.user.nickname}}
</span>
</a></li>
{% if not g.user.is_anonymous() %}
{% if not g.user.is_anonymous() %}
<li><a
id=
"logout"
href=
"{{url_for('logout')}}"
><span
class=
"glyphicon glyphicon-log-out"
></span>
{{_('Logout')}}
</a></li>
<li><a
id=
"logout"
href=
"{{url_for('logout')}}"
><span
class=
"glyphicon glyphicon-log-out"
></span>
<span
class=
"hidden-sm"
>
{{_('Logout')}}
</span>
</a></li>
{% endif %}
{% endif %}
{% endif %}
{% endif %}
{% if g.allow_registration and not g.user.is_authenticated %}
{% if g.allow_registration and not g.user.is_authenticated %}
...
...
cps/web.py
View file @
82931940
...
@@ -284,7 +284,7 @@ def mimetype_filter(val):
...
@@ -284,7 +284,7 @@ def mimetype_filter(val):
@
app
.
template_filter
(
'formatdate'
)
@
app
.
template_filter
(
'formatdate'
)
def
formatdate
(
val
):
def
formatdate
(
val
):
conformed_timestamp
=
re
.
sub
(
r"[:]|([-](?!((\d{2}[:]\d{2})|(\d{4}))$))"
,
''
,
val
)
conformed_timestamp
=
re
.
sub
(
r"[:]|([-](?!((\d{2}[:]\d{2})|(\d{4}))$))"
,
''
,
val
)
formatdate
=
datetime
.
datetime
.
strptime
(
conformed_timestamp
[:
-
5
],
"
%
Y
%
m
%
d
%
H
%
M
%
S"
)
formatdate
=
datetime
.
datetime
.
strptime
(
conformed_timestamp
[:
1
5
],
"
%
Y
%
m
%
d
%
H
%
M
%
S"
)
return
format_date
(
formatdate
,
format
=
'medium'
,
locale
=
get_locale
())
return
format_date
(
formatdate
,
format
=
'medium'
,
locale
=
get_locale
())
...
...
vendor/wand/api.py
View file @
82931940
...
@@ -180,8 +180,8 @@ try:
...
@@ -180,8 +180,8 @@ try:
libraries
=
load_library
()
libraries
=
load_library
()
except
(
OSError
,
IOError
):
except
(
OSError
,
IOError
):
msg
=
'http://docs.wand-py.org/en/latest/guide/install.html'
msg
=
'http://docs.wand-py.org/en/latest/guide/install.html'
if
sys
.
platform
.
startswith
(
'freebsd'
):
if
sys
.
platform
.
startswith
(
(
'dragonfly'
,
'freebsd'
)
):
msg
=
'pkg
_add -r
'
msg
=
'pkg
install
'
elif
sys
.
platform
==
'win32'
:
elif
sys
.
platform
==
'win32'
:
msg
+=
'#install-imagemagick-on-windows'
msg
+=
'#install-imagemagick-on-windows'
elif
sys
.
platform
==
'darwin'
:
elif
sys
.
platform
==
'darwin'
:
...
@@ -1397,7 +1397,7 @@ try:
...
@@ -1397,7 +1397,7 @@ try:
library
.
MagickAutoOrientImage
.
argtypes
=
[
ctypes
.
c_void_p
]
library
.
MagickAutoOrientImage
.
argtypes
=
[
ctypes
.
c_void_p
]
except
AttributeError
:
except
AttributeError
:
# MagickAutoOrientImage was added in 6.8.9+, we have a fallback function
# MagickAutoOrientImage was added in 6.8.9+, we have a fallback function
# so we pass silently if we cant import it
# so we pass silently if we can
no
t import it
pass
pass
...
@@ -1418,7 +1418,7 @@ else:
...
@@ -1418,7 +1418,7 @@ else:
except
OSError
:
except
OSError
:
# In case of El Capitan SIP
# In case of El Capitan SIP
libc
=
ctypes
.
cdll
.
LoadLibrary
(
'/usr/lib/libc.dylib'
)
libc
=
ctypes
.
cdll
.
LoadLibrary
(
'/usr/lib/libc.dylib'
)
elif
platform
.
system
()
==
'FreeBSD'
:
elif
sys
.
platform
.
startswith
((
'dragonfly'
,
'freebsd'
))
:
libc
=
ctypes
.
cdll
.
LoadLibrary
(
ctypes
.
util
.
find_library
(
'c'
))
libc
=
ctypes
.
cdll
.
LoadLibrary
(
ctypes
.
util
.
find_library
(
'c'
))
else
:
else
:
libc
=
ctypes
.
cdll
.
LoadLibrary
(
'libc.so.6'
)
libc
=
ctypes
.
cdll
.
LoadLibrary
(
'libc.so.6'
)
...
...
vendor/wand/drawing.py
View file @
82931940
...
@@ -1573,7 +1573,7 @@ class Drawing(Resource):
...
@@ -1573,7 +1573,7 @@ class Drawing(Resource):
def
rectangle
(
self
,
left
=
None
,
top
=
None
,
right
=
None
,
bottom
=
None
,
def
rectangle
(
self
,
left
=
None
,
top
=
None
,
right
=
None
,
bottom
=
None
,
width
=
None
,
height
=
None
,
radius
=
None
,
xradius
=
None
,
width
=
None
,
height
=
None
,
radius
=
None
,
xradius
=
None
,
yradius
=
None
):
yradius
=
None
):
"""Draws a rectangle using the current :attr:`stoke_color`,
"""Draws a rectangle using the current :attr:`st
r
oke_color`,
:attr:`stroke_width`, and :attr:`fill_color`.
:attr:`stroke_width`, and :attr:`fill_color`.
.. sourcecode:: text
.. sourcecode:: text
...
...
vendor/wand/exceptions.py
View file @
82931940
...
@@ -18,16 +18,28 @@ class WandException(Exception):
...
@@ -18,16 +18,28 @@ class WandException(Exception):
"""All Wand-related exceptions are derived from this class."""
"""All Wand-related exceptions are derived from this class."""
class
Wand
Warning
(
WandException
,
Warning
):
class
Base
Warning
(
WandException
,
Warning
):
"""Base class for Wand-related warnings.
"""
"""Base class for Wand-related warnings.
.. versionadded:: 0.4.4
class
WandError
(
WandException
):
"""
"""Base class for Wand-related errors."""
class
BaseError
(
WandException
):
"""Base class for Wand-related errors.
.. versionadded:: 0.4.4
"""
class
WandFatalError
(
WandException
):
"""Base class for Wand-related fatal errors."""
class
BaseFatalError
(
WandException
):
"""Base class for Wand-related fatal errors.
.. versionadded:: 0.4.4
"""
class
WandLibraryVersionError
(
WandException
):
class
WandLibraryVersionError
(
WandException
):
...
@@ -91,9 +103,9 @@ DOMAIN_MAP = [
...
@@ -91,9 +103,9 @@ DOMAIN_MAP = [
#: (:class:`list`) The list of (base_class, suffix) pairs (for each code).
#: (:class:`list`) The list of (base_class, suffix) pairs (for each code).
#: It would be zipped with :const:`DOMAIN_MAP` pairs' last element.
#: It would be zipped with :const:`DOMAIN_MAP` pairs' last element.
CODE_MAP
=
[
CODE_MAP
=
[
(
Wand
Warning
,
'Warning'
),
(
Base
Warning
,
'Warning'
),
(
Wand
Error
,
'Error'
),
(
Base
Error
,
'Error'
),
(
Wand
FatalError
,
'FatalError'
)
(
Base
FatalError
,
'FatalError'
)
]
]
...
...
vendor/wand/image.py
View file @
82931940
...
@@ -2757,6 +2757,17 @@ class Image(BaseImage):
...
@@ -2757,6 +2757,17 @@ class Image(BaseImage):
self
.
sequence
=
Sequence
(
self
)
self
.
sequence
=
Sequence
(
self
)
self
.
raise_exception
()
self
.
raise_exception
()
def
destroy
(
self
):
"""Manually remove :class:`~.sequence.SingleImage`'s in
the :class:`~.sequence.Sequence`, allowing it to
be properly garbage collected after using a ``with Image()`` context
manager.
"""
for
i
in
range
(
0
,
len
(
self
.
sequence
)):
self
.
sequence
.
pop
()
super
(
Image
,
self
)
.
destroy
()
def
read
(
self
,
file
=
None
,
filename
=
None
,
blob
=
None
,
resolution
=
None
):
def
read
(
self
,
file
=
None
,
filename
=
None
,
blob
=
None
,
resolution
=
None
):
"""Read new image into Image() object.
"""Read new image into Image() object.
...
...
vendor/wand/version.py
View file @
82931940
...
@@ -57,7 +57,7 @@ __all__ = ('VERSION', 'VERSION_INFO', 'MAGICK_VERSION',
...
@@ -57,7 +57,7 @@ __all__ = ('VERSION', 'VERSION_INFO', 'MAGICK_VERSION',
#:
#:
#: .. versionchanged:: 0.1.9
#: .. versionchanged:: 0.1.9
#: Becomes :class:`tuple`. (It was string before.)
#: Becomes :class:`tuple`. (It was string before.)
VERSION_INFO
=
(
0
,
4
,
3
)
VERSION_INFO
=
(
0
,
4
,
4
)
#: (:class:`basestring`) The version string e.g. ``'0.1.2'``.
#: (:class:`basestring`) The version string e.g. ``'0.1.2'``.
#:
#:
...
@@ -94,20 +94,20 @@ if libmagick:
...
@@ -94,20 +94,20 @@ if libmagick:
#: .. versionadded:: 0.2.1
#: .. versionadded:: 0.2.1
MAGICK_VERSION_INFO
=
tuple
(
int
(
v
or
0
)
for
v
in
_match
.
groups
())
MAGICK_VERSION_INFO
=
tuple
(
int
(
v
or
0
)
for
v
in
_match
.
groups
())
#: (:class:`
datetime.date`) The release date of the linked ImageMagick
#: (:class:`
basestring`) The date string e.g. ``'2012-06-03'`` of
#:
library. The same to the result of :c:func:`GetMagickReleaseDate`
#:
:const:`MAGICK_RELEASE_DATE_STRING`. This value is the exactly same
#: function.
#:
string to the result of :c:func:`GetMagickReleaseDate`
function.
#:
#:
#: .. versionadded:: 0.2.1
#: .. versionadded:: 0.2.1
MAGICK_RELEASE_DATE_STRING
=
text
(
libmagick
.
GetMagickReleaseDate
())
MAGICK_RELEASE_DATE_STRING
=
text
(
libmagick
.
GetMagickReleaseDate
())
#: (:class:`basestring`) The date string e.g. ``'2012-06-03'`` of
_match
=
re
.
match
(
r'^(\d{4})-?(\d\d)-?(\d\d)$'
,
MAGICK_RELEASE_DATE_STRING
)
#: :const:`MAGICK_RELEASE_DATE_STRING`. This value is the exactly same
#: (:class:`datetime.date`) The release date of the linked ImageMagick
#: string to the result of :c:func:`GetMagickReleaseDate` function.
#: library. Equivalent to the result of :c:func:`GetMagickReleaseDate`
#: function.
#:
#:
#: .. versionadded:: 0.2.1
#: .. versionadded:: 0.2.1
MAGICK_RELEASE_DATE
=
datetime
.
date
(
MAGICK_RELEASE_DATE
=
datetime
.
date
(
*
map
(
int
,
_match
.
groups
()))
*
map
(
int
,
MAGICK_RELEASE_DATE_STRING
.
split
(
'-'
)))
c_quantum_depth
=
ctypes
.
c_size_t
()
c_quantum_depth
=
ctypes
.
c_size_t
()
libmagick
.
GetMagickQuantumDepth
(
ctypes
.
byref
(
c_quantum_depth
))
libmagick
.
GetMagickQuantumDepth
(
ctypes
.
byref
(
c_quantum_depth
))
...
...
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