Skip to content

Commit

Permalink
Merge pull request #6 from appirits/implement-home-page
Browse files Browse the repository at this point in the history
Implement the home page
  • Loading branch information
YOSHIDA Cake committed May 31, 2015
2 parents a71b43c + 4e477b5 commit db07e5e
Show file tree
Hide file tree
Showing 15 changed files with 240 additions and 24 deletions.
2 changes: 1 addition & 1 deletion core/app/models/comable/store.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def instance
end

def default_name
'Comable store'
Comable.t('default_store_name')
end
end

Expand Down
8 changes: 8 additions & 0 deletions core/config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,14 @@ en:
new_address: 'New address'
successful: 'Successful'
failure: 'Failure'
products: 'Products'
pages: 'Pages'
home: 'Home'
support: 'Support'
sample_header: 'Sample text'
sample_subheader: 'This is sample text.'
sample_text: 'Please write your message here.'
default_store_name: 'K&B style'

price: &price
'Price'
Expand Down
8 changes: 8 additions & 0 deletions core/config/locales/ja.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,14 @@ ja:
new_address: 新しい住所
successful: 成功しました
failure: 失敗しました
products: '商品'
pages: 'ページ'
home: 'ホーム'
support: 'サポート'
sample_header: 'サンプルテキスト'
sample_subheader: 'これはサンプルテキストです。'
sample_text: 'ここにあなたのお好きなメッセージを埋め込むことができます。'
default_store_name: 'K&B style'

