Skip to content

Commit

Permalink
decouple themes from the main application some more
Browse files Browse the repository at this point in the history
  • Loading branch information
parndt committed Feb 23, 2010
1 parent 81329cb commit 266c848
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 27 deletions.
27 changes: 0 additions & 27 deletions vendor/plugins/refinery/lib/refinery/application_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,24 +34,6 @@ def image_fu(image, thumbnail = nil , options={})
end
end

def image_tag(source, options={})
theme = (options.delete(:theme) == true)
tag = super
# inject /theme/ into the image tag src if this is themed.
tag.gsub!(/src=[\"|\']/) { |m| "#{m}/theme/" }.gsub!("//", "/") if theme

tag
end

def javascript_include_tag(*sources)
theme = (arguments = sources.dup).extract_options![:theme] == true # don't ruin the current sources object
tag = super
# inject /theme/ into the javascript include tag src if this is themed.
tag.gsub!(/\/javascripts\//, "/theme/javascripts/").gsub!(/theme=(.+?)\ /, '') if theme

tag
end

def jquery_include_tags(use_caching=RefinerySetting.find_or_set(:use_resource_caching, false))
if !local_request? and RefinerySetting.find_or_set(:use_google_ajax_libraries, true)
"#{javascript_include_tag("http://www.google.com/jsapi").gsub(".js", "")}
Expand Down Expand Up @@ -123,15 +105,6 @@ def selected_page?(page)
selected = current_page?(page) or (request.path =~ Regexp.new(page.menu_match) unless page.menu_match.blank?) or (request.path == page.link_url)
end

def stylesheet_link_tag(*sources)
theme = (arguments = sources.dup).extract_options![:theme] == true # don't ruin the current sources object
tag = super
# inject /theme/ into the stylesheet link tag href if this is themed.
tag.gsub!(/\/stylesheets\//, "/theme/stylesheets/").gsub!(/theme=(.+?)\ /, '') if theme

tag
end

def setup
logger.warn("*** Refinery::ApplicationHelper::setup has now been deprecated from the Refinery API. ***")
end
Expand Down
25 changes: 25 additions & 0 deletions vendor/plugins/themes/app/helpers/themes_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
module ThemesHelper
def image_tag(source, options={})
theme = (options.delete(:theme) == true)
tag = super
# inject /theme/ into the image tag src if this is themed.
tag.gsub!(/src=[\"|\']/) { |m| "#{m}/theme/" }.gsub!("//", "/") if theme
tag.gsub(/theme=(.+?)\ /, '') # we need to remove any addition of theme='false' etc.
end

def javascript_include_tag(*sources)
theme = (arguments = sources.dup).extract_options![:theme] == true # don't ruin the current sources object
tag = super
# inject /theme/ into the javascript include tag src if this is themed.
tag.gsub!(/\/javascripts\//, "/theme/javascripts/") if theme
tag.gsub(/theme=(.+?)\ /, '') # we need to remove any addition of theme='false' etc.
end

def stylesheet_link_tag(*sources)
theme = (arguments = sources.dup).extract_options![:theme] == true # don't ruin the current sources object
tag = super
# inject /theme/ into the stylesheet link tag href if this is themed.
tag.gsub!(/\/stylesheets\//, "/theme/stylesheets/") if theme
tag.gsub(/theme=(.+?)\ /, '') # we need to remove any addition of theme='false' etc.
end
end
2 changes: 2 additions & 0 deletions vendor/plugins/themes/rails/init.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,6 @@

::ActiveSupport::Dependencies.load_paths.unshift controller_path
config.controller_paths.unshift controller_path

Refinery::ApplicationHelper.send :include, ThemesHelper
end

0 comments on commit 266c848

Please sign in to comment.