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
cd0aeb28
Commit
cd0aeb28
authored
Mar 28, 2016
by
Cervinko Cera
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add Typeahead for Author input
parent
d979ed89
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
657 additions
and
10 deletions
+657
-10
typeaheadjs.css
cps/static/css/typeaheadjs.css
+93
-0
bootstrap3-typeahead.js
cps/static/js/bootstrap3-typeahead.js
+523
-0
edit_book.html
cps/templates/edit_book.html
+21
-1
layout.html
cps/templates/layout.html
+11
-9
web.py
cps/web.py
+9
-0
No files found.
cps/static/css/typeaheadjs.css
0 → 100644
View file @
cd0aeb28
span
.twitter-typeahead
.tt-menu
,
span
.twitter-typeahead
.tt-dropdown-menu
{
position
:
absolute
;
top
:
100%
;
left
:
0
;
z-index
:
1000
;
display
:
none
;
float
:
left
;
min-width
:
160px
;
padding
:
5px
0
;
margin
:
2px
0
0
;
list-style
:
none
;
font-size
:
14px
;
text-align
:
left
;
background-color
:
#ffffff
;
border
:
1px
solid
#cccccc
;
border
:
1px
solid
rgba
(
0
,
0
,
0
,
0.15
);
border-radius
:
4px
;
-webkit-box-shadow
:
0
6px
12px
rgba
(
0
,
0
,
0
,
0.175
);
box-shadow
:
0
6px
12px
rgba
(
0
,
0
,
0
,
0.175
);
background-clip
:
padding-box
;
}
span
.twitter-typeahead
.tt-suggestion
{
display
:
block
;
padding
:
3px
20px
;
clear
:
both
;
font-weight
:
normal
;
line-height
:
1.42857143
;
color
:
#333333
;
white-space
:
nowrap
;
}
span
.twitter-typeahead
.tt-suggestion.tt-cursor
,
span
.twitter-typeahead
.tt-suggestion
:hover
,
span
.twitter-typeahead
.tt-suggestion
:focus
{
color
:
#ffffff
;
text-decoration
:
none
;
outline
:
0
;
background-color
:
#337ab7
;
}
.input-group.input-group-lg
span
.twitter-typeahead
.form-control
{
height
:
46px
;
padding
:
10px
16px
;
font-size
:
18px
;
line-height
:
1.3333333
;
border-radius
:
6px
;
}
.input-group.input-group-sm
span
.twitter-typeahead
.form-control
{
height
:
30px
;
padding
:
5px
10px
;
font-size
:
12px
;
line-height
:
1.5
;
border-radius
:
3px
;
}
span
.twitter-typeahead
{
width
:
100%
;
}
.input-group
span
.twitter-typeahead
{
display
:
block
!important
;
height
:
34px
;
}
.input-group
span
.twitter-typeahead
.tt-menu
,
.input-group
span
.twitter-typeahead
.tt-dropdown-menu
{
top
:
32px
!important
;
}
.input-group
span
.twitter-typeahead
:not
(
:first-child
)
:not
(
:last-child
)
.form-control
{
border-radius
:
0
;
}
.input-group
span
.twitter-typeahead
:first-child
.form-control
{
border-top-left-radius
:
4px
;
border-bottom-left-radius
:
4px
;
border-top-right-radius
:
0
;
border-bottom-right-radius
:
0
;
}
.input-group
span
.twitter-typeahead
:last-child
.form-control
{
border-top-left-radius
:
0
;
border-bottom-left-radius
:
0
;
border-top-right-radius
:
4px
;
border-bottom-right-radius
:
4px
;
}
.input-group.input-group-sm
span
.twitter-typeahead
{
height
:
30px
;
}
.input-group.input-group-sm
span
.twitter-typeahead
.tt-menu
,
.input-group.input-group-sm
span
.twitter-typeahead
.tt-dropdown-menu
{
top
:
30px
!important
;
}
.input-group.input-group-lg
span
.twitter-typeahead
{
height
:
46px
;
}
.input-group.input-group-lg
span
.twitter-typeahead
.tt-menu
,
.input-group.input-group-lg
span
.twitter-typeahead
.tt-dropdown-menu
{
top
:
46px
!important
;
}
cps/static/js/bootstrap3-typeahead.js
0 → 100644
View file @
cd0aeb28
This diff is collapsed.
Click to expand it.
cps/templates/edit_book.html
View file @
cd0aeb28
{% extends "layout.html" %}
{% block body %}
{% if book %}
<script
type=
"text/javascript"
>
$
(
document
).
ready
(
function
(){
$
(
'input.typeahead'
).
typeahead
({
name
:
'accounts'
,
source
:
function
(
query
,
process
)
{
$
.
ajax
({
url
:
'{{ url_for('
get_authors_json
') }} '
,
type
:
'POST'
,
dataType
:
'JSON'
,
data
:
'query='
+
query
,
success
:
function
(
data
)
{
console
.
log
(
data
);
process
(
data
);
}
});
}
});
});
</script>
<div
class=
"col-sm-3 col-lg-3 col-xs-12"
>
<div
class=
"cover"
>
{% if book.has_cover is defined %}
...
...
@@ -21,7 +41,7 @@
<p>
{{author.name.join("
&
")}}
</p>
{% endfor %}
{% endif %}
<input
type=
"text"
class=
"form-control"
name=
"author_name"
id=
"bookAuthor
"
value=
"{{book.authors[0].name}}"
>
<input
type=
"text"
data-provide=
"typeahead"
class=
"form-control typeahead"
name=
"author_name"
id=
"bookAuthor"
autocomplete=
"off
"
value=
"{{book.authors[0].name}}"
>
</div>
<div
class=
"form-group"
>
<label
for=
"description"
>
Description
</label>
...
...
cps/templates/layout.html
View file @
cd0aeb28
...
...
@@ -18,6 +18,17 @@
<script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
<script src="https://oss.maxcdn.com/libs/respond.js/1.3.0/respond.min.js"></script>
<![endif]-->
<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
<script
src=
"https://code.jquery.com/jquery.js"
></script>
<!-- Include all compiled plugins (below), or include individual files as needed -->
<script
src=
"{{ url_for('static', filename='js/bootstrap.min.js') }}"
></script>
<script
src=
"{{ url_for('static', filename='js/bootstrap3-typeahead.js') }}"
></script>
<script
src=
"{{ url_for('static', filename='js/underscore.min.js') }}"
></script>
<script
src=
"{{ url_for('static', filename='js/intention.js') }}"
></script>
<script
src=
"{{ url_for('static', filename='js/context.js') }}"
></script>
<script
src=
"{{ url_for('static', filename='js/plugins.js') }}"
></script>
<script
src=
"{{ url_for('static', filename='js/main.js') }}"
></script>
</head>
<body>
<!-- Static navbar -->
...
...
@@ -127,14 +138,5 @@
</div>
</div>
</div>
<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
<script
src=
"https://code.jquery.com/jquery.js"
></script>
<!-- Include all compiled plugins (below), or include individual files as needed -->
<script
src=
"{{ url_for('static', filename='js/bootstrap.min.js') }}"
></script>
<script
src=
"{{ url_for('static', filename='js/underscore.min.js') }}"
></script>
<script
src=
"{{ url_for('static', filename='js/intention.js') }}"
></script>
<script
src=
"{{ url_for('static', filename='js/context.js') }}"
></script>
<script
src=
"{{ url_for('static', filename='js/plugins.js') }}"
></script>
<script
src=
"{{ url_for('static', filename='js/main.js') }}"
></script>
</body>
</html>
cps/web.py
View file @
cd0aeb28
...
...
@@ -17,6 +17,7 @@ from werkzeug.security import generate_password_hash, check_password_hash
from
functools
import
wraps
import
base64
from
sqlalchemy.sql
import
*
import
json
app
=
(
Flask
(
__name__
))
...
...
@@ -221,6 +222,14 @@ def get_opds_download_link(book_id, format):
suffix
=
format
)
return
response
@
app
.
route
(
"/get_authors_json"
,
methods
=
[
'GET'
,
'POST'
])
def
get_authors_json
():
if
request
.
method
==
"POST"
:
form
=
request
.
form
.
to_dict
()
entries
=
db
.
session
.
execute
(
"select name from authors where name like '
%
"
+
form
[
'query'
]
+
"
%
'"
)
return
json
.
dumps
([
dict
(
r
)
for
r
in
entries
])
@
app
.
route
(
"/"
,
defaults
=
{
'page'
:
1
})
@
app
.
route
(
'/page/<int:page>'
)
...
...
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