Commit f6cdd883 by Truong Ba Dieu

Restruct space

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