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
87ec44ae
Commit
87ec44ae
authored
Apr 26, 2020
by
Ozzieisaacs
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'improve_reaad/keep-focus-on-search-input'
parents
898e6b4f
d093fbb0
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
20 additions
and
7 deletions
+20
-7
layout.html
cps/templates/layout.html
+6
-1
search.html
cps/templates/search.html
+3
-3
web.py
cps/web.py
+11
-3
No files found.
cps/templates/layout.html
View file @
87ec44ae
...
...
@@ -42,7 +42,7 @@
<form
class=
"navbar-form navbar-left"
role=
"search"
action=
"{{url_for('web.search')}}"
method=
"GET"
>
<div
class=
"form-group input-group input-group-sm"
>
<label
for=
"query"
class=
"sr-only"
>
{{_('Search')}}
</label>
<input
type=
"text"
class=
"form-control"
id=
"query"
name=
"query"
placeholder=
"{{_('Search Library')}}"
>
<input
type=
"text"
class=
"form-control"
id=
"query"
name=
"query"
placeholder=
"{{_('Search Library')}}"
value=
"{{searchterm}}"
>
<span
class=
"input-group-btn"
>
<button
type=
"submit"
id=
"query_submit"
class=
"btn btn-default"
>
{{_('Search')}}
</button>
</span>
...
...
@@ -224,6 +224,11 @@
$
(
"#btn-upload"
).
change
(
function
()
{
$
(
"#form-upload"
).
submit
();
});
$
(
document
).
ready
(
function
()
{
var
inp
=
$
(
'#query'
).
first
()
var
val
=
inp
.
val
()
inp
.
val
(
''
).
blur
().
focus
().
val
(
val
)
});
});
</script>
{% block js %}{% endblock %}
...
...
cps/templates/search.html
View file @
87ec44ae
...
...
@@ -2,10 +2,10 @@
{% block body %}
<div
class=
"discover"
>
{% if entries|length
<
1
%}
<
h2
>
{{_('No Results Found')}} {{searchterm}}
</h2>
<p>
{{_('Search Term:')}} {{searchterm}}
</p>
<
h2
>
{{_('No Results Found')}} {{
adv_
searchterm}}
</h2>
<p>
{{_('Search Term:')}} {{
adv_
searchterm}}
</p>
{% else %}
<h2>
{{entries|length}} {{_('Results for:')}} {{searchterm}}
</h2>
<h2>
{{entries|length}} {{_('Results for:')}} {{
adv_
searchterm}}
</h2>
{% if g.user.is_authenticated %}
{% if g.user.shelf.all() or g.shelves_access %}
<div
id=
"shelf-actions"
class=
"btn-toolbar"
role=
"toolbar"
>
...
...
cps/web.py
View file @
87ec44ae
...
...
@@ -893,9 +893,17 @@ def search():
for
element
in
entries
:
ids
.
append
(
element
.
id
)
searched_ids
[
current_user
.
id
]
=
ids
return
render_title_template
(
'search.html'
,
searchterm
=
term
,
entries
=
entries
,
title
=
_
(
u"Search"
),
page
=
"search"
)
return
render_title_template
(
'search.html'
,
searchterm
=
term
,
adv_searchterm
=
term
,
entries
=
entries
,
title
=
_
(
u"Search"
),
page
=
"search"
)
else
:
return
render_title_template
(
'search.html'
,
searchterm
=
""
,
title
=
_
(
u"Search"
),
page
=
"search"
)
return
render_title_template
(
'search.html'
,
searchterm
=
""
,
title
=
_
(
u"Search"
),
page
=
"search"
)
@
web
.
route
(
"/advanced_search"
,
methods
=
[
'GET'
])
...
...
@@ -1033,7 +1041,7 @@ def advanced_search():
for
element
in
q
:
ids
.
append
(
element
.
id
)
searched_ids
[
current_user
.
id
]
=
ids
return
render_title_template
(
'search.html'
,
searchterm
=
searchterm
,
return
render_title_template
(
'search.html'
,
adv_
searchterm
=
searchterm
,
entries
=
q
,
title
=
_
(
u"search"
),
page
=
"search"
)
# prepare data for search-form
tags
=
db
.
session
.
query
(
db
.
Tags
)
.
join
(
db
.
books_tags_link
)
.
join
(
db
.
Books
)
.
filter
(
common_filters
())
\
...
...
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