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
- 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