Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -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
91 changes: 0 additions & 91 deletions Gemfile.lock

This file was deleted.

2 changes: 1 addition & 1 deletion lib/themes_for_rails.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
15 changes: 14 additions & 1 deletion lib/themes_for_rails/common_methods.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
end
4 changes: 2 additions & 2 deletions lib/themes_for_rails/railtie.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -29,4 +29,4 @@ class Railtie < ::Rails::Railtie
load "tasks/themes_for_rails.rake"
end
end
end
end
14 changes: 7 additions & 7 deletions lib/themes_for_rails/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
24 changes: 22 additions & 2 deletions lib/themes_for_rails/url_helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
end