forked from OpenNeo/impress
neomail link on closets
This commit is contained in:
parent
02ef70f749
commit
c5103b6557
12 changed files with 137 additions and 32 deletions
|
@ -19,6 +19,10 @@ class ApplicationController < ActionController::Base
|
||||||
render :file => 'public/403.html', :layout => false, :status => :forbidden
|
render :file => 'public/403.html', :layout => false, :status => :forbidden
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def redirect_back!(default=:back)
|
||||||
|
redirect_to(params[:return_to] || default)
|
||||||
|
end
|
||||||
|
|
||||||
def user_is?(user)
|
def user_is?(user)
|
||||||
user_signed_in? && user == current_user
|
user_signed_in? && user == current_user
|
||||||
end
|
end
|
||||||
|
|
|
@ -36,7 +36,7 @@ class ClosetHangersController < ApplicationController
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html {
|
format.html {
|
||||||
flash[:success] = "Success! You own #{@closet_hanger.quantity} #{@item.name.pluralize}."
|
flash[:success] = "Success! You own #{@closet_hanger.quantity} #{@item.name.pluralize}."
|
||||||
redirect_back!
|
redirect_back!(@item)
|
||||||
}
|
}
|
||||||
|
|
||||||
format.json { render :json => true }
|
format.json { render :json => true }
|
||||||
|
@ -45,7 +45,7 @@ class ClosetHangersController < ApplicationController
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html {
|
format.html {
|
||||||
flash[:alert] = "We couldn't save how many of this item you own: #{@closet_hanger.errors.full_messages.to_sentence}"
|
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 }
|
format.json { render :json => {:errors => @closet_hanger.errors.full_messages}, :status => :unprocessable_entity }
|
||||||
|
@ -75,11 +75,7 @@ class ClosetHangersController < ApplicationController
|
||||||
|
|
||||||
def redirect_after_destroy!
|
def redirect_after_destroy!
|
||||||
flash[:success] = "Success! You do not own #{@item.name}."
|
flash[:success] = "Success! You do not own #{@item.name}."
|
||||||
redirect_back!
|
redirect_back!(@item)
|
||||||
end
|
|
||||||
|
|
||||||
def redirect_back!
|
|
||||||
redirect_to params[:return_to] || @item
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,24 @@
|
||||||
class UsersController < ApplicationController
|
class UsersController < ApplicationController
|
||||||
|
before_filter :find_and_authorize_user!, :only => [:update]
|
||||||
|
|
||||||
def top_contributors
|
def top_contributors
|
||||||
@users = User.top_contributors.paginate :page => params[:page], :per_page => 20
|
@users = User.top_contributors.paginate :page => params[:page], :per_page => 20
|
||||||
end
|
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
|
end
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,10 @@
|
||||||
|
require 'cgi'
|
||||||
|
|
||||||
module ClosetHangersHelper
|
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?
|
def public_perspective?
|
||||||
@public_perspective
|
@public_perspective
|
||||||
end
|
end
|
||||||
|
|
|
@ -11,6 +11,8 @@ class User < ActiveRecord::Base
|
||||||
|
|
||||||
devise :rememberable
|
devise :rememberable
|
||||||
|
|
||||||
|
attr_accessible :neopets_username
|
||||||
|
|
||||||
def contribute!(pet)
|
def contribute!(pet)
|
||||||
new_contributions = []
|
new_contributions = []
|
||||||
new_points = 0
|
new_points = 0
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
body.closet_hangers-index
|
body.closet_hangers-index
|
||||||
#title
|
#title
|
||||||
float: left
|
float: left
|
||||||
margin-bottom: .5em
|
margin-bottom: 0
|
||||||
|
|
||||||
.flash
|
.flash
|
||||||
clear: both
|
clear: both
|
||||||
|
@ -28,6 +28,30 @@ body.closet_hangers-index
|
||||||
repeat: no-repeat
|
repeat: no-repeat
|
||||||
padding-left: $icon-width + 4px
|
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
|
#closet-hangers
|
||||||
clear: both
|
clear: both
|
||||||
text-align: center
|
text-align: center
|
||||||
|
|
|
@ -8,15 +8,27 @@
|
||||||
- else
|
- else
|
||||||
- title "#{@user.name}'s Items"
|
- 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'}
|
#closet-hangers{:class => public_perspective? ? nil : 'current-user'}
|
||||||
- if !@closet_hangers.empty?
|
- if public_perspective?
|
||||||
- unless public_perspective?
|
- if @closet_hangers.empty?
|
||||||
|
%p #{@user.name} hasn't tracked any items on Dress to Impress.
|
||||||
|
- else
|
||||||
|
- unless @closet_hangers.empty?
|
||||||
%p
|
%p
|
||||||
These are the items you own. Hover over an item to remove it from the
|
These are the items you own. Hover over an item to remove it from the
|
||||||
list or to change the quantity.
|
list or to change the quantity.
|
||||||
= render :partial => 'closet_hanger', :collection => @closet_hangers, :locals => {:show_controls => user_is?(@user)}
|
|
||||||
- else
|
- else
|
||||||
- unless public_perspective?
|
|
||||||
%p You haven't tracked any items on Dress to Impress.
|
%p You haven't tracked any items on Dress to Impress.
|
||||||
%p
|
%p
|
||||||
Here you can keep track of what items you already own, so that as you
|
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!
|
It's easy to get started!
|
||||||
= link_to "Just import your Neopets closet in a few quick steps.", new_closet_page_path
|
= link_to "Just import your Neopets closet in a few quick steps.", new_closet_page_path
|
||||||
Have fun!
|
Have fun!
|
||||||
- else
|
%p
|
||||||
%p #{@user.name} hasn't tracked any items on Dress to Impress.
|
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
|
- content_for :stylesheets do
|
||||||
= stylesheet_link_tag 'south-street/jquery-ui'
|
= stylesheet_link_tag 'south-street/jquery-ui'
|
||||||
|
|
|
@ -35,7 +35,7 @@ OpenneoImpressItems::Application.routes.draw do |map|
|
||||||
match '/logout' => 'sessions#destroy', :as => :logout
|
match '/logout' => 'sessions#destroy', :as => :logout
|
||||||
match '/users/authorize' => 'sessions#create'
|
match '/users/authorize' => 'sessions#create'
|
||||||
|
|
||||||
resources :user, :only => [] do
|
resources :users, :path => 'user', :only => [:update] do
|
||||||
resources :contributions, :only => [:index]
|
resources :contributions, :only => [:index]
|
||||||
resources :closet_hangers, :only => [:index], :path => 'closet'
|
resources :closet_hangers, :only => [:index], :path => 'closet'
|
||||||
|
|
||||||
|
|
|
@ -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
|
|
@ -10,7 +10,7 @@
|
||||||
#
|
#
|
||||||
# It's strongly recommended to check this file into your version control system.
|
# 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|
|
create_table "auth_servers", :force => true do |t|
|
||||||
t.string "short_name", :limit => 10, :null => false
|
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_admin", :default => false, :null => false
|
||||||
t.boolean "forum_moderator"
|
t.boolean "forum_moderator"
|
||||||
t.boolean "image_mode_tester", :default => false, :null => false
|
t.boolean "image_mode_tester", :default => false, :null => false
|
||||||
|
t.string "neopets_username"
|
||||||
end
|
end
|
||||||
|
|
||||||
create_table "zones", :force => true do |t|
|
create_table "zones", :force => true do |t|
|
||||||
|
@ -187,3 +188,4 @@ ActiveRecord::Schema.define(:version => 20110712232259) do
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
BIN
public/images/neomail.png
Normal file
BIN
public/images/neomail.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 754 B |
|
@ -552,7 +552,7 @@ div.jGrowl div.jGrowl-closer {
|
||||||
/* line 5, ../../../app/stylesheets/closet_hangers/_index.sass */
|
/* line 5, ../../../app/stylesheets/closet_hangers/_index.sass */
|
||||||
body.closet_hangers-index #title {
|
body.closet_hangers-index #title {
|
||||||
float: left;
|
float: left;
|
||||||
margin-bottom: 0.5em;
|
margin-bottom: 0;
|
||||||
}
|
}
|
||||||
/* line 9, ../../../app/stylesheets/closet_hangers/_index.sass */
|
/* line 9, ../../../app/stylesheets/closet_hangers/_index.sass */
|
||||||
body.closet_hangers-index .flash {
|
body.closet_hangers-index .flash {
|
||||||
|
@ -611,11 +611,39 @@ body.closet_hangers-index #closet-hangers-items-search input[type=search].loadin
|
||||||
padding-left: 20px;
|
padding-left: 20px;
|
||||||
}
|
}
|
||||||
/* line 31, ../../../app/stylesheets/closet_hangers/_index.sass */
|
/* 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 {
|
body.closet_hangers-index #closet-hangers {
|
||||||
clear: both;
|
clear: both;
|
||||||
text-align: center;
|
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 {
|
body.closet_hangers-index #closet-hangers .object .quantity {
|
||||||
-moz-opacity: 0.75;
|
-moz-opacity: 0.75;
|
||||||
-webkit-opacity: 0.75;
|
-webkit-opacity: 0.75;
|
||||||
|
@ -629,26 +657,26 @@ body.closet_hangers-index #closet-hangers .object .quantity {
|
||||||
text-align: left;
|
text-align: left;
|
||||||
top: 60px;
|
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] {
|
body.closet_hangers-index #closet-hangers .object .quantity span, body.closet_hangers-index #closet-hangers .object .quantity input[type=number] {
|
||||||
font-size: 16px;
|
font-size: 16px;
|
||||||
font-weight: bold;
|
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 {
|
body.closet_hangers-index #closet-hangers .object form {
|
||||||
display: none;
|
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 {
|
body.closet_hangers-index #closet-hangers.current-user .object:hover form {
|
||||||
display: inline;
|
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 {
|
body.closet_hangers-index #closet-hangers.current-user .object:hover .closet-hanger-destroy {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
right: 18px;
|
right: 18px;
|
||||||
top: 0;
|
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 {
|
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 */
|
/* http://www.zurb.com/blog_uploads/0000/0617/buttons-03.html */
|
||||||
-moz-border-radius: 5px;
|
-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 {
|
body.closet_hangers-index #closet-hangers.current-user .object:hover .closet-hanger-destroy input:hover {
|
||||||
background-color: #999999;
|
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 {
|
body.closet_hangers-index #closet-hangers.current-user .object:hover .quantity {
|
||||||
-moz-opacity: 1;
|
-moz-opacity: 1;
|
||||||
-webkit-opacity: 1;
|
-webkit-opacity: 1;
|
||||||
|
@ -699,33 +727,33 @@ body.closet_hangers-index #closet-hangers.current-user .object:hover .quantity {
|
||||||
top: 56px;
|
top: 56px;
|
||||||
padding: 0;
|
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 {
|
body.closet_hangers-index #closet-hangers.current-user .object:hover .quantity span {
|
||||||
display: none;
|
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] {
|
body.closet_hangers-index #closet-hangers.current-user .object:hover .quantity input[type=number] {
|
||||||
padding: 2px;
|
padding: 2px;
|
||||||
width: 2em;
|
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] {
|
body.closet_hangers-index #closet-hangers.current-user .object:hover .quantity input[type=submit] {
|
||||||
font-size: 85%;
|
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] {
|
body.closet_hangers-index #closet-hangers.current-user.js .object:hover .quantity input[type=number] {
|
||||||
width: 2.5em;
|
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] {
|
body.closet_hangers-index #closet-hangers.current-user.js .object:hover .quantity input[type=submit] {
|
||||||
display: none;
|
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 {
|
body.closet_hangers-index #closet-hangers.current-user.js .object.loading {
|
||||||
background: #eeffee;
|
background: #eeffee;
|
||||||
outline: 1px solid #006600;
|
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 {
|
body.closet_hangers-index #closet-hangers.current-user.js .object.loading .quantity span:after {
|
||||||
content: "…";
|
content: "…";
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue