Skip to content

Commit

Permalink
fixed markup
Browse files Browse the repository at this point in the history
  • Loading branch information
pedropereira committed Nov 12, 2011
2 parents eaed23b + 00d0c4b commit 33f67d9
Show file tree
Hide file tree
Showing 104 changed files with 1,527 additions and 24 deletions.
2 changes: 2 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ gem 'jquery-rails'
gem 'devise'
gem "nifty-generators"
gem 'formtastic'
gem 'sunspot_rails'
gem 'qrencoder'

# To use ActiveModel has_secure_password
# gem 'bcrypt-ruby', '~> 3.0.0'
Expand Down
17 changes: 17 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ GEM
arel (2.2.1)
bcrypt-ruby (3.0.1)
builder (3.0.0)
chunky_png (1.2.5)
coffee-rails (3.1.1)
coffee-script (>= 2.2.0)
railties (~> 3.1.0)
Expand All @@ -45,6 +46,7 @@ GEM
orm_adapter (~> 0.0.3)
warden (~> 1.0.3)
erubis (2.7.0)
escape (0.0.4)
execjs (1.2.9)
multi_json (~> 1.0)
formtastic (2.0.2)
Expand All @@ -65,8 +67,12 @@ GEM
metaclass (~> 0.0.1)
multi_json (1.0.3)
nifty-generators (0.4.6)
nokogiri (1.5.0)
orm_adapter (0.0.5)
polyglot (0.3.3)
pr_geohash (1.0.0)
qrencoder (1.4.0)
chunky_png (~> 1.1)
rack (1.3.5)
rack-cache (1.1)
rack (>= 0.4)
Expand Down Expand Up @@ -94,6 +100,8 @@ GEM
rake (0.9.2.2)
rdoc (3.11)
json (~> 1.4)
rsolr (0.12.1)
builder (>= 2.1.2)
sass (3.1.10)
sass-rails (3.1.4)
actionpack (~> 3.1.0)
Expand All @@ -106,6 +114,13 @@ GEM
rack (~> 1.0)
tilt (!= 1.3.0, ~> 1.1)
sqlite3 (1.3.4)
sunspot (1.2.1)
escape (= 0.0.4)
pr_geohash (~> 1.0)
rsolr (= 0.12.1)
sunspot_rails (1.2.1)
nokogiri
sunspot (= 1.2.1)
thor (0.14.6)
tilt (1.3.3)
treetop (1.4.10)
Expand All @@ -130,8 +145,10 @@ DEPENDENCIES
jquery-rails
mocha
nifty-generators
qrencoder
rails (= 3.1.1)
sass-rails (~> 3.1.4)
sqlite3
sunspot_rails
turn
uglifier (>= 1.0.3)
3 changes: 3 additions & 0 deletions app/assets/javascripts/categories.js.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/
3 changes: 3 additions & 0 deletions app/assets/stylesheets/categories.css.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// Place all the styles related to the categories controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/
15 changes: 11 additions & 4 deletions app/controllers/boxes_controller.rb
Original file line number Diff line number Diff line change
@@ -1,24 +1,31 @@
class BoxesController < ApplicationController

def index
@user_boxes = current_user.warehouses
def qrCode
Box.find(params[:box_id]).create_qr_code
end

def show
@box = Box.find params[:box_id]
@box = Box.find params[:id]
@warehouse = Warehouse.find params[:warehouse_id]
@items = @box.items
@item = Item.new
render "items/new"
end

def new
@warehouse = Warehouse.find params[:warehouse_id]
@box = Box.new
@boxes = @warehouse.boxes
@search = Box.search do
fulltext params[:search]
end
@boxes = @search.results
end

def create
@warehouse = Warehouse.find params[:warehouse_id]
@boxes = @warehouse.boxes
@box = Box.new params[:box]
@box.warehouse = @warehouse
if @box.save
flash[:notice] = "Yey, a box!"
redirect_to new_warehouse_box_item_path(@warehouse,@box)
Expand Down
7 changes: 7 additions & 0 deletions app/controllers/categories_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
class CategoriesController < ApplicationController

def new
@category = Category.new
end

end
23 changes: 22 additions & 1 deletion app/controllers/items_controller.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,31 @@
class ItemsController < ApplicationController

def show
@item = Item.find params[:id]
@box = Box.find params[:box_id]
@warehouse = Warehouse.find params[:warehouse_id]
end

def new
@box = Box.find params[:box_id]
@warehouse = Warehouse.find params[:warehouse_id]
@items = @box.items
@item = Item.new
@item = Item.new
end

def create
@box = Box.find params[:box_id]
@warehouse = Warehouse.find params[:warehouse_id]
@items = @box.items
@item = Item.create params[:item]
@item.box = @box
if @item.save
flash[:notice] = "Filling the little boxes"
render :new
else
flash[:error] = "Oh noes!"
render :new
end
end

end
10 changes: 9 additions & 1 deletion app/controllers/warehouses_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,16 @@ def index
end

def new
@warehouse = Warehouse.create
@warehouse = Warehouse.create :user => current_user
flash[:notice] = "Created Warehouse #{@warehouse.id}"
redirect_to new_warehouse_box_path(@warehouse)
end

def show
@warehouse = Warehouse.find params[:id]
@box = Box.new
@boxes = @warehouse.boxes
render "boxes/new"
end

end
2 changes: 2 additions & 0 deletions app/helpers/categories_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
module CategoriesHelper
end
12 changes: 11 additions & 1 deletion app/models/box.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,17 @@
class Box < ActiveRecord::Base
belongs_to :warehouse
has_many :items

