From 94f4471ad5c66b693e335bab83dbf8d5c76378fc Mon Sep 17 00:00:00 2001 From: Chris Eppstein Date: Tue, 3 Feb 2009 10:01:06 -0800 Subject: [PATCH] Better followup messages after installation. --- .../blueprint/templates/project/manifest.rb | 6 ++--- .../compass/templates/project/manifest.rb | 6 ++--- frameworks/yui/templates/project/manifest.rb | 2 +- lib/compass/commands/create_project.rb | 7 +++--- lib/compass/installers/base.rb | 21 ++++++++++++++-- lib/compass/installers/manifest.rb | 3 +++ lib/compass/installers/stand_alone.rb | 25 ++++++++++++++++++- 7 files changed, 57 insertions(+), 13 deletions(-) diff --git a/frameworks/blueprint/templates/project/manifest.rb b/frameworks/blueprint/templates/project/manifest.rb index 330c3e35..80324ef9 100644 --- a/frameworks/blueprint/templates/project/manifest.rb +++ b/frameworks/blueprint/templates/project/manifest.rb @@ -1,5 +1,5 @@ -stylesheet 'screen.sass' -stylesheet 'print.sass' -stylesheet 'ie.sass' +stylesheet 'screen.sass', :media => 'screen, projection' +stylesheet 'print.sass', :media => 'print' +stylesheet 'ie.sass', :media => 'screen, projection', :ie => true image 'grid.png' diff --git a/frameworks/compass/templates/project/manifest.rb b/frameworks/compass/templates/project/manifest.rb index f5ba211f..34e18ab0 100644 --- a/frameworks/compass/templates/project/manifest.rb +++ b/frameworks/compass/templates/project/manifest.rb @@ -1,3 +1,3 @@ -stylesheet 'screen.sass' -stylesheet 'print.sass' -stylesheet 'ie.sass' \ No newline at end of file +stylesheet 'screen.sass', :media => 'screen, projection' +stylesheet 'print.sass', :media => 'print' +stylesheet 'ie.sass', :media => 'screen, projection', :ie => true \ No newline at end of file diff --git a/frameworks/yui/templates/project/manifest.rb b/frameworks/yui/templates/project/manifest.rb index dffc67d0..c7af4356 100644 --- a/frameworks/yui/templates/project/manifest.rb +++ b/frameworks/yui/templates/project/manifest.rb @@ -1 +1 @@ -stylesheet 'screen.sass' +stylesheet 'screen.sass', :media => "screen, projection" diff --git a/lib/compass/commands/create_project.rb b/lib/compass/commands/create_project.rb index 0b8d1f4c..76757b8d 100644 --- a/lib/compass/commands/create_project.rb +++ b/lib/compass/commands/create_project.rb @@ -15,12 +15,13 @@ module Compass # all commands must implement perform def perform - installer.run - UpdateProject.new(working_directory, options).perform + installer.run(:skip_finalization => true) + UpdateProject.new(working_directory, options).perform if installer.compilation_required? + installer.finalize(:create => true) end def installer - StandAloneInstaller.new(project_template_directory, project_directory, options) + @installer ||= StandAloneInstaller.new(project_template_directory, project_directory, options) end def project_template_directory diff --git a/lib/compass/installers/base.rb b/lib/compass/installers/base.rb index 245e82f4..86867b0b 100644 --- a/lib/compass/installers/base.rb +++ b/lib/compass/installers/base.rb @@ -24,11 +24,11 @@ module Compass # Runs the installer. # Every installer must conform to the installation strategy of configure, prepare, install, and then finalize. # A default implementation is provided for each step. - def run + def run(options = {}) configure prepare install - finalize + finalize unless options[:skip_finalization] end # The default configure method -- it sets up directories from the options @@ -67,6 +67,9 @@ module Compass def finalize end + def compilation_required? + false + end def install_stylesheet(from, to, options) copy from, "#{sass_dir}/#{to}" @@ -170,6 +173,20 @@ module Compass end end + def stylesheet_links + html = "\n" + manifest.each_stylesheet do |stylesheet| + media = if stylesheet.options[:media] + %Q{ media="#{stylesheet.options[:media]}"} + end + ss_line = %Q{ } + if stylesheet.options[:ie] + ss_line = " " + end + html << ss_line + "\n" + end + html << "" + end end end end diff --git a/lib/compass/installers/manifest.rb b/lib/compass/installers/manifest.rb index 39a3a9fe..3d016153 100644 --- a/lib/compass/installers/manifest.rb +++ b/lib/compass/installers/manifest.rb @@ -23,6 +23,9 @@ module Compass def has_#{t}? @entries.detect {|e| e.type == :#{t}} end + def each_#{t} + @entries.select {|e| e.type == :#{t}}.each {|e| yield e} + end END end diff --git a/lib/compass/installers/stand_alone.rb b/lib/compass/installers/stand_alone.rb index 094b0230..52ac28cc 100644 --- a/lib/compass/installers/stand_alone.rb +++ b/lib/compass/installers/stand_alone.rb @@ -44,7 +44,30 @@ module Compass def old_config_file @old_config_file ||= targetize('src/config.rb') end - end + def finalize(options = {}) + if options[:create] + puts <<-NEXTSTEPS + +Congratulations! Your compass project has been created. +You must recompile your sass stylesheets when they change. +This can be done in one of the following ways: + 1. From within your project directory run: + compass + 2. From any directory run: + compass -u path/to/project + 3. To monitor your project for changes and automatically recompile: + compass --watch [path/to/project] + +NEXTSTEPS + end + puts "To import your new stylesheets add the following lines of HTML (or equivalent) to your webpage:" + puts stylesheet_links + end + + def compilation_required? + true + end + end end end