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
......@@ -94,4 +94,6 @@ gem 'rubocop', '~> 0.32.1'
gem 'cartman', '~> 2.1.2'
gem 'font-awesome-rails', '~> 4.3.0.0'
\ No newline at end of file
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
nokogiri (>= 1.5.9)
mail (2.6.3)
mime-types (>= 1.16, < 3)
meta-tags (2.0.0)
actionpack (>= 3.0.0)
method_source (0.8.2)
mime-types (2.6.1)
mini_magick (3.8.1)
......@@ -343,6 +345,7 @@ DEPENDENCIES
jquery-rails
kaminari (~> 0.16.3)
letter_opener (~> 1.4.1)
meta-tags (~> 2.0.0)
mini_magick (~> 3.8.1)
mysql2
pry-rails (~> 0.3.4)
......
......@@ -31,11 +31,28 @@ label.error{
#content{
.products-list-detail{
.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{
position: relative;
&.disable{
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{
height: 180px;
......@@ -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{
margin: 10px 0;
}
......@@ -136,4 +170,8 @@ footer{
.text-left{
text-align: left !important;
}
.breadcrumb{
margin-bottom: 0;
}
\ No newline at end of file
......@@ -9,4 +9,8 @@
.product-title{
font-size: 16px;
}
.share-social{
display: block !important;
}
}
\ No newline at end of file
class ApplicationController < ActionController::Base
include MetaManagement
rescue_from ActiveRecord::RecordNotFound, :with => :record_not_found
layout Proc.new { |controller| controller.devise_controller? ? 'devise' : 'application' }
......@@ -19,4 +21,5 @@ class ApplicationController < ActionController::Base
def record_not_found
redirect_to(root_path, alert: "Resource not found")
end
end
\ No newline at end of file
class CategoriesController < ApplicationController
before_action :set_category, only: [:show]
before_action :add_breadcrumb_home
before_action :set_metas, only: [:show]
def show
@products = @category.products.page(params[:page])
add_breadcrumb(@category.decorate.title)
end
def meta_attributes
return if @category.blank?
@meta_attributes ||= {
title: @category.decorate.title,
description: @category.decorate.title
}
end
private
def set_category
@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
add_breadcrumb('Search result')
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
def set_product
@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
%button.navbar-toggle.collapsed{"aria-controls" => "navbar", "aria-expanded" => "false", "data-target" => "#navbar", "data-toggle" => "collapse", :type => "button"}
%span.sr-only Toggle navigation
%span.icon-bar
%span.icon-bar
%span.icon-bar
%a.navbar-brand.logo{:href => "/"}
%img{src: 'http://zigexn.vn/assets/logo-main-e75d68f895f288e75637440f337c1687.png'}
#navbar.navbar-collapse.collapse
%ul.nav.navbar-nav.navbar-right
- if user_signed_in?
%li
= link_to 'Logout', destroy_user_session_path, method: :delete
%li
= link_to 'Change profile', edit_user_registration_path
%li
= link_to 'New product', new_product_path
%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"}
%span.sr-only Toggle navigation
%span.icon-bar
%span.icon-bar
%span.icon-bar
= link_to root_path, class: 'navbar-brand logo' do
%img{src: 'http://zigexn.vn/assets/logo-main-e75d68f895f288e75637440f337c1687.png'}
#navbar.navbar-collapse.collapse
%ul.nav.navbar-nav.navbar-right
- if user_signed_in?
%li
= link_to 'Logout', destroy_user_session_path, method: :delete
%li
= link_to 'Change profile', edit_user_registration_path
%li
= link_to 'New product', new_product_path
- else
%li
= link_to('Login', new_user_session_path)
%li
= 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!
- else
%li
= link_to('Login', new_user_session_path)
%li
= link_to 'Register', new_user_registration_path
= 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"}
%title Vendor
= stylesheet_link_tag 'application', media: 'all'
= javascript_include_tag 'application'
= csrf_meta_tags
= display_meta_tags
%body
%nav.navbar.navbar-inverse.navbar-fixed-top
.container-fluid
= render '/layouts/header'
= render 'layouts/header'
#wrapper.container-fluid
= render '/layouts/message'
= render 'layouts/message'
.row
.col-md-6.search-wrapper
......@@ -28,6 +29,9 @@
.row
.col-md-12
= render 'layouts/cart'
.row
.col-md-12
= render 'layouts/share_social'
.col-md-10
= yield
......
%h3.title Checkout
- if cart_valid?
#checkout-cart
#checkout-cart.table-responsive
= form_for Order.new do |f|
%table.table
%thead
......
.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
= text_field_tag :quantity, 1, class: 'form-control quantity'
= hidden_field_tag :stock, max_quantity, class: 'max-quantity'
.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
= link_to product.decorate.short_title, product
.product-price
......@@ -11,3 +11,11 @@
Stock:
= product.stock
= 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
= render 'product', product: @product
.clearfix
.col-md-4.text-center
.col-md-3.text-center
.product-id
Item ID:
= @product.id
......
......@@ -3,4 +3,6 @@ AWS_ACCESS: AKIAJ77C4CTZOP7TUVWQ
AWS_SECRET: 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
AWS_TAG: zigexn6400-22
FB_APP_ID: 1629224294024346
SOLR_URL: http://localhost:8080/solr/venshop
\ No newline at end of file
Kaminari.configure do |config|
config.default_per_page = 6
config.default_per_page = 8
# config.max_per_page = nil
# config.window = 4
# config.outer_window = 0
......
defaults: &defaults
limit_category: 6
limit_product_recommended: 6
limit_product_newest: 9
limit_category: 8
limit_product_recommended: 8
limit_product_newest: 12
limit_length_category_title: 50
development:
<<: *defaults
solr_url: http://localhost:8080/solr/venshop
base_url: http://locahost:3000
test:
<<: *defaults
solr_url: http://localhost:8080/solr/venshop_test
base_url: http://locahost:3000
production:
<<: *defaults
solr_url: http://localhost:8080/solr/venshop
base_url: http://192.168.1.204:3005
staging:
<<: *defaults
solr_url: http://localhost:8080/solr/venshop
\ No newline at end of file
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