Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: spree/spree
...
head fork: spree/spree
  • 5 commits
  • 20 files changed
  • 0 commit comments
  • 3 contributors
Commits on Oct 08, 2011
@BDQ BDQ Dumped Deface version cbae351
Commits on Oct 10, 2011
@BDQ BDQ Add block to load/require overrides in install generator 91b51ab
Commits on Oct 11, 2011
@BDQ BDQ Fixed precompiling again b3c43fb
Commits on Oct 20, 2011
@cmar cmar Check for security alerts and other
important announcements.
d80e80d
@schof schof Version bump 866529b
View
46 Gemfile.lock
@@ -1,24 +1,24 @@
PATH
remote: .
specs:
- spree (0.70.0)
- spree_api (= 0.70.0)
- spree_auth (= 0.70.0)
- spree_core (= 0.70.0)
- spree_dash (= 0.70.0)
- spree_promo (= 0.70.0)
- spree_sample (= 0.70.0)
- spree_api (0.70.0)
- spree_auth (= 0.70.0)
- spree_core (= 0.70.0)
- spree_auth (0.70.0)
+ spree (0.70.1)
+ spree_api (= 0.70.1)
+ spree_auth (= 0.70.1)
+ spree_core (= 0.70.1)
+ spree_dash (= 0.70.1)
+ spree_promo (= 0.70.1)
+ spree_sample (= 0.70.1)
+ spree_api (0.70.1)
+ spree_auth (= 0.70.1)
+ spree_core (= 0.70.1)
+ spree_auth (0.70.1)
cancan (= 1.6.5)
devise (= 1.4.7)
- spree_core (= 0.70.0)
- spree_core (0.70.0)
+ spree_core (= 0.70.1)
+ spree_core (0.70.1)
activemerchant (= 1.17.0)
acts_as_list (= 0.1.4)
- deface (>= 0.6.1)
+ deface (>= 0.7.0)
faker (= 1.0.0)
highline (= 1.5.1)
jquery-rails (>= 1.0.14)
@@ -31,13 +31,13 @@ PATH
rd_resource_controller
state_machine (= 1.0.1)
stringex (= 1.0.3)
- spree_dash (0.70.0)
- spree_core (= 0.70.0)
- spree_promo (0.70.0)
- spree_auth (= 0.70.0)
- spree_core (= 0.70.0)
- spree_sample (0.70.0)
- spree_core (= 0.70.0)
+ spree_dash (0.70.1)
+ spree_core (= 0.70.1)
+ spree_promo (0.70.1)
+ spree_auth (= 0.70.1)
+ spree_core (= 0.70.1)
+ spree_sample (0.70.1)
+ spree_core (= 0.70.1)
GEM
remote: http://rubygems.org/
@@ -113,7 +113,7 @@ GEM
nokogiri (>= 1.4.4)
rack-test (>= 0.5.7)
database_cleaner (0.6.7)
- deface (0.6.1)
+ deface (0.7.0)
nokogiri (~> 1.5.0)
rails (>= 3.0.9)
devise (1.4.7)
@@ -136,7 +136,7 @@ GEM
highline (1.5.1)
hike (1.2.1)
i18n (0.6.0)
- jquery-rails (1.0.14)
+ jquery-rails (1.0.16)
railties (~> 3.0)
thor (~> 0.14)
json (1.6.1)
View
2  README.md
@@ -49,7 +49,7 @@ Peformance
Rails 3.1 introduced a concept known as the asset pipeline. Unfortunately it results in poor performance when running your site in development mode (production mode is unaffected.) You may want to run the following command when testing locally in development mode
- $ bundle exec rake assets:precompile RAILS_ENV=development RAILS_ASSETS_NONDIGEST=true
+ $ bundle exec rake assets:precompile:nondigest
Using the precompile rake task in development will prevent any changes to asset files from being automatically included in when you reload the page. You must re-run the precompile task for changes to become available.
View
2  Rakefile
@@ -98,5 +98,5 @@ task :sandbox do
Spree::SiteGenerator.start
cmd = "bundle exec rake db:bootstrap AUTO_ACCEPT=true"; puts cmd; system cmd
- cmd = "bundle exec rake assets:precompile RAILS_ENV=development RAILS_ASSETS_NONDIGEST=true"; puts cmd; system cmd
+ cmd = "bundle exec rake assets:precompile:nondigest"; puts cmd; system cmd
end
View
2  SPREE_VERSION
@@ -1 +1 @@
-0.70.0
+0.70.1
View
8 core/app/assets/javascripts/admin/admin.js.erb
@@ -210,7 +210,7 @@ $(document).ready(function(){
$.each($('table.sortable tbody tr'), function(position, obj){
reg = /(\w+_?)+_(\d+)/;
parts = reg.exec($(obj).attr('id'));
- if (parts) {
+ if (parts) {
positions['positions['+parts[2]+']'] = position;
type = parts[1];
}
@@ -227,3 +227,9 @@ $(document).ready(function(){
});
});
+
+jQuery(document).ready(function() {
+ $('div.alert a.dismiss').click(function() {
+ $(this).parent().fadeOut();
+ });
+});
View
28 core/app/assets/stylesheets/admin/admin.css.erb
@@ -588,3 +588,31 @@ span.handle{
width:14px;
height:15px;
}
+
+.alert {
+ -moz-border-radius: 5px;
+ -webkit-border-radius: 5px;
+ border-radius: 5px;
+ font-size: 1.3em;
+ margin-bottom: 1em;
+ padding: 0.8em;
+}
+.alert a.dismiss {
+ float:right;
+ font-size: 0.8em;
+}
+.alert.release {
+ background: #ccddff url(../images/shadow_top.png) 0px -50px repeat-x;
+ color: #556699;
+ border: 1px solid #99aacc;
+}
+.alert.security {
+ background: #f4b4b4 url(../images/shadow_top.png) 0px -50px repeat-x;
+ color: #000000;
+ border: 1px solid #e75b5b;
+}
+.alert.news {
+ background: #ccffd4 url(../images/shadow_top.png) 0px -50px repeat-x;
+ color: #000000;
+ border: 1px solid #66ff7e;
+}
View
32 core/app/controllers/admin/base_controller.rb
@@ -1,12 +1,42 @@
class Admin::BaseController < Spree::BaseController
ssl_required
+ before_filter :check_alerts if Rails.env.production?
+
helper :search
helper 'admin/navigation'
layout 'admin'
protected
-
+ def check_alerts
+ return unless current_user and should_check_alerts?
+
+ unless session.has_key? :alerts
+ begin
+ session[:alerts] = Spree::Alert.current(request.host)
+ filter_dismissed_alerts
+ Spree::Config.set :last_check_for_spree_alerts => DateTime.now.to_s
+ rescue
+ session[:alerts] = nil
+ end
+ end
+ end
+
+ def should_check_alerts?
+ return false if not Spree::Config[:check_for_spree_alerts]
+
+ last_check = Spree::Config[:last_check_for_spree_alerts]
+ return true if last_check.blank?
+
+ DateTime.parse(last_check) < 12.hours.ago
+ end
+
+ def filter_dismissed_alerts
+ return unless session[:alerts]
+ dismissed = (Spree::Config[:dismissed_spree_alerts] || '').split(',')
+ session[:alerts].reject! { |a| dismissed.include? a.id.to_s }
+ end
+
def flash_message_for(object, event_sym)
resource_desc = object.class.model_name.human
resource_desc += " \"#{object.name}\"" if object.respond_to?(:name)
View
9 core/app/controllers/admin/general_settings_controller.rb
@@ -18,4 +18,13 @@ def update
redirect_to admin_general_settings_path
end
+ def dismiss_alert
+ if request.xhr? and params[:alert_id]
+ dismissed = Spree::Config[:dismissed_spree_alerts] || ''
+ Spree::Config.set :dismissed_spree_alerts => dismissed.split(',').push(params[:alert_id]).join(',')
+ filter_dismissed_alerts
+ render :nothing => true
+ end
+ end
+
end
View
3  core/app/models/app_configuration.rb
@@ -39,6 +39,9 @@ class AppConfiguration < Configuration
preference :allow_checkout_on_gateway_error, :boolean, :default => false
preference :select_taxons_from_tree, :boolean, :default => false # provide opportunity to select taxons from tree instead of search with autocomplete
preference :max_level_in_taxons_menu, :integer, :default => 1 # maximum nesting level in taxons menu
+ preference :check_for_spree_alerts, :boolean, :default => true
+ preference :dismissed_spree_alerts, :string, :default => ''
+ preference :last_check_for_spree_alerts, :string, :default => nil
validates :name, :presence => true, :uniqueness => true
View
13 core/app/models/spree/alert.rb
@@ -0,0 +1,13 @@
+class Spree::Alert < ActiveResource::Base
+ self.site = "http://alerts.spreecommerce.com/"
+ self.format = :json
+
+ def self.current(host)
+ find(:all, :params => { :version => Spree.version,
+ :name => Spree::Config[:site_name],
+ :host => host,
+ :rails_env => Rails.env,
+ :rails_version => Rails.version })
+ end
+end
+
View
6 core/app/views/admin/shared/_alert.html.erb
@@ -0,0 +1,6 @@
+<div class="alert <%= alert.severity.downcase %>">
+ <%= alert.message %> <%= link_to alert.url_name, alert.url if alert.url %>
+ <%= link_to 'X', dismiss_alert_admin_general_settings_path(:alert_id => alert.id),
+ :remote => true, :method => :post, :class => 'dismiss' %>
+</div>
+
View
2  core/app/views/layouts/admin.html.erb
@@ -40,6 +40,8 @@
<div class="flash notice"><%= notice %></div>
<% end %>
+ <%= render :partial => 'admin/shared/alert', :collection => session[:alerts] %>
+
<%= yield %>
<% if content_for?(:sidebar) %>
View
2  core/config/locales/en.yml
@@ -937,6 +937,8 @@ en:
ssl_will_be_used_in_production_mode: "SSL will be used in production mode"
ssl_will_not_be_used_in_development_and_test_modes: "SSL will not be used in development and test mode if necessary."
ssl_will_not_be_used_in_production_mode: "SSL will not be used in production mode"
+ spree_alert_checking: "Check for Spree security and release alerts"
+ spree_alert_not_checking: "Not checking for Spree security and release alerts"
start: Start
start_date: Valid from
state: State
View
6 core/config/routes.rb
@@ -159,7 +159,11 @@
end
end
- resource :general_settings
+ resource :general_settings do
+ collection do
+ post :dismiss_alert
+ end
+ end
resources :taxonomies do
member do
View
10 core/lib/generators/spree/site/site_generator.rb
@@ -56,15 +56,25 @@ def setup_assets
template "app/assets/stylesheets/admin/all.css"
end
+ def create_overrides_directory
+ empty_directory "app/overrides"
+ end
+
def configure_application
application <<-APP
config.middleware.use "SeoAssist"
config.middleware.use "RedirectLegacyProductUrl"
config.to_prepare do
+ #loads application's model / class decorators
Dir.glob(File.join(File.dirname(__FILE__), "../app/**/*_decorator*.rb")) do |c|
Rails.configuration.cache_classes ? require(c) : load(c)
end
+
+ #loads application's deface view overrides
+ Dir.glob(File.join(File.dirname(__FILE__), "../app/overrides/*.rb")) do |c|
+ Rails.application.config.cache_classes ? require(c) : load(c)
+ end
end
APP
View
2  core/lib/spree_core/railtie.rb
@@ -55,7 +55,7 @@ def self.activate
end
# sets the manifests / assets to be precompiled
- initializer "spree.assets.precompile", :group => :assets do |app|
+ initializer "spree.assets.precompile" do |app|
app.config.assets.precompile += ['store/all.*', 'admin/all.*', 'admin/spree_dash.*', 'admin/orders/edit_form.js', 'jqPlot/excanvas.min.js', 'admin/images/new.js']
end
View
2  core/lib/spree_core/version.rb
@@ -1,5 +1,5 @@
module Spree
def self.version
- "0.70.0"
+ "0.70.1"
end
end
View
61 core/spec/controllers/admin/base_controller_spec.rb
@@ -0,0 +1,61 @@
+require File.dirname(__FILE__) + '/../../spec_helper'
+
+describe Admin::BaseController do
+
+ describe "Spree Alert Checks" do
+ it "only checks once per session" do
+ controller.stub(:current_user => true)
+ Spree::Config.set :check_for_spree_alerts => true
+ session[:alerts] = []
+ Spree::Alert.should_not_receive(:current)
+ controller.send(:check_alerts)
+ end
+
+ it "does not check if preference is false" do
+ controller.stub(:current_user => true)
+ Spree::Config.set :check_for_spree_alerts => false
+ controller.send(:check_alerts)
+ session[:alerts].should be_nil
+ end
+
+ it "checks alerts if preference is true" do
+ controller.stub(:current_user => true)
+ Spree::Config.set :check_for_spree_alerts => true
+ alerts = []
+ Spree::Alert.should_receive(:current).and_return(alerts)
+ controller.send(:check_alerts)
+ session[:alerts].should eq alerts
+ Spree::Config[:last_check_for_spree_alerts].should_not be_nil
+ end
+
+ it "filters alerts stored in preferences" do
+ Spree::Config.set :dismissed_spree_alerts => "1,3"
+ alerts = [mock(:id => 1), mock(:id => 2), mock(:id => 3)]
+ session[:alerts] = alerts
+ controller.send(:filter_dismissed_alerts)
+ session[:alerts].count.should be 1
+ session[:alerts].first.id.should be 2
+ end
+
+ it "checks if last check was more then 12 hours" do
+ Spree::Config.set :check_for_spree_alerts => true
+ Spree::Config.set :last_check_for_spree_alerts => 13.hours.ago.to_s
+ controller.send(:should_check_alerts?).should be_true
+ end
+
+ it "does not check if last check was recent" do
+ Spree::Config.set :check_for_spree_alerts => true
+ Spree::Config.set :last_check_for_spree_alerts => 4.hours.ago.to_s
+ controller.send(:should_check_alerts?).should be_false
+ end
+
+ it "does not check if preference is false" do
+ Spree::Config.set :check_for_spree_alerts => false
+ controller.send(:should_check_alerts?).should be_false
+ end
+
+ end
+
+end
+
+
View
17 core/spec/controllers/admin/general_settings_controller_spec.rb
@@ -0,0 +1,17 @@
+require File.dirname(__FILE__) + '/../../spec_helper'
+
+describe Admin::GeneralSettingsController do
+ before :each do
+ controller.stub :current_user => mock
+ end
+
+ it "saves dismissed alerts in a preference" do
+ Spree::Config.set :dismissed_spree_alerts => "1"
+ xhr :post, :dismiss_alert, :alert_id => 2
+ response.response_code.should == 200
+ Spree::Config[:dismissed_spree_alerts].should eq "1,2"
+ end
+
+end
+
+
View
2  core/spree_core.gemspec
@@ -33,5 +33,5 @@ Gem::Specification.new do |s|
s.add_dependency 'activemerchant', '= 1.17.0'
s.add_dependency 'rails', '= 3.1.1'
s.add_dependency 'kaminari', '>= 0.12.4'
- s.add_dependency 'deface', '>= 0.6.1'
+ s.add_dependency 'deface', '>= 0.7.0'
end

No commit comments for this range

Something went wrong with that request. Please try again.