brought-to-you-by on items#show lists contributors
This commit is contained in:
parent
e9e7d305f0
commit
f56b544963
10 changed files with 156 additions and 24 deletions
|
@ -48,6 +48,9 @@ class ItemsController < ApplicationController
|
||||||
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html do
|
format.html do
|
||||||
|
unless fragment_exist?("items/#{@item.id} contributors")
|
||||||
|
@contributors_with_counts = @item.contributors_with_counts
|
||||||
|
end
|
||||||
|
|
||||||
@trading_closet_hangers_by_owned = {
|
@trading_closet_hangers_by_owned = {
|
||||||
true => @item.closet_hangers.owned_trading.newest.includes(:user),
|
true => @item.closet_hangers.owned_trading.newest.includes(:user),
|
||||||
|
|
|
@ -108,6 +108,10 @@ module ItemsHelper
|
||||||
link_to hanger.user.name, user_closet_hangers_path(hanger.user)
|
link_to hanger.user.name, user_closet_hangers_path(hanger.user)
|
||||||
end.to_sentence.html_safe
|
end.to_sentence.html_safe
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def format_contribution_count(count)
|
||||||
|
"(×#{count})".html_safe if count > 1
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,11 @@
|
||||||
class ContributionObserver < ActiveRecord::Observer
|
class ContributionObserver < ActiveRecord::Observer
|
||||||
def after_create(contribution)
|
def after_create(contribution)
|
||||||
controller.expire_fragment('outfits#new latest_contribution')
|
controller.expire_fragment('outfits#new latest_contribution')
|
||||||
|
|
||||||
|
if contribution.contributed_type == 'SwfAsset'
|
||||||
|
item = contribution.contributed.item
|
||||||
|
controller.expire_fragment("items/#{item.id} contributors")
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
|
@ -42,6 +42,32 @@ class Item < ActiveRecord::Base
|
||||||
def closeted?
|
def closeted?
|
||||||
@owned || @wanted
|
@owned || @wanted
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Return an OrderedHash mapping users to the number of times they
|
||||||
|
# contributed to this item's assets, from most contributions to least.
|
||||||
|
def contributors_with_counts
|
||||||
|
# Get contributing users' IDs
|
||||||
|
swf_asset_ids = swf_assets.select(SwfAsset.arel_table[:id]).map(&:id)
|
||||||
|
swf_asset_contributions = Contribution.select('user_id').
|
||||||
|
where(:contributed_type => 'SwfAsset', :contributed_id => swf_asset_ids)
|
||||||
|
contributor_ids = swf_asset_contributions.map(&:user_id)
|
||||||
|
|
||||||
|
# Get the users, mapped by ID
|
||||||
|
contributors_by_id = {}
|
||||||
|
User.find(contributor_ids).each { |u| contributors_by_id[u.id] = u }
|
||||||
|
|
||||||
|
# Count each user's contributions
|
||||||
|
contributor_counts_by_id = Hash.new(0)
|
||||||
|
contributor_ids.each { |id| contributor_counts_by_id[id] += 1 }
|
||||||
|
|
||||||
|
# Build an OrderedHash mapping users to counts in descending order
|
||||||
|
contributors_with_counts = ActiveSupport::OrderedHash.new
|
||||||
|
contributor_counts_by_id.sort_by { |k, v| v }.reverse.each do |id, count|
|
||||||
|
contributor = contributors_by_id[id]
|
||||||
|
contributors_with_counts[contributor] = count
|
||||||
|
end
|
||||||
|
contributors_with_counts
|
||||||
|
end
|
||||||
|
|
||||||
def nc?
|
def nc?
|
||||||
NCRarities.include?(rarity_index)
|
NCRarities.include?(rarity_index)
|
||||||
|
|
|
@ -108,6 +108,24 @@ body.items-show
|
||||||
|
|
||||||
.less
|
.less
|
||||||
display: none
|
display: none
|
||||||
|
|
||||||
|
#item-contributors
|
||||||
|
+subtle-banner
|
||||||
|
clear: both
|
||||||
|
|
||||||
|
header
|
||||||
|
display: inline
|
||||||
|
font-weight: bold
|
||||||
|
margin-right: .25em
|
||||||
|
|
||||||
|
footer
|
||||||
|
display: inline
|
||||||
|
|
||||||
|
ul
|
||||||
|
+comma-delimited-list
|
||||||
|
|
||||||
|
li:last-child::after
|
||||||
|
content: "."
|
||||||
|
|
||||||
#item-preview-header
|
#item-preview-header
|
||||||
clear: both
|
clear: both
|
||||||
|
|
|
@ -198,14 +198,7 @@ body.outfits-new
|
||||||
width: 80px
|
width: 80px
|
||||||
|
|
||||||
#latest-contribution
|
#latest-contribution
|
||||||
border:
|
+subtle-banner
|
||||||
color: $soft-border-color
|
|
||||||
style: solid
|
|
||||||
width: 1px 0
|
|
||||||
font-size: 85%
|
|
||||||
margin: 1em 0
|
|
||||||
padding: .5em 0
|
|
||||||
text-align: center
|
|
||||||
|
|
||||||
#recent-contributions-link
|
#recent-contributions-link
|
||||||
font-weight: bold
|
font-weight: bold
|
||||||
|
|
|
@ -106,3 +106,13 @@
|
||||||
background: $warning-bg-color
|
background: $warning-bg-color
|
||||||
border: 1px solid $warning-border-color
|
border: 1px solid $warning-border-color
|
||||||
color: $warning-color
|
color: $warning-color
|
||||||
|
|
||||||
|
=subtle-banner
|
||||||
|
border:
|
||||||
|
color: $soft-border-color
|
||||||
|
style: solid
|
||||||
|
width: 1px 0
|
||||||
|
font-size: 85%
|
||||||
|
margin: 1em 0
|
||||||
|
padding: .5em 0
|
||||||
|
text-align: center
|
||||||
|
|
|
@ -89,6 +89,15 @@
|
||||||
%span.more more
|
%span.more more
|
||||||
%span.less less
|
%span.less less
|
||||||
|
|
||||||
|
- cache "items/#{@item.id} contributors" do
|
||||||
|
- unless @contributors_with_counts.empty?
|
||||||
|
#item-contributors
|
||||||
|
%header Brought to you by:
|
||||||
|
%ul
|
||||||
|
- @contributors_with_counts.each do |contributor, count|
|
||||||
|
%li #{link_to contributor.name, user_contributions_path(contributor)} #{format_contribution_count(count)}
|
||||||
|
%footer Thanks, everybody!
|
||||||
|
|
||||||
- cache 'items#show preview_header' do
|
- cache 'items#show preview_header' do
|
||||||
#item-preview-header
|
#item-preview-header
|
||||||
%h3 Preview
|
%h3 Preview
|
||||||
|
|
21
config/initializers/activemerchant.rb
Normal file
21
config/initializers/activemerchant.rb
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
if defined? ActiveMerchant
|
||||||
|
if Rails.env.development?
|
||||||
|
ActiveMerchant::Billing::Base.mode = :test
|
||||||
|
paypal_options = {
|
||||||
|
:login => "dti00_1309660809_biz_api1.gmail.com",
|
||||||
|
:password => "1309660841",
|
||||||
|
:signature => "A8hoaApkuosyp0eSB5fO.FMMFsFPA2E9DtCZkbNkmIuVRqeOmTOzXqQQ"
|
||||||
|
}
|
||||||
|
elsif Rails.env.production?
|
||||||
|
ActiveMerchant::Billing::Base.mode = :production
|
||||||
|
paypal_options = {
|
||||||
|
:login => "matchu1993_api1.gmail.com",
|
||||||
|
:password => "JCJ2NK5DTBZ94QNP",
|
||||||
|
:signature => "AFcWxV21C7fd0v3bYYYRCpSSRl31AFGfnit6OH.i894Lf4Bgc81N2lfc"
|
||||||
|
}
|
||||||
|
else
|
||||||
|
raise RuntimeError, "ActiveMerchant is not configured for #{Rails.env}. See config/initializers/activemerchant.rb"
|
||||||
|
end
|
||||||
|
|
||||||
|
::DONATION_GATEWAY = ActiveMerchant::Billing::PaypalExpressGateway.new(paypal_options)
|
||||||
|
end
|
|
@ -1935,10 +1935,53 @@ body.items-show #trade-hangers .toggle .less {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
/* line 112, ../../../app/stylesheets/items/_show.sass */
|
/* line 112, ../../../app/stylesheets/items/_show.sass */
|
||||||
|
body.items-show #item-contributors {
|
||||||
|
border-color: #aaddaa;
|
||||||
|
border-style: solid;
|
||||||
|
border-width: 1px 0;
|
||||||
|
font-size: 85%;
|
||||||
|
margin: 1em 0;
|
||||||
|
padding: 0.5em 0;
|
||||||
|
text-align: center;
|
||||||
|
clear: both;
|
||||||
|
}
|
||||||
|
/* line 116, ../../../app/stylesheets/items/_show.sass */
|
||||||
|
body.items-show #item-contributors header {
|
||||||
|
display: inline;
|
||||||
|
font-weight: bold;
|
||||||
|
margin-right: 0.25em;
|
||||||
|
}
|
||||||
|
/* line 121, ../../../app/stylesheets/items/_show.sass */
|
||||||
|
body.items-show #item-contributors footer {
|
||||||
|
display: inline;
|
||||||
|
}
|
||||||
|
/* line 124, ../../../app/stylesheets/items/_show.sass */
|
||||||
|
body.items-show #item-contributors ul {
|
||||||
|
list-style-type: none;
|
||||||
|
}
|
||||||
|
/* line 5, ../../../../../../.rvm/gems/ruby-1.9.2-p290/gems/compass-0.10.6/frameworks/compass/stylesheets/compass/utilities/lists/_inline-list.scss */
|
||||||
|
body.items-show #item-contributors ul, body.items-show #item-contributors ul li {
|
||||||
|
margin: 0px;
|
||||||
|
padding: 0px;
|
||||||
|
display: inline;
|
||||||
|
}
|
||||||
|
/* line 24, ../../../../../../.rvm/gems/ruby-1.9.2-p290/gems/compass-0.10.6/frameworks/compass/stylesheets/compass/utilities/lists/_inline-list.scss */
|
||||||
|
body.items-show #item-contributors ul li:after {
|
||||||
|
content: ", ";
|
||||||
|
}
|
||||||
|
/* line 26, ../../../../../../.rvm/gems/ruby-1.9.2-p290/gems/compass-0.10.6/frameworks/compass/stylesheets/compass/utilities/lists/_inline-list.scss */
|
||||||
|
body.items-show #item-contributors ul li:last-child:after, body.items-show #item-contributors ul li.last:after {
|
||||||
|
content: "";
|
||||||
|
}
|
||||||
|
/* line 127, ../../../app/stylesheets/items/_show.sass */
|
||||||
|
body.items-show #item-contributors ul li:last-child::after {
|
||||||
|
content: ".";
|
||||||
|
}
|
||||||
|
/* line 130, ../../../app/stylesheets/items/_show.sass */
|
||||||
body.items-show #item-preview-header {
|
body.items-show #item-preview-header {
|
||||||
clear: both;
|
clear: both;
|
||||||
}
|
}
|
||||||
/* line 115, ../../../app/stylesheets/items/_show.sass */
|
/* line 133, ../../../app/stylesheets/items/_show.sass */
|
||||||
body.items-show #item-preview-header h3, body.items-show #item-preview-header a {
|
body.items-show #item-preview-header h3, body.items-show #item-preview-header a {
|
||||||
display: -moz-inline-box;
|
display: -moz-inline-box;
|
||||||
-moz-box-orient: vertical;
|
-moz-box-orient: vertical;
|
||||||
|
@ -1950,17 +1993,17 @@ body.items-show #item-preview-header h3, body.items-show #item-preview-header a
|
||||||
body.items-show #item-preview-header h3, body.items-show #item-preview-header a {
|
body.items-show #item-preview-header h3, body.items-show #item-preview-header a {
|
||||||
*display: inline;
|
*display: inline;
|
||||||
}
|
}
|
||||||
/* line 117, ../../../app/stylesheets/items/_show.sass */
|
/* line 135, ../../../app/stylesheets/items/_show.sass */
|
||||||
body.items-show #item-preview-header a {
|
body.items-show #item-preview-header a {
|
||||||
font-size: 85%;
|
font-size: 85%;
|
||||||
margin: -1.5em 0 0 1em;
|
margin: -1.5em 0 0 1em;
|
||||||
}
|
}
|
||||||
/* line 121, ../../../app/stylesheets/items/_show.sass */
|
/* line 139, ../../../app/stylesheets/items/_show.sass */
|
||||||
body.items-show .nc-icon {
|
body.items-show .nc-icon {
|
||||||
height: 16px;
|
height: 16px;
|
||||||
width: 16px;
|
width: 16px;
|
||||||
}
|
}
|
||||||
/* line 125, ../../../app/stylesheets/items/_show.sass */
|
/* line 143, ../../../app/stylesheets/items/_show.sass */
|
||||||
body.items-show #closet-hangers {
|
body.items-show #closet-hangers {
|
||||||
border: 1px solid #006600;
|
border: 1px solid #006600;
|
||||||
float: right;
|
float: right;
|
||||||
|
@ -1972,13 +2015,13 @@ body.items-show #closet-hangers {
|
||||||
position: relative;
|
position: relative;
|
||||||
z-index: 2;
|
z-index: 2;
|
||||||
}
|
}
|
||||||
/* line 138, ../../../app/stylesheets/items/_show.sass */
|
/* line 156, ../../../app/stylesheets/items/_show.sass */
|
||||||
body.items-show #closet-hangers h3 {
|
body.items-show #closet-hangers h3 {
|
||||||
font-size: 150%;
|
font-size: 150%;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
margin-bottom: 0.25em;
|
margin-bottom: 0.25em;
|
||||||
}
|
}
|
||||||
/* line 143, ../../../app/stylesheets/items/_show.sass */
|
/* line 161, ../../../app/stylesheets/items/_show.sass */
|
||||||
body.items-show #closet-hangers #closet-hangers-ownership-groups {
|
body.items-show #closet-hangers #closet-hangers-ownership-groups {
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
|
@ -1988,41 +2031,41 @@ body.items-show #closet-hangers #closet-hangers-ownership-groups {
|
||||||
body.items-show #closet-hangers #closet-hangers-ownership-groups {
|
body.items-show #closet-hangers #closet-hangers-ownership-groups {
|
||||||
display: block;
|
display: block;
|
||||||
}
|
}
|
||||||
/* line 147, ../../../app/stylesheets/items/_show.sass */
|
/* line 165, ../../../app/stylesheets/items/_show.sass */
|
||||||
body.items-show #closet-hangers #closet-hangers-ownership-groups div {
|
body.items-show #closet-hangers #closet-hangers-ownership-groups div {
|
||||||
float: left;
|
float: left;
|
||||||
margin: 0 5%;
|
margin: 0 5%;
|
||||||
text-align: left;
|
text-align: left;
|
||||||
width: 40%;
|
width: 40%;
|
||||||
}
|
}
|
||||||
/* line 153, ../../../app/stylesheets/items/_show.sass */
|
/* line 171, ../../../app/stylesheets/items/_show.sass */
|
||||||
body.items-show #closet-hangers #closet-hangers-ownership-groups div li {
|
body.items-show #closet-hangers #closet-hangers-ownership-groups div li {
|
||||||
list-style: none;
|
list-style: none;
|
||||||
word-wrap: break-word;
|
word-wrap: break-word;
|
||||||
}
|
}
|
||||||
/* line 157, ../../../app/stylesheets/items/_show.sass */
|
/* line 175, ../../../app/stylesheets/items/_show.sass */
|
||||||
body.items-show #closet-hangers #closet-hangers-ownership-groups div li label.unlisted {
|
body.items-show #closet-hangers #closet-hangers-ownership-groups div li label.unlisted {
|
||||||
font-style: italic;
|
font-style: italic;
|
||||||
}
|
}
|
||||||
/* line 160, ../../../app/stylesheets/items/_show.sass */
|
/* line 178, ../../../app/stylesheets/items/_show.sass */
|
||||||
body.items-show #closet-hangers form {
|
body.items-show #closet-hangers form {
|
||||||
padding: 0.5em 0;
|
padding: 0.5em 0;
|
||||||
}
|
}
|
||||||
/* line 163, ../../../app/stylesheets/items/_show.sass */
|
/* line 181, ../../../app/stylesheets/items/_show.sass */
|
||||||
body.items-show #closet-hangers select {
|
body.items-show #closet-hangers select {
|
||||||
width: 9em;
|
width: 9em;
|
||||||
}
|
}
|
||||||
/* line 166, ../../../app/stylesheets/items/_show.sass */
|
/* line 184, ../../../app/stylesheets/items/_show.sass */
|
||||||
body.items-show #closet-hangers input[type=number] {
|
body.items-show #closet-hangers input[type=number] {
|
||||||
margin-right: 0.5em;
|
margin-right: 0.5em;
|
||||||
width: 3em;
|
width: 3em;
|
||||||
}
|
}
|
||||||
/* line 172, ../../../app/stylesheets/items/_show.sass */
|
/* line 190, ../../../app/stylesheets/items/_show.sass */
|
||||||
body.items-show.js #trade-hangers p {
|
body.items-show.js #trade-hangers p {
|
||||||
max-height: 3em;
|
max-height: 3em;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
}
|
}
|
||||||
/* line 176, ../../../app/stylesheets/items/_show.sass */
|
/* line 194, ../../../app/stylesheets/items/_show.sass */
|
||||||
body.items-show.js #trade-hangers p.showing-more {
|
body.items-show.js #trade-hangers p.showing-more {
|
||||||
max-height: none;
|
max-height: none;
|
||||||
}
|
}
|
||||||
|
@ -3932,12 +3975,12 @@ body.outfits-new #latest-contribution {
|
||||||
padding: 0.5em 0;
|
padding: 0.5em 0;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
}
|
}
|
||||||
/* line 210, ../../../app/stylesheets/outfits/_new.sass */
|
/* line 203, ../../../app/stylesheets/outfits/_new.sass */
|
||||||
body.outfits-new #latest-contribution #recent-contributions-link {
|
body.outfits-new #latest-contribution #recent-contributions-link {
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
margin-right: 0.5em;
|
margin-right: 0.5em;
|
||||||
}
|
}
|
||||||
/* line 214, ../../../app/stylesheets/outfits/_new.sass */
|
/* line 207, ../../../app/stylesheets/outfits/_new.sass */
|
||||||
body.outfits-new #latest-contribution #latest-contribution-created-at {
|
body.outfits-new #latest-contribution #latest-contribution-created-at {
|
||||||
color: #448844;
|
color: #448844;
|
||||||
margin-left: 0.5em;
|
margin-left: 0.5em;
|
||||||
|
|
Loading…
Reference in a new issue