1
0
Fork 0
forked from OpenNeo/impress

neomail link on closets

This commit is contained in:
Emi Matchu 2011-07-20 15:16:22 -04:00
parent 02ef70f749
commit c5103b6557
12 changed files with 137 additions and 32 deletions

View file

@ -19,6 +19,10 @@ class ApplicationController < ActionController::Base
render :file => 'public/403.html', :layout => false, :status => :forbidden
end
def redirect_back!(default=:back)
redirect_to(params[:return_to] || default)
end
def user_is?(user)
user_signed_in? && user == current_user
end

View file

@ -36,7 +36,7 @@ class ClosetHangersController < ApplicationController
respond_to do |format|
format.html {
flash[:success] = "Success! You own #{@closet_hanger.quantity} #{@item.name.pluralize}."
redirect_back!
redirect_back!(@item)
}
format.json { render :json => true }
@ -45,7 +45,7 @@ class ClosetHangersController < ApplicationController
respond_to do |format|
format.html {
flash[:alert] = "We couldn't save how many of this item you own: #{@closet_hanger.errors.full_messages.to_sentence}"
redirect_back!
redirect_back!(@item)
}
format.json { render :json => {:errors => @closet_hanger.errors.full_messages}, :status => :unprocessable_entity }
@ -75,11 +75,7 @@ class ClosetHangersController < ApplicationController
def redirect_after_destroy!
flash[:success] = "Success! You do not own #{@item.name}."
redirect_back!
end
def redirect_back!
redirect_to params[:return_to] || @item
redirect_back!(@item)
end
end

View file

@ -1,5 +1,24 @@
class UsersController < ApplicationController
before_filter :find_and_authorize_user!, :only => [:update]
def top_contributors
@users = User.top_contributors.paginate :page => params[:page], :per_page => 20
end
def update
@user.update_attributes params[:user]
flash[:success] = "Settings successfully saved"
redirect_back! user_closet_hangers_path(@user)
end
protected
def find_and_authorize_user!
if current_user.id == params[:id].to_i
@user = current_user
else
raise AccessDenied
end
end
end

View file

@ -1,4 +1,10 @@
require 'cgi'
module ClosetHangersHelper
def send_neomail_url(user)
"http://www.neopets.com/neomessages.phtml?type=send&recipient=#{CGI.escape @user.neopets_username}"
end
def public_perspective?
@public_perspective
end

View file

@ -11,6 +11,8 @@ class User < ActiveRecord::Base
devise :rememberable
attr_accessible :neopets_username
def contribute!(pet)
new_contributions = []
new_points = 0

View file

@ -4,7 +4,7 @@
body.closet_hangers-index
#title
float: left
margin-bottom: .5em
margin-bottom: 0
.flash
clear: both
@ -28,6 +28,30 @@ body.closet_hangers-index
repeat: no-repeat
padding-left: $icon-width + 4px
#closet-hangers-contact
clear: both
font-size: 85%
margin-bottom: 1em
margin-left: 2em
min-height: image-height("neomail.png")
a
background:
image: image-url("neomail.png")
position: left center
repeat: no-repeat
padding-left: image-width("neomail.png") + 2px
input[type=text]
width: 10em
label
font-weight: bold
margin-right: .5em
&:after
content: ":"
#closet-hangers
clear: both
text-align: center

View file

@ -8,15 +8,27 @@
- else
- title "#{@user.name}'s Items"
- content_for :before_flashes do
#closet-hangers-contact
- if public_perspective?
- if @user.neopets_username?
= link_to "Neomail #{@user.neopets_username}", send_neomail_url(@user)
- else
= form_for @user do |f|
= f.label :neopets_username
= f.text_field :neopets_username
= f.submit "Save"
#closet-hangers{:class => public_perspective? ? nil : 'current-user'}
- if !@closet_hangers.empty?
- unless public_perspective?
- if public_perspective?
- if @closet_hangers.empty?
%p #{@user.name} hasn't tracked any items on Dress to Impress.
- else
- unless @closet_hangers.empty?
%p
These are the items you own. Hover over an item to remove it from the
list or to change the quantity.
= render :partial => 'closet_hanger', :collection => @closet_hangers, :locals => {:show_controls => user_is?(@user)}
- else
- unless public_perspective?
- else
%p You haven't tracked any items on Dress to Impress.
%p
Here you can keep track of what items you already own, so that as you
@ -27,8 +39,11 @@
It's easy to get started!
= link_to "Just import your Neopets closet in a few quick steps.", new_closet_page_path
Have fun!
- else
%p #{@user.name} hasn't tracked any items on Dress to Impress.
%p
You can share
= link_to "this page", request.fullpath
with the world, and they'll be able to see what items you own.
= render :partial => 'closet_hanger', :collection => @closet_hangers, :locals => {:show_controls => user_is?(@user)}
- content_for :stylesheets do
= stylesheet_link_tag 'south-street/jquery-ui'

