Skip to content

Commit

Permalink
Remove deprecated warnings, and move core helpers to frontend.
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeff Dutil authored and Jeff Dutil committed Dec 2, 2014
1 parent 620caa7 commit d466afc
Show file tree
Hide file tree
Showing 19 changed files with 51 additions and 105 deletions.
31 changes: 0 additions & 31 deletions core/app/helpers/spree/checkout_helper.rb

This file was deleted.

6 changes: 5 additions & 1 deletion frontend/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## Spree 3.0.0 (unreleased) ##

Switched to Bootstrap
* Switched to Bootstrap.

Jeff Dutil & [Other Contributors](https://github.com/200Creative/spree_bootstrap_frontend/graphs/contributors)

* Moved Core's helpers into Frontend. Jeff Dutil
File renamed without changes.
30 changes: 0 additions & 30 deletions frontend/app/helpers/spree/checkout_helper_decorator.rb

This file was deleted.

44 changes: 39 additions & 5 deletions frontend/app/helpers/spree/frontend_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,47 @@ module FrontendHelper
def breadcrumbs(taxon, separator=" ")
return "" if current_page?("/") || taxon.nil?
separator = raw(separator)
crumbs = [content_tag(:li, content_tag(:span, link_to(Spree.t(:home), spree.root_path, itemprop: "url") + separator, itemprop: "title"), itemscope:"itemscope", itemtype:"http://data-vocabulary.org/Breadcrumb")]
crumbs = [content_tag(:li, content_tag(:span, link_to(Spree.t(:home), spree.root_path, itemprop: "url") + separator, itemprop: "title"), itemscope: "itemscope", itemtype: "http://data-vocabulary.org/Breadcrumb")]
if taxon
crumbs << content_tag(:li, content_tag(:span, link_to(Spree.t(:products), products_path, itemprop: "url") + separator, itemprop: "title"), itemscope:"itemscope", itemtype:"http://data-vocabulary.org/Breadcrumb")
crumbs << taxon.ancestors.collect { |ancestor| content_tag(:li, content_tag(:span, link_to(ancestor.name , seo_url(ancestor), itemprop: "url") + separator, itemprop: "title"), itemscope:"itemscope", itemtype:"http://data-vocabulary.org/Breadcrumb") } unless taxon.ancestors.empty?
crumbs << content_tag(:li, content_tag(:span, link_to(taxon.name , seo_url(taxon), itemprop: "url"), itemprop: "title"), class: 'active', itemscope:"itemscope", itemtype:"http://data-vocabulary.org/Breadcrumb")
crumbs << content_tag(:li, content_tag(:span, link_to(Spree.t(:products), products_path, itemprop: "url") + separator, itemprop: "title"), itemscope: "itemscope", itemtype: "http://data-vocabulary.org/Breadcrumb")
crumbs << taxon.ancestors.collect { |ancestor| content_tag(:li, content_tag(:span, link_to(ancestor.name , seo_url(ancestor), itemprop: "url") + separator, itemprop: "title"), itemscope: "itemscope", itemtype: "http://data-vocabulary.org/Breadcrumb") } unless taxon.ancestors.empty?
crumbs << content_tag(:li, content_tag(:span, link_to(taxon.name , seo_url(taxon), itemprop: "url"), itemprop: "title"), class: 'active', itemscope: "itemscope", itemtype: "http://data-vocabulary.org/Breadcrumb")
else
crumbs << content_tag(:li, content_tag(:span, Spree.t(:products), itemprop: "title"), class: 'active', itemscope:"itemscope", itemtype:"http://data-vocabulary.org/Breadcrumb")
crumbs << content_tag(:li, content_tag(:span, Spree.t(:products), itemprop: "title"), class: 'active', itemscope: "itemscope", itemtype: "http://data-vocabulary.org/Breadcrumb")
end
crumb_list = content_tag(:ol, raw(crumbs.flatten.map{|li| li.mb_chars}.join), class: 'breadcrumb')
content_tag(:nav, crumb_list, id: 'breadcrumbs', class: 'col-md-12')
end

def checkout_progress
states = @order.checkout_steps
items = states.map do |state|
text = Spree.t("order_state.#{state}").titleize

css_classes = []
current_index = states.index(@order.state)
state_index = states.index(state)

if state_index < current_index
css_classes << 'completed'
text = link_to text, checkout_state_path(state)
end

css_classes << 'next' if state_index == current_index + 1
css_classes << 'active' if state == @order.state
css_classes << 'first' if state_index == 0
css_classes << 'last' if state_index == states.length - 1
# No more joined classes. IE6 is not a target browser.
# Hack: Stops <a> being wrapped round previous items twice.
if state_index < current_index
content_tag('li', text, class: css_classes.join(' '))
else
content_tag('li', content_tag('a', text), class: css_classes.join(' '))
end
end
content_tag('ul', raw(items.join("\n")), class: 'progress-steps nav nav-pills nav-justified', id: "checkout-step-#{@order.state}")
end

def flash_messages(opts = {})
ignore_types = ["order_completed"].concat(Array(opts[:ignore_types]).map(&:to_s) || [])

Expand All @@ -41,6 +70,11 @@ def link_to_cart(text = nil)
link_to text.html_safe, spree.cart_path, :class => "cart-info #{css_class}"
end

# helper to determine if its appropriate to show the store menu
def store_menu?
%w{thank_you}.exclude? params[:action]
end

def taxons_tree(root_taxon, current_taxon, max_level = 1)
return '' if max_level < 1 || root_taxon.children.empty?
content_tag :div, class: 'list-group' do
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,3 @@ def order_just_completed?(order)
end
end
end

File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
# Methods added to this helper will be available to all templates in the frontend.
module Spree
module StoreHelper

# helper to determine if its appropriate to show the store menu
def store_menu?
%w{thank_you}.exclude? params[:action]
end

def cache_key_for_taxons
max_updated_at = @taxons.maximum(:updated_at).to_i
parts = [@taxon.try(:id), max_updated_at].compact.join("-")
Expand Down
File renamed without changes.

This file was deleted.

7 changes: 0 additions & 7 deletions frontend/config/initializers/deprecation_checker.rb

This file was deleted.

8 changes: 0 additions & 8 deletions frontend/config/initializers/rails_5868.rb

This file was deleted.

9 changes: 4 additions & 5 deletions frontend/lib/spree/frontend.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
require 'rails/all'
require 'jquery-rails'

require 'bootstrap-kaminari-views'
require 'canonical-rails'
require 'deface'
require 'bootstrap-kaminari-views'

require 'jquery-rails'
require 'spree/core'

require 'spree/responder'
require 'spree/frontend/middleware/seo_assist'
require 'spree/frontend/engine'
require 'spree/responder'
4 changes: 2 additions & 2 deletions frontend/lib/spree/frontend/engine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ class Engine < ::Rails::Engine
config.middleware.use "Spree::Frontend::Middleware::SeoAssist"

# sets the manifests / assets to be precompiled, even when initialize_on_precompile is false
initializer "spree.assets.precompile", :group => :all do |app|
initializer "spree.assets.precompile", group: :all do |app|
app.config.assets.precompile += %w[
spree/frontend/all*
jquery.validate/localization/messages_*
]
end

initializer "spree.frontend.environment", :before => :load_config_initializers do |app|
initializer "spree.frontend.environment", before: :load_config_initializers do |app|
Spree::Frontend::Config = Spree::FrontendConfiguration.new
end
end
Expand Down
1 change: 1 addition & 0 deletions frontend/lib/spree/frontend/preference_rescue.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# TODO: I think this can be removed now?
module Spree
class OldPrefs < ActiveRecord::Base
self.table_name = "spree_preferences"
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit d466afc

Please sign in to comment.