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
1
Merge Requests
1
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
Truong Ba Dieu
VenShop
Commits
f6cdd883
Commit
f6cdd883
authored
Jul 15, 2015
by
Truong Ba Dieu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Restruct space
parent
45697591
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
22 changed files
with
117 additions
and
109 deletions
+117
-109
app/assets/stylesheets/components/layout.css.scss
+13
-12
app/assets/stylesheets/components/products.css.scss
+8
-7
app/assets/stylesheets/components/style.css.scss
+6
-5
app/controllers/application_controller.rb
+1
-1
app/controllers/categories_controller.rb
+6
-4
app/controllers/home_controller.rb
+17
-16
app/controllers/products_controller.rb
+5
-4
app/helpers/application_helper.rb
+3
-3
app/models/category.rb
+1
-1
app/models/product.rb
+11
-11
app/models/user.rb
+1
-1
app/services/datetime_service.rb
+8
-7
app/services/vacuum_aws_service.rb
+0
-0
app/views/home/index.html.slim
+9
-9
app/views/home/search.html.slim
+5
-5
app/views/layouts/application.html.slim
+1
-1
app/views/products/_item.html.slim
+6
-6
app/views/products/_recommend_item.html.slim
+3
-3
app/views/shared/_categories.html.slim
+3
-3
app/views/shared/_search_bar.html.slim
+6
-6
app/views/users/mailer/unlock_instructions.html.slim
+1
-1
lib/tasks/crawler.rake
+3
-3
No files found.
app/assets/stylesheets/components/layout.css.scss
View file @
f6cdd883
.navbar-brand
{
padding
:
2px
;
img
{
height
:
45px
;
display
:
inline-block
;
margin-right
:
10px
;
}
padding
:
2px
;
img
{
height
:
45px
;
display
:
inline-block
;
margin-right
:
10px
;
}
}
.logo
{
margin
:
0
;
margin
:
0
;
line-height
:
25px
;
font-size
:
22px
;
font-family
:
serif
;
}
.wrap-img
{
display
:
inline-block
;
display
:
inline-block
;
}
#search-bar
{
margin
:
20px
0
;
input
[
type
=
"text"
]
{
height
:
35px
;
}
margin
:
20px
0
;
input
[
type
=
"text"
]
{
height
:
35px
;
}
}
\ No newline at end of file
app/assets/stylesheets/components/products.css.scss
View file @
f6cdd883
.recommend
{
}
.products
{
.wrap-img
{
float
:
left
;
}
.title
{
padding-left
:
60px
;
}
.wrap-img
{
float
:
left
;
}
.title
{
padding-left
:
60px
;
}
}
\ No newline at end of file
app/assets/stylesheets/components/style.css.scss
View file @
f6cdd883
.mar-top-20
{
margin-top
:
20px
;
margin-top
:
20px
;
}
.mar-bot-20
{
margin-bottom
:
20px
;
margin-bottom
:
20px
;
}
.mar-r-10
{
margin-right
:
10px
;
margin-right
:
10px
;
}
.text-center
{
text-align
:
center
;
text-align
:
center
;
}
.pad-0
{
padding
:
0
;
padding
:
0
;
}
\ No newline at end of file
app/controllers/application_controller.rb
View file @
f6cdd883
...
...
@@ -4,6 +4,6 @@ class ApplicationController < ActionController::Base
protect_from_forgery
with: :exception
def
get_categories
@categories
=
Category
.
all
@categories
=
Category
.
all
end
end
app/controllers/categories_controller.rb
View file @
f6cdd883
class
CategoriesController
<
ApplicationController
before_filter
:get_categories
def
show
@category
=
Category
.
find
(
params
[
:id
])
end
before_filter
:get_categories
def
show
@category
=
Category
.
find
(
params
[
:id
])
end
end
\ No newline at end of file
app/controllers/home_controller.rb
View file @
f6cdd883
class
HomeController
<
ApplicationController
add_breadcrumb
"Home"
,
:root_path
add_breadcrumb
"Home"
,
:root_path
before_filter
:get_categories
before_filter
:get_recommend
before_filter
:get_categories
before_filter
:get_recommend
def
index
params
[
:per_page
]
||=
5
params
[
:page
]
||=
1
@products
=
Product
.
page
(
params
[
:page
]).
per
(
params
[
:per_page
])
end
def
index
params
[
:per_page
]
||=
5
params
[
:page
]
||=
1
@products
=
Product
.
page
(
params
[
:page
]).
per
(
params
[
:per_page
])
end
def
search
add_breadcrumb
"Search"
,
:search_path
@products
=
Product
.
search
(
params
)
end
def
search
add_breadcrumb
"Search"
,
:search_path
@products
=
Product
.
search
(
params
)
end
private
def
get_recommend
@recommend_products
=
Product
.
recommend
end
private
def
get_recommend
@recommend_products
=
Product
.
recommend
end
end
\ No newline at end of file
app/controllers/products_controller.rb
View file @
f6cdd883
class
ProductsController
<
ApplicationController
before_filter
:get_categories
def
show
@product
=
Product
.
find
(
params
[
:id
])
end
before_filter
:get_categories
def
show
@product
=
Product
.
find
(
params
[
:id
])
end
end
\ No newline at end of file
app/helpers/application_helper.rb
View file @
f6cdd883
module
ApplicationHelper
def
currency_number
(
price
=
0
,
currency
=
"usd"
)
"
#{
currency
}#{
price
}
"
end
def
currency_number
(
price
=
0
,
currency
=
"usd"
)
"
#{
currency
}#{
price
}
"
end
end
app/models/category.rb
View file @
f6cdd883
class
Category
<
ActiveRecord
::
Base
has_many
:products
has_many
:products
end
app/models/product.rb
View file @
f6cdd883
class
Product
<
ActiveRecord
::
Base
belongs_to
:category
belongs_to
:user
belongs_to
:category
belongs_to
:user
dragonfly_accessor
:image
dragonfly_accessor
:image
validates
:pid
,
:title
,
:price
,
:category_id
,
presence:
true
validates
:pid
,
uniqueness:
true
validates
:pid
,
:title
,
:price
,
:category_id
,
presence:
true
validates
:pid
,
uniqueness:
true
scope
:recommend
,
->
{
where
(
recommend:
true
)}
scope
:recommend
,
->
{
where
(
recommend:
true
)}
def
self
.
search
(
params
)
params
[
:per_page
]
||=
5
params
[
:page
]
||=
1
def
self
.
search
(
params
)
params
[
:per_page
]
||=
5
params
[
:page
]
||=
1
Product
.
order
(
"release_date DESC"
).
page
(
params
[
:page
]).
per
(
params
[
:per_page
])
end
Product
.
order
(
"release_date DESC"
).
page
(
params
[
:page
]).
per
(
params
[
:per_page
])
end
end
app/models/user.rb
View file @
f6cdd883
...
...
@@ -2,7 +2,7 @@ class User < ActiveRecord::Base
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable and :omniauthable
devise
:database_authenticatable
,
:registerable
,
:recoverable
,
:rememberable
,
:trackable
,
:validatable
:recoverable
,
:rememberable
,
:trackable
,
:validatable
has_many
:products
end
app/services/datetime_service.rb
View file @
f6cdd883
class
DatetimeService
def
self
.
strptime
(
str
=
nil
,
type
=
"%Y-%m-%d"
)
begin
DateTime
.
strptime
(
str
,
type
)
rescue
DateTime
.
now
end
end
def
self
.
strptime
(
str
=
nil
,
type
=
"%Y-%m-%d"
)
begin
DateTime
.
strptime
(
str
,
type
)
rescue
DateTime
.
now
end
end
end
\ No newline at end of file
app/services/vacuum_aws_service.rb
View file @
f6cdd883
This diff is collapsed.
Click to expand it.
app/views/home/index.html.slim
View file @
f6cdd883
-
if
@recommend_products
.
present?
.row.recommends
-
@recommend_products
.
each
do
|
product
|
=
render
"products/recommend_item"
,
product:
product
.row.recommends
-
@recommend_products
.
each
do
|
product
|
=
render
"products/recommend_item"
,
product:
product
-
if
@products
.
present?
.products
-
@products
.
each
do
|
product
|
=
render
"products/item"
,
product:
product
.products
-
@products
.
each
do
|
product
|
=
render
"products/item"
,
product:
product
.text-center
=
paginate
@products
\ No newline at end of file
=
paginate
@products
\ No newline at end of file
app/views/home/search.html.slim
View file @
f6cdd883
-
if
@products
.
present?
.products
-
@products
.
each
do
|
product
|
=
render
"products/item"
,
product:
product
.products
-
@products
.
each
do
|
product
|
=
render
"products/item"
,
product:
product
.text-center
=
paginate
@products
\ No newline at end of file
=
paginate
@products
\ No newline at end of file
app/views/layouts/application.html.slim
View file @
f6cdd883
...
...
@@ -22,7 +22,7 @@ html
=
render_breadcrumbs
:separator
=>
' / '
.row.mar-top-20
.col-sm-4
=
render
'shared/categories'
=
render
'shared/categories'
.col-sm-8
=
yield
.clearfix
...
...
app/views/products/_item.html.slim
View file @
f6cdd883
.row.mar-bot-20
.col-lg-7
.wrap-img.mar-r-10
=
image_tag
product
.
image
.
thumb
(
'51x32#'
).
url
.title
=
link_to
product
.
title
,
product_path
(
product
)
.col-lg-5
=
"Price:
#{
currency_number
(
product
.
currency
,
product
.
price
)
}
"
.col-lg-7
.wrap-img.mar-r-10
=
image_tag
product
.
image
.
thumb
(
'51x32#'
).
url
.title
=
link_to
product
.
title
,
product_path
(
product
)
.col-lg-5
=
"Price:
#{
currency_number
(
product
.
currency
,
product
.
price
)
}
"
app/views/products/_recommend_item.html.slim
View file @
f6cdd883
.col-sm-4
h4
=
product
.
title
=
image_tag
product
.
image
.
thumb
(
'71x38>'
)
\ No newline at end of file
h4
=
product
.
title
=
image_tag
product
.
image
.
thumb
(
'71x38>'
)
\ No newline at end of file
app/views/shared/_categories.html.slim
View file @
f6cdd883
ul
.list-group
-
@categories
.
each
do
|
cate
|
=
link_to
cate
.
name
,
category_path
(
cate
),
class:
'list-group-item'
\ No newline at end of file
-
@categories
.
each
do
|
cate
|
=
link_to
cate
.
name
,
category_path
(
cate
),
class:
'list-group-item'
\ No newline at end of file
app/views/shared/_search_bar.html.slim
View file @
f6cdd883
#search-bar
=
form_tag
search_path
,
class:
"form-horizontal"
,
method:
"GET"
do
|
f
|
.row
.col-sm-9
=
text_field_tag
:keyword
,
params
[
:keyword
],
placeholder:
"Keyword"
,
class:
"form-control"
.col-sm-3
=
submit_tag
"Search"
,
class:
"btn btn-primary"
=
form_tag
search_path
,
class:
"form-horizontal"
,
method:
"GET"
do
|
f
|
.row
.col-sm-9
=
text_field_tag
:keyword
,
params
[
:keyword
],
placeholder:
"Keyword"
,
class:
"form-control"
.col-sm-3
=
submit_tag
"Search"
,
class:
"btn btn-primary"
app/views/users/mailer/unlock_instructions.html.slim
View file @
f6cdd883
p
|
Hello
|
Hello
=
@resource
.
email
|
!
p
...
...
lib/tasks/crawler.rake
View file @
f6cdd883
namespace
:crawler
do
task
:aws
=>
:environment
do
# categories name want to craw
# categories name want to craw
categories
=
%w(Books Music Electronics Software Kitchen)
categories
.
each
do
|
search_cate
|
category
=
Category
.
find_or_create_by
(
name:
search_cate
)
(
1
..
5
).
each
do
|
page
|
...
...
@@ -13,7 +13,7 @@ namespace :crawler do
'SearchIndex'
=>
search_cate
,
'ItemPage'
=>
page
,
'ResponseGroup'
=>
'Medium'
}
}
})
items
=
VacuumAwsService
.
parse_items
(
response
)
...
...
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