Skip to content

Commit

Permalink
updated for 0.10.2
Browse files Browse the repository at this point in the history
  • Loading branch information
pkordel authored and myabc committed May 17, 2010
1 parent fd4a456 commit b7cc2a1
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 20 deletions.
21 changes: 1 addition & 20 deletions wordsmith_extension.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,6 @@ def activate
# app/controllers/admin/yourextension_controller
# and that you mapped your admin in config/routes

Admin::BaseController.class_eval do
before_filter :add_wordsmith_tab
#
def add_wordsmith_tab
# # add_extension_admin_tab takes an array containing the same arguments expected
# # by the tab helper method:
# # [ :extension_name, { :label => "Your Extension", :route => "/some/non/standard/route" } ]
add_extension_admin_tab [ :wordsmith, { :label => t("Wordsmith"), :route => :admin_posts } ]
end
end

# make your helper avaliable in all views
Spree::BaseController.class_eval do
helper WordsmithHelper
Expand Down Expand Up @@ -74,15 +63,7 @@ def title_with_wordsmith_post_check
preference :wordsmith_page_status_default, :integer, :default => 0
preference :wordsmith_page_comment_default, :integer, :default => 0
preference :wordsmith_rss_description, :string, :default => 'description about your main post rss.'
end

# TODO: Not sure I like this solution for the long term because you cannot control placement in view.
Admin::UsersController.class_eval do
before_filter :add_display_name_field
def add_display_name_field
@extension_partials << 'display_name'
end
end
end

User.class_eval do
has_many :ws_items
Expand Down
49 changes: 49 additions & 0 deletions wordsmith_hooks.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
class WordsmithHooks < Spree::ThemeSupport::HookListener

#
# In this file you can modify the content of the hooks available in the default templates
# and avoid overriding a template in many situations. Multiple extensions can modify the
# same hook, the changes being applied cumulatively based on extension load order
#
# Most hooks are defined with blocks so they span a region of the template, allowing content
# to be replaced or removed as well as added to.
#
# Usage
#
# The following methods are available
#
# * insert_before
# * insert_after
# * replace
# * remove
#
# All accept a block name symbol followed either by arguments that would be valid for 'render'
# or a block which returns the string to be inserted. The block will have access to any methods
# or instance variables accessible in your views
#
# Examples
#
# insert_before :homepage_products, :text => "<h1>Welcome!</h1>"
# insert_after :homepage_products, 'shared/offers' # renders a partial
# replace :taxon_sidebar_navigation, 'shared/my_sidebar
#
# adding a link below product details:
#
# insert_after :product_description do
# '<p>' + link_to('Back to products', products_path) + '</p>'
# end
#
# adding a new tab to the admin navigation
#
# insert_after :admin_tabs do
# tab(:taxonomies)
# end
#

insert_after :admin_tabs do
%(<%= tab(:wordsmith, :label => t("Wordsmith"), :route => :admin_posts) %>)
end

insert_after :admin_user_form_fields, "admin/users/display_name"

end

0 comments on commit b7cc2a1

Please sign in to comment.