Permalink
Browse files

working copy

  • Loading branch information...
1 parent 3fe4db9 commit 3a852729bf69b6ad5e64047048397ce578edcca5 bzhang committed Jan 20, 2012
View
@@ -3,6 +3,7 @@ source 'http://rubygems.org'
gem 'rails', '3.1.3'
gem 'devise','1.5.2'
gem "omniauth-facebook"
+gem "koala"
gem "erb2haml", :group => :development
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
@@ -13,6 +14,8 @@ gem 'cells'
gem 'mongoid'
gem 'bson_ext'
gem 'savon'
+gem "puffer"
+gem "orm_adapter"
gem 'rest-client'
# Gems used only for assets and not required
# in production environments by default.
View
@@ -86,6 +86,9 @@ GEM
actionpack (>= 3.0.0)
activesupport (>= 3.0.0)
railties (>= 3.0.0)
+ koala (1.3.0)
+ faraday (~> 0.7.0)
+ multi_json (~> 1.0)
launchy (2.0.5)
addressable (~> 2.2.6)
mail (2.3.0)
@@ -121,6 +124,10 @@ GEM
orm_adapter (0.0.6)
pg (0.12.2)
polyglot (0.3.3)
+ puffer (0.1.0)
+ kaminari
+ orm_adapter
+ rails (~> 3.1.0)
rack (1.3.6)
rack-cache (1.1)
rack (>= 0.4)
@@ -203,11 +210,14 @@ DEPENDENCIES
heroku
jquery-rails
kaminari
+ koala
mocha
mongoid
nifty-generators
omniauth-facebook
+ orm_adapter
pg
+ puffer
rails (= 3.1.3)
rest-client
sass-rails (~> 3.1.5)
@@ -0,0 +1,41 @@
+class Admin::UsersController < Puffer::Base
+
+ setup do
+ group :users
+ end
+
+ index do
+ # field :id
+ field :email
+ field :encrypted_password
+ field :reset_password_token
+ field :reset_password_sent_at
+ field :remember_created_at
+ field :sign_in_count
+ field :current_sign_in_at
+ field :last_sign_in_at
+ field :current_sign_in_ip
+ field :last_sign_in_ip
+ # field :created_at
+ # field :updated_at
+ field :name
+ end
+
+ form do
+ # field :id
+ field :email
+ field :encrypted_password
+ field :reset_password_token
+ field :reset_password_sent_at
+ field :remember_created_at
+ field :sign_in_count
+ field :current_sign_in_at
+ field :last_sign_in_at
+ field :current_sign_in_ip
+ field :last_sign_in_ip
+ # field :created_at
+ # field :updated_at
+ field :name
+ end
+
+end
@@ -1,5 +1,8 @@
class ApplicationController < ActionController::Base
protect_from_forgery
+ def after_sign_in_path_for(resource)
+ return request.env['omniauth.origin'] || stored_location_for(resource) || root_path
+ end
end
@@ -5,9 +5,8 @@ def facebook
if @user.persisted?
flash[:notice] = I18n.t "devise.omniauth_callbacks.success", :kind => "Facebook"
- logger.info request.env["omniauth.auth"]["credentials"]
- session["name"] = request.env["omniauth.auth"]["extra"]["raw_info"]["name"]
- @user.update_attribute(:name,session["name"])
+ @user.update_attribute(:name,request.env["omniauth.auth"]["extra"]["raw_info"]["name"])
+ @user.update_attribute(:uid,request.env["omniauth.auth"]["extra"]["raw_info"]["id"])
sign_in_and_redirect @user, :event => :authentication
else
session["devise.facebook_data"] = request.env["omniauth.auth"]
@@ -0,0 +1,11 @@
+class UsersController < ApplicationController
+
+ def show
+ @user = User.find(params[:id])
+ end
+
+ def index
+ @users = User.all
+ end
+
+end
@@ -3,7 +3,7 @@
=image_tag product.thumbnail_url, :width=>90
.span6
%h4=link_to product.name, product
- %p=product.short_description
+ %p=raw product.short_description
.span2.price
%p= "Price: #{product.pprice}"
@@ -67,19 +67,21 @@
.tab-content
.tab-pane#desc{:class=>"#{params[:q]=='reviews' ? '' : 'active'}"}
- %p=@product.short_description
- %p=@product.long_description
+ %p.full_desc=raw @product.long_description
.tab-pane#specs
%p Curabitur ut lobortis enim. Fusce accumsan faucibus faucibus. In bibendum ipsum non odio eleifend pulvinar. Mauris eget augue a erat hendrerit sodales. Nullam adipiscing lorem nec est fermentum iaculis. Nulla facilisi. Integer tempus lacus nec ligula lacinia in vestibulum sem fermentum. Aliquam erat enim, malesuada eu pulvinar a, fermentum vel turpis. Sed ultricies odio sit amet enim suscipit quis gravida dolor malesuada. Aenean at odio lectus.
.tab-pane#reviews{:class=>"#{params[:q]=='reviews' ? 'active' : ''}"}
.row.span5#review
- =form_for @review do |f|
- =f.text_field :title,:placeholder=>"Title"
- =f.text_area :content,:rows=>4
- =f.hidden_field :user_id,:value=>current_user.id
- =f.hidden_field :product_id, :value=>@product.id
- =f.submit 'submit review',:class=>"btn"
+ -if current_user
+ =form_for @review do |f|
+ =f.text_field :title,:placeholder=>"Title"
+ =f.text_area :content,:rows=>4
+ =f.hidden_field :user_id,:value=>current_user.id
+ =f.hidden_field :product_id, :value=>@product.id
+ =f.submit 'submit review',:class=>"btn"
+ -else
+ =link_to 'sign in to leave a review',user_omniauth_authorize_path(:facebook)
=render @product.reviews.reverse
@@ -3,6 +3,6 @@
%p=review.content
.footer
posted by
- =link_to review.user.name, ''
+ =link_to review.user.name, review.user
#{time_ago_in_words(review.created_at)} ago
@@ -0,0 +1,12 @@
+%table.zebra-striped.bordered-table
+ %tr
+ %th name
+ %th join date
+ %th wishlist item count
+
+ - for user in @users
+ %tr
+ %td=link_to user.name, user
+ %td=l user.created_at.to_date,:format=>:long
+ %td= user.wishlist_items.count
+
@@ -0,0 +1,5 @@
+%h3=@user.name
+%h5 Wishlist Items
+=render @user.wishlist_items
+%h5 Following
+
@@ -7,4 +7,4 @@
.row
.span2 Price: #{product.price}
.span3 added #{time_ago_in_words(wishlist_item.created_at)} ago
- .span3=link_to 'remove from list', wishlist_item, :confirm => 'Are you sure?', :method => :delete, :class=>'btn danger'
+ .span3=link_to 'remove from list', wishlist_item, :confirm => 'Are you sure?', :method => :delete, :class=>'btn danger' if wishlist_item.wishlist.user==current_user
View
@@ -10,7 +10,7 @@
match 'populate/:class_name'=>"products#populate", :as=>"populate"
devise_for :users, :controllers => { :omniauth_callbacks => "users/omniauth_callbacks" }
-
+ resources :users
devise_scope :user do
get '/users/auth/:provider' => 'users/omniauth_callbacks#passthru'
end
@@ -0,0 +1,5 @@
+class AddUidToUsers < ActiveRecord::Migration
+ def change
+ add_column :users, :uid, :integer
+ end
+end
View
@@ -11,7 +11,7 @@
#
# It's strongly recommended to check this file into your version control system.
-ActiveRecord::Schema.define(:version => 20120110225740) do
+ActiveRecord::Schema.define(:version => 20120118231437) do
create_table "users", :force => true do |t|
t.string "email", :default => "", :null => false
@@ -27,6 +27,7 @@
t.datetime "created_at"
t.datetime "updated_at"
t.string "name"
+ t.integer "uid"
end
add_index "users", ["email"], :name => "index_users_on_email", :unique => true

0 comments on commit 3a85272

Please sign in to comment.