Skip to content

Commit

Permalink
Merge pull request #379 from azul/bugfix/images-css-task
Browse files Browse the repository at this point in the history
bugfix: cg:images:update_css works without public/stylesheets
  • Loading branch information
azul committed Jan 13, 2016
2 parents 340629c + b1e00f7 commit 0c24f76
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 16 deletions.
14 changes: 9 additions & 5 deletions doc/INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,17 +38,17 @@ Once you have git:
git clone https://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build
source ~/.zshrc
rbenv versions

Once you have the code, run this from inside of the source directory. Ruby 2.1.5 should work here, but you can customize it if need be.

rbenv install 2.1.5
gem install bundler
Now for the app dependencies

brew install mysql graphicsmagick sphinx --with-mysql

To run MySQL

mysqld

If you run into any problems bundling with bundle install (a few steps down), make sure that you are up to date with XCode and that you have installed the command line developer tools. XCode can be updated from the App Store. You may need to open XCode after updating to accept the licenses. If you need the command line tools, run the following.
Expand Down Expand Up @@ -197,9 +197,13 @@ this should be run after deploying a new version of the codebase:

rake assets:precompile

See the asset pipeline docs for more information and alternative strategies:
See the asset pipeline docs for more information and alternative strategies:
http://guides.rubyonrails.org/asset_pipeline.html#precompiling-assets


For css we rely on our custom theming mechanism. In order to install the css
files for images please run

rake cg:images:update_css

configure apache
-----------------------
Expand Down
34 changes: 23 additions & 11 deletions lib/tasks/images.rb
Original file line number Diff line number Diff line change
@@ -1,20 +1,34 @@
require 'pathname'

def write_file(type, images)
File.open(images_dir + "/../stylesheets/icon_#{type}.css", 'w') do |file|
pathname = stylesheets_dir + "icon_#{type}.css"
pathname.open('w') do |file|
images.each do |image|
str = ".#{image[1]}_#{image[0]} {background-image: url(/images/#{type}/#{image[0]}/#{image[1]}.#{type})}\n"
file.write(str)
end
end
rescue Errno::ENOENT # directory missing
Dir.mkdir stylesheets_dir
retry
end

def stylesheets_dir
rails_root + 'public/stylesheets'
end

def images_dir
Pathname.new(File.dirname(__FILE__) + '/../../public/images').realpath.to_s
rails_root + 'public/images'
end

def svg_dir
Pathname.new(File.dirname(__FILE__) + '/../../doc/image-sources').realpath.to_s
rails_root + 'doc/image-sources'
end

# replacement for Rails.root - which is not available here.
def rails_root
path = Pathname.new File.dirname(__FILE__)
path.realpath + '../..'
end

namespace :cg do
Expand All @@ -23,14 +37,12 @@ def svg_dir
desc "updates the css for all the icons"
task :update_css do
images = []
Dir.chdir(images_dir) do
Dir.chdir('png') do
['16','48'].each do |dir|
Dir.chdir(dir) do
Dir.glob('*.png') do |png_file|
images << [dir,png_file.sub(/\.png$/,'')]
putc '.'; STDOUT.flush;
end
Dir.chdir(images_dir + 'png') do
['16','48'].each do |dir|
Dir.chdir(dir) do
Dir.glob('*.png') do |png_file|
images << [dir,png_file.sub(/\.png$/,'')]
putc '.'; STDOUT.flush;
end
end
end
Expand Down

0 comments on commit 0c24f76

Please sign in to comment.