Better followup messages after installation.

This commit is contained in:
Chris Eppstein 2009-02-03 10:01:06 -08:00
parent 1da3b3ae9b
commit 94f4471ad5
7 changed files with 57 additions and 13 deletions

View File

@ -1,5 +1,5 @@
stylesheet 'screen.sass' stylesheet 'screen.sass', :media => 'screen, projection'
stylesheet 'print.sass' stylesheet 'print.sass', :media => 'print'
stylesheet 'ie.sass' stylesheet 'ie.sass', :media => 'screen, projection', :ie => true
image 'grid.png' image 'grid.png'

View File

@ -1,3 +1,3 @@
stylesheet 'screen.sass' stylesheet 'screen.sass', :media => 'screen, projection'
stylesheet 'print.sass' stylesheet 'print.sass', :media => 'print'
stylesheet 'ie.sass' stylesheet 'ie.sass', :media => 'screen, projection', :ie => true

View File

@ -1 +1 @@
stylesheet 'screen.sass' stylesheet 'screen.sass', :media => "screen, projection"

View File

@ -15,12 +15,13 @@ module Compass
# all commands must implement perform # all commands must implement perform
def perform def perform
installer.run installer.run(:skip_finalization => true)
UpdateProject.new(working_directory, options).perform UpdateProject.new(working_directory, options).perform if installer.compilation_required?
installer.finalize(:create => true)
end end
def installer def installer
StandAloneInstaller.new(project_template_directory, project_directory, options) @installer ||= StandAloneInstaller.new(project_template_directory, project_directory, options)
end end
def project_template_directory def project_template_directory

View File

@ -24,11 +24,11 @@ module Compass
# Runs the installer. # Runs the installer.
# Every installer must conform to the installation strategy of configure, prepare, install, and then finalize. # Every installer must conform to the installation strategy of configure, prepare, install, and then finalize.
# A default implementation is provided for each step. # A default implementation is provided for each step.
def run def run(options = {})
configure configure
prepare prepare
install install
finalize finalize unless options[:skip_finalization]
end end
# The default configure method -- it sets up directories from the options # The default configure method -- it sets up directories from the options
@ -67,6 +67,9 @@ module Compass
def finalize def finalize
end end
def compilation_required?
false
end
def install_stylesheet(from, to, options) def install_stylesheet(from, to, options)
copy from, "#{sass_dir}/#{to}" copy from, "#{sass_dir}/#{to}"
@ -170,6 +173,20 @@ module Compass
end end
end end
def stylesheet_links
html = "<head>\n"
manifest.each_stylesheet do |stylesheet|
media = if stylesheet.options[:media]
%Q{ media="#{stylesheet.options[:media]}"}
end
ss_line = %Q{ <link href="/stylesheets/#{stylesheet.to.sub(/\.sass$/,'.css')}"#{media} rel="stylesheet" type="text/css" />}
if stylesheet.options[:ie]
ss_line = " <!--[if IE]>\n #{ss_line}\n <![endif]-->"
end
html << ss_line + "\n"
end
html << "</head>"
end
end end
end end
end end

View File

@ -23,6 +23,9 @@ module Compass
def has_#{t}? def has_#{t}?
@entries.detect {|e| e.type == :#{t}} @entries.detect {|e| e.type == :#{t}}
end end
def each_#{t}
@entries.select {|e| e.type == :#{t}}.each {|e| yield e}
end
END END
end end

View File

@ -44,7 +44,30 @@ module Compass
def old_config_file def old_config_file
@old_config_file ||= targetize('src/config.rb') @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 end
def compilation_required?
true
end
end
end end
end end