diff --git a/.gitignore b/.gitignore index 7fa29ee..ad019ae 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,6 @@ spec/dummy/db/*.sqlite3 spec/dummy/log/test.log .svn *.gem + +# http://stackoverflow.com/questions/4151495/should-gemfile-lock-be-included-in-gitignore +Gemfile.lock diff --git a/Gemfile.lock b/Gemfile.lock deleted file mode 100644 index 039bfde..0000000 --- a/Gemfile.lock +++ /dev/null @@ -1,91 +0,0 @@ -PATH - remote: . - specs: - themes_for_rails (0.5.1) - rails (>= 3.0.0) - -GEM - remote: http://rubygems.org/ - specs: - abstract (1.0.0) - actionmailer (3.0.11) - actionpack (= 3.0.11) - mail (~> 2.2.19) - actionpack (3.0.11) - activemodel (= 3.0.11) - activesupport (= 3.0.11) - builder (~> 2.1.2) - erubis (~> 2.6.6) - i18n (~> 0.5.0) - rack (~> 1.2.1) - rack-mount (~> 0.6.14) - rack-test (~> 0.5.7) - tzinfo (~> 0.3.23) - activemodel (3.0.11) - activesupport (= 3.0.11) - builder (~> 2.1.2) - i18n (~> 0.5.0) - activerecord (3.0.11) - activemodel (= 3.0.11) - activesupport (= 3.0.11) - arel (~> 2.0.10) - tzinfo (~> 0.3.23) - activeresource (3.0.11) - activemodel (= 3.0.11) - activesupport (= 3.0.11) - activesupport (3.0.11) - arel (2.0.10) - builder (2.1.2) - contest (0.1.2) - erubis (2.6.6) - abstract (>= 1.0.0) - i18n (0.5.0) - json (1.6.5) - mail (2.2.19) - activesupport (>= 2.3.6) - i18n (>= 0.4.0) - mime-types (~> 1.16) - treetop (~> 1.4.8) - mime-types (1.17.2) - mocha (0.9.12) - polyglot (0.3.3) - rack (1.2.5) - rack-mount (0.6.14) - rack (>= 1.0.0) - rack-test (0.5.7) - rack (>= 1.0) - rails (3.0.11) - actionmailer (= 3.0.11) - actionpack (= 3.0.11) - activerecord (= 3.0.11) - activeresource (= 3.0.11) - activesupport (= 3.0.11) - bundler (~> 1.0) - railties (= 3.0.11) - railties (3.0.11) - actionpack (= 3.0.11) - activesupport (= 3.0.11) - rake (>= 0.8.7) - rdoc (~> 3.4) - thor (~> 0.14.4) - rake (0.9.2.2) - rdoc (3.12) - json (~> 1.4) - sqlite3 (1.3.5) - test-unit (2.2.0) - thor (0.14.6) - treetop (1.4.10) - polyglot - polyglot (>= 0.3.1) - tzinfo (0.3.31) - -PLATFORMS - ruby - -DEPENDENCIES - contest - mocha - rails (= 3.0.11) - sqlite3 - test-unit - themes_for_rails! diff --git a/lib/themes_for_rails.rb b/lib/themes_for_rails.rb index 09a97a9..b68774e 100644 --- a/lib/themes_for_rails.rb +++ b/lib/themes_for_rails.rb @@ -53,7 +53,7 @@ def already_configured_in_sass?(sass_dir) require 'themes_for_rails/url_helpers' require 'themes_for_rails/action_view' -require 'themes_for_rails/assets_controller' +#require 'themes_for_rails/assets_controller' require 'themes_for_rails/action_controller' require 'themes_for_rails/action_mailer' require 'themes_for_rails/railtie' diff --git a/lib/themes_for_rails/common_methods.rb b/lib/themes_for_rails/common_methods.rb index c7fe876..9f54d3d 100644 --- a/lib/themes_for_rails/common_methods.rb +++ b/lib/themes_for_rails/common_methods.rb @@ -24,6 +24,7 @@ def set_theme(name) self.theme_name = name if valid_theme? add_theme_view_path + #add_theme_sprockets_path end end @@ -62,5 +63,17 @@ def theme_view_path_for(theme_name) def theme_asset_path_for(theme_name) interpolate(ThemesForRails.config.assets_dir, theme_name) end + + protected + + def add_theme_sprockets_path + ['stylesheets', 'javascripts', 'images'].each do |kind| + path = File.join(theme_asset_path, kind) + unless Rails.application.assets.paths.include?(path) + Rails.application.assets.prepend_path path + end + end + end + end -end \ No newline at end of file +end diff --git a/lib/themes_for_rails/railtie.rb b/lib/themes_for_rails/railtie.rb index 276446d..d64576f 100644 --- a/lib/themes_for_rails/railtie.rb +++ b/lib/themes_for_rails/railtie.rb @@ -10,7 +10,7 @@ class Railtie < ::Rails::Railtie end # Adding theme stylesheets path to sass, automatically. - ThemesForRails.add_themes_path_to_sass if ThemesForRails.config.use_sass? + #ThemesForRails.add_themes_path_to_sass if ThemesForRails.config.use_sass? ActiveSupport.on_load(:action_view) do include ThemesForRails::ActionView @@ -29,4 +29,4 @@ class Railtie < ::Rails::Railtie load "tasks/themes_for_rails.rake" end end -end \ No newline at end of file +end diff --git a/lib/themes_for_rails/routes.rb b/lib/themes_for_rails/routes.rb index d52301b..8950541 100644 --- a/lib/themes_for_rails/routes.rb +++ b/lib/themes_for_rails/routes.rb @@ -5,13 +5,13 @@ module Routes def themes_for_rails theme_dir = ThemesForRails.config.themes_routes_dir constraints = { :theme => /[\w\.]*/ } - - match "#{theme_dir}/:theme/stylesheets/*asset" => 'themes_for_rails/assets#stylesheets', - :as => :base_theme_stylesheet, :constraints => constraints - match "#{theme_dir}/:theme/javascripts/*asset" => 'themes_for_rails/assets#javascripts', - :as => :base_theme_javascript, :constraints => constraints - match "#{theme_dir}/:theme/images/*asset" => 'themes_for_rails/assets#images', - :as => :base_theme_image, :constraints => constraints + +# get "#{theme_dir}/:theme/stylesheets/*asset" => 'themes_for_rails/assets#stylesheets', +# :as => :base_theme_stylesheet, :constraints => constraints +# get "#{theme_dir}/:theme/javascripts/*asset" => 'themes_for_rails/assets#javascripts', +# :as => :base_theme_javascript, :constraints => constraints +# get "#{theme_dir}/:theme/images/*asset" => 'themes_for_rails/assets#images', +# :as => :base_theme_image, :constraints => constraints end end diff --git a/lib/themes_for_rails/url_helpers.rb b/lib/themes_for_rails/url_helpers.rb index 43dbc47..1010288 100644 --- a/lib/themes_for_rails/url_helpers.rb +++ b/lib/themes_for_rails/url_helpers.rb @@ -3,13 +3,26 @@ module ThemesForRails module UrlHelpers extend ActiveSupport::Concern + include AbstractController::Helpers included do helper_method :current_theme_stylesheet_path, :current_theme_javascript_path, :current_theme_image_path end - + + def base_theme_stylesheet_path(args) + base_theme_asset_path('stylesheets', args) + end + + def base_theme_javascript_path(args) + base_theme_asset_path('javascripts', args) + end + + def base_theme_image_path(args) + base_theme_asset_path('images', args) + end + def current_theme_stylesheet_path(asset) base_theme_stylesheet_path(:theme => self.theme_name, :asset => "#{asset}.css") end @@ -23,5 +36,12 @@ def current_theme_image_path(asset) base_theme_image_path(:theme => self.theme_name, :asset => "#{image}.#{extension}") end + protected + + def base_theme_asset_path(asset, args) + theme_dir = ThemesForRails.config.themes_routes_dir + File.join('/themes', args[:theme], asset, args[:asset]) + end + end -end \ No newline at end of file +end