From b5442d0f3f1efee5e0127bd17b00ee7bfc99401c Mon Sep 17 00:00:00 2001 From: Matchu Date: Sat, 26 Sep 2015 20:37:03 -0700 Subject: [PATCH] news posts read from the database, with a campaign-supplement classname option :) --- app/assets/stylesheets/_layout.sass | 5 ++++- app/assets/stylesheets/campaigns/_show.sass | 6 +++--- app/assets/stylesheets/outfits/_new.sass | 13 +++++++++++++ .../stylesheets/partials/_campaign-progress.sass | 2 ++ app/controllers/outfits_controller.rb | 2 ++ app/models/news_post.rb | 3 +++ app/views/outfits/new.html.haml | 3 +++ db/migrate/20150927033046_create_news_posts.rb | 10 ++++++++++ db/schema.rb | 9 ++++++++- spec/models/news_post_spec.rb | 5 +++++ 10 files changed, 53 insertions(+), 5 deletions(-) create mode 100644 app/models/news_post.rb create mode 100644 db/migrate/20150927033046_create_news_posts.rb create mode 100644 spec/models/news_post_spec.rb diff --git a/app/assets/stylesheets/_layout.sass b/app/assets/stylesheets/_layout.sass index 9d6cbf2f..63c33f54 100644 --- a/app/assets/stylesheets/_layout.sass +++ b/app/assets/stylesheets/_layout.sass @@ -119,11 +119,14 @@ ul.buttons #locale-form float: right -.success, .alert, .warning +=flash margin-bottom: 1em padding: .25em .5em text-align: center +.success, .alert, .warning + +flash + .success +notice diff --git a/app/assets/stylesheets/campaigns/_show.sass b/app/assets/stylesheets/campaigns/_show.sass index ee2f5889..37ce5719 100644 --- a/app/assets/stylesheets/campaigns/_show.sass +++ b/app/assets/stylesheets/campaigns/_show.sass @@ -12,10 +12,10 @@ $outfit-banner-inner-width: $outfit-inner-width - (2 * $outfit-banner-h-padding) body.campaigns-show, body.campaigns-current +campaign-progress - color: #004 + color: $campaign-text-color a - color: #004 + #222 + color: $campaign-text-color + #222 #userbar, #footer color: $text-color @@ -73,7 +73,7 @@ body.campaigns-show, body.campaigns-current input[type=text] border-color: #cce - color: #004 + color: $campaign-text-color width: 3em button diff --git a/app/assets/stylesheets/outfits/_new.sass b/app/assets/stylesheets/outfits/_new.sass index 051d875d..12f9c30d 100644 --- a/app/assets/stylesheets/outfits/_new.sass +++ b/app/assets/stylesheets/outfits/_new.sass @@ -3,6 +3,19 @@ body.outfits-new +campaign-progress + .news-post + p:last-child + margin-bottom: 0 + + &.campaign-supplement + +flash + background: $campaign-background-color + border: 1px solid $campaign-border-color + color: $campaign-text-color + + a + color: $campaign-link-color + #pet-not-found, #neopia-error display: none diff --git a/app/assets/stylesheets/partials/_campaign-progress.sass b/app/assets/stylesheets/partials/_campaign-progress.sass index a395921a..32ceb65d 100644 --- a/app/assets/stylesheets/partials/_campaign-progress.sass +++ b/app/assets/stylesheets/partials/_campaign-progress.sass @@ -1,5 +1,7 @@ $campaign-border-color: #006 $campaign-background-color: #eef +$campaign-text-color: #004 +$campaign-link-color: $campaign-text-color + #222 =campaign-progress .campaign-progress-wrapper diff --git a/app/controllers/outfits_controller.rb b/app/controllers/outfits_controller.rb index 22477f15..220eb346 100644 --- a/app/controllers/outfits_controller.rb +++ b/app/controllers/outfits_controller.rb @@ -79,6 +79,8 @@ class OutfitsController < ApplicationController @neopets_usernames = user_signed_in? ? current_user.neopets_usernames : [] @campaign = Campaign.current rescue nil + + @news_posts = NewsPost.all end def show diff --git a/app/models/news_post.rb b/app/models/news_post.rb new file mode 100644 index 00000000..5b5bdf53 --- /dev/null +++ b/app/models/news_post.rb @@ -0,0 +1,3 @@ +class NewsPost < ActiveRecord::Base + attr_accessible :body, :html_class +end diff --git a/app/views/outfits/new.html.haml b/app/views/outfits/new.html.haml index 4128b649..f9ff09f3 100644 --- a/app/views/outfits/new.html.haml +++ b/app/views/outfits/new.html.haml @@ -2,6 +2,9 @@ = advertise_campaign_progress @campaign +- @news_posts.each do |news_post| + .news-post{class: news_post.html_class}= md news_post.body + %p#pet-not-found.alert= t 'pets.load.not_found' %p#neopia-error.alert= t 'pets.load.neopia_error' diff --git a/db/migrate/20150927033046_create_news_posts.rb b/db/migrate/20150927033046_create_news_posts.rb new file mode 100644 index 00000000..06cd757b --- /dev/null +++ b/db/migrate/20150927033046_create_news_posts.rb @@ -0,0 +1,10 @@ +class CreateNewsPosts < ActiveRecord::Migration + def change + create_table :news_posts do |t| + t.text :body + t.string :html_class, default: 'success' + + t.timestamps + end + end +end diff --git a/db/schema.rb b/db/schema.rb index e72a496d..8da3610a 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 => 20150923052017) do +ActiveRecord::Schema.define(:version => 20150927033046) do create_table "auth_servers", :force => true do |t| t.string "short_name", :limit => 10, :null => false @@ -200,6 +200,13 @@ ActiveRecord::Schema.define(:version => 20150923052017) do t.datetime "updated_at", :null => false end + create_table "news_posts", :force => true do |t| + t.text "body" + t.string "html_class", :default => "success" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + create_table "outfit_features", :force => true do |t| t.integer "donation_id" t.integer "outfit_id" diff --git a/spec/models/news_post_spec.rb b/spec/models/news_post_spec.rb new file mode 100644 index 00000000..000af5af --- /dev/null +++ b/spec/models/news_post_spec.rb @@ -0,0 +1,5 @@ +require 'spec_helper' + +describe NewsPost do + pending "add some examples to (or delete) #{__FILE__}" +end