Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
dhp-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
Hoang Phuc Do
dhp-venshop
Commits
30bbcb60
Commit
30bbcb60
authored
Jun 08, 2017
by
Hoang Phuc Do
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor code - Fix pull request #1
parent
0f75f6bb
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
76 additions
and
119 deletions
+76
-119
app/assets/stylesheets/main_style.css
+0
-0
app/helpers/products_helper.rb
+1
-5
app/views/kaminari/_first_page.html.erb
+0
-8
app/views/kaminari/_gap.html.erb
+0
-7
app/views/kaminari/_last_page.html.erb
+0
-8
app/views/kaminari/_next_page.html.erb
+0
-8
app/views/kaminari/_page.html.erb
+1
-10
app/views/kaminari/_paginator.html.erb
+0
-8
app/views/kaminari/_prev_page.html.erb
+0
-8
app/views/layouts/application.html.erb
+5
-7
app/views/products/_product.html.erb
+17
-13
app/views/products/_recommended.html.erb
+31
-17
app/views/static_pages/index.html.erb
+17
-19
db/migrate/20170606060101_create_products.rb
+1
-1
db/seeds.rb
+3
-0
No files found.
app/assets/stylesheets/main_style.css
View file @
30bbcb60
This diff is collapsed.
Click to expand it.
app/helpers/products_helper.rb
View file @
30bbcb60
module
ProductsHelper
module
ProductsHelper
def
get_product_thumbnail
(
product
,
thumbnail_width
,
thumbnail_height
)
def
get_product_thumbnail
(
product
,
thumbnail_width
,
thumbnail_height
)
if
product
.
image_url
.
present?
product
.
image_url
||
product
.
image_url
else
"product/placeholder_
#{
thumbnail_width
}
x
#{
thumbnail_height
}
"
"product/placeholder_
#{
thumbnail_width
}
x
#{
thumbnail_height
}
"
end
end
end
end
end
\ No newline at end of file
app/views/kaminari/_first_page.html.erb
View file @
30bbcb60
<%# Link to the "First" page
- available local variables
url: url to the first page
current_page: a page object for the currently displayed page
total_pages: total number of pages
per_page: number of items to fetch per page
remote: data-remote
-%>
<li
class=
"first"
>
<li
class=
"first"
>
<%=
link_to_unless
current_page
.
first?
,
t
(
'views.pagination.first'
).
html_safe
,
url
,
remote:
remote
%>
<%=
link_to_unless
current_page
.
first?
,
t
(
'views.pagination.first'
).
html_safe
,
url
,
remote:
remote
%>
</li>
</li>
app/views/kaminari/_gap.html.erb
View file @
30bbcb60
<%# Non-link tag that stands for skipped pages...
- available local variables
current_page: a page object for the currently displayed page
total_pages: total number of pages
per_page: number of items to fetch per page
remote: data-remote
-%>
<li
class=
"dots"
>
<li
class=
"dots"
>
<a
href=
"#"
>
<%=
t
(
'views.pagination.truncate'
).
html_safe
%>
</a>
<a
href=
"#"
>
<%=
t
(
'views.pagination.truncate'
).
html_safe
%>
</a>
</li>
</li>
app/views/kaminari/_last_page.html.erb
View file @
30bbcb60
<%# Link to the "Last" page
- available local variables
url: url to the last page
current_page: a page object for the currently displayed page
total_pages: total number of pages
per_page: number of items to fetch per page
remote: data-remote
-%>
<li
class=
"last"
>
<li
class=
"last"
>
<%=
link_to_unless
current_page
.
last?
,
t
(
'views.pagination.last'
).
html_safe
,
url
,
remote:
remote
%>
<%=
link_to_unless
current_page
.
last?
,
t
(
'views.pagination.last'
).
html_safe
,
url
,
remote:
remote
%>
</li>
</li>
app/views/kaminari/_next_page.html.erb
View file @
30bbcb60
<%# Link to the "Next" page
- available local variables
url: url to the next page
current_page: a page object for the currently displayed page
total_pages: total number of pages
per_page: number of items to fetch per page
remote: data-remote
-%>
<li
class=
"next"
>
<li
class=
"next"
>
<%=
link_to_unless
current_page
.
last?
,
t
(
'views.pagination.next'
).
html_safe
,
url
,
rel:
'next'
,
remote:
remote
%>
<%=
link_to_unless
current_page
.
last?
,
t
(
'views.pagination.next'
).
html_safe
,
url
,
rel:
'next'
,
remote:
remote
%>
</li>
</li>
app/views/kaminari/_page.html.erb
View file @
30bbcb60
<%# Link showing page number
- available local variables
page: a page object for "this" page
url: url to this page
current_page: a page object for the currently displayed page
total_pages: total number of pages
per_page: number of items to fetch per page
remote: data-remote
-%>
<li
class=
"page
<%=
' active'
if
page
.
current?
%>
"
>
<li
class=
"page
<%=
' active'
if
page
.
current?
%>
"
>
<%= link_to page, url, opts = {:remote => remote, :class => 'page-link', :rel => page.next? ? 'next' : page.prev? ? 'prev' : nil} %>
<%=
link_to
page
,
url
,
opts
=
{
:remote
=>
remote
,
:class
=>
page
.
current?
?
'active'
:
'page-link'
,
:rel
=>
page
.
next?
?
'next'
:
page
.
prev?
?
'prev'
:
nil
}
%>
</li>
</li>
app/views/kaminari/_paginator.html.erb
View file @
30bbcb60
<%# The container tag
- available local variables
current_page: a page object for the currently displayed page
total_pages: total number of pages
per_page: number of items to fetch per page
remote: data-remote
paginator: the paginator that renders the pagination tags inside
-%>
<%=
paginator
.
render
do
-%>
<%=
paginator
.
render
do
-%>
<nav
aria-label=
"Page Navigation"
>
<nav
aria-label=
"Page Navigation"
>
<ul
class=
"pagination"
>
<ul
class=
"pagination"
>
...
...
app/views/kaminari/_prev_page.html.erb
View file @
30bbcb60
<%# Link to the "Previous" page
- available local variables
url: url to the previous page
current_page: a page object for the currently displayed page
total_pages: total number of pages
per_page: number of items to fetch per page
remote: data-remote
-%>
<li
class=
"prev"
>
<li
class=
"prev"
>
<%=
link_to_unless
current_page
.
first?
,
t
(
'views.pagination.previous'
).
html_safe
,
url
,
rel:
'prev'
,
remote:
remote
%>
<%=
link_to_unless
current_page
.
first?
,
t
(
'views.pagination.previous'
).
html_safe
,
url
,
rel:
'prev'
,
remote:
remote
%>
</li>
</li>
app/views/layouts/application.html.erb
View file @
30bbcb60
...
@@ -9,14 +9,12 @@
...
@@ -9,14 +9,12 @@
</head>
</head>
<body>
<body>
<div
id=
"wrapper"
>
<div
id=
"main-container col2-left-layout"
>
<div
class=
"main"
>
<div
class=
"container"
>
<div
class=
"container"
>
<%=
yield
%>
<%=
yield
%>
</div>
<!-- End .container -->
</div>
</div>
<!-- End .
main
-->
<!-- End .
container
-->
</div>
</div>
<!-- End .main-container -->
</body>
</body>
</html>
</html>
app/views/products/_product.html.erb
View file @
30bbcb60
<li
class=
"product product-
<%=
product
.
id
%>
"
>
<li
class=
"item"
>
<div
class=
"product-image-area"
>
<div
class=
"product-img"
>
<a
href=
"#"
class=
"product-image"
>
<a
href=
"#"
>
<%=
image_tag
(
get_product_thumbnail
(
product
,
170
,
204
))
%>
<figure>
<%=
image_tag
(
get_product_thumbnail
(
product
,
170
,
204
),
class:
"small-image"
)
%>
</figure>
</a>
</a>
</div>
</div>
<div
class=
"product-details-area"
>
<div
class=
"product-shop"
>
<h2
class=
"product-title"
>
<%=
product
.
title
%>
</h2>
<h2
class=
"product-name"
>
<%=
product
.
title
%>
</h2>
<div
class=
"product-price-container"
>
<div
class=
"price-box"
>
<span
class=
"product-price"
>
<%=
product
.
price
%>
</span>
<div
class=
"special-price"
>
<span
class=
"price"
>
<%=
number_to_currency
(
product
.
price
)
%>
</span>
</div>
</div>
<div
class=
"desc std"
>
<%=
simple_format
(
product
.
description
)
%>
</div>
</div>
<!-- End .product-price-container -->
<div
class=
"product-short-desc"
>
<%=
product
.
description
%>
</div>
</div>
</div>
</li>
</li>
<!-- End .product -->
\ No newline at end of file
\ No newline at end of file
app/views/products/_recommended.html.erb
View file @
30bbcb60
<ul
class=
"products-grid"
>
<%
@recommended_products
.
each
do
|
product
|
%>
<%
@recommended_products
.
each
do
|
product
|
%>
<div
class=
"product-item"
>
<li
class=
"item col-lg-4 col-md-4 col-sm-6 col-xs-6 "
>
<div
class=
"product product-
<%=
product
.
id
%>
"
>
<div
class=
"product-item"
>
<div
class=
"product-image-container"
>
<div
class=
"item-inner"
>
<a
href=
"#"
class=
"product-image"
>
<div
class=
"product-thumb"
>
<%=
image_tag
(
get_product_thumbnail
(
product
,
170
,
204
))
%>
<figure>
</a>
<a
href=
"#"
>
</div>
<%=
image_tag
(
get_product_thumbnail
(
product
,
170
,
204
))
%>
<div
class=
"product-details-area"
>
</a>
<h2
class=
"product-title"
>
<%=
product
.
title
%>
</h2>
</figure>
<div
class=
"product-price-container"
>
</div>
<span
class=
"product-price"
>
<%=
product
.
price
%>
</span>
<div
class=
"item-info"
>
<div
class=
"info-inner"
>
<div
class=
"item-title"
>
<%=
link_to
product
.
title
,
"#"
%>
</div>
<div
class=
"item-content"
>
<div
class=
"item-price"
>
<div
class=
"price-box"
>
<div
class=
"regular-price"
>
<span
class=
"price"
>
<%=
number_to_currency
(
product
.
price
)
%>
</span>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- End .product-price-container -->
</div>
</div>
</div>
</li>
<!-- End .product -->
<%
end
%>
</div>
</ul>
<%
end
%>
\ No newline at end of file
\ No newline at end of file
app/views/static_pages/index.html.erb
View file @
30bbcb60
<div
class=
"row"
>
<div
class=
"row"
>
<div
class=
"col-m
d-9 col-md
-push-3"
>
<div
class=
"col-m
ain col-sm-9 col-xs-12 col-sm
-push-3"
>
<div
class=
"
category-head
er"
>
<div
class=
"
shop-inn
er"
>
<
h2>
Recommended Items
</h2
>
<
div
class=
"page-title"
>
</div
>
<h1>
Recommended Items
</h1
>
<div
class=
"shop-row"
>
</div
>
<div
class=
"
shop-container max-col-3
"
>
<div
class=
"
product-grid-area
"
>
<%=
render
'products/recommended'
%>
<%=
render
'products/recommended'
%>
</div>
</div>
</div>
<div
class=
"category-header"
>
<div
class=
"page-title"
>
<h2>
Newest Items
</h2>
<h1>
Newest Items
</h1>
</div>
</div>
<div
class=
"shop-row"
>
<div
class=
"product-list-area"
>
<div
class=
"shop-container"
>
<ul
id=
"products-list"
class=
"products-list"
>
<ul
class=
"products-list"
>
<%=
render
@latest_products
%>
<%=
render
@latest_products
%>
</ul>
</ul>
</div>
</div>
</div>
<%=
paginate
@latest_products
%>
<div
class=
"pagination-area"
>
<%=
paginate
@latest_products
%>
</div>
</div>
</div>
</div>
<!-- End .col-md-9 -->
<aside
class=
"sidebar col-sm-3 col-xs-12 col-sm-pull-9"
>
<div
class=
"col-md-3 col-md-pull-9 sidebar"
>
<%=
render
'shared/sidebar'
%>
<%=
render
'shared/sidebar'
%>
</
div
>
</
aside
>
</div>
</div>
<!-- End .row -->
db/migrate/20170606060101_create_products.rb
View file @
30bbcb60
...
@@ -5,7 +5,7 @@ class CreateProducts < ActiveRecord::Migration[5.1]
...
@@ -5,7 +5,7 @@ class CreateProducts < ActiveRecord::Migration[5.1]
t
.
text
:description
t
.
text
:description
t
.
text
:sku
t
.
text
:sku
t
.
decimal
:price
,
precision:
8
,
scale:
2
t
.
decimal
:price
,
precision:
8
,
scale:
2
t
.
references
:category
,
foreign_key
:
true
t
.
references
:category
,
index
:
true
t
.
timestamps
t
.
timestamps
end
end
end
end
...
...
db/seeds.rb
View file @
30bbcb60
...
@@ -6,6 +6,9 @@
...
@@ -6,6 +6,9 @@
# movies = Movie.create([{ name: 'Star Wars' }, { name: 'Lord of the Rings' }])
# movies = Movie.create([{ name: 'Star Wars' }, { name: 'Lord of the Rings' }])
# Character.create(name: 'Luke', movie: movies.first)
# Character.create(name: 'Luke', movie: movies.first)
# Delete all categories
Category
.
destroy_all
# Create Product Categories
# Create Product Categories
4
.
times
do
|
n
|
4
.
times
do
|
n
|
title
=
"Category
#{
n
}
"
title
=
"Category
#{
n
}
"
...
...
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