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
fb23db57
Commit
fb23db57
authored
Mar 03, 2019
by
Ozzieisaacs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added filtering of authors, series, categories, publishers
parent
fda977b1
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
78 additions
and
16 deletions
+78
-16
style.css
cps/static/css/style.css
+1
-0
filter_list.js
cps/static/js/filter_list.js
+46
-0
list.html
cps/templates/list.html
+16
-10
web.py
cps/web.py
+15
-6
No files found.
cps/static/css/style.css
View file @
fb23db57
...
...
@@ -130,3 +130,4 @@ input.pill:not(:checked) + label .glyphicon {
.editable-cancel
{
margin-bottom
:
0px
!important
;
margin-left
:
7px
!important
;}
.editable-submit
{
margin-bottom
:
0px
!important
;}
.filterheader
{
margin-bottom
:
20px
;
}
cps/static/js/filter_list.js
0 → 100644
View file @
fb23db57
var
direction
=
0
;
// Descending order
$
(
"#desc"
).
click
(
function
()
{
if
(
direction
===
0
)
{
return
;
}
var
list
=
$
(
'#list'
);
var
listItems
=
list
.
children
(
".row"
);
list
.
append
(
listItems
.
get
().
reverse
());
console
.
log
(
"desc"
)
direction
=
0
;
});
$
(
"#asc"
).
click
(
function
()
{
if
(
direction
===
1
)
{
return
;
}
var
list
=
$
(
'#list'
);
var
listItems
=
list
.
children
(
".row"
);
list
.
append
(
listItems
.
get
().
reverse
());
console
.
log
(
"asc"
)
direction
=
1
;
});
$
(
"#all"
).
click
(
function
()
{
$
(
".row"
).
each
(
function
()
{
$
(
this
).
show
();
});
});
$
(
".char"
).
click
(
function
()
{
console
.
log
(
this
.
innerText
);
var
character
=
this
.
innerText
;
// var listItems = ;
$
(
".row"
).
each
(
function
()
{
if
(
this
.
attributes
[
'data-id'
].
value
.
charAt
(
0
).
toUpperCase
()
!==
character
)
{
$
(
this
).
hide
();
}
else
{
$
(
this
).
show
();
}
});
});
cps/templates/list.html
View file @
fb23db57
...
...
@@ -2,20 +2,26 @@
{% block body %}
<h1
class=
"{{page}}"
>
{{_(title)}}
</h1>
<div
class=
"container"
>
<span
class=
"btn btn-success"
><span
class=
"glyphicon glyphicon-sort-by-alphabet"
></span></span></button>
<button
class=
"btn btn-success"
><span
class=
"glyphicon glyphicon-sort-by-alphabet-alt"
></span></button>
<div
class=
"btn-group"
role=
"group"
>
<div
class=
"filterheader hidden-xs hidden-sm"
>
<button
id=
"desc"
class=
"btn btn-success"
><span
class=
"glyphicon glyphicon-sort-by-alphabet"
></span></button>
<button
id=
"asc"
class=
"btn btn-success"
><span
class=
"glyphicon glyphicon-sort-by-alphabet-alt"
></span></button>
<button
id=
"all"
class=
"btn btn-success"
>
{{_('All')}}
</button>
<div
class=
"btn-group character"
role=
"group"
>
{% for char in charlist%}
<button
class=
"btn btn-success"
>
{{char.char}}
</button>
<button
class=
"btn btn-success
char
"
>
{{char.char}}
</button>
{% endfor %}
</div>
<div
class=
"grid"
>
{% for entry in entries %}
<div
class=
"grid-item"
>
<span
class=
"badge"
>
{{entry.count}}
</span>
<a
id=
"list_{{loop.index0}}"
href=
"{{url_for(folder, book_id=entry[0].id )}}"
>
{{entry[0].name}}
</a>
</div>
</div>
<div
id=
"list"
class=
"col-xs-12 col-sm-6"
>
{% for entry in entries %}
<div
class=
"row"
data-id=
"{% if entry[0].sort %}{{entry[0].sort}}{% else %}{{entry[0].name}}{% endif %}"
>
<div
class=
"col-xs-2 col-sm-2 col-md-1"
align=
"left"
><span
class=
"badge"
>
{{entry.count}}
</span></div>
<div
class=
"col-xs-10 col-sm-10 col-md-11"
><a
id=
"list_{{loop.index0}}"
href=
"{{url_for(folder, book_id=entry[0].id )}}"
>
{{entry[0].name}}
</a></div>
</div>
{% endfor %}
</div>
</div>
{% endblock %}
{% block js %}
<script
src=
"{{ url_for('static', filename='js/filter_list.js') }}"
></script>
{% endblock %}
cps/web.py
View file @
fb23db57
...
...
@@ -433,7 +433,6 @@ def get_tags_json():
def
get_languages_json
():
if
request
.
method
==
"GET"
:
query
=
request
.
args
.
get
(
'q'
)
.
lower
()
# languages = speaking_language()
languages
=
language_table
[
get_locale
()]
entries_start
=
[
s
for
key
,
s
in
languages
.
items
()
if
s
.
lower
()
.
startswith
(
query
.
lower
())]
if
len
(
entries_start
)
<
5
:
...
...
@@ -602,7 +601,6 @@ def author_list():
charlist
=
db
.
session
.
query
(
func
.
upper
(
func
.
substr
(
db
.
Authors
.
sort
,
1
,
1
))
.
label
(
'char'
))
\
.
join
(
db
.
books_authors_link
)
.
join
(
db
.
Books
)
.
filter
(
common_filters
())
\
.
group_by
(
func
.
upper
(
func
.
substr
(
db
.
Authors
.
sort
,
1
,
1
)))
.
all
()
# charlist = db.session.query(func.substr(db.Authors.sort,1,1).label('char'),func.count(db.Authors.sort).label('count')).group_by(func.substr(db.Authors.sort,1,1)).all()
for
entry
in
entries
:
entry
.
Authors
.
name
=
entry
.
Authors
.
name
.
replace
(
'|'
,
','
)
return
render_title_template
(
'list.html'
,
entries
=
entries
,
folder
=
'web.author'
,
charlist
=
charlist
,
...
...
@@ -645,7 +643,10 @@ def publisher_list():
entries
=
db
.
session
.
query
(
db
.
Publishers
,
func
.
count
(
'books_publishers_link.book'
)
.
label
(
'count'
))
\
.
join
(
db
.
books_publishers_link
)
.
join
(
db
.
Books
)
.
filter
(
common_filters
())
\
.
group_by
(
'books_publishers_link.publisher'
)
.
order_by
(
db
.
Publishers
.
sort
)
.
all
()
return
render_title_template
(
'list.html'
,
entries
=
entries
,
folder
=
'web.publisher'
,
charlist
=
db
.
session
.
query
(
func
.
upper
(
func
.
substr
(
db
.
Publishers
.
name
,
1
,
1
))
.
label
(
'char'
))
\
.
join
(
db
.
books_publishers_link
)
.
join
(
db
.
Books
)
.
filter
(
common_filters
())
\
.
group_by
(
func
.
upper
(
func
.
substr
(
db
.
Publishers
.
name
,
1
,
1
)))
.
all
()
return
render_title_template
(
'list.html'
,
entries
=
entries
,
folder
=
'web.publisher'
,
charlist
=
charlist
,
title
=
_
(
u"Publisher list"
),
page
=
"publisherlist"
)
else
:
abort
(
404
)
...
...
@@ -696,7 +697,10 @@ def series_list():
entries
=
db
.
session
.
query
(
db
.
Series
,
func
.
count
(
'books_series_link.book'
)
.
label
(
'count'
))
\
.
join
(
db
.
books_series_link
)
.
join
(
db
.
Books
)
.
filter
(
common_filters
())
\
.
group_by
(
'books_series_link.series'
)
.
order_by
(
db
.
Series
.
sort
)
.
all
()
return
render_title_template
(
'list.html'
,
entries
=
entries
,
folder
=
'web.series'
,
charlist
=
db
.
session
.
query
(
func
.
upper
(
func
.
substr
(
db
.
Series
.
sort
,
1
,
1
))
.
label
(
'char'
))
\
.
join
(
db
.
books_series_link
)
.
join
(
db
.
Books
)
.
filter
(
common_filters
())
\
.
group_by
(
func
.
upper
(
func
.
substr
(
db
.
Series
.
sort
,
1
,
1
)))
.
all
()
return
render_title_template
(
'list.html'
,
entries
=
entries
,
folder
=
'web.series'
,
charlist
=
charlist
,
title
=
_
(
u"Series list"
),
page
=
"serieslist"
)
else
:
abort
(
404
)
...
...
@@ -720,8 +724,10 @@ def series(book_id, page):
@
login_required_if_no_ano
def
language_overview
():
if
current_user
.
show_language
():
charlist
=
list
()
if
current_user
.
filter_language
()
==
u"all"
:
languages
=
speaking_language
()
# ToDo: generate first character list for languages
else
:
try
:
cur_l
=
LC
.
parse
(
current_user
.
filter_language
())
...
...
@@ -737,7 +743,7 @@ def language_overview():
func
.
count
(
'books_languages_link.book'
)
.
label
(
'bookcount'
))
.
group_by
(
'books_languages_link.lang_code'
)
.
all
()
return
render_title_template
(
'languages.html'
,
languages
=
languages
,
lang_counter
=
lang_counter
,
title
=
_
(
u"Available languages"
),
page
=
"langlist"
)
charlist
=
charlist
,
title
=
_
(
u"Available languages"
),
page
=
"langlist"
)
else
:
abort
(
404
)
...
...
@@ -767,7 +773,10 @@ def category_list():
entries
=
db
.
session
.
query
(
db
.
Tags
,
func
.
count
(
'books_tags_link.book'
)
.
label
(
'count'
))
\
.
join
(
db
.
books_tags_link
)
.
join
(
db
.
Books
)
.
order_by
(
db
.
Tags
.
name
)
.
filter
(
common_filters
())
\
.
group_by
(
'books_tags_link.tag'
)
.
all
()
return
render_title_template
(
'list.html'
,
entries
=
entries
,
folder
=
'web.category'
,
charlist
=
db
.
session
.
query
(
func
.
upper
(
func
.
substr
(
db
.
Tags
.
name
,
1
,
1
))
.
label
(
'char'
))
\
.
join
(
db
.
books_tags_link
)
.
join
(
db
.
Books
)
.
filter
(
common_filters
())
\
.
group_by
(
func
.
upper
(
func
.
substr
(
db
.
Tags
.
name
,
1
,
1
)))
.
all
()
return
render_title_template
(
'list.html'
,
entries
=
entries
,
folder
=
'web.category'
,
charlist
=
charlist
,
title
=
_
(
u"Category list"
),
page
=
"catlist"
)
else
:
abort
(
404
)
...
...
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