validates_presence_of :description
validates_length_of :description, :maximum => 140

searchable do
text :description, :boost => 5
text :items do items.map(&:name) + items.map(&:description) end
end

def create_qr_code
p "Hello"
end

end
4 changes: 4 additions & 0 deletions app/models/item.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,8 @@ class Item < ActiveRecord::Base
belongs_to :box
belongs_to :category

validates_numericality_of :quantity,
:greater_than_or_equal_to =>0,
:only_integer => true

end
20 changes: 17 additions & 3 deletions app/views/boxes/new.html.erb
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
<% if user_signed_in? %>
<h2><%= "Warehouse #{@warehouse.id}" %></h2>
<% @boxes.each do |box| %>
<%= link_to "Box #{box.id}: #{box.description}", warehouse_box_path(@warehouse,box) %>
<% end %>
<ul class="boxes-list">
<% @boxes.each do |box| %>
<li>
<span class="box-link"><%= link_to "Box #{box.id}: #{box.description}", warehouse_box_path(@warehouse,box) %></span>
<span class="qr-link"><%= link_to "Create QR Code", warehouse_box_qrCode_path(@warehouse,box) %></span>
</li>
<% end %>
</ul>

<%= semantic_form_for @box, :url => warehouse_boxes_path(@warehouse) do |f| %>
<%= f.inputs do %>
Expand All @@ -12,4 +17,13 @@
<%= f.commit_button %>
<% end %>
<% end %>
<% content_for :sidebar do %>
<%= form_tag new_warehouse_box_path(@warehouse), :method => :get do %>
<p>
<%= text_field_tag :search, params[:search] %>
<%= submit_tag "Search", :name => nil %>
</p>
<% end %>
<% end %>
<% end %>
1 change: 1 addition & 0 deletions app/views/boxes/qrCode.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
HW
8 changes: 8 additions & 0 deletions app/views/categories/new.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<%= semantic_form_for @category, :url => categories_path do |f| %>
<%= f.inputs do %>
<%= f.input :name %>
<% end %>
<%= f.buttons do %>
<%= f.commit_button %>
<% end %>
<% end %>
15 changes: 11 additions & 4 deletions app/views/items/new.html.erb
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
<% if user_signed_in? %>
<% @items.each do |item| %>
<%= "Item #{item.id}: #{item.name}" %>
<% end %>
<ul class="items-list">
<% @items.each do |item| %>
<li><%= link_to "Item #{item.id}: #{item.name}", warehouse_box_item_path(@warehouse, @box, item), :method => :get %></li>
<% end %>
</ul>

<%= semantic_form_for @item, :url => warehouse_boxes_path(@warehouse,@box) do |f| %>
<%= semantic_form_for @item, :url => warehouse_box_items_path(@warehouse,@box) do |f| %>
<%= f.inputs do %>
<%= f.input :name %>
<%= f.input :description %>
Expand All @@ -14,4 +16,9 @@
<%= f.commit_button %>
<% end %>
<% end %>
<% content_for :sidebar do %>
<%= link_to "Boxes", warehouse_path(@warehouse) %>
<%= link_to "Category", new_category_path %>
<% end %>
<% end %>
10 changes: 10 additions & 0 deletions app/views/items/show.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<div class="item">
<span class="name"><%= @item.name %></span>
<span class="description"><%= @item.description %></span>
</div>

<% content_for :sidebar do %>
<%= link_to "Boxes", warehouse_path(@warehouse) %>
<%= link_to "Items", warehouse_box_path(@warehouse,@box) %>
<%= link_to "Category", new_category_path %>
<% end %>
9 changes: 7 additions & 2 deletions app/views/layouts/application.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
</head>

<body>
<div id="wrapper">
<div id="wrapper">
<div id="header">
<span id="product-name">Boxify</span>

Expand All @@ -34,7 +34,12 @@
<div id="main">
<%= yield %>
</div>

<div class="sidebar">
<%= link_to "Warehouses", warehouses_path %>
<%= yield :sidebar %>
</div>
</div>
</div>
</body>
</html>
</html>
12 changes: 5 additions & 7 deletions app/views/warehouses/index.html.erb
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
<% if user_signed_in? %>
<% if @warehouses.empty? %>
<%= button_to "Create Warehouse", new_warehouse_path, :method => :get %>
<% else %>
<% @warehouses.each do |warehouse| %>
<%= link_to "Warehouse #{warehouse.id}", warehouse_path(warehouse) %>
<% end %>
<% end %>
<% @warehouses.each do |warehouse| %>
<%= link_to "Warehouse #{warehouse.id}", warehouse_path(warehouse) %>
<% end %>
<%= button_to "Create Warehouse", new_warehouse_path, :method => :get %>
<% end %>
3 changes: 3 additions & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,12 @@

resources :warehouses do
resources :boxes do
get 'qrCode'
resources :items
end
end

resources :categories

# The priority is based upon order of creation:
# first created -> highest priority.
Expand Down
17 changes: 17 additions & 0 deletions config/sunspot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
production:
solr:
hostname: localhost
port: 8983
log_level: WARNING

development:
solr:
hostname: localhost
port: 8982
log_level: INFO

test:
solr:
hostname: localhost
port: 8981
log_level: WARNING
2 changes: 1 addition & 1 deletion db/migrate/20111110202456_create_boxes.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
class CreateBoxes < ActiveRecord::Migration
def up
create_table :boxes do |t|
t.string :description
t.string :description, :limit => 140
t.references :warehouse

t.timestamps
Expand Down
Empty file.
Loading

0 comments on commit 33f67d9

Please sign in to comment.