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
7c6d527a
Commit
7c6d527a
authored
Apr 02, 2017
by
OzzieIsaacs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Code cosmetics
parent
66181daf
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
17 changed files
with
254 additions
and
255 deletions
+254
-255
cps.py
cps.py
+1
-1
helper.py
cps/helper.py
+1
-0
edit_books.js
cps/static/js/edit_books.js
+10
-11
get_meta.js
cps/static/js/get_meta.js
+93
-93
main.js
cps/static/js/main.js
+6
-6
book_edit.html
cps/templates/book_edit.html
+1
-1
detail.html
cps/templates/detail.html
+6
-6
discover.html
cps/templates/discover.html
+2
-2
feed.xml
cps/templates/feed.xml
+4
-4
index.html
cps/templates/index.html
+4
-4
json.txt
cps/templates/json.txt
+2
-2
list.html
cps/templates/list.html
+1
-1
search.html
cps/templates/search.html
+2
-2
shelf.html
cps/templates/shelf.html
+2
-2
user_edit.html
cps/templates/user_edit.html
+1
-1
ub.py
cps/ub.py
+2
-1
web.py
cps/web.py
+116
-118
No files found.
cps.py
View file @
7c6d527a
...
...
@@ -22,7 +22,7 @@ except ImportError:
if
__name__
==
'__main__'
:
if
web
.
ub
.
DEVELOPMENT
:
web
.
app
.
run
(
host
=
"0.0.0.0"
,
port
=
web
.
ub
.
config
.
config_port
,
debug
=
True
)
web
.
app
.
run
(
port
=
web
.
ub
.
config
.
config_port
,
debug
=
True
)
else
:
if
gevent_present
:
web
.
app
.
logger
.
info
(
'Attempting to start gevent'
)
...
...
cps/helper.py
View file @
7c6d527a
...
...
@@ -13,6 +13,7 @@ import os
import
traceback
import
re
import
unicodedata
try
:
from
StringIO
import
StringIO
from
email.MIMEBase
import
MIMEBase
...
...
cps/static/js/edit_books.js
View file @
7c6d527a
...
...
@@ -8,7 +8,7 @@
Takes a prefix, query typeahead callback, Bloodhound typeahead adapter
and returns the completions it gets from the bloodhound engine prefixed.
*/
function
prefixed
_s
ource
(
prefix
,
query
,
cb
,
bhAdapter
)
{
function
prefixed
S
ource
(
prefix
,
query
,
cb
,
bhAdapter
)
{
bhAdapter
(
query
,
function
(
retArray
){
var
matches
=
[];
for
(
var
i
=
0
;
i
<
retArray
.
length
;
i
++
)
{
...
...
@@ -18,7 +18,7 @@ function prefixed_source(prefix, query, cb, bhAdapter) {
cb
(
matches
);
});
}
function
get
_p
ath
(){
function
get
P
ath
(){
var
jsFileLocation
=
$
(
"script[src*=edit_books]"
).
attr
(
"src"
);
// the js file path
jsFileLocation
=
jsFileLocation
.
replace
(
"/static/js/edit_books.js"
,
''
);
// the js folder path
return
jsFileLocation
;
...
...
@@ -31,7 +31,7 @@ var authors = new Bloodhound({
},
queryTokenizer
:
Bloodhound
.
tokenizers
.
whitespace
,
remote
:
{
url
:
get
_p
ath
()
+
"/get_authors_json?q=%QUERY"
url
:
get
P
ath
()
+
"/get_authors_json?q=%QUERY"
}
});
...
...
@@ -44,7 +44,7 @@ var series = new Bloodhound({
return
[
query
];
},
remote
:
{
url
:
get
_p
ath
()
+
"/get_series_json?q="
,
url
:
get
P
ath
()
+
"/get_series_json?q="
,
replace
:
function
(
url
,
query
)
{
return
url
+
encodeURIComponent
(
query
);
}
...
...
@@ -63,7 +63,7 @@ var tags = new Bloodhound({
return
tokens
;
},
remote
:
{
url
:
get
_p
ath
()
+
"/get_tags_json?q=%QUERY"
url
:
get
P
ath
()
+
"/get_tags_json?q=%QUERY"
}
});
...
...
@@ -76,10 +76,9 @@ var languages = new Bloodhound({
return
[
query
];
},
remote
:
{
url
:
get
_p
ath
()
+
"/get_languages_json?q="
,
url
:
get
P
ath
()
+
"/get_languages_json?q="
,
replace
:
function
(
url
,
query
)
{
url_query
=
url
+
encodeURIComponent
(
query
);
return
url_query
;
return
url
+
encodeURIComponent
(
query
);
}
}
});
...
...
@@ -101,7 +100,7 @@ function sourceSplit(query, cb, split, source) {
for
(
var
i
=
0
;
i
<
tokens
.
length
;
i
++
)
{
prefix
+=
tokens
[
i
].
trim
()
+
newSplit
;
}
prefixed
_s
ource
(
prefix
,
currentSource
,
cb
,
bhAdapter
);
prefixed
S
ource
(
prefix
,
currentSource
,
cb
,
bhAdapter
);
}
var
promiseAuthors
=
authors
.
initialize
();
...
...
@@ -130,7 +129,7 @@ var promiseSeries = series.initialize();
displayKey
:
"name"
,
source
:
series
.
ttAdapter
()
}
)
)
;
});
var
promiseTags
=
tags
.
initialize
();
...
...
@@ -165,7 +164,7 @@ var promiseLanguages = languages.initialize();
$
(
"form"
).
on
(
"change input typeahead:selected"
,
function
(
data
){
var
form
=
$
(
"form"
).
serialize
();
$
.
getJSON
(
get
_p
ath
()
+
"/get_matching_tags"
,
form
,
function
(
data
)
{
$
.
getJSON
(
get
P
ath
()
+
"/get_matching_tags"
,
form
,
function
(
data
)
{
$
(
".tags_click"
).
each
(
function
()
{
if
(
$
.
inArray
(
parseInt
(
$
(
this
).
children
(
"input"
).
first
().
val
(),
10
),
data
.
tags
)
===
-
1
)
{
if
(
!
(
$
(
this
).
hasClass
(
"active"
)))
{
...
...
cps/static/js/get_meta.js
View file @
7c6d527a
This diff is collapsed.
Click to expand it.
cps/static/js/main.js
View file @
7c6d527a
...
...
@@ -49,13 +49,13 @@ $(function() {
});
});
$
(
"#check_for_update"
).
click
(
function
()
{
var
button
_t
ext
=
$
(
"#check_for_update"
).
html
();
var
button
T
ext
=
$
(
"#check_for_update"
).
html
();
$
(
"#check_for_update"
).
html
(
"..."
);
$
.
ajax
({
dataType
:
"json"
,
url
:
window
.
location
.
pathname
+
"/../../get_update_status"
,
success
:
function
(
data
)
{
$
(
"#check_for_update"
).
html
(
button
_t
ext
);
$
(
"#check_for_update"
).
html
(
button
T
ext
);
if
(
data
.
status
===
true
)
{
$
(
"#check_for_update"
).
addClass
(
"hidden"
);
$
(
"#perform_update"
).
removeClass
(
"hidden"
);
...
...
@@ -67,7 +67,7 @@ $(function() {
});
$
(
"#restart_database"
).
click
(
function
()
{
$
.
ajax
({
dataType
:
'json'
,
dataType
:
"json"
,
url
:
window
.
location
.
pathname
+
"/../../shutdown"
,
data
:
{
"parameter"
:
2
}
});
...
...
@@ -76,7 +76,7 @@ $(function() {
$
(
"#spinner2"
).
show
();
$
.
ajax
({
type
:
"POST"
,
dataType
:
'json'
,
dataType
:
"json"
,
data
:
{
start
:
"True"
},
url
:
window
.
location
.
pathname
+
"/../../get_updater_status"
,
success
:
function
(
data
)
{
...
...
@@ -94,10 +94,10 @@ $(function() {
function
updateTimer
()
{
$
.
ajax
({
dataType
:
'json'
,
dataType
:
"json"
,
url
:
window
.
location
.
pathname
+
"/../../get_updater_status"
,
success
:
function
(
data
)
{
console
.
log
(
data
.
status
);
//
console.log(data.status);
$
(
"#UpdateprogressDialog #Updatecontent"
).
html
(
updateText
[
data
.
status
]);
if
(
data
.
status
>
6
){
clearInterval
(
updateTimerID
);
...
...
cps/templates/book_edit.html
View file @
7c6d527a
...
...
@@ -106,7 +106,7 @@
</div>
<a
href=
"#"
id=
"get_meta"
class=
"btn btn-default"
data-toggle=
"modal"
data-target=
"#metaModal"
>
{{_('Get metadata')}}
</a>
<button
type=
"submit"
class=
"btn btn-default"
>
{{_('Submit')}}
</button>
<a
href=
"{{ url_for('show_book',id=book.id) }}"
class=
"btn btn-default"
>
{{_('Back')}}
</a>
<a
href=
"{{ url_for('show_book',
book_
id=book.id) }}"
class=
"btn btn-default"
>
{{_('Back')}}
</a>
</form>
</div>
{% endif %}
...
...
cps/templates/detail.html
View file @
7c6d527a
...
...
@@ -15,7 +15,7 @@
<h2>
{{entry.title}}
</h2>
<p
class=
"author"
>
{% for author in entry.authors %}
<a
href=
"{{url_for('author', id=author.id ) }}"
>
{{author.name}}
</a>
<a
href=
"{{url_for('author',
book_
id=author.id ) }}"
>
{{author.name}}
</a>
{% if not loop.last %}
&
{% endif %}
...
...
@@ -37,7 +37,7 @@
{% endif %}
{% if entry.series|length > 0 %}
<p>
{{_('Book')}} {{entry.series_index}} {{_('of')}}
<a
href=
"{{url_for('series', id=entry.series[0].id)}}"
>
{{entry.series[0].name}}
</a></p>
<p>
{{_('Book')}} {{entry.series_index}} {{_('of')}}
<a
href=
"{{url_for('series',
book_
id=entry.series[0].id)}}"
>
{{entry.series[0].name}}
</a></p>
{% endif %}
{% if entry.languages.__len__() > 0 %}
...
...
@@ -65,7 +65,7 @@
<span
class=
"glyphicon glyphicon-tags"
></span>
{% for tag in entry.tags %}
<a
href=
"{{ url_for('category', id=tag.id) }}"
class=
"btn btn-xs btn-info"
role=
"button"
>
{{tag.name}}
</a>
<a
href=
"{{ url_for('category',
book_
id=tag.id) }}"
class=
"btn btn-xs btn-info"
role=
"button"
>
{{tag.name}}
</a>
{%endfor%}
</div>
</p>
...
...
@@ -110,7 +110,7 @@
{% if not g.user.is_anonymous() %}
<p>
<div
class=
"custom_columns"
id=
"have_read_container"
>
<form
id=
"have_read_form"
action=
"{{ url_for('toggle_read', id=entry.id)}}"
method=
"POST"
)
>
<form
id=
"have_read_form"
action=
"{{ url_for('toggle_read',
book_
id=entry.id)}}"
method=
"POST"
)
>
<input
id=
"have_read_cb"
type=
"checkbox"
{%
if
have_read
%}
checked
{%
endif
%}
>
<label
for=
"have_read_cb"
>
{{_('Read')}}
</label>
</form>
...
...
@@ -136,7 +136,7 @@
</button>
<ul
class=
"dropdown-menu"
aria-labelledby=
"btnGroupDrop1"
>
{% for format in entry.data %}
<li><a
href=
"{{ url_for('get_download_link_ext', book_id=entry.id, format=format.format|lower, anyname=entry.id|string+'.'+format.format) }}"
>
{{format.format}}
</a></li>
<li><a
href=
"{{ url_for('get_download_link_ext', book_id=entry.id,
book_
format=format.format|lower, anyname=entry.id|string+'.'+format.format) }}"
>
{{format.format}}
</a></li>
{%endfor%}
</ul>
</div>
...
...
@@ -154,7 +154,7 @@
<ul
class=
"dropdown-menu"
aria-labelledby=
"btnGroupDrop2"
>
{% for format in entry.data %}
{%if format.format|lower == 'epub' or format.format|lower == 'txt' or format.format|lower == 'pdf' or format.format|lower == 'cbr' or format.format|lower == 'cbt' or format.format|lower == 'cbz' %}
<li><a
target=
"_blank"
href=
"{{ url_for('read_book', book_id=entry.id, format=format.format|lower) }}"
>
{{format.format}}
</a></li>
<li><a
target=
"_blank"
href=
"{{ url_for('read_book', book_id=entry.id,
book_
format=format.format|lower) }}"
>
{{format.format}}
</a></li>
{% endif %}
{%endfor%}
</ul>
...
...
cps/templates/discover.html
View file @
7c6d527a
...
...
@@ -8,14 +8,14 @@
<div
class=
"col-sm-3 col-lg-2 col-xs-6 book"
>
<div
class=
"cover"
>
{% if entry.has_cover is defined %}
<a
href=
"{{ url_for('show_book', id=entry.id) }}"
>
<a
href=
"{{ url_for('show_book',
book_
id=entry.id) }}"
>
<img
src=
"{{ url_for('get_cover', cover_path=entry.path.replace('\\','/')) }}"
/>
</a>
{% endif %}
</div>
<div
class=
"meta"
>
<p
class=
"title"
>
{{entry.title|shortentitle}}
</p>
<p
class=
"author"
><a
href=
"{{url_for('author', id=entry.authors[0].id) }}"
>
{{entry.authors[0].name}}
</a></p>
<p
class=
"author"
><a
href=
"{{url_for('author',
book_
id=entry.authors[0].id) }}"
>
{{entry.authors[0].name}}
</a></p>
{% if entry.ratings.__len__() > 0 %}
<div
class=
"rating"
>
{% for number in range((entry.ratings[0].rating/2)|int(2)) %}
...
...
cps/templates/feed.xml
View file @
7c6d527a
...
...
@@ -56,7 +56,7 @@
<link
type=
"image/jpeg"
href=
"{{url_for('feed_get_cover', book_id=entry.id)}}"
rel=
"http://opds-spec.org/image/thumbnail"
/>
{% endif %}
{% for format in entry.data %}
<link
rel=
"http://opds-spec.org/acquisition"
href=
"{{ url_for('get_opds_download_link', book_id=entry.id, format=format.format|lower)}}"
<link
rel=
"http://opds-spec.org/acquisition"
href=
"{{ url_for('get_opds_download_link', book_id=entry.id,
book_
format=format.format|lower)}}"
length=
"{{format.uncompressed_size}}"
mtime=
"{{entry.timestamp}}"
type=
"{{format.format|lower|mimetype}}"
/>
{% endfor %}
</entry>
...
...
@@ -65,9 +65,9 @@
{% for entry in listelements %}
<entry>
<title>
{{entry.name}}
</title>
<id>
{{ url_for(folder, id=entry.id) }}
</id>
<link
type=
"application/atom+xml;profile=opds-catalog;type=feed;kind=acquisition"
href=
"{{url_for(folder, id=entry.id)}}"
/>
<link
type=
"application/atom+xml"
href=
"{{url_for(folder, id=entry.id)}}"
rel=
"subsection"
/>
<id>
{{ url_for(folder,
book_
id=entry.id) }}
</id>
<link
type=
"application/atom+xml;profile=opds-catalog;type=feed;kind=acquisition"
href=
"{{url_for(folder,
book_
id=entry.id)}}"
/>
<link
type=
"application/atom+xml"
href=
"{{url_for(folder,
book_
id=entry.id)}}"
rel=
"subsection"
/>
</entry>
{% endfor %}
</feed>
cps/templates/index.html
View file @
7c6d527a
...
...
@@ -8,7 +8,7 @@
{% for entry in random %}
<div
id=
"books_rand"
class=
"col-sm-3 col-lg-2 col-xs-6 book"
>
<div
class=
"cover"
>
<a
href=
"{{ url_for('show_book', id=entry.id) }}"
>
<a
href=
"{{ url_for('show_book',
book_
id=entry.id) }}"
>
{% if entry.has_cover %}
<img
src=
"{{ url_for('get_cover', cover_path=entry.path.replace('\\','/')) }}"
/>
{% else %}
...
...
@@ -18,7 +18,7 @@
</div>
<div
class=
"meta"
>
<p
class=
"title"
>
{{entry.title|shortentitle}}
</p>
<p
class=
"author"
><a
href=
"{{url_for('author', id=entry.authors[0].id) }}"
>
{{entry.authors[0].name}}
</a></p>
<p
class=
"author"
><a
href=
"{{url_for('author',
book_
id=entry.authors[0].id) }}"
>
{{entry.authors[0].name}}
</a></p>
{% if entry.ratings.__len__() > 0 %}
<div
class=
"rating"
>
{% for number in range((entry.ratings[0].rating/2)|int(2)) %}
...
...
@@ -44,7 +44,7 @@
{% for entry in entries %}
<div
id=
"books"
class=
"col-sm-3 col-lg-2 col-xs-6 book"
>
<div
class=
"cover"
>
<a
href=
"{{ url_for('show_book', id=entry.id) }}"
>
<a
href=
"{{ url_for('show_book',
book_
id=entry.id) }}"
>
{% if entry.has_cover %}
<img
src=
"{{ url_for('get_cover', cover_path=entry.path.replace('\\','/')) }}"
/>
{% else %}
...
...
@@ -56,7 +56,7 @@
<p
class=
"title"
>
{{entry.title|shortentitle}}
</p>
<p
class=
"author"
>
{% for author in entry.authors %}
<a
href=
"{{url_for('author', id=author.id) }}"
>
{{author.name}}
</a>
<a
href=
"{{url_for('author',
book_
id=author.id) }}"
>
{{author.name}}
</a>
{% if not loop.last %}
&
{% endif %}
...
...
cps/templates/json.txt
View file @
7c6d527a
...
...
@@ -36,7 +36,7 @@
"timestamp": "{{entry.timestamp}}",
"thumbnail": "{{url_for('feed_get_cover', book_id=entry.id)}}",
"main_format": {
"{{entry.data[0].format|lower}}": "{{ url_for('get_opds_download_link', book_id=entry.id, format=entry.data[0].format|lower)}}"
"{{entry.data[0].format|lower}}": "{{ url_for('get_opds_download_link', book_id=entry.id,
book_
format=entry.data[0].format|lower)}}"
},
"rating":{% if entry.ratings.__len__() > 0 %} "{{entry.ratings[0].rating}}.0"{% else %}0.0{% endif %},
"authors": [
...
...
@@ -47,7 +47,7 @@
"other_formats": {
{% if entry.data.__len__() > 1 %}
{% for format in entry.data[1:] %}
"{{format.format|lower}}": "{{ url_for('get_opds_download_link', book_id=entry.id, format=format.format|lower)}}"{% if not loop.last %},{% endif %}
"{{format.format|lower}}": "{{ url_for('get_opds_download_link', book_id=entry.id,
book_
format=format.format|lower)}}"{% if not loop.last %},{% endif %}
{% endfor %}
{% endif %} },
"title_sort": "{{entry.sort}}"
...
...
cps/templates/list.html
View file @
7c6d527a
...
...
@@ -10,7 +10,7 @@
{% endif %}
<div
class=
"row"
>
<div
class=
"col-xs-1"
align=
"left"
><span
class=
"badge"
>
{{entry.count}}
</span></div>
<div
class=
"col-xs-6"
><a
id=
"list_{{loop.index0}}"
href=
"{{url_for(folder, id=entry[0].id )}}"
>
{{entry[0].name}}
</a></div>
<div
class=
"col-xs-6"
><a
id=
"list_{{loop.index0}}"
href=
"{{url_for(folder,
book_
id=entry[0].id )}}"
>
{{entry[0].name}}
</a></div>
</div>
{% endfor %}
</div>
...
...
cps/templates/search.html
View file @
7c6d527a
...
...
@@ -15,7 +15,7 @@
<div
class=
"col-sm-3 col-lg-2 col-xs-6 book"
>
<div
class=
"cover"
>
{% if entry.has_cover is defined %}
<a
href=
"{{ url_for('show_book', id=entry.id) }}"
>
<a
href=
"{{ url_for('show_book',
book_
id=entry.id) }}"
>
<img
src=
"{{ url_for('get_cover', cover_path=entry.path.replace('\\','/')) }}"
/>
</a>
{% endif %}
...
...
@@ -24,7 +24,7 @@
<p
class=
"title"
>
{{entry.title|shortentitle}}
</p>
<p
class=
"author"
>
{% for author in entry.authors %}
<a
href=
"{{url_for('author', id=author.id ) }}"
>
{{author.name}}
</a>
<a
href=
"{{url_for('author',
book_
id=author.id ) }}"
>
{{author.name}}
</a>
{% if not loop.last %}
&
{% endif %}
...
...
cps/templates/shelf.html
View file @
7c6d527a
...
...
@@ -15,14 +15,14 @@
<div
class=
"col-sm-3 col-lg-2 col-xs-6 book"
>
<div
class=
"cover"
>
{% if entry.has_cover is defined %}
<a
href=
"{{ url_for('show_book', id=entry.id) }}"
>
<a
href=
"{{ url_for('show_book',
book_
id=entry.id) }}"
>
<img
src=
"{{ url_for('get_cover', cover_path=entry.path.replace('\\','/')) }}"
/>
</a>
{% endif %}
</div>
<div
class=
"meta"
>
<p
class=
"title"
>
{{entry.title|shortentitle}}
</p>
<p
class=
"author"
><a
href=
"{{url_for('author', id=entry.authors[0].id) }}"
>
{{entry.authors[0].name}}
</a></p>
<p
class=
"author"
><a
href=
"{{url_for('author',
book_
id=entry.authors[0].id) }}"
>
{{entry.authors[0].name}}
</a></p>
{% if entry.ratings.__len__() > 0 %}
<div
class=
"rating"
>
{% for number in range((entry.ratings[0].rating/2)|int(2)) %}
...
...
cps/templates/user_edit.html
View file @
7c6d527a
...
...
@@ -131,7 +131,7 @@
<h2>
{{_('Recent Downloads')}}
</h2>
{% for entry in downloads %}
<div
class=
"col-sm-2"
>
<a
class=
"pull-left"
href=
"{{ url_for('show_book', id=entry.id) }}"
>
<a
class=
"pull-left"
href=
"{{ url_for('show_book',
book_
id=entry.id) }}"
>
<img
class=
"media-object"
width=
"100"
src=
"{{ url_for('get_cover', cover_path=entry.path.replace('\\','/')) }}"
alt=
"..."
>
</a>
</div>
...
...
cps/ub.py
View file @
7c6d527a
...
...
@@ -93,9 +93,11 @@ class UserBase:
else
:
return
False
@
staticmethod
def
is_active
(
self
):
return
True
@
staticmethod
def
is_anonymous
(
self
):
return
False
...
...
@@ -526,7 +528,6 @@ def create_admin_user():
session
.
commit
()
except
Exception
:
session
.
rollback
()
pass
# Open session for database connection
...
...
cps/web.py
View file @
7c6d527a
This diff is collapsed.
Click to expand it.
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