diff --git a/app/assets/images/campaigns/bird.gif b/app/assets/images/campaigns/bird.gif new file mode 100644 index 00000000..cb83e601 Binary files /dev/null and b/app/assets/images/campaigns/bird.gif differ diff --git a/app/assets/images/campaigns/hug.gif b/app/assets/images/campaigns/hug.gif new file mode 100644 index 00000000..628712ee Binary files /dev/null and b/app/assets/images/campaigns/hug.gif differ diff --git a/app/assets/javascripts/campaigns.js b/app/assets/javascripts/campaigns.js new file mode 100644 index 00000000..dee720fa --- /dev/null +++ b/app/assets/javascripts/campaigns.js @@ -0,0 +1,2 @@ +// Place all the behaviors and hooks related to the matching controller here. +// All this logic will automatically be available in application.js. diff --git a/app/assets/stylesheets/_layout.sass b/app/assets/stylesheets/_layout.sass index 402b10f9..9d6cbf2f 100644 --- a/app/assets/stylesheets/_layout.sass +++ b/app/assets/stylesheets/_layout.sass @@ -1,7 +1,7 @@ @import "partials/icon" -@import url(http://fonts.googleapis.com/css?family=Droid+Sans:400,700) -@import url(http://fonts.googleapis.com/css?family=Droid+Serif:400,700,400italic) -@import url(http://fonts.googleapis.com/css?family=Calligraffitti) +@import url(//fonts.googleapis.com/css?family=Droid+Sans:400,700) +@import url(//fonts.googleapis.com/css?family=Droid+Serif:400,700,400italic) +@import url(//fonts.googleapis.com/css?family=Calligraffitti) /* Reset diff --git a/app/assets/stylesheets/application.css.sass b/app/assets/stylesheets/application.css.sass index 815326ad..940ed703 100644 --- a/app/assets/stylesheets/application.css.sass +++ b/app/assets/stylesheets/application.css.sass @@ -10,6 +10,7 @@ @import partials/jquery.jgrowl @import broken_image_reports/new +@import campaigns/show @import closet_hangers/index @import closet_hangers/petpage @import closet_lists/form @@ -25,7 +26,6 @@ @import outfits/new @import outfits/show @import pets/bulk -@import static/donate @import static/image_mode @import static/terms @import swf_assets/links diff --git a/app/assets/stylesheets/campaigns.css.scss b/app/assets/stylesheets/campaigns.css.scss new file mode 100644 index 00000000..4d58636e --- /dev/null +++ b/app/assets/stylesheets/campaigns.css.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the campaigns controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/app/assets/stylesheets/static/_donate.sass b/app/assets/stylesheets/campaigns/_show.sass similarity index 71% rename from app/assets/stylesheets/static/_donate.sass rename to app/assets/stylesheets/campaigns/_show.sass index 4616d74f..a1fae484 100644 --- a/app/assets/stylesheets/static/_donate.sass +++ b/app/assets/stylesheets/campaigns/_show.sass @@ -1,6 +1,7 @@ @import "compass/css3/text-shadow" @import "partials/campaign-progress" +@import "partials/outfit" /* TODO: redundant with outfits/index; why is it not in the partial? */ $outfit-inner-height: 150px @@ -9,25 +10,46 @@ $outfit-banner-h-padding: 4px $outfit-banner-v-padding: 2px $outfit-banner-inner-width: $outfit-inner-width - (2 * $outfit-banner-h-padding) -body.static-donate +body.campaigns-show, body.campaigns-current +campaign-progress + color: #004 + + a + color: #004 + #222 + + #userbar, #footer + color: $text-color + a + color: $link-color + + #home-link + color: $link-color #title display: none #donation-form +module - - background: - image: url(http://images.neopets.com/new_shopkeepers/t_993.gif) - position: ($container-width - 150px - 8px) -4px - repeat: no-repeat + background: $campaign-background-color + border-color: $campaign-border-color margin-top: 1em margin-bottom: 1.5em padding-bottom: 32px padding-left: 24px padding-top: 32px + &[data-campaign-theme="hug"] + background: + image: url(image_path("campaigns/hug.gif")) + position: ($container-width - 150px - 8px) -4px + repeat: no-repeat + + &[data-campaign-theme="bird"] + background: + image: url(image_path("campaigns/bird.gif")) + position: ($container-width - 150px - 8px) -4px + repeat: no-repeat + header, div +inline-block @@ -50,6 +72,8 @@ body.static-donate margin-top: .5em input[type=text] + border-color: #cce + color: #004 width: 3em button @@ -101,6 +125,11 @@ body.static-donate line-height: 1.5 vertical-align: middle + #last-years-donors + font-weight: bold + margin-top: 1em + text-align: center + #fine-print font-size: 85% margin-top: 2em diff --git a/app/assets/stylesheets/partials/_campaign-progress.sass b/app/assets/stylesheets/partials/_campaign-progress.sass index c5d58afd..a395921a 100644 --- a/app/assets/stylesheets/partials/_campaign-progress.sass +++ b/app/assets/stylesheets/partials/_campaign-progress.sass @@ -1,10 +1,13 @@ +$campaign-border-color: #006 +$campaign-background-color: #eef + =campaign-progress .campaign-progress-wrapper +border-radius(8px) - background: desaturate(lighten($module-border-color, 30%), 85%) - background-image: linear-gradient(color-stops(desaturate(lighten($module-border-color, 50%), 85%), desaturate(lighten($module-border-color, 30%), 85%))) + background: desaturate(lighten($campaign-border-color, 30%), 85%) + background-image: linear-gradient(color-stops(desaturate(lighten($campaign-border-color, 50%), 85%), desaturate(lighten($campaign-border-color, 30%), 85%))) - border: 4px solid $module-border-color + border: 4px solid $campaign-border-color clear: both margin-bottom: 1em margin-top: .5em @@ -18,9 +21,9 @@ padding: .25em .75em .campaign-progress - background: $module-border-color - background-image: linear-gradient(color-stops($module-border-color + #222, $module-border-color)) - border-right: 1px solid $module-border-color + background: $campaign-border-color + background-image: linear-gradient(color-stops($campaign-border-color + #222, $campaign-border-color)) + border-right: 1px solid $campaign-border-color .campaign-progress-wrapper, .campaign-progress height: 2.5em diff --git a/app/assets/stylesheets/partials/_outfit.sass b/app/assets/stylesheets/partials/_outfit.sass index adce069e..41d672f6 100644 --- a/app/assets/stylesheets/partials/_outfit.sass +++ b/app/assets/stylesheets/partials/_outfit.sass @@ -1,3 +1,5 @@ +@import "outfits/star" + =outfit +inline-block +outfit-star diff --git a/app/controllers/campaigns_controller.rb b/app/controllers/campaigns_controller.rb new file mode 100644 index 00000000..880d779d --- /dev/null +++ b/app/controllers/campaigns_controller.rb @@ -0,0 +1,20 @@ +class CampaignsController < ApplicationController + def show + @campaign = Campaign.find(params[:id]) + redirect_to(action: :current) if @campaign.active? + @donations = find_donations + end + + def current + @campaign = Campaign.current + @donations = find_donations + render action: :show + end + + private + + def find_donations + @donations = @campaign.donations.includes(features: :outfit). + order('created_at DESC') + end +end diff --git a/app/controllers/static_controller.rb b/app/controllers/static_controller.rb index 4d153d27..c6df11e2 100644 --- a/app/controllers/static_controller.rb +++ b/app/controllers/static_controller.rb @@ -1,7 +1,2 @@ class StaticController < ApplicationController - def donate - @campaign = Campaign.current - @donations = @campaign.donations.includes(features: :outfit). - order('created_at DESC') - end end diff --git a/app/helpers/campaigns_helper.rb b/app/helpers/campaigns_helper.rb new file mode 100644 index 00000000..d9089a01 --- /dev/null +++ b/app/helpers/campaigns_helper.rb @@ -0,0 +1,2 @@ +module CampaignsHelper +end diff --git a/app/views/static/donate.html.haml b/app/views/campaigns/show.html.haml similarity index 63% rename from app/views/static/donate.html.haml rename to app/views/campaigns/show.html.haml index f69d95a2..730dccec 100644 --- a/app/views/static/donate.html.haml +++ b/app/views/campaigns/show.html.haml @@ -3,12 +3,13 @@ - if @campaign.progress > 0 = campaign_progress(@campaign) do We've received #{number_to_currency(@campaign.progress / 100.0)} - toward our hosting costs this year. + toward #{@campaign.name}. Thanks so much! = form_tag donations_path, method: 'POST', id: 'donation-form', 'data-checkout-image' => image_path('default_preview.png'), - 'data-checkout-publishable-key' => Rails.configuration.stripe[:publishable_key] do + 'data-checkout-publishable-key' => Rails.configuration.stripe[:publishable_key], + 'data-campaign-theme' => @campaign.theme_id do = hidden_field_tag 'donation[stripe_token]' = hidden_field_tag 'donation[stripe_token_type]' = hidden_field_tag 'donation[donor_email]' @@ -25,58 +26,7 @@ = text_field_tag 'donation[amount]', '10.00' %button{:type => 'submit'} Donate now! -#success-thanks - :markdown - **Oh, wow! We've raised enough money for our 2014 hosting costs in less - than a week! Thanks a ton!** - - As it happens, we didn't have a fundraiser last year because I didn't have - the time or energy to ask for money properly—whoops. So, any further - donations will go toward last year's hosting costs that I paid out of - pocket, and will therefore help me have enough money to pay for college - ♥ - - And you'll still totally get featured here and on the homepage, too. - Thanks again for all your help! We're proud to be your Neopets fix during - the downtime - - -#description - :markdown - **Dress to Impress is cool!** We have loads of fancy features: y'all are - constantly adding models to our database, making NC trades, and saving your - outfits and sharing them across the interwebs. - It's pretty sweet, and we're super proud to have a community of users - consistently putting our resources to good use. - - **But cool features cost us money—about $800 a year.** We're running on a - [4GB Linode server][linode] for $40/mo, and y'all's fancy outfit thumbnails - live on [Amazon Web Services][aws] for about $25/mo (it varies by usage), - so that leaves us at about $65/mo. Add in $10 for the domain name and $10 - room to grow (our Amazon usage, and therefore costs, are on the rise), and - that comes to an annual budget of $800 USD. - - **So, we're here to ask for help.** If you have some spare change to send - our way, we'll gladly accept - - Thanks for helping Dress to Impress stay online and running smoothly! - - **And, to show our undying gratitude, we'll feature your outfits right - here!** Eeyup, for every $5 you send our way, we'll post one of your - beautiful outfits right here on the donors list, and feature it on the - homepage, too! Personally, I'm looking forward to seeing all your lovely - creations, and wishing I could make things even [half as pretty][matts_bat] - - (See the fine print at the bottom of the page for details.) - - **Thanks again for all your help.** Dress to Impress runs on you, from our - data to our servers. You make this site the great resource that it is, and - I'm consistently impressed by this community's generosity. Thanks for - all you do! - - [linode]: https://www.linode.com/pricing - [aws]: http://aws.amazon.com/ - [matts_bat]: http://www.neopets.com/petlookup.phtml?pet=matts_bat +#description= md @campaign.description - if @donations.present? %h2 Thanks to our lovely donors! @@ -97,6 +47,9 @@ %header Thanks, #{donation.donor_name.presence || 'Anonymous'}! +- if @campaign.active? + %p#last-years-donors= link_to "Don't forget to check out last year's donors, too!", Campaign.first + #fine-print %h2 Other ways to donate :markdown diff --git a/app/views/donations/show.html.haml b/app/views/donations/show.html.haml index f56a932d..7e23851e 100644 --- a/app/views/donations/show.html.haml +++ b/app/views/donations/show.html.haml @@ -14,7 +14,7 @@ %p %strong But enough about us. Let's talk about you! - When we brag about you on our #{link_to 'donors list', donate_path}, + When we brag about you on our #{link_to 'donors list', @donation.campaign}, what should we say? (If you'd rather take care of this later, no worries! Check your email for a copy of this URL.) diff --git a/config/routes.rb b/config/routes.rb index 613ad966..a0035b7c 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -86,6 +86,9 @@ OpenneoImpressItems::Application.routes.draw do end end + resources :campaigns, only: [:show], path: '/donate/campaigns' + match '/donate' => 'campaigns#current', as: :donate + match 'users/current-user/closet' => 'closet_hangers#index', :as => :your_items match 'users/top-contributors' => 'users#top_contributors', :as => :top_contributors @@ -94,7 +97,6 @@ OpenneoImpressItems::Application.routes.draw do match '/wardrobe' => 'outfits#edit', :as => :wardrobe match '/start/:color_name/:species_name' => 'outfits#start' - match '/donate' => 'static#donate', :as => :donate match 'image-mode' => 'static#image_mode', :as => :image_mode match '/terms' => 'static#terms', :as => :terms diff --git a/db/migrate/20150728192329_add_description_to_campaigns.rb b/db/migrate/20150728192329_add_description_to_campaigns.rb new file mode 100644 index 00000000..98f440ac --- /dev/null +++ b/db/migrate/20150728192329_add_description_to_campaigns.rb @@ -0,0 +1,5 @@ +class AddDescriptionToCampaigns < ActiveRecord::Migration + def change + add_column :campaigns, :description, :text, null: false, default: '' + end +end diff --git a/db/migrate/20150728195029_add_name_to_campaigns.rb b/db/migrate/20150728195029_add_name_to_campaigns.rb new file mode 100644 index 00000000..7df25bbd --- /dev/null +++ b/db/migrate/20150728195029_add_name_to_campaigns.rb @@ -0,0 +1,6 @@ +class AddNameToCampaigns < ActiveRecord::Migration + def change + # TODO: translations? + add_column :campaigns, :name, :string, null: false, default: 'our hosting costs this year' + end +end diff --git a/db/migrate/20150802202909_add_theme_id_to_campaigns.rb b/db/migrate/20150802202909_add_theme_id_to_campaigns.rb new file mode 100644 index 00000000..2d7aef80 --- /dev/null +++ b/db/migrate/20150802202909_add_theme_id_to_campaigns.rb @@ -0,0 +1,5 @@ +class AddThemeIdToCampaigns < ActiveRecord::Migration + def change + add_column :campaigns, :theme_id, :string, null: false, default: 'hug' + end +end diff --git a/db/schema.rb b/db/schema.rb index 2147294d..56a669ba 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20150225194522) do +ActiveRecord::Schema.define(:version => 20150802202909) do create_table "auth_servers", :force => true do |t| t.string "short_name", :limit => 10, :null => false @@ -33,12 +33,15 @@ ActiveRecord::Schema.define(:version => 20150225194522) do add_index "campaign_translations", ["locale"], :name => "index_campaign_translations_on_locale" create_table "campaigns", :force => true do |t| - t.integer "progress", :null => false - t.integer "goal", :null => false - t.boolean "active", :null => false - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.boolean "advertised", :default => true, :null => false + t.integer "progress", :null => false + t.integer "goal", :null => false + t.boolean "active", :null => false + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.boolean "advertised", :default => true, :null => false + t.text "description", :null => false + t.string "name", :default => "our hosting costs this year", :null => false + t.string "theme_id", :default => "hug", :null => false end create_table "campaigns_old", :force => true do |t| diff --git a/spec/controllers/campaigns_controller_spec.rb b/spec/controllers/campaigns_controller_spec.rb new file mode 100644 index 00000000..3c06fcef --- /dev/null +++ b/spec/controllers/campaigns_controller_spec.rb @@ -0,0 +1,5 @@ +require 'spec_helper' + +describe CampaignsController do + +end diff --git a/spec/helpers/campaigns_helper_spec.rb b/spec/helpers/campaigns_helper_spec.rb new file mode 100644 index 00000000..76e29d3d --- /dev/null +++ b/spec/helpers/campaigns_helper_spec.rb @@ -0,0 +1,15 @@ +require 'spec_helper' + +# Specs in this file have access to a helper object that includes +# the CampaignsHelper. For example: +# +# describe CampaignsHelper do +# describe "string concat" do +# it "concats two strings with spaces" do +# helper.concat_strings("this","that").should == "this that" +# end +# end +# end +describe CampaignsHelper do + pending "add some examples to (or delete) #{__FILE__}" +end