Commit 02b7599e by Tran Hoang Viet

Merge branch 'vietth_feat_share_scocial' into 'develop'

VietTH: Feature share scocial

See merge request !10
parents f04cca90 03601722
...@@ -95,3 +95,5 @@ gem 'rubocop', '~> 0.32.1' ...@@ -95,3 +95,5 @@ gem 'rubocop', '~> 0.32.1'
gem 'cartman', '~> 2.1.2' gem 'cartman', '~> 2.1.2'
gem 'font-awesome-rails', '~> 4.3.0.0' gem 'font-awesome-rails', '~> 4.3.0.0'
gem 'meta-tags', '~> 2.0.0'
\ No newline at end of file
...@@ -155,6 +155,8 @@ GEM ...@@ -155,6 +155,8 @@ GEM
nokogiri (>= 1.5.9) nokogiri (>= 1.5.9)
mail (2.6.3) mail (2.6.3)
mime-types (>= 1.16, < 3) mime-types (>= 1.16, < 3)
meta-tags (2.0.0)
actionpack (>= 3.0.0)
method_source (0.8.2) method_source (0.8.2)
mime-types (2.6.1) mime-types (2.6.1)
mini_magick (3.8.1) mini_magick (3.8.1)
...@@ -343,6 +345,7 @@ DEPENDENCIES ...@@ -343,6 +345,7 @@ DEPENDENCIES
jquery-rails jquery-rails
kaminari (~> 0.16.3) kaminari (~> 0.16.3)
letter_opener (~> 1.4.1) letter_opener (~> 1.4.1)
meta-tags (~> 2.0.0)
mini_magick (~> 3.8.1) mini_magick (~> 3.8.1)
mysql2 mysql2
pry-rails (~> 0.3.4) pry-rails (~> 0.3.4)
......
...@@ -31,11 +31,28 @@ label.error{ ...@@ -31,11 +31,28 @@ label.error{
#content{ #content{
.products-list-detail{ .products-list-detail{
.product-item{ .product-item{
margin-bottom: 30px; position: relative;
min-height: 380px;
&:hover{
-webkit-box-shadow: 0px 1px 5px 0px rgba(0,0,0,0.72);
-moz-box-shadow: 0px 1px 5px 0px rgba(0,0,0,0.72);
box-shadow: 0px 1px 5px 0px rgba(0,0,0,0.72);
background-color: #F3F3F3;
.share-social{
display: block;
}
}
padding-bottom: 30px;
.product-image{ .product-image{
position: relative; position: relative;
&.disable{ &.disable{
opacity: 0.4; opacity: 0.4;
img{
-webkit-filter: grayscale(100%);
filter: grayscale(100%);
filter: gray;
filter: url("data:image/svg+xml;utf8,<svg version='1.1' xmlns='http://www.w3.org/2000/svg' height='0'><filter id='greyscale'><feColorMatrix type='matrix' values='0.3333 0.3333 0.3333 0 0 0.3333 0.3333 0.3333 0 0 0.3333 0.3333 0.3333 0 0 0 0 0 1 0' /></filter></svg>#greyscale");
}
} }
img{ img{
height: 180px; height: 180px;
...@@ -44,6 +61,23 @@ label.error{ ...@@ -44,6 +61,23 @@ label.error{
} }
} }
.share-social{
display: none;
text-align: center;
margin-left: -15px;
position: absolute;
bottom: 0;
width: 100%;
.facebook, .twitter{
img{
min-width: 10px;
width: 100px;
margin-bottom: 10px;
height: auto;
}
}
}
.product-title{ .product-title{
margin: 10px 0; margin: 10px 0;
} }
...@@ -137,3 +171,7 @@ footer{ ...@@ -137,3 +171,7 @@ footer{
.text-left{ .text-left{
text-align: left !important; text-align: left !important;
} }
.breadcrumb{
margin-bottom: 0;
}
\ No newline at end of file
...@@ -9,4 +9,8 @@ ...@@ -9,4 +9,8 @@
.product-title{ .product-title{
font-size: 16px; font-size: 16px;
} }
.share-social{
display: block !important;
}
} }
\ No newline at end of file
class ApplicationController < ActionController::Base class ApplicationController < ActionController::Base
include MetaManagement
rescue_from ActiveRecord::RecordNotFound, :with => :record_not_found rescue_from ActiveRecord::RecordNotFound, :with => :record_not_found
layout Proc.new { |controller| controller.devise_controller? ? 'devise' : 'application' } layout Proc.new { |controller| controller.devise_controller? ? 'devise' : 'application' }
...@@ -19,4 +21,5 @@ class ApplicationController < ActionController::Base ...@@ -19,4 +21,5 @@ class ApplicationController < ActionController::Base
def record_not_found def record_not_found
redirect_to(root_path, alert: "Resource not found") redirect_to(root_path, alert: "Resource not found")
end end
end end
\ No newline at end of file
class CategoriesController < ApplicationController class CategoriesController < ApplicationController
before_action :set_category, only: [:show] before_action :set_category, only: [:show]
before_action :add_breadcrumb_home before_action :add_breadcrumb_home
before_action :set_metas, only: [:show]
def show def show
@products = @category.products.page(params[:page]) @products = @category.products.page(params[:page])
add_breadcrumb(@category.decorate.title) add_breadcrumb(@category.decorate.title)
end end
def meta_attributes
return if @category.blank?
@meta_attributes ||= {
title: @category.decorate.title,
description: @category.decorate.title
}
end
private private
def set_category def set_category
@category = Category.find(params[:id]) @category = Category.find(params[:id])
......
module MetaManagement extend ActiveSupport::Concern
included do
def render(options = nil, extra_options = {}, &block)
set_metas
super
end
def meta_attributes_default
{
image: ActionController::Base.helpers.asset_url('logo.png'),
title: 'Venshop Zigexn VeNtura',
description: 'Venshop',
keywords: 'Ventura, Zigexn, venshop',
type: 'shop'
}
end
def set_metas
attributes = meta_attributes_default
if self.respond_to?(:meta_attributes) && meta_attributes.present?
attributes = attributes.merge(meta_attributes)
end
set_meta_tags(
title: attributes[:title],
description: attributes[:description],
keywords: attributes[:keywords],
separator: "&mdash;".html_safe,
og: {
title: attributes[:title],
type: attributes[:type],
url: Settings.base_url,
image: attributes[:image],
description: attributes[:description]
},
twitter: {
title: attributes[:title],
description: attributes[:description],
card: attributes[:type],
image: {
_: attributes[:image],
width: 100,
height: 100
}
}
)
end
end
end
\ No newline at end of file
...@@ -38,6 +38,16 @@ class ProductsController < ApplicationController ...@@ -38,6 +38,16 @@ class ProductsController < ApplicationController
add_breadcrumb('Search result') add_breadcrumb('Search result')
end end
def meta_attributes
return if @product.blank?
@meta_attributes ||= {
title: @product.title,
image: @product.image_lg_url,
description: "#{@product.title} - #{@product.price}"
}
end
private private
def set_product def set_product
@product = Product.find(params[:id]) @product = Product.find(params[:id])
......
module SocialHelper
def facebook_share_url(url)
"https://www.facebook.com/sharer/sharer.php?u=#{url || request.original_url}"
end
def twitter_share_url(url)
"https://twitter.com/home?status=#{url || request.original_url}"
end
end
\ No newline at end of file
class Meta
class << self
attr_accessor :title, :description, :name, :image, :image_lg, :author
def title
@title || 'Venshop Zigexn VeNtura'
end
def image
@image || ActionController::Base.helpers.asset_url('logo.png')
end
def image_lg
@image_lg || image
end
end
end
\ No newline at end of file
.navbar-header %nav.navbar.navbar-inverse.navbar-fixed-top
.container-fluid
.navbar-header
%button.navbar-toggle.collapsed{"aria-controls" => "navbar", "aria-expanded" => "false", "data-target" => "#navbar", "data-toggle" => "collapse", :type => "button"} %button.navbar-toggle.collapsed{"aria-controls" => "navbar", "aria-expanded" => "false", "data-target" => "#navbar", "data-toggle" => "collapse", :type => "button"}
%span.sr-only Toggle navigation %span.sr-only Toggle navigation
%span.icon-bar %span.icon-bar
%span.icon-bar %span.icon-bar
%span.icon-bar %span.icon-bar
%a.navbar-brand.logo{:href => "/"} = link_to root_path, class: 'navbar-brand logo' do
%img{src: 'http://zigexn.vn/assets/logo-main-e75d68f895f288e75637440f337c1687.png'} %img{src: 'http://zigexn.vn/assets/logo-main-e75d68f895f288e75637440f337c1687.png'}
#navbar.navbar-collapse.collapse #navbar.navbar-collapse.collapse
%ul.nav.navbar-nav.navbar-right %ul.nav.navbar-nav.navbar-right
- if user_signed_in? - if user_signed_in?
%li %li
...@@ -21,3 +23,11 @@ ...@@ -21,3 +23,11 @@
= link_to('Login', new_user_session_path) = link_to('Login', new_user_session_path)
%li %li
= link_to 'Register', new_user_registration_path = link_to 'Register', new_user_registration_path
.navbar-form.navbar-right
= form_tag search_products_path, method: :get do
.input-group
= text_field_tag :query, params[:query], class: 'form-control', placeholder: 'Search for title...'
%span.input-group-btn
%button.btn.btn-default{type: "submit"} Go!
= form_tag search_products_path, method: :get do
.input-group
= text_field_tag :query, params[:query], class: 'form-control', placeholder: 'Search for title...'
%span.input-group-btn
%button.btn.btn-default{type: "submit"} Go!
!!! !!!
%html{:lang => "en"} %html{:lang => "en"}
%title Vendor
= stylesheet_link_tag 'application', media: 'all' = stylesheet_link_tag 'application', media: 'all'
= javascript_include_tag 'application' = javascript_include_tag 'application'
= csrf_meta_tags = csrf_meta_tags
= display_meta_tags
%body %body
%nav.navbar.navbar-inverse.navbar-fixed-top %nav.navbar.navbar-inverse.navbar-fixed-top
.container-fluid .container-fluid
= render '/layouts/header' = render 'layouts/header'
#wrapper.container-fluid #wrapper.container-fluid
= render '/layouts/message' = render 'layouts/message'
.row .row
.col-md-6.search-wrapper .col-md-6.search-wrapper
...@@ -28,6 +29,9 @@ ...@@ -28,6 +29,9 @@
.row .row
.col-md-12 .col-md-12
= render 'layouts/cart' = render 'layouts/cart'
.row
.col-md-12
= render 'layouts/share_social'
.col-md-10 .col-md-10
= yield = yield
......
%h3.title Checkout %h3.title Checkout
- if cart_valid? - if cart_valid?
#checkout-cart #checkout-cart.table-responsive
= form_for Order.new do |f| = form_for Order.new do |f|
%table.table %table.table
%thead %thead
......
.product-addto-cart.input-group .product-addto-cart.input-group
- max_quantity = product.stock - current_user.cart.find(product).try(:quantity).to_i - max_quantity = product.stock
- max_quantity -= current_user.cart.find(product).try(:quantity).to_i if user_signed_in?
= form_tag add_cart_product_path(product), method: :get, class: 'form-quantity' do = form_tag add_cart_product_path(product), method: :get, class: 'form-quantity' do
= text_field_tag :quantity, 1, class: 'form-control quantity' = text_field_tag :quantity, 1, class: 'form-control quantity'
= hidden_field_tag :stock, max_quantity, class: 'max-quantity' = hidden_field_tag :stock, max_quantity, class: 'max-quantity'
.input-group-btn .input-group-btn
= submit_tag 'Add', class: "btn-add btn btn-default", disabled: product.stock.zero? = submit_tag 'Add', class: "btn-add btn btn-danger", disabled: product.stock.zero?
.product-item.col-md-4.text-center .product-item.col-md-3.text-center
.product-title .product-title
= link_to product.decorate.short_title, product = link_to product.decorate.short_title, product
.product-price .product-price
...@@ -11,3 +11,11 @@ ...@@ -11,3 +11,11 @@
Stock: Stock:
= product.stock = product.stock
= render 'products/add_to_cart_btn', product: product = render 'products/add_to_cart_btn', product: product
.clearfix
.share-social
= link_to facebook_share_url(product_url(product)), class: 'facebook', target: '_blank' do
= image_tag 'facebook.png'
= link_to twitter_share_url(product_url(product)), class: 'twitter', target: '_blank' do
= image_tag 'twitter.png'
\ No newline at end of file
#product-detail.products-list-detail #product-detail.products-list-detail
= render 'product', product: @product = render 'product', product: @product
.clearfix .clearfix
.col-md-4.text-center .col-md-3.text-center
.product-id .product-id
Item ID: Item ID:
= @product.id = @product.id
......
...@@ -3,4 +3,6 @@ AWS_ACCESS: AKIAJ77C4CTZOP7TUVWQ ...@@ -3,4 +3,6 @@ AWS_ACCESS: AKIAJ77C4CTZOP7TUVWQ
AWS_SECRET: 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 AWS_SECRET: cYJYb/MLGV0M6oi1+DjlliL1cfxmh78tKXnT6ZmX
AWS_TAG: zigexn6400-22 AWS_TAG: zigexn6400-22
FB_APP_ID: 1629224294024346
SOLR_URL: http://localhost:8080/solr/venshop SOLR_URL: http://localhost:8080/solr/venshop
\ No newline at end of file
Kaminari.configure do |config| Kaminari.configure do |config|
config.default_per_page = 6 config.default_per_page = 8
# config.max_per_page = nil # config.max_per_page = nil
# config.window = 4 # config.window = 4
# config.outer_window = 0 # config.outer_window = 0
......
defaults: &defaults defaults: &defaults
limit_category: 6 limit_category: 8
limit_product_recommended: 6 limit_product_recommended: 8
limit_product_newest: 9 limit_product_newest: 12
limit_length_category_title: 50 limit_length_category_title: 50
development: development:
<<: *defaults <<: *defaults
solr_url: http://localhost:8080/solr/venshop solr_url: http://localhost:8080/solr/venshop
base_url: http://locahost:3000
test: test:
<<: *defaults <<: *defaults
solr_url: http://localhost:8080/solr/venshop_test solr_url: http://localhost:8080/solr/venshop_test
base_url: http://locahost:3000
production: production:
<<: *defaults <<: *defaults
solr_url: http://localhost:8080/solr/venshop solr_url: http://localhost:8080/solr/venshop
base_url: http://192.168.1.204:3005
staging: staging:
<<: *defaults <<: *defaults
solr_url: http://localhost:8080/solr/venshop solr_url: http://localhost:8080/solr/venshop
base_url: http://alicuche.koding.io
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment