From 70de82bb081697526ddf25b569179d15bfdc8593 Mon Sep 17 00:00:00 2001 From: Azul Date: Wed, 13 Jan 2016 16:22:23 +0100 Subject: [PATCH 1/2] bugfix: cg:images:update_css works without public/stylesheets using pathname properly. --- lib/tasks/images.rb | 34 +++++++++++++++++++++++----------- 1 file changed, 23 insertions(+), 11 deletions(-) diff --git a/lib/tasks/images.rb b/lib/tasks/images.rb index ea6e028ed..d021804cc 100644 --- a/lib/tasks/images.rb +++ b/lib/tasks/images.rb @@ -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 @@ -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 From b1e00f77d5cc537e1bbd026936919d2edcf325e7 Mon Sep 17 00:00:00 2001 From: Azul Date: Wed, 13 Jan 2016 16:24:35 +0100 Subject: [PATCH 2/2] docs: add cg:images:update_css to production install --- doc/INSTALL.md | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/doc/INSTALL.md b/doc/INSTALL.md index cb14b03e1..75b772565 100644 --- a/doc/INSTALL.md +++ b/doc/INSTALL.md @@ -38,7 +38,7 @@ 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 @@ -46,9 +46,9 @@ Once you have the code, run this from inside of the source directory. Ruby 2.1.5 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. @@ -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 -----------------------