Skip to content

Commit

Permalink
Allow for image folder to be nested within css folder in theme
Browse files Browse the repository at this point in the history
  • Loading branch information
drnic committed Mar 3, 2010
1 parent b7178a3 commit 50d9e09
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 10 deletions.
10 changes: 6 additions & 4 deletions lib/install_theme.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ def initialize(options = {})
@template_root = File.expand_path(options[:template_root] || File.dirname('.'))
@rails_root = File.expand_path(options[:rails_root] || File.dirname('.'))
@template_type = (options[:template_type] || detect_template).to_s
@defaults_file = options[:defaults_file] || "install_theme.yml"
@defaults_file = options[:defaults_file] || "install_theme.yml"
@stylesheet_dir = options[:stylesheet_dir] || detect_stylesheet_dir
@javascript_dir = options[:javascript_dir] || detect_javascript_dir
@image_dir = options[:image_dir] || detect_image_dir
@layout_name = options[:layout] || "application"
@image_dir = options[:image_dir] || detect_image_dir
@layout_name = options[:layout] || "application"
@layout_name.gsub!(/\..*/, '') # allow application.html.erb to be passed in, but clean it up to 'application'
@action = options[:action]

Expand Down Expand Up @@ -362,7 +362,9 @@ def template_images
end

def clean_stylesheet(contents)
contents.gsub(%r{url\((["']?)[\./]*(#{image_dir}|#{stylesheet_dir}|)\/?(.*?)(["']?)\)}) do |match|
relative_image_dir = image_dir.gsub(/#{stylesheet_dir}\//, '')
dirs = "#{image_dir}|#{stylesheet_dir}|#{relative_image_dir}|".gsub("/", '\/')
contents.gsub(%r{url\((["']?)[\./]*(#{dirs}|)\/?(.*?)(["']?)\)}) do |match|
quote, path, file_name = $1, $2, $3
target_path = "stylesheets" if file_name =~ /css$/
target_path ||= (!stylesheet_dir.blank? && path == stylesheet_dir) ? "stylesheets" : "images"
Expand Down
4 changes: 2 additions & 2 deletions spec/expected/rails/boxie-admin/public/stylesheets/blue.css
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ a img {border: none;}
#nav #h-wrap.active .inner {-moz-border-radius: 6px; -webkit-border-radius: 6px; border-radius: 6px;}
#nav #h-wrap .h-ico {background: 0 50% no-repeat;}
#nav #h-wrap .h-ico span {display: block; padding-left: 50px;}
#nav #h-wrap .ico-dashboard {background-image: url("/images/h-ico/dashboard.png");} /* feel free to add/modify your own icons - icons are located in "css//images/h-ico/*" */
#nav #h-wrap .ico-dashboard {background-image: url("/images/h-ico/dashboard.png");} /* feel free to add/modify your own icons - icons are located in "css/img/h-ico/*" */
#nav #h-wrap .ico-comments {background-image: url("/images/h-ico/comments.png");}
#nav #h-wrap .ico-color {background-image: url("/images/h-ico/color.png");}
#nav #h-wrap .ico-edit {background-image: url("/images/h-ico/edit.png");}
Expand All @@ -116,7 +116,7 @@ a img {border: none;}
#nav #h-wrap .ico-users {background-image: url("/images/h-ico/users.png");}
#nav #h-wrap .ico-advanced {background-image: url("/images/h-ico/advanced.png");}
#nav #h-wrap .ico-send {background-image: url("/images/h-ico/send.png");}
/* feel free to add more icons here like above (icon set is included in directory ".//images/h-ico" and is free for commercial use) */
/* feel free to add more icons here like above (icon set is included in directory "./img/h-ico" and is free for commercial use) */
#nav #h-wrap h2 {background: url("/images/h-wrap-h2.png") 100% 100% no-repeat; position: relative; float: left; height: 51px; line-height: 55px; vertical-align: middle; font-size: 200%; font-weight: bold;}
#nav #h-wrap.active h2 {background: none;}
#nav #h-wrap h2 .h-ico {display: block; height: 100%; padding-right: 42px;}
Expand Down
11 changes: 7 additions & 4 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,12 @@ def setup_hobbit(theme_options = {})

def setup_boxie(theme_options = {})
setup_app_with_theme('boxie-admin', {
:content_path => ".inner-container text()",
:partials => { "accounts" => "#userbox text()" },
:index_path => "blue.html"
:content_path => ".inner-container text()",
:partials => { "accounts" => "#userbox text()" },
:index_path => "blue.html",
:stylesheet_dir => "css",
:image_dir => "css/img",
:javascript_dir => "js"
}.merge(theme_options))
end

Expand All @@ -113,4 +116,4 @@ def setup_base_rails(options)
@target_application
end
end


0 comments on commit 50d9e09

Please sign in to comment.