View file

@ -35,7 +35,7 @@ OpenneoImpressItems::Application.routes.draw do |map|
match '/logout' => 'sessions#destroy', :as => :logout
match '/users/authorize' => 'sessions#create'
resources :user, :only => [] do
resources :users, :path => 'user', :only => [:update] do
resources :contributions, :only => [:index]
resources :closet_hangers, :only => [:index], :path => 'closet'

View file

@ -0,0 +1,9 @@
class AddNeopetsUsernameToUsers < ActiveRecord::Migration
def self.up
add_column :users, :neopets_username, :string
end
def self.down
remove_column :users, :neopets_username
end
end

View file

@ -10,7 +10,7 @@
#
# It's strongly recommended to check this file into your version control system.
ActiveRecord::Schema.define(:version => 20110712232259) do
ActiveRecord::Schema.define(:version => 20110720183722) do
create_table "auth_servers", :force => true do |t|
t.string "short_name", :limit => 10, :null => false
@ -177,6 +177,7 @@ ActiveRecord::Schema.define(:version => 20110712232259) do
t.boolean "forum_admin", :default => false, :null => false
t.boolean "forum_moderator"
t.boolean "image_mode_tester", :default => false, :null => false
t.string "neopets_username"
end
create_table "zones", :force => true do |t|
@ -187,3 +188,4 @@ ActiveRecord::Schema.define(:version => 20110712232259) do
end
end

BIN
public/images/neomail.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 754 B

View file

