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
431b6009
Commit
431b6009
authored
9 years ago
by
Cervinko Cera
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add advanced search
parent
3719b7e4
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
46 additions
and
1 deletion
+46
-1
style.css
cps/static/css/style.css
+5
-0
layout.html
cps/templates/layout.html
+2
-1
web.py
cps/web.py
+39
-0
No files found.
cps/static/css/style.css
View file @
431b6009
...
@@ -31,3 +31,8 @@ span.glyphicon.glyphicon-tags {padding-right: 5px;color: #999;vertical-align: te
...
@@ -31,3 +31,8 @@ span.glyphicon.glyphicon-tags {padding-right: 5px;color: #999;vertical-align: te
.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
;}
.btn-toolbar
.btn
{
margin-bottom
:
5px
;
}
.btn-primary
:hover
,
.btn-primary
:focus
,
.btn-primary
:active
,
.btn-primary.active
,
.open
.dropdown-toggle.btn-primary
{
background-color
:
#1C5484
;
}
.btn-primary.disabled
,
.btn-primary
[
disabled
],
fieldset
[
disabled
]
.btn-primary
,
.btn-primary.disabled
:hover
,
.btn-primary
[
disabled
]
:hover
,
fieldset
[
disabled
]
.btn-primary
:hover
,
.btn-primary.disabled
:focus
,
.btn-primary
[
disabled
]
:focus
,
fieldset
[
disabled
]
.btn-primary
:focus
,
.btn-primary.disabled
:active
,
.btn-primary
[
disabled
]
:active
,
fieldset
[
disabled
]
.btn-primary
:active
,
.btn-primary.disabled.active
,
.btn-primary
[
disabled
]
.active
,
fieldset
[
disabled
]
.btn-primary.active
{
background-color
:
#89B9E2
;
}
This diff is collapsed.
Click to expand it.
cps/templates/layout.html
View file @
431b6009
...
@@ -57,9 +57,10 @@
...
@@ -57,9 +57,10 @@
<div
class=
"form-group"
>
<div
class=
"form-group"
>
<input
type=
"text"
class=
"form-control"
name=
"query"
placeholder=
"Search"
>
<input
type=
"text"
class=
"form-control"
name=
"query"
placeholder=
"Search"
>
</div>
</div>
<button
type=
"submit"
class=
"btn btn-default"
>
Submit
</button>
<button
type=
"submit"
class=
"btn btn-default"
>
Go!
</button>
</form>
</form>
</li>
</li>
<li><a
href=
"{{url_for('advanced_search')}}"
><span
class=
"glyphicon glyphicon-search"
></span>
Advanced Search
</a></li>
</ul>
</ul>
<ul
class=
"nav navbar-nav navbar-right"
id=
"main-nav"
>
<ul
class=
"nav navbar-nav navbar-right"
id=
"main-nav"
>
{% if g.user.is_authenticated() %}
{% if g.user.is_authenticated() %}
...
...
This diff is collapsed.
Click to expand it.
cps/web.py
View file @
431b6009
...
@@ -318,6 +318,26 @@ def get_series_json():
...
@@ -318,6 +318,26 @@ def get_series_json():
entries
=
db
.
session
.
execute
(
"select name from series where name like '
%
"
+
query
+
"
%
'"
)
entries
=
db
.
session
.
execute
(
"select name from series where name like '
%
"
+
query
+
"
%
'"
)
json_dumps
=
json
.
dumps
([
dict
(
r
)
for
r
in
entries
])
json_dumps
=
json
.
dumps
([
dict
(
r
)
for
r
in
entries
])
return
json_dumps
return
json_dumps
@
app
.
route
(
"/get_matching_tags"
,
methods
=
[
'GET'
,
'POST'
])
@
login_required_if_no_ano
def
get_matching_tags
():
tag_dict
=
{
'tags'
:
[]}
if
request
.
method
==
"GET"
:
q
=
db
.
session
.
query
(
db
.
Books
)
author_input
=
request
.
args
.
get
(
'author_name'
)
title_input
=
request
.
args
.
get
(
'book_title'
)
tag_inputs
=
request
.
args
.
getlist
(
'tag'
)
q
=
q
.
filter
(
db
.
Books
.
authors
.
any
(
db
.
Authors
.
name
.
like
(
"
%
"
+
author_input
+
"
%
"
)),
db
.
Books
.
title
.
like
(
"
%
"
+
title_input
+
"
%
"
))
if
len
(
tag_inputs
)
>
0
:
for
tag
in
tag_inputs
:
q
=
q
.
filter
(
db
.
Books
.
tags
.
any
(
db
.
Tags
.
id
==
tag
))
for
book
in
q
:
for
tag
in
book
.
tags
:
if
tag
.
id
not
in
tag_dict
[
'tags'
]:
tag_dict
[
'tags'
]
.
append
(
tag
.
id
)
json_dumps
=
json
.
dumps
(
tag_dict
)
return
json_dumps
@
app
.
route
(
"/"
,
defaults
=
{
'page'
:
1
})
@
app
.
route
(
"/"
,
defaults
=
{
'page'
:
1
})
@
app
.
route
(
'/page/<int:page>'
)
@
app
.
route
(
'/page/<int:page>'
)
...
@@ -421,6 +441,25 @@ def search():
...
@@ -421,6 +441,25 @@ def search():
return
render_template
(
'search.html'
,
searchterm
=
term
,
entries
=
entries
)
return
render_template
(
'search.html'
,
searchterm
=
term
,
entries
=
entries
)
else
:
else
:
return
render_template
(
'search.html'
,
searchterm
=
""
)
return
render_template
(
'search.html'
,
searchterm
=
""
)
@
app
.
route
(
"/advanced_search"
,
methods
=
[
"GET"
])
@
login_required_if_no_ano
def
advanced_search
():
if
request
.
method
==
'GET'
:
print
"GETTTTTTTTTTTT"
q
=
db
.
session
.
query
(
db
.
Books
)
tag_inputs
=
request
.
args
.
getlist
(
'tag'
)
author_name
=
request
.
args
.
get
(
"author_name"
)
book_title
=
request
.
args
.
get
(
"book_title"
)
if
tag_inputs
or
author_name
or
book_title
:
q
=
q
.
filter
(
db
.
Books
.
authors
.
any
(
db
.
Authors
.
name
.
like
(
"
%
"
+
author_name
+
"
%
"
)),
db
.
Books
.
title
.
like
(
"
%
"
+
book_title
+
"
%
"
))
random
=
db
.
session
.
query
(
db
.
Books
)
.
order_by
(
func
.
random
())
.
limit
(
config
.
RANDOM_BOOKS
)
for
tag
in
tag_inputs
:
q
=
q
.
filter
(
db
.
Books
.
tags
.
any
(
db
.
Tags
.
id
==
tag
))
q
=
q
.
all
()
return
render_template
(
'search.html'
,
searchterm
=
"tags"
,
entries
=
q
)
tags
=
db
.
session
.
query
(
db
.
Tags
)
.
order_by
(
db
.
Tags
.
name
)
.
all
()
return
render_template
(
'search_form.html'
,
tags
=
tags
)
@
app
.
route
(
"/author"
)
@
app
.
route
(
"/author"
)
@
login_required_if_no_ano
@
login_required_if_no_ano
...
...
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