Commit f6cdd883 by Truong Ba Dieu

Restruct space

parent 45697591
.navbar-brand{ .navbar-brand{
padding: 2px; padding: 2px;
img{ img{
height: 45px; height: 45px;
display: inline-block; display: inline-block;
margin-right: 10px; margin-right: 10px;
} }
} }
.logo{ .logo{
margin: 0; margin: 0;
line-height: 25px; line-height: 25px;
font-size: 22px; font-size: 22px;
font-family: serif; font-family: serif;
} }
.wrap-img{ .wrap-img{
display: inline-block; display: inline-block;
} }
#search-bar{ #search-bar{
margin: 20px 0; margin: 20px 0;
input[type="text"]{ input[type="text"]{
height: 35px; height: 35px;
} }
} }
\ No newline at end of file
.recommend{ .recommend{
} }
.products{ .products{
.wrap-img{ .wrap-img{
float: left; float: left;
} }
.title{ .title{
padding-left: 60px; padding-left: 60px;
} }
} }
\ No newline at end of file
.mar-top-20{ .mar-top-20{
margin-top: 20px; margin-top: 20px;
} }
.mar-bot-20{ .mar-bot-20{
margin-bottom: 20px; margin-bottom: 20px;
} }
.mar-r-10{ .mar-r-10{
margin-right: 10px; margin-right: 10px;
} }
.text-center{ .text-center{
text-align: center; text-align: center;
} }
.pad-0{ .pad-0{
padding: 0; padding: 0;
} }
\ No newline at end of file
...@@ -4,6 +4,6 @@ class ApplicationController < ActionController::Base ...@@ -4,6 +4,6 @@ class ApplicationController < ActionController::Base
protect_from_forgery with: :exception protect_from_forgery with: :exception
def get_categories def get_categories
@categories = Category.all @categories = Category.all
end end
end end
class CategoriesController < ApplicationController class CategoriesController < ApplicationController
before_filter :get_categories before_filter :get_categories
def show
@category = Category.find(params[:id]) def show
end @category = Category.find(params[:id])
end
end end
\ No newline at end of file
class HomeController < ApplicationController class HomeController < ApplicationController
add_breadcrumb "Home", :root_path add_breadcrumb "Home", :root_path
before_filter :get_categories before_filter :get_categories
before_filter :get_recommend before_filter :get_recommend
def index def index
params[:per_page] ||= 5 params[:per_page] ||= 5
params[:page] ||= 1 params[:page] ||= 1
@products = Product.page(params[:page]).per(params[:per_page]) @products = Product.page(params[:page]).per(params[:per_page])
end end
def search def search
add_breadcrumb "Search", :search_path add_breadcrumb "Search", :search_path
@products = Product.search(params) @products = Product.search(params)
end end
private private
def get_recommend def get_recommend
@recommend_products = Product.recommend @recommend_products = Product.recommend
end end
end end
\ No newline at end of file
class ProductsController < ApplicationController class ProductsController < ApplicationController
before_filter :get_categories before_filter :get_categories
def show def show
@product = Product.find(params[:id]) @product = Product.find(params[:id])
end end
end end
\ No newline at end of file
module ApplicationHelper module ApplicationHelper
def currency_number(price=0, currency="usd") def currency_number(price=0, currency="usd")
"#{currency}#{price}" "#{currency}#{price}"
end end
end end
class Category < ActiveRecord::Base class Category < ActiveRecord::Base
has_many :products has_many :products
end end
class Product < ActiveRecord::Base class Product < ActiveRecord::Base
belongs_to :category belongs_to :category
belongs_to :user belongs_to :user
dragonfly_accessor :image dragonfly_accessor :image
validates :pid, :title, :price, :category_id, presence: true validates :pid, :title, :price, :category_id, presence: true
validates :pid, uniqueness: true validates :pid, uniqueness: true
scope :recommend, -> {where(recommend: true)} scope :recommend, -> {where(recommend: true)}
def self.search(params) def self.search(params)
params[:per_page] ||= 5 params[:per_page] ||= 5
params[:page] ||= 1 params[:page] ||= 1
Product.order("release_date DESC").page(params[:page]).per(params[:per_page]) Product.order("release_date DESC").page(params[:page]).per(params[:per_page])
end end
end end
...@@ -2,7 +2,7 @@ class User < ActiveRecord::Base ...@@ -2,7 +2,7 @@ class User < ActiveRecord::Base
# Include default devise modules. Others available are: # Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable and :omniauthable # :confirmable, :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :registerable, devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable :recoverable, :rememberable, :trackable, :validatable
has_many :products has_many :products
end end
class DatetimeService class DatetimeService
def self.strptime(str = nil, type="%Y-%m-%d") def self.strptime(str = nil, type="%Y-%m-%d")
begin begin
DateTime.strptime(str, type) DateTime.strptime(str, type)
rescue rescue
DateTime.now DateTime.now
end end
end end
end end
\ No newline at end of file
class VacuumAwsService class VacuumAwsService
def self.item_search(options={}) def self.item_search(options={})
options[:country_code] ||='GB' options[:country_code] ||='GB'
options[:query] ||={} options[:query] ||={}
request = Vacuum.new(options[:country_code]) request = Vacuum.new(options[:country_code])
request.configure(
aws_access_key_id: 'AKIAJ77C4CTZOP7TUVWQ',
aws_secret_access_key: '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',
associate_tag: 'zigexn6400-22'
)
request.item_search( request.configure(
aws_access_key_id: 'AKIAJ77C4CTZOP7TUVWQ',
aws_secret_access_key: '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',
associate_tag: 'zigexn6400-22'
)
request.item_search(
query: options[:query] query: options[:query]
) )
end end
def self.parse_items(response) def self.parse_items(response)
response = response.to_h response = response.to_h
if response["ItemSearchResponse"].present? && response["ItemSearchResponse"]["Items"].present? && response["ItemSearchResponse"]["Items"]["Item"].present? if response["ItemSearchResponse"].present? && response["ItemSearchResponse"]["Items"].present? && response["ItemSearchResponse"]["Items"]["Item"].present?
response["ItemSearchResponse"]["Items"]["Item"] response["ItemSearchResponse"]["Items"]["Item"]
else else
[] []
end end
end end
def self.parse_item(item) def self.parse_item(item)
# only get product have pid, title, price # only get product have pid, title, price
if item.present? && item["ASIN"].present? && item["ItemAttributes"]["Title"].present? && item["ItemAttributes"]["ListPrice"].present? if item.present? && item["ASIN"].present? && item["ItemAttributes"]["Title"].present? && item["ItemAttributes"]["ListPrice"].present?
{ {
pid: item["ASIN"], pid: item["ASIN"],
title: item["ItemAttributes"]["Title"], title: item["ItemAttributes"]["Title"],
author: item["ItemAttributes"]["Author"], author: item["ItemAttributes"]["Author"],
publisher: item["ItemAttributes"]["Publisher"], publisher: item["ItemAttributes"]["Publisher"],
studio: item["ItemAttributes"]["Studio"], studio: item["ItemAttributes"]["Studio"],
price: item["ItemAttributes"]["ListPrice"]["FormattedPrice"][1..-1].to_f, price: item["ItemAttributes"]["ListPrice"]["FormattedPrice"][1..-1].to_f,
currency: item["ItemAttributes"]["ListPrice"]["FormattedPrice"].to_s.first, currency: item["ItemAttributes"]["ListPrice"]["FormattedPrice"].to_s.first,
release_date: DatetimeService.strptime(item["ItemAttributes"]["ReleaseDate"], "%Y-%m-%d"), release_date: DatetimeService.strptime(item["ItemAttributes"]["ReleaseDate"], "%Y-%m-%d"),
public_date: DatetimeService.strptime(item["ItemAttributes"]["PublicationDate"], "%Y-%m-%d"), public_date: DatetimeService.strptime(item["ItemAttributes"]["PublicationDate"], "%Y-%m-%d"),
image_url: item["LargeImage"]["URL"] image_url: item["LargeImage"]["URL"]
} }
end end
end end
end end
# Sample item response # Sample item response
# {"ASIN"=>"B00000G43U", "DetailPageURL"=>"http://www.amazon.co.uk/All-Saints-Remix-Album-Saints/dp/B00000G43U%3FSubscriptionId%3DAKIAJ77C4CTZOP7TUVWQ%26tag%3Dzigexn6400-22%26linkCode%3Dxm2%26camp%3D2025%26creative%3D165953%26creativeASIN%3DB00000G43U", # {"ASIN"=>"B00000G43U", "DetailPageURL"=>"http://www.amazon.co.uk/All-Saints-Remix-Album-Saints/dp/B00000G43U%3FSubscriptionId%3DAKIAJ77C4CTZOP7TUVWQ%26tag%3Dzigexn6400-22%26linkCode%3Dxm2%26camp%3D2025%26creative%3D165953%26creativeASIN%3DB00000G43U",
# "ItemLinks"=>{ # "ItemLinks"=>{
# "ItemLink"=>[ # "ItemLink"=>[
# {"Description"=>"Add To Wishlist", "URL"=>"http://www.amazon.co.uk/gp/registry/wishlist/add-item.html%3Fasin.0%3DB00000G43U%26SubscriptionId%3DAKIAJ77C4CTZOP7TUVWQ%26tag%3Dzigexn6400-22%26linkCode%3Dxm2%26camp%3D2025%26creative%3D12734%26creativeASIN%3DB00000G43U"}, # {"Description"=>"Add To Wishlist", "URL"=>"http://www.amazon.co.uk/gp/registry/wishlist/add-item.html%3Fasin.0%3DB00000G43U%26SubscriptionId%3DAKIAJ77C4CTZOP7TUVWQ%26tag%3Dzigexn6400-22%26linkCode%3Dxm2%26camp%3D2025%26creative%3D12734%26creativeASIN%3DB00000G43U"},
# {"Description"=>"Tell A Friend", "URL"=>"http://www.amazon.co.uk/gp/pdp/taf/B00000G43U%3FSubscriptionId%3DAKIAJ77C4CTZOP7TUVWQ%26tag%3Dzigexn6400-22%26linkCode%3Dxm2%26camp%3D2025%26creative%3D12734%26creativeASIN%3DB00000G43U"}, # {"Description"=>"Tell A Friend", "URL"=>"http://www.amazon.co.uk/gp/pdp/taf/B00000G43U%3FSubscriptionId%3DAKIAJ77C4CTZOP7TUVWQ%26tag%3Dzigexn6400-22%26linkCode%3Dxm2%26camp%3D2025%26creative%3D12734%26creativeASIN%3DB00000G43U"},
# {"Description"=>"All Customer Reviews", "URL"=>"http://www.amazon.co.uk/review/product/B00000G43U%3FSubscriptionId%3DAKIAJ77C4CTZOP7TUVWQ%26tag%3Dzigexn6400-22%26linkCode%3Dxm2%26camp%3D2025%26creative%3D12734%26creativeASIN%3DB00000G43U"}, # {"Description"=>"All Customer Reviews", "URL"=>"http://www.amazon.co.uk/review/product/B00000G43U%3FSubscriptionId%3DAKIAJ77C4CTZOP7TUVWQ%26tag%3Dzigexn6400-22%26linkCode%3Dxm2%26camp%3D2025%26creative%3D12734%26creativeASIN%3DB00000G43U"},
# {"Description"=>"All Offers", "URL"=>"http://www.amazon.co.uk/gp/offer-listing/B00000G43U%3FSubscriptionId%3DAKIAJ77C4CTZOP7TUVWQ%26tag%3Dzigexn6400-22%26linkCode%3Dxm2%26camp%3D2025%26creative%3D12734%26creativeASIN%3DB00000G43U"} # {"Description"=>"All Offers", "URL"=>"http://www.amazon.co.uk/gp/offer-listing/B00000G43U%3FSubscriptionId%3DAKIAJ77C4CTZOP7TUVWQ%26tag%3Dzigexn6400-22%26linkCode%3Dxm2%26camp%3D2025%26creative%3D12734%26creativeASIN%3DB00000G43U"}
# ] # ]
# }, # },
# "ItemAttributes"=>{"Artist"=>"All Saints", "Manufacturer"=>"CD", "ProductGroup"=>"Music", "Title"=>"All Saints-Remix Album"} # "ItemAttributes"=>{"Artist"=>"All Saints", "Manufacturer"=>"CD", "ProductGroup"=>"Music", "Title"=>"All Saints-Remix Album"}
# } # }
# { # {
# "ASIN"=>"0008138303", # "ASIN"=>"0008138303",
# "DetailPageURL"=>"http://www.amazon.co.uk/All-Light-We-Cannot-See/dp/0008138303%3FSubscriptionId%3DAKIAJ77C4CTZOP7TUVWQ%26tag%3Dzigexn6400-22%26linkCode%3Dxm2%26camp%3D2025%26creative%3D165953%26creativeASIN%3D0008138303", # "DetailPageURL"=>"http://www.amazon.co.uk/All-Light-We-Cannot-See/dp/0008138303%3FSubscriptionId%3DAKIAJ77C4CTZOP7TUVWQ%26tag%3Dzigexn6400-22%26linkCode%3Dxm2%26camp%3D2025%26creative%3D165953%26creativeASIN%3D0008138303",
# "ItemLinks"=>{ # "ItemLinks"=>{
# "ItemLink"=>[ # "ItemLink"=>[
# {"Description"=>"Add To Wishlist", "URL"=>"http://www.amazon.co.uk/gp/registry/wishlist/add-item.html%3Fasin.0%3D0008138303%26SubscriptionId%3DAKIAJ77C4CTZOP7TUVWQ%26tag%3Dzigexn6400-22%26linkCode%3Dxm2%26camp%3D2025%26creative%3D12734%26creativeASIN%3D0008138303"}, # {"Description"=>"Add To Wishlist", "URL"=>"http://www.amazon.co.uk/gp/registry/wishlist/add-item.html%3Fasin.0%3D0008138303%26SubscriptionId%3DAKIAJ77C4CTZOP7TUVWQ%26tag%3Dzigexn6400-22%26linkCode%3Dxm2%26camp%3D2025%26creative%3D12734%26creativeASIN%3D0008138303"},
# {"Description"=>"Tell A Friend", "URL"=>"http://www.amazon.co.uk/gp/pdp/taf/0008138303%3FSubscriptionId%3DAKIAJ77C4CTZOP7TUVWQ%26tag%3Dzigexn6400-22%26linkCode%3Dxm2%26camp%3D2025%26creative%3D12734%26creativeASIN%3D0008138303"}, # {"Description"=>"Tell A Friend", "URL"=>"http://www.amazon.co.uk/gp/pdp/taf/0008138303%3FSubscriptionId%3DAKIAJ77C4CTZOP7TUVWQ%26tag%3Dzigexn6400-22%26linkCode%3Dxm2%26camp%3D2025%26creative%3D12734%26creativeASIN%3D0008138303"},
# {"Description"=>"All Customer Reviews", "URL"=>"http://www.amazon.co.uk/review/product/0008138303%3FSubscriptionId%3DAKIAJ77C4CTZOP7TUVWQ%26tag%3Dzigexn6400-22%26linkCode%3Dxm2%26camp%3D2025%26creative%3D12734%26creativeASIN%3D0008138303"}, # {"Description"=>"All Customer Reviews", "URL"=>"http://www.amazon.co.uk/review/product/0008138303%3FSubscriptionId%3DAKIAJ77C4CTZOP7TUVWQ%26tag%3Dzigexn6400-22%26linkCode%3Dxm2%26camp%3D2025%26creative%3D12734%26creativeASIN%3D0008138303"},
# {"Description"=>"All Offers", "URL"=>"http://www.amazon.co.uk/gp/offer-listing/0008138303%3FSubscriptionId%3DAKIAJ77C4CTZOP7TUVWQ%26tag%3Dzigexn6400-22%26linkCode%3Dxm2%26camp%3D2025%26creative%3D12734%26creativeASIN%3D0008138303"} # {"Description"=>"All Offers", "URL"=>"http://www.amazon.co.uk/gp/offer-listing/0008138303%3FSubscriptionId%3DAKIAJ77C4CTZOP7TUVWQ%26tag%3Dzigexn6400-22%26linkCode%3Dxm2%26camp%3D2025%26creative%3D12734%26creativeASIN%3D0008138303"}
# ] # ]
# }, # },
# "SalesRank"=>"41", # "SalesRank"=>"41",
# "SmallImage"=>{ # "SmallImage"=>{
# "URL"=>"http://ecx.images-amazon.com/images/I/511qpsWcTyL._SL75_.jpg", # "URL"=>"http://ecx.images-amazon.com/images/I/511qpsWcTyL._SL75_.jpg",
# "Height"=>{"__content__"=>"75", "Units"=>"pixels"}, # "Height"=>{"__content__"=>"75", "Units"=>"pixels"},
# "Width"=>{"__content__"=>"49", "Units"=>"pixels"} # "Width"=>{"__content__"=>"49", "Units"=>"pixels"}
# }, # },
# "MediumImage"=>{ # "MediumImage"=>{
# "URL"=>"http://ecx.images-amazon.com/images/I/511qpsWcTyL._SL160_.jpg", # "URL"=>"http://ecx.images-amazon.com/images/I/511qpsWcTyL._SL160_.jpg",
# "Height"=>{"__content__"=>"160", "Units"=>"pixels"}, # "Height"=>{"__content__"=>"160", "Units"=>"pixels"},
# "Width"=>{"__content__"=>"104", "Units"=>"pixels"} # "Width"=>{"__content__"=>"104", "Units"=>"pixels"}
# }, # },
# "LargeImage"=>{ # "LargeImage"=>{
# "URL"=>"http://ecx.images-amazon.com/images/I/511qpsWcTyL.jpg", # "URL"=>"http://ecx.images-amazon.com/images/I/511qpsWcTyL.jpg",
# "Height"=>{"__content__"=>"500", "Units"=>"pixels"}, # "Height"=>{"__content__"=>"500", "Units"=>"pixels"},
# "Width"=>{"__content__"=>"326", "Units"=>"pixels"} # "Width"=>{"__content__"=>"326", "Units"=>"pixels"}
# }, # },
# "ImageSets"=>{ # "ImageSets"=>{
# "ImageSet"=>{ # "ImageSet"=>{
# "SwatchImage"=>{ # "SwatchImage"=>{
# "URL"=>"http://ecx.images-amazon.com/images/I/511qpsWcTyL._SL30_.jpg", # "URL"=>"http://ecx.images-amazon.com/images/I/511qpsWcTyL._SL30_.jpg",
# "Height"=>{"__content__"=>"30", "Units"=>"pixels"}, # "Height"=>{"__content__"=>"30", "Units"=>"pixels"},
# "Width"=>{"__content__"=>"20", "Units"=>"pixels"} # "Width"=>{"__content__"=>"20", "Units"=>"pixels"}
# }, # },
# "SmallImage"=>{ # "SmallImage"=>{
# "URL"=>"http://ecx.images-amazon.com/images/I/511qpsWcTyL._SL75_.jpg", # "URL"=>"http://ecx.images-amazon.com/images/I/511qpsWcTyL._SL75_.jpg",
# "Height"=>{"__content__"=>"75", "Units"=>"pixels"}, # "Height"=>{"__content__"=>"75", "Units"=>"pixels"},
# "Width"=>{"__content__"=>"49", "Units"=>"pixels"} # "Width"=>{"__content__"=>"49", "Units"=>"pixels"}
# }, # },
# "ThumbnailImage"=>{ # "ThumbnailImage"=>{
# "URL"=>"http://ecx.images-amazon.com/images/I/511qpsWcTyL._SL75_.jpg", # "URL"=>"http://ecx.images-amazon.com/images/I/511qpsWcTyL._SL75_.jpg",
# "Height"=>{"__content__"=>"75", "Units"=>"pixels"}, # "Height"=>{"__content__"=>"75", "Units"=>"pixels"},
# "Width"=>{"__content__"=>"49", "Units"=>"pixels"} # "Width"=>{"__content__"=>"49", "Units"=>"pixels"}
# }, # },
# "TinyImage"=>{ # "TinyImage"=>{
# "URL"=>"http://ecx.images-amazon.com/images/I/511qpsWcTyL._SL110_.jpg", # "URL"=>"http://ecx.images-amazon.com/images/I/511qpsWcTyL._SL110_.jpg",
# "Height"=>{"__content__"=>"110", "Units"=>"pixels"}, # "Height"=>{"__content__"=>"110", "Units"=>"pixels"},
# "Width"=>{"__content__"=>"72", "Units"=>"pixels"} # "Width"=>{"__content__"=>"72", "Units"=>"pixels"}
# }, # },
# "MediumImage"=>{"URL"=>"http://ecx.images-amazon.com/images/I/511qpsWcTyL._SL160_.jpg", # "MediumImage"=>{"URL"=>"http://ecx.images-amazon.com/images/I/511qpsWcTyL._SL160_.jpg",
# "Height"=>{"__content__"=>"160", "Units"=>"pixels"}, # "Height"=>{"__content__"=>"160", "Units"=>"pixels"},
# "Width"=>{"__content__"=>"104", "Units"=>"pixels"} # "Width"=>{"__content__"=>"104", "Units"=>"pixels"}
# }, # },
# "LargeImage"=>{ # "LargeImage"=>{
# "URL"=>"http://ecx.images-amazon.com/images/I/511qpsWcTyL.jpg", # "URL"=>"http://ecx.images-amazon.com/images/I/511qpsWcTyL.jpg",
# "Height"=>{"__content__"=>"500", "Units"=>"pixels"}, # "Height"=>{"__content__"=>"500", "Units"=>"pixels"},
# "Width"=>{"__content__"=>"326", "Units"=>"pixels"} # "Width"=>{"__content__"=>"326", "Units"=>"pixels"}
# }, "Category"=>"primary" # }, "Category"=>"primary"
# } # }
# }, # },
# "ItemAttributes"=>{ # "ItemAttributes"=>{
# "Author"=>"Anthony Doerr", # "Author"=>"Anthony Doerr",
# "Binding"=>"Paperback", # "Binding"=>"Paperback",
# "EAN"=>"9780008138301", # "EAN"=>"9780008138301",
# "EANList"=>{"EANListElement"=>"9780008138301"}, # "EANList"=>{"EANListElement"=>"9780008138301"},
# "Edition"=>"0", # "Edition"=>"0",
# "ISBN"=>"0008138303", # "ISBN"=>"0008138303",
# "IsEligibleForTradeIn"=>"1", # "IsEligibleForTradeIn"=>"1",
# "ItemDimensions"=>{ # "ItemDimensions"=>{
# "Height"=>{"__content__"=>"787", "Units"=>"hundredths-inches"}, # "Height"=>{"__content__"=>"787", "Units"=>"hundredths-inches"},
# "Length"=>{"__content__"=>"508", "Units"=>"hundredths-inches"}, # "Length"=>{"__content__"=>"508", "Units"=>"hundredths-inches"},
# "Weight"=>{"__content__"=>"84", "Units"=>"hundredths-pounds"}, # "Weight"=>{"__content__"=>"84", "Units"=>"hundredths-pounds"},
# "Width"=>{"__content__"=>"142", "Units"=>"hundredths-inches"} # "Width"=>{"__content__"=>"142", "Units"=>"hundredths-inches"}
# }, # },
# "Label"=>"Fourth Estate", # "Label"=>"Fourth Estate",
# "Languages"=>{ # "Languages"=>{
# "Language"=>[ # "Language"=>[
# {"Name"=>"English", "Type"=>"Published"}, # {"Name"=>"English", "Type"=>"Published"},
# {"Name"=>"English", "Type"=>"Original Language"} # {"Name"=>"English", "Type"=>"Original Language"}
# ] # ]
# }, # },
# "ListPrice"=>{ # "ListPrice"=>{
# "Amount"=>"899", # "Amount"=>"899",
# "CurrencyCode"=>"GBP", # "CurrencyCode"=>"GBP",
# "FormattedPrice"=>"£8.99" # "FormattedPrice"=>"£8.99"
# }, # },
# "Manufacturer"=>"Fourth Estate", # "Manufacturer"=>"Fourth Estate",
# "NumberOfPages"=>"544", # "NumberOfPages"=>"544",
# "PackageDimensions"=>{ # "PackageDimensions"=>{
# "Height"=>{"__content__"=>"142", "Units"=>"hundredths-inches"}, # "Height"=>{"__content__"=>"142", "Units"=>"hundredths-inches"},
# "Length"=>{"__content__"=>"772", "Units"=>"hundredths-inches"}, # "Length"=>{"__content__"=>"772", "Units"=>"hundredths-inches"},
# "Weight"=>{"__content__"=>"84", "Units"=>"hundredths-pounds"}, # "Weight"=>{"__content__"=>"84", "Units"=>"hundredths-pounds"},
# "Width"=>{"__content__"=>"504", "Units"=>"hundredths-inches"} # "Width"=>{"__content__"=>"504", "Units"=>"hundredths-inches"}
# }, # },
# "ProductGroup"=>"Book", # "ProductGroup"=>"Book",
# "ProductTypeName"=>"ABIS_BOOK", # "ProductTypeName"=>"ABIS_BOOK",
# "PublicationDate"=>"2015-04-23", # "PublicationDate"=>"2015-04-23",
# "Publisher"=>"Fourth Estate", # "Publisher"=>"Fourth Estate",
# "ReleaseDate"=>"2015-04-23", # "ReleaseDate"=>"2015-04-23",
# "Studio"=>"Fourth Estate", # "Studio"=>"Fourth Estate",
# "Title"=>"All the Light We Cannot See", # "Title"=>"All the Light We Cannot See",
# "TradeInValue"=>{ # "TradeInValue"=>{
# "Amount"=>"50", "CurrencyCode"=>"GBP", "FormattedPrice"=>"£0.50" # "Amount"=>"50", "CurrencyCode"=>"GBP", "FormattedPrice"=>"£0.50"
# } # }
# }, # },
# "OfferSummary"=>{ # "OfferSummary"=>{
# "LowestNewPrice"=>{ # "LowestNewPrice"=>{
# "Amount"=>"399", "CurrencyCode"=>"GBP", "FormattedPrice"=>"£3.99" # "Amount"=>"399", "CurrencyCode"=>"GBP", "FormattedPrice"=>"£3.99"
# }, # },
# "LowestUsedPrice"=>{"Amount"=>"263", "CurrencyCode"=>"GBP", "FormattedPrice"=>"£2.63"}, # "LowestUsedPrice"=>{"Amount"=>"263", "CurrencyCode"=>"GBP", "FormattedPrice"=>"£2.63"},
# "TotalNew"=>"20", # "TotalNew"=>"20",
# "TotalUsed"=>"7", # "TotalUsed"=>"7",
# "TotalCollectible"=>"0", # "TotalCollectible"=>"0",
# "TotalRefurbished"=>"0" # "TotalRefurbished"=>"0"
# } # }
# } # }
\ No newline at end of file
- if @recommend_products.present? - if @recommend_products.present?
.row.recommends .row.recommends
- @recommend_products.each do |product| - @recommend_products.each do |product|
= render "products/recommend_item", product: product = render "products/recommend_item", product: product
- if @products.present? - if @products.present?
.products .products
- @products.each do |product| - @products.each do |product|
= render "products/item", product: product = render "products/item", product: product
.text-center .text-center
= paginate @products = paginate @products
\ No newline at end of file \ No newline at end of file
- if @products.present? - if @products.present?
.products .products
- @products.each do |product| - @products.each do |product|
= render "products/item", product: product = render "products/item", product: product
.text-center .text-center
= paginate @products = paginate @products
\ No newline at end of file \ No newline at end of file
...@@ -22,7 +22,7 @@ html ...@@ -22,7 +22,7 @@ html
= render_breadcrumbs :separator => ' / ' = render_breadcrumbs :separator => ' / '
.row.mar-top-20 .row.mar-top-20
.col-sm-4 .col-sm-4
= render 'shared/categories' = render 'shared/categories'
.col-sm-8 .col-sm-8
= yield = yield
.clearfix .clearfix
......
.row.mar-bot-20 .row.mar-bot-20
.col-lg-7 .col-lg-7
.wrap-img.mar-r-10 .wrap-img.mar-r-10
= image_tag product.image.thumb('51x32#').url = image_tag product.image.thumb('51x32#').url
.title= link_to product.title, product_path(product) .title= link_to product.title, product_path(product)
.col-lg-5 .col-lg-5
= "Price: #{currency_number(product.currency, product.price)}" = "Price: #{currency_number(product.currency, product.price)}"
.col-sm-4 .col-sm-4
h4= product.title h4= product.title
= image_tag product.image.thumb('71x38>') = image_tag product.image.thumb('71x38>')
\ No newline at end of file \ No newline at end of file
ul.list-group ul.list-group
- @categories.each do |cate| - @categories.each do |cate|
= link_to cate.name, category_path(cate), class: 'list-group-item' = link_to cate.name, category_path(cate), class: 'list-group-item'
\ No newline at end of file \ No newline at end of file
#search-bar #search-bar
= form_tag search_path, class: "form-horizontal", method: "GET" do |f| = form_tag search_path, class: "form-horizontal", method: "GET" do |f|
.row .row
.col-sm-9 .col-sm-9
= text_field_tag :keyword, params[:keyword], placeholder: "Keyword", class: "form-control" = text_field_tag :keyword, params[:keyword], placeholder: "Keyword", class: "form-control"
.col-sm-3 .col-sm-3
= submit_tag "Search", class: "btn btn-primary" = submit_tag "Search", class: "btn btn-primary"
p p
| Hello | Hello
= @resource.email = @resource.email
| ! | !
p p
......
namespace :crawler do namespace :crawler do
task :aws => :environment do task :aws => :environment do
# categories name want to craw # categories name want to craw
categories = %w(Books Music Electronics Software Kitchen) categories = %w(Books Music Electronics Software Kitchen)
categories.each do |search_cate| categories.each do |search_cate|
category = Category.find_or_create_by(name: search_cate) category = Category.find_or_create_by(name: search_cate)
(1..5).each do |page| (1..5).each do |page|
...@@ -13,7 +13,7 @@ namespace :crawler do ...@@ -13,7 +13,7 @@ namespace :crawler do
'SearchIndex' => search_cate, 'SearchIndex' => search_cate,
'ItemPage' => page, 'ItemPage' => page,
'ResponseGroup' => 'Medium' 'ResponseGroup' => 'Medium'
} }
}) })
items = VacuumAwsService.parse_items(response) items = VacuumAwsService.parse_items(response)
......
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