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
251780be
Commit
251780be
authored
May 16, 2021
by
Ozzie Isaacs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added google scholar as metadata provider
parent
decc2a9c
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
399 additions
and
297 deletions
+399
-297
about.py
cps/about.py
+7
-0
editbooks.py
cps/editbooks.py
+26
-0
caliBlur.css
cps/static/css/caliBlur.css
+19
-21
academicpaper.svg
cps/static/img/academicpaper.svg
+1
-0
get_meta.js
cps/static/js/get_meta.js
+338
-273
book_edit.html
cps/templates/book_edit.html
+5
-1
detail.html
cps/templates/detail.html
+2
-2
optional-requirements.txt
optional-requirements.txt
+1
-0
No files found.
cps/about.py
View file @
251780be
...
...
@@ -54,6 +54,12 @@ try:
except
ImportError
:
greenlet_Version
=
None
try
:
from
scholarly
import
scholarly
scholarly_version
=
_
(
u'installed'
)
except
ImportError
:
scholarly_version
=
_
(
u'not installed'
)
from
.
import
services
about
=
flask
.
Blueprint
(
'about'
,
__name__
)
...
...
@@ -79,6 +85,7 @@ _VERSIONS = OrderedDict(
iso639
=
isoLanguages
.
__version__
,
pytz
=
pytz
.
__version__
,
Unidecode
=
unidecode_version
,
Scholarly
=
scholarly_version
,
Flask_SimpleLDAP
=
u'installed'
if
bool
(
services
.
ldap
)
else
None
,
python_LDAP
=
services
.
ldapVersion
if
bool
(
services
.
ldapVersion
)
else
None
,
Goodreads
=
u'installed'
if
bool
(
services
.
goodreads_support
)
else
None
,
...
...
cps/editbooks.py
View file @
251780be
...
...
@@ -27,6 +27,15 @@ import json
from
shutil
import
copyfile
from
uuid
import
uuid4
# Improve this to check if scholarly is available in a global way, like other pythonic libraries
have_scholar
=
True
try
:
from
scholarly
import
scholarly
except
ImportError
:
have_scholar
=
False
pass
from
babel
import
Locale
as
LC
from
babel.core
import
UnknownLocaleError
from
flask
import
Blueprint
,
request
,
flash
,
redirect
,
url_for
,
abort
,
Markup
,
Response
...
...
@@ -1058,6 +1067,23 @@ def convert_bookformat(book_id):
flash
(
_
(
u"There was an error converting this book:
%(res)
s"
,
res
=
rtn
),
category
=
"error"
)
return
redirect
(
url_for
(
'editbook.edit_book'
,
book_id
=
book_id
))
@
editbook
.
route
(
"/scholarsearch/<query>"
,
methods
=
[
'GET'
])
@
login_required_if_no_ano
@
edit_required
def
scholar_search
(
query
):
if
have_scholar
:
scholar_gen
=
scholarly
.
search_pubs
(
' '
.
join
(
query
.
split
(
'+'
)))
i
=
0
result
=
[]
for
publication
in
scholar_gen
:
del
publication
[
'source'
]
result
.
append
(
publication
)
i
+=
1
if
(
i
>=
10
):
break
return
Response
(
json
.
dumps
(
result
),
mimetype
=
'application/json'
)
else
:
return
[]
@
editbook
.
route
(
"/ajax/editbooks/<param>"
,
methods
=
[
'POST'
])
@
login_required_if_no_ano
...
...
cps/static/css/caliBlur.css
View file @
251780be
...
...
@@ -1498,7 +1498,7 @@ body > div.container-fluid > div.row-fluid > div.col-sm-10 > div.discover > form
}
#books
>
.cover
>
a
:hover
,
#books_rand
>
.cover
>
a
:hover
,
.book.isotope-item
>
.cover
>
a
:hover
,
body
>
div
.container-fluid
>
div
.row-fluid
>
div
.col-sm-10
>
div
.discover
>
form
>
div
.col-sm-12
>
div
.col-sm-12
>
div
.col-sm-2
>
a
:hover
{
outline
:
solid
var
(
--color-secondary
);
/* outline: solid var(--color-secondary); */
font-size
:
50px
;
-o-transition
:
outline
0s
;
transition
:
outline
0s
;
...
...
@@ -3133,7 +3133,7 @@ div.btn-group[role=group][aria-label="Download, send to Kindle, reading"] > div.
float
:
left
}
#add-to-shelf
,
#btnGroupDrop1
,
#read
-in-browser
,
#sendbtn
,
.book-meta
.btn-toolbar
>
.btn-group
>
.btn-group
:nth-child
(
1
)
>
a
:first-of-type
,
.book-meta
.btn-toolbar
>
.btn-group
>
.btn-warning
,
.btn-toolbar
>
.btn-group
>
#btnGroupDrop2
,
.btn-toolbar
>
.btn-group
>
.btn-group
>
#btnGroupDrop2
{
#add-to-shelf
,
#btnGroupDrop1
,
#read
btn
,
#sendbtn
,
.book-meta
.btn-toolbar
>
.btn-group
>
.btn-group
:nth-child
(
1
)
>
a
:first-of-type
,
.book-meta
.btn-toolbar
>
.btn-group
>
.btn-warning
,
.btn-toolbar
>
.btn-group
>
#btnGroupDrop2
,
.btn-toolbar
>
.btn-group
>
.btn-group
>
#btnGroupDrop2
{
background
:
0
0
;
color
:
transparent
;
width
:
50px
;
...
...
@@ -3142,20 +3142,16 @@ div.btn-group[role=group][aria-label="Download, send to Kindle, reading"] > div.
overflow
:
hidden
;
padding
:
0
}
#readbtn
{
height
:
100%
;
padding
:
16px
;
}
#add-to-shelf
>
span
.caret
,
#btnGroupDrop1
>
span
.caret
,
#read-in-browser
>
span
.caret
,
.btn-toolbar
>
.btn-group
>
#btnGroupDrop2
>
span
.caret
,
.btn-toolbar
>
.btn-group
>
.btn-group
>
#btnGroupDrop2
>
span
.caret
{
padding-bottom
:
5px
}
#add-to-shelf
>
span
,
#btnGroupDrop1
>
span
,
#read
-in-browser
>
span
,
#sendbtn
>
span
,
.book-meta
.btn-toolbar
>
.btn-group
>
.btn-group
:nth-child
(
1
)
>
a
:first-of-type
>
span
,
.book-meta
.btn-toolbar
>
.btn-group
>
.btn-warning
>
span
,
.btn-toolbar
>
.btn-group
>
#btnGroupDrop2
>
span
,
.btn-toolbar
>
.btn-group
>
.btn-group
>
#btnGroupDrop2
>
span
{
#add-to-shelf
>
span
,
#btnGroupDrop1
>
span
,
#read
btn
>
span
,
#sendbtn
>
span
,
.book-meta
.btn-toolbar
>
.btn-group
>
.btn-group
:nth-child
(
1
)
>
a
:first-of-type
>
span
,
.book-meta
.btn-toolbar
>
.btn-group
>
.btn-warning
>
span
,
.btn-toolbar
>
.btn-group
>
#btnGroupDrop2
>
span
,
.btn-toolbar
>
.btn-group
>
.btn-group
>
#btnGroupDrop2
>
span
{
color
:
hsla
(
0
,
0%
,
100%
,
.7
)
}
#add-to-shelf
:hover
span
,
#btnGroupDrop1
:hover
>
span
,
#read
-in-browser
:hover
>
span
,
#sendbtn
:hover
>
span
,
.book-meta
.btn-toolbar
>
.btn-group
>
.btn-group
:nth-child
(
1
)
>
a
:first-of-type:hover
>
span
,
.book-meta
.btn-toolbar
>
.btn-group
>
.btn-warning
:hover
>
span
,
.btn-toolbar
>
.btn-group
>
#btnGroupDrop2
:hover
>
span
,
.btn-toolbar
>
.btn-group
>
.btn-group
>
#btnGroupDrop2
:hover
>
span
{
#add-to-shelf
:hover
span
,
#btnGroupDrop1
:hover
>
span
,
#read
btn
:hover
>
span
,
#sendbtn
:hover
>
span
,
.book-meta
.btn-toolbar
>
.btn-group
>
.btn-group
:nth-child
(
1
)
>
a
:first-of-type:hover
>
span
,
.book-meta
.btn-toolbar
>
.btn-group
>
.btn-warning
:hover
>
span
,
.btn-toolbar
>
.btn-group
>
#btnGroupDrop2
:hover
>
span
,
.btn-toolbar
>
.btn-group
>
.btn-group
>
#btnGroupDrop2
:hover
>
span
{
color
:
#fff
}
...
...
@@ -3165,13 +3161,13 @@ div.btn-group[role=group][aria-label="Download, send to Kindle, reading"] > div.
font-size
:
18px
}
#sendbtn
>
span
,
.book-meta
.btn-toolbar
>
.btn-group
>
.btn-group
:nth-child
(
1
)
>
a
:first-of-type
>
span
,
.book-meta
.btn-toolbar
>
.btn-group
>
.btn-warning
>
span
.glyphicon-edit
{
#sendbtn
>
span
,
#readbtn
>
span
,
.book-meta
.btn-toolbar
>
.btn-group
>
.btn-group
:nth-child
(
1
)
>
a
:first-of-type
>
span
,
.book-meta
.btn-toolbar
>
.btn-group
>
.btn-warning
>
span
.glyphicon-edit
{
font-size
:
16px
;
line-height
:
54px
;
width
:
100%
}
#read
-in-browser
>
span
.glyphicon-eye-open
:before
,
.btn-toolbar
>
.btn-group
>
.btn-group
>
#btnGroupDrop2
>
span
.glyphicon-eye-open
:before
{
#read
btn
>
span
.glyphicon-book
:before
,
.btn-toolbar
>
.btn-group
>
.btn-group
>
#btnGroupDrop2
>
span
.glyphicon-book
:before
{
content
:
"\e352"
;
font-family
:
Glyphicons
Regular
,
serif
;
font-size
:
18px
;
...
...
@@ -3294,7 +3290,9 @@ div.btn-group[role=group][aria-label="Download, send to Kindle, reading"] .dropd
-ms-transform-origin
:
center
top
;
transform-origin
:
center
top
;
border
:
0
;
left
:
0
!important
left
:
0
!important
;
max-height
:
80%
;
overflow-y
:
auto
;
}
.dropdown-menu
>
li
>
a
{
...
...
@@ -5163,11 +5161,11 @@ body.login > div.navbar.navbar-default.navbar-static-top > div > div.navbar-head
right
:
5px
}
#
read-in-browser
[
aria-expanded
=
true
],
#
shelf-actions
>
.btn-group.open
,
.downloadBtn.open
,
.profileDrop
[
aria-expanded
=
true
]
{
#shelf-actions
>
.btn-group.open
,
.downloadBtn.open
,
.profileDrop
[
aria-expanded
=
true
]
{
pointer-events
:
none
}
#btnGroupDrop1
[
aria-expanded
=
true
]
>
span
,
#
read-in-browser
[
aria-expanded
=
true
]
>
span
,
#
shelf-actions
>
.btn-group.open
>
#add-to-shelf
>
span
{
#btnGroupDrop1
[
aria-expanded
=
true
]
>
span
,
#shelf-actions
>
.btn-group.open
>
#add-to-shelf
>
span
{
color
:
#fff
}
...
...
@@ -7484,14 +7482,14 @@ body.edituser.admin > div.container-fluid > div.row-fluid > div.col-sm-10 > div.
margin-left
:
8px
}
#read-in-browser
>
span
.caret
,
.btn-toolbar
>
.btn-group
>
#btnGroupDrop2
>
span
.caret
,
.btn-toolbar
>
.btn-group
>
.btn-group
>
#btnGroupDrop2
>
span
.caret
{
.btn-toolbar
>
.btn-group
>
#btnGroupDrop2
>
span
.caret
,
.btn-toolbar
>
.btn-group
>
.btn-group
>
#btnGroupDrop2
>
span
.caret
{
position
:
absolute
;
margin-left
:
0
;
left
:
33px
;
top
:
28px
}
#read-in-browser
>
span
.glyphicon-eye-open
:before
,
.btn-toolbar
>
.btn-group
>
.btn-group
>
#btnGroupDrop2
>
span
.glyphicon-eye-open
:before
{
.btn-toolbar
>
.btn-group
>
.btn-group
>
#btnGroupDrop2
>
span
.glyphicon-eye-open
:before
{
margin-left
:
8px
}
...
...
@@ -7892,7 +7890,7 @@ body.mailset > div.container-fluid > div > div.col-sm-10 > div.discover .glyphic
}
}
#sendbtn2
{
#sendbtn2
,
#read-in-browser
{
background
:
0
0
;
color
:
transparent
;
width
:
50px
;
...
...
@@ -7902,15 +7900,15 @@ body.mailset > div.container-fluid > div > div.col-sm-10 > div.discover .glyphic
padding
:
0
}
#sendbtn2
>
span
{
#sendbtn2
>
span
,
#read-in-browser
>
span
{
color
:
hsla
(
0
,
0%
,
100%
,
.7
)
}
#sendbtn2
>
span
.glyphicon-send
:before
{
#sendbtn2
>
span
.glyphicon-send
:before
,
#read-in-browser
>
span
.glyphicon-book
:before
{
margin-left
:
8px
}
#sendbtn2
>
span
.caret
{
#sendbtn2
>
span
.caret
,
#read-in-browser
>
span
.caret
{
position
:
absolute
;
margin-left
:
0
;
left
:
33px
;
...
...
@@ -7918,11 +7916,11 @@ body.mailset > div.container-fluid > div > div.col-sm-10 > div.discover .glyphic
padding-bottom
:
5px
}
#sendbtn2
:focus
span
,
#sendbtn2
:hover
span
{
#sendbtn2
:focus
span
,
#sendbtn2
:hover
span
,
#read-in-browser
:focus
span
,
#read-in-browser
:hover
span
{
color
:
#fff
}
#sendbtn2
[
aria-expanded
=
true
]
{
#sendbtn2
[
aria-expanded
=
true
]
,
#read-in-browser
[
aria-expanded
=
true
]
{
pointer-events
:
none
}
...
...
cps/static/img/academicpaper.svg
0 → 100644
View file @
251780be
This source diff could not be displayed because it is too large. You can
view the blob
instead.
cps/static/js/get_meta.js
View file @
251780be
This diff is collapsed.
Click to expand it.
cps/templates/book_edit.html
View file @
251780be
...
...
@@ -246,6 +246,10 @@
<input
type=
"checkbox"
id=
"show-comics"
class=
"pill"
data-control=
"comicvine"
checked
>
<label
for=
"show-comics"
>
ComicVine
<span
class=
"glyphicon glyphicon-ok"
></span></label>
<input
type=
"checkbox"
id=
"show-googlescholar"
class=
"pill"
data-control=
"googlescholar"
checked
>
<label
for=
"show-googlescholar"
>
Google Scholar
<span
class=
"glyphicon glyphicon-ok"
></span></label>
</div>
<div
id=
"meta-info"
>
...
...
@@ -267,7 +271,7 @@
<
img
class
=
"pull-left img-responsive"
data
-
toggle
=
"modal"
data
-
target
=
"#metaModal"
src
=
"<%= cover %>"
src
=
"<%= cover
|| "
{{
url_for
(
'static'
,
filename
=
'img/academicpaper.svg'
)
}}
"
%>"
alt
=
"Cover"
>
<
div
class
=
"media-body"
>
...
...
cps/templates/detail.html
View file @
251780be
...
...
@@ -57,7 +57,7 @@
<div
class=
"btn-group"
role=
"group"
>
{% if reader_list|length > 1 %}
<button
id=
"read-in-browser"
type=
"button"
class=
"btn btn-primary dropdown-toggle"
data-toggle=
"dropdown"
aria-haspopup=
"true"
aria-expanded=
"false"
>
<span
class=
"glyphicon glyphicon-
eye-open
"
></span>
{{_('Read in Browser')}}
<span
class=
"glyphicon glyphicon-
book
"
></span>
{{_('Read in Browser')}}
<span
class=
"caret"
></span>
</button>
<ul
class=
"dropdown-menu"
aria-labelledby=
"read-in-browser"
>
...
...
@@ -66,7 +66,7 @@
{%endfor%}
</ul>
{% else %}
<a
target=
"_blank"
href=
"{{url_for('web.read_book', book_id=entry.id, book_format=reader_list[0])}}"
id=
"readbtn"
class=
"btn btn-primary"
role=
"button"
><span
class=
"glyphicon glyphicon-
eye-open
"
></span>
{{_('Read in Browser')}} - {{reader_list[0]}}
</a>
<a
target=
"_blank"
href=
"{{url_for('web.read_book', book_id=entry.id, book_format=reader_list[0])}}"
id=
"readbtn"
class=
"btn btn-primary"
role=
"button"
><span
class=
"glyphicon glyphicon-
book
"
></span>
{{_('Read in Browser')}} - {{reader_list[0]}}
</a>
{% endif %}
</div>
{% endif %}
...
...
optional-requirements.txt
View file @
251780be
...
...
@@ -32,6 +32,7 @@ SQLAlchemy-Utils>=0.33.5,<0.38.0
# extracting metadata
lxml
>=3.8.0,<4.7.0
rarfile
>=2.7
scholarly
>=1.2.0, <1.3
# other
natsort
>=2.2.0,<7.2.0
...
...
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