Commit 7f6a553a by Vy Quoc Vu

better

parent a7655c6e
...@@ -5,6 +5,8 @@ gem 'bootstrap-sass', '3.2.0.0' ...@@ -5,6 +5,8 @@ gem 'bootstrap-sass', '3.2.0.0'
gem 'will_paginate-bootstrap' gem 'will_paginate-bootstrap'
gem 'bootstrap-will_paginate', '0.0.10' gem 'bootstrap-will_paginate', '0.0.10'
gem 'faker', '1.4.2' gem 'faker', '1.4.2'
gem 'sunspot_rails'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails' # Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.2.3' gem 'rails', '4.2.3'
...@@ -46,6 +48,8 @@ group :development, :test do ...@@ -46,6 +48,8 @@ group :development, :test do
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
gem 'spring' gem 'spring'
gem 'sunspot_solr'
end end
......
...@@ -127,6 +127,7 @@ GEM ...@@ -127,6 +127,7 @@ GEM
nenv (~> 0.1) nenv (~> 0.1)
shellany (~> 0.0) shellany (~> 0.0)
orm_adapter (0.5.0) orm_adapter (0.5.0)
pr_geohash (1.0.0)
pry (0.10.1) pry (0.10.1)
coderay (~> 1.1.0) coderay (~> 1.1.0)
method_source (~> 0.8.1) method_source (~> 0.8.1)
...@@ -171,6 +172,8 @@ GEM ...@@ -171,6 +172,8 @@ GEM
json (~> 1.4) json (~> 1.4)
responders (2.1.0) responders (2.1.0)
railties (>= 4.2.0, < 5) railties (>= 4.2.0, < 5)
rsolr (1.0.12)
builder (>= 2.1.2)
ruby-progressbar (1.7.5) ruby-progressbar (1.7.5)
sass (3.4.16) sass (3.4.16)
sass-rails (5.0.3) sass-rails (5.0.3)
...@@ -191,6 +194,14 @@ GEM ...@@ -191,6 +194,14 @@ GEM
actionpack (>= 3.0) actionpack (>= 3.0)
activesupport (>= 3.0) activesupport (>= 3.0)
sprockets (>= 2.8, < 4.0) sprockets (>= 2.8, < 4.0)
sunspot (2.2.0)
pr_geohash (~> 1.0)
rsolr (~> 1.0.7)
sunspot_rails (2.2.0)
nokogiri
rails (>= 3)
sunspot (= 2.2.0)
sunspot_solr (2.2.0)
thor (0.19.1) thor (0.19.1)
thread_safe (0.3.5) thread_safe (0.3.5)
tilt (1.4.1) tilt (1.4.1)
...@@ -236,6 +247,8 @@ DEPENDENCIES ...@@ -236,6 +247,8 @@ DEPENDENCIES
sass-rails (~> 5.0) sass-rails (~> 5.0)
sdoc (~> 0.4.0) sdoc (~> 0.4.0)
spring spring
sunspot_rails
sunspot_solr
turbolinks turbolinks
uglifier (>= 1.3.0) uglifier (>= 1.3.0)
vacuum vacuum
......
...@@ -8,6 +8,24 @@ ...@@ -8,6 +8,24 @@
box-sizing: border-box; box-sizing: border-box;
} }
select {
outline: 0;
overflow: hidden;
height: 30px;
background: #2c343c;
color: #747a80;
border: #2c343c;
padding: 5px 3px 5px 10px;
-moz-border-radius: 6px;
-webkit-border-radius: 6px;
border-radius: 10px;
}
select option {border: 1px solid #000; background: #010;}
/* universal */ /* universal */
.container { .container {
padding-top: 10px; padding-top: 10px;
......
...@@ -7,16 +7,16 @@ class Admins::CartsController < ApplicationController ...@@ -7,16 +7,16 @@ class Admins::CartsController < ApplicationController
end end
def edit def edit
if admin_signed_in? && !params[:cart][:status].nil? && !params[:cart][:status].empty? if admin_signed_in? && !params[:status].nil? && !params[:status].empty?
@cart = Cart.find(params[:id]) @cart = Cart.find(params[:id])
if @cart.status == params[:cart][:status] if @cart.status == params[:status]
flash[:danger] = "Notthing change!" flash[:danger] = "Notthing change!"
redirect_to :back redirect_to action: :index
else else
@cart.status = params[:cart][:status] @cart.status = params[:status]
@cart.save @cart.save
flash[:success] = "Success!" flash[:success] = "Success!"
redirect_to :back redirect_to action: :index
end end
else else
flash[:danger] = "Notthing change!" flash[:danger] = "Notthing change!"
......
class Admins::ProductsController < ApplicationController class Admins::ProductsController < ApplicationController
def new def new
@product = Product.new if admin_signed_in?
@product = Product.new
else
flash[:danger] = "only admin!"
redirect_to root_path
end
end
def index
if admin_signed_in?
@products = Product.all
else
flash[:danger] = "only admin!"
redirect_to root_path
end
end end
def create def create
...@@ -19,15 +32,18 @@ class Admins::ProductsController < ApplicationController ...@@ -19,15 +32,18 @@ class Admins::ProductsController < ApplicationController
flash[:success] = "Success!" flash[:success] = "Success!"
redirect_to "/products/#{product.id}" redirect_to "/products/#{product.id}"
else else
flash[:danger] = "Wrong params!" flash[:danger] = "Wrong params! Please check name, price and image again."
redirect_to :action => :new redirect_to :action => :new
end end
else
flash[:danger] = "only admin!"
redirect_to root_path
end end
end end
def edit def edit
if admin_signed_in? if admin_signed_in?
if product_params[:price].to_i >= 0 && params[:category][:id].to_i > 0 && if product_params[:price].to_i > 0 && params[:category][:id].to_i > 0 &&
!product_params[:image].nil? && !product_params[:image].empty? && !product_params[:image].nil? && !product_params[:image].empty? &&
!product_params[:price].empty? && !product_params[:name].empty? && !product_params[:price].empty? && !product_params[:name].empty? &&
product_params[:price].to_i <= 999999 product_params[:price].to_i <= 999999
...@@ -41,9 +57,12 @@ class Admins::ProductsController < ApplicationController ...@@ -41,9 +57,12 @@ class Admins::ProductsController < ApplicationController
flash[:success] = "Success!" flash[:success] = "Success!"
redirect_to "/products/#{product.id}" redirect_to "/products/#{product.id}"
else else
flash[:danger] = "Wrong params!" flash[:danger] = "Wrong params! Please check name, price and image again."
redirect_to :action => :new redirect_to :back
end end
else
flash[:danger] = "only admin!"
redirect_to root_path
end end
end end
...@@ -53,16 +72,15 @@ class Admins::ProductsController < ApplicationController ...@@ -53,16 +72,15 @@ class Admins::ProductsController < ApplicationController
@product.destroy @product.destroy
flash[:success] = "Deleted!" flash[:success] = "Deleted!"
redirect_to :back redirect_to :back
else
flash[:danger] = "only admin!"
redirect_to root_path
end end
end end
def show def show
if params[:id].to_i > 0 if params[:id].to_i > 0 && admin_signed_in?
if @product = Product.find(params[:id])
@product = Product.find(params[:id])
else
flash[:danger] = "Only Admin"
end
else else
redirect_to :action => :new redirect_to :action => :new
end end
......
...@@ -3,11 +3,11 @@ class CartProductsController < ApplicationController ...@@ -3,11 +3,11 @@ class CartProductsController < ApplicationController
include CategoriesHelper include CategoriesHelper
def add def add
if params[:id].nil? || params[:quantity].nil? if params[:id].nil?
flash[:danger] = "Product not found!" flash[:danger] = "Product not found!"
redirect_to :action => :index elsif params[:quantity].nil? || params[:quantity].to_i <= 0
end flash[:danger] = "Wrong quantity"
if params[:quantity].to_i > 0 elsif params[:quantity].to_i > 0
id = params[:id] id = params[:id]
if session[:cart] then if session[:cart] then
cart_product = session[:cart] cart_product = session[:cart]
...@@ -15,15 +15,14 @@ class CartProductsController < ApplicationController ...@@ -15,15 +15,14 @@ class CartProductsController < ApplicationController
session[:cart] ={} session[:cart] ={}
cart_product = session[:cart] cart_product = session[:cart]
end end
if cart_product[id] then if cart_product[id] then
cart_product[id] = cart_product[id] + params[:quantity].to_i cart_product[id] = cart_product[id] + params[:quantity].to_i
else else
cart_product[id] = params[:quantity].to_i cart_product[id] = params[:quantity].to_i
end end
flash[:success] = "success" flash[:success] = "success"
redirect_to :back
end end
redirect_to :back
end end
def remove def remove
...@@ -32,10 +31,14 @@ class CartProductsController < ApplicationController ...@@ -32,10 +31,14 @@ class CartProductsController < ApplicationController
end end
def update def update
if params[:new_quantity].nil? || params[:id].nil? byebug
if params[:id].nil?
flash[:danger] = "Product not found!" flash[:danger] = "Product not found!"
elsif params[:new_quantity].nil? || params[:new_quantity].to_i <= 0
flash[:danger] = "Wrong quantity"
else else
session[:cart][params[:id].to_s] = params[:new_quantity].to_i session[:cart][params[:id].to_s] = params[:new_quantity].to_i
flash[:success] = "Update success"
end end
redirect_to :action => :index redirect_to :action => :index
end end
......
...@@ -8,15 +8,17 @@ class CartsController < ApplicationController ...@@ -8,15 +8,17 @@ class CartsController < ApplicationController
end end
def create def create
if !session[:cart].nil? if session[:cart].nil?
flash[:danger] = "Your cart Empty"
redirect_to :action => "show"
else
new_cart = Cart.new(cart_params) new_cart = Cart.new(cart_params)
new_cart.total_price = calculate_total_price new_cart.total_price = calculate_total_price
new_cart.status = "In process" new_cart.status = "In process"
if user_signed_in? if user_signed_in?
new_cart.user_id = current_user.id new_cart.user_id = current_user.id
end end
new_cart.save if new_cart.save
if !new_cart.id.nil?
session[:cart].each do |id, quantity| session[:cart].each do |id, quantity|
cart_product = CartProduct.new cart_product = CartProduct.new
cart_product.cart_id = new_cart.id cart_product.cart_id = new_cart.id
...@@ -28,9 +30,11 @@ class CartsController < ApplicationController ...@@ -28,9 +30,11 @@ class CartsController < ApplicationController
Emailer.send_email_to(cart_params[:mail].to_s,session[:cart]).deliver Emailer.send_email_to(cart_params[:mail].to_s,session[:cart]).deliver
flash[:success] = "Success!" flash[:success] = "Success!"
session[:cart] = nil session[:cart] = nil
else
flash[:danger] = "Your mail, your address, your name"
redirect_to :back
end end
end end
redirect_to :action => "show"
end end
def info def info
......
class CategoriesController < ApplicationController class CategoriesController < ApplicationController
include CategoriesHelper include CategoriesHelper
def index
@categories = Category.all
end
def show def show
if !Category.exists?(params[:id])
flash[:danger] = "Category not found!"
params[:id] = 1
else
params[:id]
end
category = Category.find(params[:id]) category = Category.find(params[:id])
@products = category.products @products = category.products
end end
......
...@@ -3,21 +3,32 @@ class ProductsController < ApplicationController ...@@ -3,21 +3,32 @@ class ProductsController < ApplicationController
include CategoriesHelper include CategoriesHelper
def index def index
if !params[:page] || (params[:page].to_i == 0)
params[:page] = 1
else
params[:page]
end
@products = Product.paginate(page: params[:page], :per_page => 50) @products = Product.paginate(page: params[:page], :per_page => 50)
@search_products = Product.new @search_products = Product.new
end end
def show def show
if !Product.find(params[:id]).nil? if !Product.exists?(params[:id])
@product = Product.find(params[:id])
else
flash[:danger] = "Product not found!" flash[:danger] = "Product not found!"
redirect_to root_path
else
@product = Product.find(params[:id])
end end
end end
def search def search
if params[:product][:search] if params[:search]
@products = Product.search(params[:product][:search]).paginate(page: params[:page], :per_page => 50) if !params[:page] || (params[:page].to_i == 0)
params[:page] = 1
else
params[:page]
end
@products = Product.search(params[:search]).paginate(page: params[:page], :per_page => 50)
flash[:success] = "Success!" flash[:success] = "Success!"
else else
flash[:danger] = "Danger!" flash[:danger] = "Danger!"
......
module ApplicationHelper module ApplicationHelper
end end
class Cart < ActiveRecord::Base class Cart < ActiveRecord::Base
validates :name, presence: true, length: { maximum: 255 } validates :name, presence: true, length: { maximum: 255 }
validates :address, presence: true, length: { maximum: 65000 }
VALID_EMAIL_REGEX = /\A[\w+\-.]+@[a-z\d\-.]+\.[a-z]+\z/i VALID_EMAIL_REGEX = /\A[\w+\-.]+@[a-z\d\-.]+\.[a-z]+\z/i
validates :mail, presence: true, length: { maximum: 255 }, validates :mail, presence: true, length: { maximum: 255 },
format: { with: VALID_EMAIL_REGEX } format: { with: VALID_EMAIL_REGEX }
......
...@@ -20,13 +20,17 @@ ...@@ -20,13 +20,17 @@
<td><%= cart.name.to_s %></td> <td><%= cart.name.to_s %></td>
<td><%= number_to_currency(cart.total_price/100, :unit => "$")%></td> <td><%= number_to_currency(cart.total_price/100, :unit => "$")%></td>
<td><%= cart.address %></td> <td><%= cart.address %></td>
<%= form_for(cart, url: "/admins/carts/#{cart.id}/edit" ,method: :get ) do |f| %> <td style="color-font:red;"><%= cart.status %></td>
<td><%= f.text_field :status, value: cart.status.to_s, size: 10 , class: "create_input" %> <form action= "/admins/carts/<%=cart.id%>/edit" style="padding-left : 0px ; resize: vertical;" >
</td> <td><select class="form-control" id="status" name="status">
<td> <option>In process</option>
<%= f.submit "Submit" , class: "btn btn-primary" %> <option>Pending</option>
</td> <option>Shipping</option>
<% end %> <option>Done</option>
</select></td>
<input type="hidden" value=this.form['status'] , class="btn btn-primary"/>
<td><input type="submit" value="Update" style="font-size: 1em;" , class="btn btn-primary"/></td>
</form>
</tr> </tr>
<% end -%> <% end -%>
</tbody> </tbody>
......
<% if admin_signed_in? %>
<div class="row">
<td> <%= link_to "Add product", "/admins/products/new", class: "btn btn-lg btn-primary" %></td>
<table class="table">
<thead>
<tr>
<th>Id</th>
<th>Name</th>
<th>Price</th>
<th></th>
</tr>
</thead>
<tbody>
<% @products.each do |product|%>
<tr>
<td><%= product.id.to_s %></td>
<td><%= product.name.to_s %></td>
<td><%= number_to_currency(product.price/100, :unit => "$")%></td>
<td> <%= link_to "Edit", "/admins/products/#{product.id}", class: "btn btn-lg btn-primary" %></td>
<td> <%= link_to "delete", "/admins/destroy/#{product.id}", class: "btn btn-lg btn-danger" %></td>
</tr>
<% end -%>
</tbody>
</table>
</div>
<% end %>
...@@ -6,6 +6,8 @@ ...@@ -6,6 +6,8 @@
<%= f.label :price %> <%= f.label :price %>
<%= f.number_field :price, value: "", class: 'form-control' %> <%= f.number_field :price, value: "", class: 'form-control' %>
</br>
<%= f.label :Category %> <%= f.label :Category %>
<%= collection_select :category, :id, Category.all, :id, :name %> <%= collection_select :category, :id, Category.all, :id, :name %>
</br> </br>
......
<h2>Log in Admin</h2> <h2>Log in Admin</h2>
<div class="col-md-12"> <% if user_signed_in? %>
<div class="center jumbotron"> <% flash[:danger] = "Only admin"%>
<%= form_for(resource, as: resource_name, url: session_path(resource_name)) do |f| %> <%else%>
<div class="field"> <div class="col-md-12">
<%= f.label :email %><br /> <div class="center jumbotron">
<%= f.email_field :email, autofocus: true %> <%= form_for(resource, as: resource_name, url: session_path(resource_name)) do |f| %>
</div> <div class="field">
<%= f.label :email %><br />
<div class="field"> <%= f.email_field :email, autofocus: true %>
<%= f.label :password %><br /> </div>
<%= f.password_field :password, autocomplete: "off" %>
</div>
<% if devise_mapping.rememberable? -%>
<div class="field"> <div class="field">
<%= f.check_box :remember_me %> <%= f.label :password %><br />
<%= f.label :remember_me %> <%= f.password_field :password, autocomplete: "off" %>
</div> </div>
<% end -%>
<div class="actions"> <% if devise_mapping.rememberable? -%>
<%= f.submit "Log in" %> <div class="field">
</div> <%= f.check_box :remember_me %>
<% end %> <%= f.label :remember_me %>
</div> </div>
</div> <% end -%>
<%= render "admins/shared/links" %> <div class="actions">
<%= f.submit "Log in" %>
</div>
<% end %>
</div>
</div>
<%= render "admins/shared/links" %>
<% end -%>
...@@ -22,3 +22,4 @@ ...@@ -22,3 +22,4 @@
<%= link_to "Pay", "/cart", class: "btn btn-lg btn-danger"%> <%= link_to "Pay", "/cart", class: "btn btn-lg btn-danger"%>
<%= link_to "info", "/carts", class: "btn btn-lg btn-success"%> <%= link_to "info", "/carts", class: "btn btn-lg btn-success"%>
</ul> </ul>
<a href="/carts/show" class="glyphicon glyphicon-shopping-cart">Ordered cart</a>
\ No newline at end of file
<h1>Your Cart</h1>
<div class="col-md-3"> <div class="col-md-3">
<% if !admin_signed_in? %> <% if !admin_signed_in? %>
<%= render 'layouts/cart' %> <%= render 'layouts/cart' %>
...@@ -6,6 +5,7 @@ ...@@ -6,6 +5,7 @@
<% end %> <% end %>
</div> </div>
<div class="col-md-9"> <div class="col-md-9">
<h1>Your Cart</h1>
<div class="col-md-12"> <div class="col-md-12">
<form class="navbar-left" style="padding-left: 0px" > <form class="navbar-left" style="padding-left: 0px" >
<%= link_to "Empty Cart" ,'/cart_product/clear' %> <%= link_to "Empty Cart" ,'/cart_product/clear' %>
......
<h1>Show cart</h1>
<div class="col-md-3" style=" padding-top: 50px;"> <div class="col-md-3" style=" padding-top: 50px;">
<% if !admin_signed_in? %>
<%= render 'layouts/cart' %> <%= render 'layouts/cart' %>
<%= render 'categories/view' %> <%= render 'categories/view' %>
<% end %>
</div> </div>
<div class="col-md-9" style=" padding-top: 50px;"> <div class="col-md-9" style=" padding-top: 50px;">
<ul> <ul>
......
<div class="col-md-3" style=" padding-top: 50px;">
<%= render 'layouts/cart' %>
<%= render 'categories/view' %>
</div>
<div class="col-md-9" style=" padding-top: 50px;">
<ul>
<% if !@categories.nil? %>
<table class="table">
<thead>
<tr>
<th>Id</th>
<th>Name</th>
<th></th>
</tr>
</thead>
<tbody>
<% @categories.each do |category|%>
<tr>
<td><%= category.id.to_s %></td>
<td><%= link_to category.name, "/categories/#{category.id}" %></td>
</tr>
<% end -%>
</tbody>
</table>
<% else -%>
<h2> Your cart Empty </h2>
<% end -%>
</ul>
</div>
<div class="col-md-3" > <div class="col-md-3" >
<% if !admin_signed_in? %> <% if !admin_signed_in? %>
<%= render 'layouts/cart' %> <%= render 'layouts/cart' %>
...@@ -12,13 +13,15 @@ ...@@ -12,13 +13,15 @@
<h5><%= truncate(product.name, length: 22) %></h5> <h5><%= truncate(product.name, length: 22) %></h5>
<%= (product.price/100.to_f).to_s + "$" %> <%= (product.price/100.to_f).to_s + "$" %>
</br> </br>
<% if admin_signed_in? %> <div>
<%= link_to "Edit", "/admins/products/#{product.id}", class: "btn btn-lg btn-primary" %> <form action="/cart_products" style="padding-left : 0px" >
<%= link_to "delete", "/admins/destroy/#{product.id}", class: "btn btn-lg btn-danger" %> <input type="number" name="quantity" value= "1" min="1" max="100">
<%else %> </br>
<%= link_to "Info", "/products/#{product.id}", class: "btn btn-lg btn-info" %> <input type="submit" value="Add" class = "btn btn-lg btn-success" />
<%= link_to "Buy", "/products/#{product.id}", class: "btn btn-lg btn-danger" %> <%= link_to "Detail", "/products/#{product.id}", class: "btn btn-lg btn-info" %>
<%end %> <input type="hidden" name="id" value="<%= product.id %>"/>
</form>
</div>
</div> </div>
</div> </div>
<% end -%> <% end -%>
......
<h2>Sign up Devise</h2> <h2>Sign up Devise</h2>
<div class="col-md-12"> <% if user_signed_in? || admin_signed_in? %>
<div class="center jumbotron"> <%flash[:danger] = "Signed in"%>
<%= form_for(resource, as: resource_name, url: registration_path(resource_name)) do |f| %> <%else%>
<%= devise_error_messages! %> <div class="col-md-12">
<div class="center jumbotron">
<%= form_for(resource, as: resource_name, url: registration_path(resource_name)) do |f| %>
<%= devise_error_messages! %>
<div class="field"> <div class="field">
<%= f.label :email %><br /> <%= f.label :email %><br />
<%= f.email_field :email, autofocus: true %> <%= f.email_field :email, autofocus: true %>
</div> </div>
<div class="field"> <div class="field">
<%= f.label :password %> <%= f.label :password %>
<% if @minimum_password_length %> <% if @minimum_password_length %>
<em>(<%= @minimum_password_length %> characters minimum)</em> <em>(<%= @minimum_password_length %> characters minimum)</em>
<% end %><br /> <% end %><br />
<%= f.password_field :password, autocomplete: "off" %> <%= f.password_field :password, autocomplete: "off" %>
</div> </div>
<div class="field"> <div class="field">
<%= f.label :password_confirmation %><br /> <%= f.label :password_confirmation %><br />
<%= f.password_field :password_confirmation, autocomplete: "off" %> <%= f.password_field :password_confirmation, autocomplete: "off" %>
</div> </div>
<div class="actions"> <div class="actions">
<%= f.submit "Sign up" %> <%= f.submit "Sign up" %>
</div> </div>
<% end %> <% end %>
</div>
</div> </div>
</div> <%= render "devise/shared/links" %>
<%end%>
\ No newline at end of file
<%= render "devise/shared/links" %>
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
<h3><%=link_to("Home", root_path )%></h3> <h3><%=link_to("Home", root_path )%></h3>
</li> </li>
<li> <li>
<h3><%=link_to("Products", new_admins_product_path )%></h3> <h3><%=link_to("Products", '/admins/products' )%></h3>
</li> </li>
<li> <li>
<h3><%=link_to("Carts", '/admins/carts' )%></h3> <h3><%=link_to("Carts", '/admins/carts' )%></h3>
......
...@@ -4,7 +4,13 @@ ...@@ -4,7 +4,13 @@
<div class="container-fluid"> <div class="container-fluid">
<!-- Brand and toggle get grouped for better mobile display --> <!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header"> <div class="navbar-header">
<a class="navbar-brand" href= "/" > Venshop </a> <table>
<td><a class="navbar-brand" href= "/" > Venshop </a></td>
<form action= "/search" style="padding-left : 100px ; resize: vertical;" method="get" class="navbar-brand" >
<td ><input type="text" name="search" value="" , class="form-control"/></td>
<td style="padding-left : 20px" ><input type="submit" value="Search" style="font-size: 1em;" , class="btn btn-primary"/></td>
</form>
</table>
</div> </div>
<!-- Collect the nav links, forms, and other content for toggling --> <!-- Collect the nav links, forms, and other content for toggling -->
...@@ -12,6 +18,7 @@ ...@@ -12,6 +18,7 @@
<ul class="nav navbar-nav navbar-right"> <ul class="nav navbar-nav navbar-right">
<% if user_signed_in? || admin_signed_in? %> <% if user_signed_in? || admin_signed_in? %>
<li> <li>
<li>
<span class="glyphicon glyphicon-log-out"> <span class="glyphicon glyphicon-log-out">
<%= link_to "Log out", destroy_user_session_path, method: "delete" %> <%= link_to "Log out", destroy_user_session_path, method: "delete" %>
</span> </span>
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
<% @products.each do |product| %> <% @products.each do |product| %>
<div class="col-md-4" style="padding-top : 20px"> <div class="col-md-4" style="padding-top : 20px">
<div> <div>
<%= image_tag(product.image, size: "180x230")%> <%= image_tag(product.image, size: "200x250")%>
<%= simple_format(truncate(product.name, length:21)) %> <%= simple_format(truncate(product.name, length:21)) %>
</div> </div>
<div> <div>
......
...@@ -3,19 +3,19 @@ ...@@ -3,19 +3,19 @@
<% @products.each do |product| %> <% @products.each do |product| %>
<div class="col-md-4" style="padding-top : 20px"> <div class="col-md-4" style="padding-top : 20px">
<div> <div>
<%= image_tag(product.image, size: "180x230")%> <%= image_tag(product.image, size: "200x250")%>
<%= simple_format(truncate(product.name, length:21)) %> <%= simple_format(truncate(product.name, length:21)) %>
<%= (product.price/100.to_f).to_s + "$" %> <%= (product.price/100.to_f).to_s + "$" %>
</div> </div>
<div> <div>
<form action="/cart_products" style="padding-left : 0px" > <form action="/cart_products" style="padding-left : 0px" >
<input type="number" name="quantity" value= "1" min="1" max="100"> <input type="number" name="quantity" value= "1" min="1" max="100">
</br> </br>
<input type="submit" value="Add" class = "btn btn-lg btn-success" /> <input type="submit" value="Add" class = "btn btn-lg btn-success" />
<%= link_to "Detail", "/products/#{product.id}", class: "btn btn-lg btn-info" %> <%= link_to "Detail", "/products/#{product.id}", class: "btn btn-lg btn-info" %>
<input type="hidden" name="id" value="<%= product.id %>"/> <input type="hidden" name="id" value="<%= product.id %>"/>
</form> </form>
</div> </div>
</div> </div>
<% end %> <% end %>
</div> </div>
......
<div class="row"> <div class="row">
<div class="col-md-3"> <div class="col-md-3">
<% if !admin_signed_in? %>
<%= render 'layouts/cart' %> <%= render 'layouts/cart' %>
<% end %>
<%= render 'categories/view' %> <%= render 'categories/view' %>
</div> </div>
<div class="col-md-9" > <div class="col-md-9" >
<div class="form-group"> <div class="form-group">
<table class="table">
<tr>
<%= form_for(@search_products, url: "search", method: :get) do |f| %>
<th class="col-md-6">
<%= f.text_field :search, value: "" ,class: 'form-control' %>
</th>
<th>
<%= f.submit "Search" , class: "btn btn-primary" %>
</th>
<% end %>
</tr>
</table>
</div>
<% if admin_signed_in? %>
<%= render 'products/admin_products' %>
<% else %>
<%= render 'products/custom_products' %> <%= render 'products/custom_products' %>
<% end %>
</div> </div>
</div> </div>
\ No newline at end of file
...@@ -5,10 +5,6 @@ ...@@ -5,10 +5,6 @@
<% end %> <% end %>
</div> </div>
<div class="col-md-9" > <div class="col-md-9" >
<% if admin_signed_in? %>
<%= render 'products/admin_products' %>
<% else %>
<%= render 'products/custom_products' %> <%= render 'products/custom_products' %>
<% end %>
</div> </div>
</div> </div>
\ No newline at end of file
<h2>Log in user</h2> <h2>Log in user</h2>
<div class="col-md-12"> <% if user_signed_in? || admin_signed_in? %>
<div class="center jumbotron"> <%flash[:danger] = "Signed in"%>
<%= form_for(resource, as: resource_name, url: session_path(resource_name)) do |f| %> <%else%>
<div class="field"> <div class="col-md-12">
<%= f.label :email %><br /> <div class="center jumbotron">
<%= f.email_field :email, autofocus: true %> <%= form_for(resource, as: resource_name, url: session_path(resource_name)) do |f| %>
</div> <div class="field">
<%= f.label :email %><br />
<div class="field"> <%= f.email_field :email, autofocus: true %>
<%= f.label :password %><br /> </div>
<%= f.password_field :password, autocomplete: "off" %>
</div>
<% if devise_mapping.rememberable? -%>
<div class="field"> <div class="field">
<%= f.check_box :remember_me %> <%= f.label :password %><br />
<%= f.label :remember_me %> <%= f.password_field :password, autocomplete: "off" %>
</div> </div>
<% end -%>
<div class="actions"> <% if devise_mapping.rememberable? -%>
<%= f.submit "Log in" %> <div class="field">
</div> <%= f.check_box :remember_me %>
<% end %> <%= f.label :remember_me %>
</div> </div>
</div> <% end -%>
<%= render "users/shared/links" %> <div class="actions">
<%= f.submit "Log in" %>
</div>
<% end %>
</div>
</div>
<%= render "users/shared/links" %>
<% end -%>
\ No newline at end of file
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
get '/admins/destroy/:id' => 'admins/products#destroy', as: 'destroy_product' get '/admins/destroy/:id' => 'admins/products#destroy', as: 'destroy_product'
get '/admins/carts' => 'admins/carts#index' , as: 'admins_carts_index' get '/admins/carts' => 'admins/carts#index' , as: 'admins_carts_index'
get '/admins/users' => 'admins/users#index' get '/admins/users' => 'admins/users#index'
get '/admins/search' =>'products#search'
patch "/admins/products/:id/edit"=>'admins/products#edit' patch "/admins/products/:id/edit"=>'admins/products#edit'
patch "/admins/carts/:id/edit" => 'admins/carts#edit' patch "/admins/carts/:id/edit" => 'admins/carts#edit'
......
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<!-- The content of this page will be statically included into the top
of the admin page. Uncomment this as an example to see there the content
will show up.
<hr>
<i>This line will appear before the first table</i>
<tr>
<td colspan="2">
This row will be appended to the end of the first table
</td>
</tr>
<hr>
-->
<?xml version="1.0" encoding="UTF-8" ?>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<!-- If this file is found in the config directory, it will only be
loaded once at startup. If it is found in Solr's data
directory, it will be re-loaded every commit.
-->
<elevate>
<query text="foo bar">
<doc id="1" />
<doc id="2" />
<doc id="3" />
</query>
<query text="ipod">
<doc id="MA147LL/A" /> <!-- put the actual ipod at the top -->
<doc id="IW-02" exclude="true" /> <!-- exclude this cable -->
</query>
</elevate>
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Syntax:
# "source" => "target"
# "source".length() > 0 (source cannot be empty.)
# "target".length() >= 0 (target can be empty.)
# example:
# "À" => "A"
# "\u00C0" => "A"
# "\u00C0" => "\u0041"
# "ß" => "ss"
# "\t" => " "
# "\n" => ""
# À => A
"\u00C0" => "A"
# Á => A
"\u00C1" => "A"
# Â => A
"\u00C2" => "A"
# Ã => A
"\u00C3" => "A"
# Ä => A
"\u00C4" => "A"
# Å => A
"\u00C5" => "A"
# Æ => AE
"\u00C6" => "AE"
# Ç => C
"\u00C7" => "C"
# È => E
"\u00C8" => "E"
# É => E
"\u00C9" => "E"
# Ê => E
"\u00CA" => "E"
# Ë => E
"\u00CB" => "E"
# Ì => I
"\u00CC" => "I"
# Í => I
"\u00CD" => "I"
# Î => I
"\u00CE" => "I"
# Ï => I
"\u00CF" => "I"
# IJ => IJ
"\u0132" => "IJ"
# Ð => D
"\u00D0" => "D"
# Ñ => N
"\u00D1" => "N"
# Ò => O
"\u00D2" => "O"
# Ó => O
"\u00D3" => "O"
# Ô => O
"\u00D4" => "O"
# Õ => O
"\u00D5" => "O"
# Ö => O
"\u00D6" => "O"
# Ø => O
"\u00D8" => "O"
# Œ => OE
"\u0152" => "OE"
# Þ
"\u00DE" => "TH"
# Ù => U
"\u00D9" => "U"
# Ú => U
"\u00DA" => "U"
# Û => U
"\u00DB" => "U"
# Ü => U
"\u00DC" => "U"
# Ý => Y
"\u00DD" => "Y"
# Ÿ => Y
"\u0178" => "Y"
# à => a
"\u00E0" => "a"
# á => a
"\u00E1" => "a"
# â => a
"\u00E2" => "a"
# ã => a
"\u00E3" => "a"
# ä => a
"\u00E4" => "a"
# å => a
"\u00E5" => "a"
# æ => ae
"\u00E6" => "ae"
# ç => c
"\u00E7" => "c"
# è => e
"\u00E8" => "e"
# é => e
"\u00E9" => "e"
# ê => e
"\u00EA" => "e"
# ë => e
"\u00EB" => "e"
# ì => i
"\u00EC" => "i"
# í => i
"\u00ED" => "i"
# î => i
"\u00EE" => "i"
# ï => i
"\u00EF" => "i"
# ij => ij
"\u0133" => "ij"
# ð => d
"\u00F0" => "d"
# ñ => n
"\u00F1" => "n"
# ò => o
"\u00F2" => "o"
# ó => o
"\u00F3" => "o"
# ô => o
"\u00F4" => "o"
# õ => o
"\u00F5" => "o"
# ö => o
"\u00F6" => "o"
# ø => o
"\u00F8" => "o"
# œ => oe
"\u0153" => "oe"
# ß => ss
"\u00DF" => "ss"
# þ => th
"\u00FE" => "th"
# ù => u
"\u00F9" => "u"
# ú => u
"\u00FA" => "u"
# û => u
"\u00FB" => "u"
# ü => u
"\u00FC" => "u"
# ý => y
"\u00FD" => "y"
# ÿ => y
"\u00FF" => "y"
# ff => ff
"\uFB00" => "ff"
# fi => fi
"\uFB01" => "fi"
# fl => fl
"\uFB02" => "fl"
# ffi => ffi
"\uFB03" => "ffi"
# ffl => ffl
"\uFB04" => "ffl"
# ſt => ft
"\uFB05" => "ft"
# st => st
"\uFB06" => "st"
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#-----------------------------------------------------------------------
# Use a protected word file to protect against the stemmer reducing two
# unrelated words to the same base word.
# Some non-words that normally won't be encountered,
# just to test that they won't be stemmed.
dontstems
zwhacky
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
user=
solr_hostname=localhost
solr_port=8983
rsyncd_port=18983
data_dir=
webapp_name=solr
master_host=
master_data_dir=
master_status_dir=
pizza
history
\ No newline at end of file
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#-----------------------------------------------------------------------
# a couple of test stopwords to test that the words are really being
# configured from this file:
stopworda
stopwordb
#Standard english stop words taken from Lucene's StopAnalyzer
a
an
and
are
as
at
be
but
by
for
if
in
into
is
it
no
not
of
on
or
s
such
t
that
the
their
then
there
these
they
this
to
was
will
with
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#-----------------------------------------------------------------------
#some test synonym mappings unlikely to appear in real input text
aaa => aaaa
bbb => bbbb1 bbbb2
ccc => cccc1,cccc2
a\=>a => b\=>b
a\,a => b\,b
fooaaa,baraaa,bazaaa
# Some synonym groups specific to this example
GB,gib,gigabyte,gigabytes
MB,mib,megabyte,megabytes
Television, Televisions, TV, TVs
#notice we use "gib" instead of "GiB" so any WordDelimiterFilter coming
#after us won't split it into two words.
# Synonym mappings can be used for spelling correction too
pixima => pixma
<?xml version="1.0" encoding="UTF-8" ?>
<solr persistent="false">
<cores adminPath="/admin/cores" host="${host:}" hostPort="${jetty.port:}">
<core name="default" instanceDir="." dataDir="default/data"/>
<core name="development" instanceDir="." dataDir="development/data"/>
<core name="test" instanceDir="." dataDir="test/data"/>
</cores>
</solr>
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