Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
V
venshop
Overview
Overview
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
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
huanvl
venshop
Commits
4a7b53ad
Commit
4a7b53ad
authored
Oct 28, 2013
by
vulehuan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
search product with solr
parent
d6f6c521
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
41 additions
and
17 deletions
+41
-17
venshop_app/app/assets/javascripts/custom.js
+13
-2
venshop_app/app/assets/stylesheets/custom.css.scss
+5
-2
venshop_app/app/controllers/products_controller.rb
+4
-1
venshop_app/app/views/layouts/_header.html.erb
+6
-7
venshop_app/app/views/products/search.html.erb
+6
-0
venshop_app/app/views/shared/_grid.html.erb
+5
-3
venshop_app/solr/default/data/index/write.lock
+0
-0
venshop_app/solr/pids/development/sunspot-solr-development.pid
+2
-2
No files found.
venshop_app/app/assets/javascripts/custom.js
View file @
4a7b53ad
...
@@ -37,6 +37,18 @@
...
@@ -37,6 +37,18 @@
var
requestUrl
=
$
(
this
).
attr
(
'href'
)
+
'&quantity='
+
quantity
;
var
requestUrl
=
$
(
this
).
attr
(
'href'
)
+
'&quantity='
+
quantity
;
window
.
location
.
href
=
requestUrl
;
window
.
location
.
href
=
requestUrl
;
});
});
//
$
(
'#btn-search'
).
unbind
(
'click'
).
bind
(
'click'
,
function
(
e
){
e
.
preventDefault
();
var
keyword
=
$
(
'#txt-keyword'
).
val
();
var
url
=
$
(
this
).
attr
(
'href'
)
+
'?keyword='
+
encodeURI
(
keyword
);
window
.
location
.
href
=
url
;
});
$
(
'#txt-keyword'
).
keydown
(
function
(
e
){
if
(
e
.
keyCode
==
13
){
$
(
'#btn-search'
).
click
();
}
})
});
});
})(
jQuery
);
})(
jQuery
);
jQuery
.
noConflict
();
jQuery
.
noConflict
();
\ No newline at end of file
venshop_app/app/assets/stylesheets/custom.css.scss
View file @
4a7b53ad
...
@@ -464,4 +464,8 @@ footer {
...
@@ -464,4 +464,8 @@ footer {
}
}
.btn-update-card-quantity
{
.btn-update-card-quantity
{
margin-bottom
:
3px
;
margin-bottom
:
3px
;
}
}
\ No newline at end of file
.block-search-result
{
padding-top
:
10px
;
}
venshop_app/app/controllers/products_controller.rb
View file @
4a7b53ad
...
@@ -53,11 +53,14 @@ class ProductsController < ApplicationController
...
@@ -53,11 +53,14 @@ class ProductsController < ApplicationController
if
params
[
:keyword
]
==
nil
if
params
[
:keyword
]
==
nil
redirect_to
products_path
redirect_to
products_path
end
end
@products
=
Product
.
search
do
search
=
Product
.
search
do
fulltext
params
[
:keyword
]
do
fulltext
params
[
:keyword
]
do
boost_fields
:name
=>
2.0
boost_fields
:name
=>
2.0
end
end
paginate
:page
=>
params
[
:page
],
:per_page
=>
8
end
end
@products
=
search
.
results
@total
=
search
.
total
end
end
private
private
...
...
venshop_app/app/views/layouts/_header.html.erb
View file @
4a7b53ad
...
@@ -11,8 +11,8 @@
...
@@ -11,8 +11,8 @@
</div>
</div>
<div
class=
"block-user-action"
>
<div
class=
"block-user-action"
>
<div
class=
"btn-group"
>
<div
class=
"btn-group"
>
<%
<%
if
signed_in?
if
signed_in?
user
=
current_user
user
=
current_user
%>
%>
<a
href=
"
<%=
cards_path
%>
"
class=
"btn btn-danger"
>
<span
class=
"glyphicon glyphicon-shopping-cart"
></span>
Your cart
<a
href=
"
<%=
cards_path
%>
"
class=
"btn btn-danger"
>
<span
class=
"glyphicon glyphicon-shopping-cart"
></span>
Your cart
...
@@ -51,7 +51,7 @@
...
@@ -51,7 +51,7 @@
</a>
</a>
<%
end
%>
<%
end
%>
</div>
</div>
</div>
</div>
<div
class=
"clearfix"
></div>
<div
class=
"clearfix"
></div>
...
@@ -59,9 +59,9 @@
...
@@ -59,9 +59,9 @@
<!-- search -->
<!-- search -->
<div
class=
"input-group block-search"
>
<div
class=
"input-group block-search"
>
<input
id=
"txt-keyword"
type=
"text"
class=
"form-control"
<input
id=
"txt-keyword"
type=
"text"
class=
"form-control"
placeholder=
"Enter keywords"
value=
""
>
<span
placeholder=
"Enter keywords"
value=
"
<%=
params
[
'keyword'
]
%>
"
>
<span
class=
"input-group-btn"
>
<a
id=
"btn-search"
class=
"input-group-btn"
>
<a
id=
"btn-search"
class=
"btn btn-default"
href=
"
javascript:void(0)
"
><span
class=
"btn btn-default"
href=
"
<%=
url_for
(
controller:
'products'
,
action:
'search'
)
%>
"
><span
class=
"glyphicon glyphicon-search"
></span>
Search
</a>
class=
"glyphicon glyphicon-search"
></span>
Search
</a>
</span>
</span>
</div>
</div>
\ No newline at end of file
venshop_app/app/views/products/search.html.erb
View file @
4a7b53ad
...
@@ -3,5 +3,11 @@
...
@@ -3,5 +3,11 @@
<h2
class=
"sprite-2"
>
<h2
class=
"sprite-2"
>
Search results
<span
class=
"sprite-2"
></span>
Search results
<span
class=
"sprite-2"
></span>
</h2>
</h2>
<div
class=
"block-search-result"
>
<p>
Found
<%=
@total
%>
product(s) with
<b>
<%=
params
[
:keyword
]
%>
</b>
</p>
<%=
render
'shared/grid'
,
items:
@products
%>
<%=
render
'shared/grid'
,
items:
@products
%>
</div>
<%=
will_paginate
@products
,
renderer:
BootstrapPagination
::
Rails
%>
</div>
</div>
venshop_app/app/views/shared/_grid.html.erb
View file @
4a7b53ad
<%
<%
if
items
==
nil
||
items
.
empty?
if
items
==
nil
||
items
.
empty?
if
params
[
:action
]
!=
'search'
%>
%>
<p>
No products available.
</p>
<p>
No products available.
</p>
<%
<%
end
else
else
items
.
each_slice
(
4
)
do
|
row
|
items
.
each_slice
(
4
)
do
|
row
|
%>
%>
<div
class=
"row"
>
<div
class=
"row"
>
<%
<%
row
.
each
do
|
obj
|
row
.
each
do
|
obj
|
url
=
product_path
(
obj
)
url
=
product_path
(
obj
)
add_to_card_url
=
cards_path
+
"?product_id="
+
obj
.
id
.
to_s
add_to_card_url
=
cards_path
+
"?product_id="
+
obj
.
id
.
to_s
...
...
venshop_app/solr/default/data/index/write.lock
deleted
100644 → 0
View file @
d6f6c521
venshop_app/solr/pids/development/sunspot-solr-development.pid
View file @
4a7b53ad
7100
23236
\ No newline at end of file
\ No newline at end of file
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