diff --git a/lib/guides/cli.rb b/lib/guides/cli.rb index 0a58d8b..483fc2b 100644 --- a/lib/guides/cli.rb +++ b/lib/guides/cli.rb @@ -23,6 +23,8 @@ def new(name) method_option "clean", :type => :boolean method_option "edge", :type => :boolean, :default => false method_option "production", :type => :boolean, :default => true, :banner => "use production mode", :aliases => "-p" + method_option "ga", :type => :boolean, :default => false + def build if options[:clean] FileUtils.rm_rf(File.join(Guides.root, options[:production] ? 'output' : 'staging')) diff --git a/lib/guides/generator.rb b/lib/guides/generator.rb index 014eeaa..4a1821a 100644 --- a/lib/guides/generator.rb +++ b/lib/guides/generator.rb @@ -59,7 +59,7 @@ module Guides class Generator - attr_reader :guides_dir, :source_dir, :output_dir, :edge, :warnings, :all + attr_reader :guides_dir, :source_dir, :output_dir, :edge, :ga, :warnings, :all EXTENSIONS = %w(textile md html.erb) GUIDES_RE = /\.(?:#{EXTENSIONS.map{|e| Regexp.escape(e)}.join('|')})$/ @@ -78,6 +78,7 @@ def initialize(options) @warnings = options[:warnings] @all = options[:all] @production = options[:production] + @ga = options[:ga] @meta = Guides.meta end @@ -139,7 +140,7 @@ def generate_guide(guide, output_file) puts "Generating #{output_file}" File.open(File.join(output_dir, output_file), 'w') do |f| - view = ActionView::Base.new(source_dir, :edge => edge, :production => @production) + view = ActionView::Base.new(source_dir, :edge => edge, :ga => ga, :production => @production) view.extend(Helpers) if guide =~ /\.html\.erb$/ diff --git a/lib/guides/templates/source/layout.html.erb b/lib/guides/templates/source/layout.html.erb index 826e8af..320b0a2 100644 --- a/lib/guides/templates/source/layout.html.erb +++ b/lib/guides/templates/source/layout.html.erb @@ -89,5 +89,20 @@ + <% if @ga %> + + <% end %>