price: &price
'価格'
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
109 changes: 101 additions & 8 deletions frontend/app/assets/stylesheets/comable/frontend/application.scss
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ body.comable-checkout-layout {
nav {
&.navbar {
@include border-radius(0);
margin-bottom: 0;
}

.navbar-nav > li > a {
Expand Down Expand Up @@ -295,7 +296,8 @@ table {
}

// main
main {
main.container {
margin-top: 20px;
}

#comable-order {
Expand All @@ -311,11 +313,6 @@ main {
}
}

footer {
margin: 30px;
text-align: center;
}

.comable-mini-cart {
$width: 250px;
$image-size: 40px;
Expand Down Expand Up @@ -418,8 +415,24 @@ footer {
margin-bottom: 20px;
padding-bottom: 20px;

&:not(:last-child) {
border-bottom: 1px solid $list-group-border;
a {
font-weight: normal;

&:link, &:visited, &:hover, &:active {
color: #444;
}
}

a {
display: block;
overflow: hidden;

img {
@include transition(all 0.5s ease 0s);
&:hover {
@include transform(scale(1.1) rotate(-1.5deg));
}
}
}
}
}
Expand All @@ -432,3 +445,83 @@ footer {
height: 100%;
overflow: hidden;
}

body.comable-checkout-layout footer {
margin-top: 30px;
text-align: center;

.container {
display: none;
}
}

body:not(.comable-checkout-layout) footer {
margin-top: 30px;
background-color: #edeff1;
border-top: 2px solid #e3e3e3;

.container {
padding: 30px;
color: #036;
}

h3 {
padding-bottom: 10px;
border-bottom: 1px solid $list-group-border;
}

li {
padding: 3px 0;
}

.credit {
border-top: 2px solid #ccc;
text-align: center;
padding: 20px;
background-color: #e3e3e3;
}
}

// home
#comable-home {
section {
padding: 100px;
text-align: center;

& > h2 {
margin: 0;
}

& > *:last-child {
margin-bottom: 0;
padding-bottom: 0;
}
}

.comable-home-top {
padding: 0;
overflow: hidden;
max-height: 600px;

img {
width: 100%;
height: auto;
}
}

.comable-home-one {
color: white;
background-color: #444;
background-image: image-url('comable/frontend/home-one.jpg');
background-position: top center;
background-size: cover;
}

.comable-home-two {
}

#comable-product {
padding-top: 100px;
padding-bottom: 60px;
}
}
14 changes: 14 additions & 0 deletions frontend/app/controllers/comable/home_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
module Comable
class HomeController < Comable::ApplicationController
before_filter :load_products, only: :show

def show
end

private

def load_products
@products = Comable::Product.limit(5)
end
end
end
24 changes: 24 additions & 0 deletions frontend/app/views/comable/home/show.slim
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#comable-home
section.comable-home-top
= image_tag 'comable/frontend/home-top.jpg'

section#comable-product
.container
.products
= render 'comable/shared/products'

section.comable-home-one
h2
= Comable.t('sample_header')
h3
= Comable.t('sample_subheader')
p
= Comable.t('sample_text')

section.comable-home-two
h2
= Comable.t('sample_header')
h3
= Comable.t('sample_subheader')
p
= Comable.t('sample_text')
13 changes: 1 addition & 12 deletions frontend/app/views/comable/products/index.slim
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,7 @@
= listed_categories Comable::Category.roots

.products.col-sm-10
- @products.each_slice(3) do |products|
ul.row
- products.each do |product|
li.product.col-sm-4
= link_to comable.product_path(product), class: 'thumbnail' do
= image_tag product.image_url, width: '100%'
.name
= link_to product.name, comable.product_path(product)
.caption
= product.caption
.price
= number_to_currency product.price
= render 'comable/shared/products'

.text-center
= paginate @products, theme: :comable_frontend
39 changes: 38 additions & 1 deletion frontend/app/views/comable/shared/_footer.slim
Original file line number Diff line number Diff line change
@@ -1,2 +1,39 @@
footer
| Powered by #{link_to 'Comable', 'https://github.com/appirits/comable'}
.container
.row
.col-md-4
h3
= Comable.t('support')
ul.list-unstyled
li
i.glyphicon.glyphicon-earphone>
| 0123-XX-XXXX
li
i.glyphicon.glyphicon-envelope>
| comable@example.com
.col-md-4
h3
= Comable.t('pages')
ul.list-unstyled
li
= link_to Comable.t('home'), comable.root_path
li
= link_to Comable.t('products'), comable.products_path
li
= link_to Comable.t('cart'), comable.cart_path
li
= link_to Comable.t('my_account'), comable.user_path
.col-md-4
h3
= Comable.t('my_account')
ul.list-unstyled
li
= link_to Comable.t('sign_in'), comable.new_user_session_path
li
= link_to Comable.t('my_account'), comable.user_path
li
= link_to Comable.t('change_email_or_password'), comable.edit_user_path
li
= link_to Comable.t('edit_your_address_book'), comable.addresses_user_path
.credit
| Powered by #{link_to 'Comable', 'https://github.com/appirits/comable'}
23 changes: 23 additions & 0 deletions frontend/app/views/comable/shared/_products.slim
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
ul.row
- @products.each do |product|
li.col-xs-6.col-sm-3
.thumbnail.text-center
= link_to comable.product_path(product) do
= image_tag product.image_url, width: '100%'
h5
= link_to product.name, comable.product_path(product)
- if product.caption.present?
p
= product.caption
strong
= number_to_currency product.price
p
= form_tag comable.add_cart_path do
- stock = product.stocks.first
- if stock && stock.stocked?
.add_cart.form-inline.form-group
= hidden_field_tag :stock_id, stock.id
= submit_tag Comable.t('add_to_cart'), class: 'btn btn-default'
- else
.soldout
= submit_tag Comable.t('soldout'), class: 'btn btn-default', disabled: true
2 changes: 1 addition & 1 deletion frontend/app/views/layouts/comable/application.slim
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ html
- else
= render 'comable/shared/header'

main.container
main class="#{'container' if controller_name != 'home'}"
- flash.each do |name, msg|
= content_tag(:div, msg, id: "flash_#{name}")

Expand Down
3 changes: 2 additions & 1 deletion frontend/config/routes.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
Comable::Core::Engine.routes.draw do
root to: 'products#index'
root to: 'home#show'

resource :home, only: :show
resources :products

resource :cart do
Expand Down
9 changes: 9 additions & 0 deletions frontend/spec/controllers/comable/home_controller_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
describe Comable::HomeController do
describe 'GET show' do
it 'assigns the products as @products' do
product = create(:product)
get :show
expect(assigns(:products)).to include(product)
end
end
end
10 changes: 10 additions & 0 deletions frontend/spec/views/comable/home/show.slim_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
describe 'comable/home/show' do
let!(:product) { create(:product) }

before { assign(:products, [product]) }

it 'renders attributes in products' do
render
expect(rendered).to include(product.name)
end
end

0 comments on commit db07e5e

Please sign in to comment.