@ -552,7 +552,7 @@ div.jGrowl div.jGrowl-closer {
/* line 5, ../../../app/stylesheets/closet_hangers/_index.sass */
body.closet_hangers-index #title {
float: left;
margin-bottom: 0.5em;
margin-bottom: 0;
}
/* line 9, ../../../app/stylesheets/closet_hangers/_index.sass */
body.closet_hangers-index .flash {
@ -611,11 +611,39 @@ body.closet_hangers-index #closet-hangers-items-search input[type=search].loadin
padding-left: 20px;
}
/* line 31, ../../../app/stylesheets/closet_hangers/_index.sass */
body.closet_hangers-index #closet-hangers-contact {
clear: both;
font-size: 85%;
margin-bottom: 1em;
margin-left: 2em;
min-height: 16px;
}
/* line 38, ../../../app/stylesheets/closet_hangers/_index.sass */
body.closet_hangers-index #closet-hangers-contact a {
background-image: url('/images/neomail.png?1311187553');
background-position: left center;
background-repeat: no-repeat;
padding-left: 18px;
}
/* line 45, ../../../app/stylesheets/closet_hangers/_index.sass */
body.closet_hangers-index #closet-hangers-contact input[type=text], body.closet_hangers-index #closet-hangers-contact body.pets-bulk #bulk-pets-form textarea, body.pets-bulk #bulk-pets-form body.closet_hangers-index #closet-hangers-contact textarea {
width: 10em;
}
/* line 48, ../../../app/stylesheets/closet_hangers/_index.sass */
body.closet_hangers-index #closet-hangers-contact label {
font-weight: bold;
margin-right: 0.5em;
}
/* line 52, ../../../app/stylesheets/closet_hangers/_index.sass */
body.closet_hangers-index #closet-hangers-contact label:after {
content: ":";
}
/* line 55, ../../../app/stylesheets/closet_hangers/_index.sass */
body.closet_hangers-index #closet-hangers {
clear: both;
text-align: center;
}
/* line 36, ../../../app/stylesheets/closet_hangers/_index.sass */
/* line 60, ../../../app/stylesheets/closet_hangers/_index.sass */
body.closet_hangers-index #closet-hangers .object .quantity {
-moz-opacity: 0.75;
-webkit-opacity: 0.75;
@ -629,26 +657,26 @@ body.closet_hangers-index #closet-hangers .object .quantity {
text-align: left;
top: 60px;
}
/* line 46, ../../../app/stylesheets/closet_hangers/_index.sass */
/* line 70, ../../../app/stylesheets/closet_hangers/_index.sass */
body.closet_hangers-index #closet-hangers .object .quantity span, body.closet_hangers-index #closet-hangers .object .quantity input[type=number] {
font-size: 16px;
font-weight: bold;
}
/* line 50, ../../../app/stylesheets/closet_hangers/_index.sass */
/* line 74, ../../../app/stylesheets/closet_hangers/_index.sass */
body.closet_hangers-index #closet-hangers .object form {
display: none;
}
/* line 55, ../../../app/stylesheets/closet_hangers/_index.sass */
/* line 79, ../../../app/stylesheets/closet_hangers/_index.sass */
body.closet_hangers-index #closet-hangers.current-user .object:hover form {
display: inline;
}
/* line 58, ../../../app/stylesheets/closet_hangers/_index.sass */
/* line 82, ../../../app/stylesheets/closet_hangers/_index.sass */
body.closet_hangers-index #closet-hangers.current-user .object:hover .closet-hanger-destroy {
position: absolute;
right: 18px;
top: 0;
}
/* line 63, ../../../app/stylesheets/closet_hangers/_index.sass */
/* line 87, ../../../app/stylesheets/closet_hangers/_index.sass */
body.closet_hangers-index #closet-hangers.current-user .object:hover .closet-hanger-destroy input {
/* http://www.zurb.com/blog_uploads/0000/0617/buttons-03.html */
-moz-border-radius: 5px;
@ -689,7 +717,7 @@ body.closet_hangers-index #closet-hangers.current-user .object:hover .closet-han
body.closet_hangers-index #closet-hangers.current-user .object:hover .closet-hanger-destroy input:hover {
background-color: #999999;
}
/* line 66, ../../../app/stylesheets/closet_hangers/_index.sass */
/* line 90, ../../../app/stylesheets/closet_hangers/_index.sass */
body.closet_hangers-index #closet-hangers.current-user .object:hover .quantity {
-moz-opacity: 1;
-webkit-opacity: 1;
@ -699,33 +727,33 @@ body.closet_hangers-index #closet-hangers.current-user .object:hover .quantity {
top: 56px;
padding: 0;
}
/* line 72, ../../../app/stylesheets/closet_hangers/_index.sass */
/* line 96, ../../../app/stylesheets/closet_hangers/_index.sass */
body.closet_hangers-index #closet-hangers.current-user .object:hover .quantity span {
display: none;
}
/* line 75, ../../../app/stylesheets/closet_hangers/_index.sass */
/* line 99, ../../../app/stylesheets/closet_hangers/_index.sass */
body.closet_hangers-index #closet-hangers.current-user .object:hover .quantity input[type=number] {
padding: 2px;
width: 2em;
}
/* line 79, ../../../app/stylesheets/closet_hangers/_index.sass */
/* line 103, ../../../app/stylesheets/closet_hangers/_index.sass */
body.closet_hangers-index #closet-hangers.current-user .object:hover .quantity input[type=submit] {
font-size: 85%;
}
/* line 84, ../../../app/stylesheets/closet_hangers/_index.sass */
/* line 108, ../../../app/stylesheets/closet_hangers/_index.sass */
body.closet_hangers-index #closet-hangers.current-user.js .object:hover .quantity input[type=number] {
width: 2.5em;
}
/* line 87, ../../../app/stylesheets/closet_hangers/_index.sass */
/* line 111, ../../../app/stylesheets/closet_hangers/_index.sass */
body.closet_hangers-index #closet-hangers.current-user.js .object:hover .quantity input[type=submit] {
display: none;
}
/* line 90, ../../../app/stylesheets/closet_hangers/_index.sass */
/* line 114, ../../../app/stylesheets/closet_hangers/_index.sass */
body.closet_hangers-index #closet-hangers.current-user.js .object.loading {
background: #eeffee;
outline: 1px solid #006600;
}
/* line 94, ../../../app/stylesheets/closet_hangers/_index.sass */
/* line 118, ../../../app/stylesheets/closet_hangers/_index.sass */
body.closet_hangers-index #closet-hangers.current-user.js .object.loading .quantity span:after {
content: "…";
}