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
26cc64bd
Commit
26cc64bd
authored
Apr 01, 2021
by
cbartondock
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use google scholar to fetch metadata
parent
c0623a94
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
373 additions
and
274 deletions
+373
-274
editbooks.py
cps/editbooks.py
+29
-0
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
No files found.
cps/editbooks.py
View file @
26cc64bd
...
@@ -27,6 +27,15 @@ import json
...
@@ -27,6 +27,15 @@ import json
from
shutil
import
copyfile
from
shutil
import
copyfile
from
uuid
import
uuid4
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
flask
import
Blueprint
,
request
,
flash
,
redirect
,
url_for
,
abort
,
Markup
,
Response
from
flask
import
Blueprint
,
request
,
flash
,
redirect
,
url_for
,
abort
,
Markup
,
Response
from
flask_babel
import
gettext
as
_
from
flask_babel
import
gettext
as
_
from
flask_login
import
current_user
,
login_required
from
flask_login
import
current_user
,
login_required
...
@@ -996,6 +1005,26 @@ def convert_bookformat(book_id):
...
@@ -996,6 +1005,26 @@ def convert_bookformat(book_id):
flash
(
_
(
u"There was an error converting this book:
%(res)
s"
,
res
=
rtn
),
category
=
"error"
)
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
))
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
'Scholarly not installed'
@
editbook
.
route
(
"/ajax/editbooks/<param>"
,
methods
=
[
'POST'
])
@
editbook
.
route
(
"/ajax/editbooks/<param>"
,
methods
=
[
'POST'
])
@
login_required_if_no_ano
@
login_required_if_no_ano
@
edit_required
@
edit_required
...
...
cps/static/img/academicpaper.svg
0 → 100644
View file @
26cc64bd
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 @
26cc64bd
This diff is collapsed.
Click to expand it.
cps/templates/book_edit.html
View file @
26cc64bd
...
@@ -227,6 +227,10 @@
...
@@ -227,6 +227,10 @@
<input
type=
"checkbox"
id=
"show-comics"
class=
"pill"
data-control=
"comicvine"
checked
>
<input
type=
"checkbox"
id=
"show-comics"
class=
"pill"
data-control=
"comicvine"
checked
>
<label
for=
"show-comics"
>
ComicVine
<span
class=
"glyphicon glyphicon-ok"
></span></label>
<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>
<div
id=
"meta-info"
>
<div
id=
"meta-info"
>
...
@@ -248,7 +252,7 @@
...
@@ -248,7 +252,7 @@
<
img
class
=
"pull-left img-responsive"
<
img
class
=
"pull-left img-responsive"
data
-
toggle
=
"modal"
data
-
toggle
=
"modal"
data
-
target
=
"#metaModal"
data
-
target
=
"#metaModal"
src
=
"<%= cover %>"
src
=
"<%= cover
|| "
{{
url_for
(
'static'
,
filename
=
'img/academicpaper.svg'
)
}}
"
%>"
alt
=
"Cover"
alt
=
"Cover"
>
>
<
div
class
=
"media-body"
>
<
div
class
=
"media-body"
>
...
...
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