fix issue #5
did
committed Mar 17, 2013
commit 2e620dddc90c9897e7cb7060a6ddc93827ebf761
Showing 3
changed files with
30 additions
and 15 deletions
locomotive/wagon/cli.rb b/lib/locomotive/wagon/cli.rb
+17
-9
| @@ | @@ -12,7 +12,7 @@ module Locomotive |
| # Check if the path given in option ('.' by default) points to a LocomotiveCMS | |
| # site. It is also possible to pass a path other than the one from the options. | |
| # | |
| - | # @param [ String ] path The optional path instead of options['path'] |
| + | # @param [ String ] path The optional path of the site instead of options['path'] |
| # | |
| # @return [ String ] The fullpath to the LocomotiveCMS site or nil if it is not a valid site. | |
| # | |
| @@ | @@ -69,8 +69,9 @@ module Locomotive |
| * wagon generate page about_us/me | |
| LONGDESC | |
| def page(fullpath) | |
| - | if check_path! |
| - | Locomotive::Wagon.generate :page, fullpath, self.options['path'] |
| + | if path = check_path! |
| + | locales = self.site_config(path)['locales'] |
| + | Locomotive::Wagon.generate :page, fullpath, self.options['path'], locales |
| end | |
| end | |
| @@ | @@ -89,6 +90,19 @@ module Locomotive |
| end | |
| end | |
| + | protected |
| + | |
| + | # Read the YAML config file of a LocomotiveCMS site. |
| + | # The path should be returned by the check_path! method first. |
| + | # |
| + | # @param [ String ] path The full path to a LocomotiveCMS site. |
| + | # |
| + | # @return [ Hash ] The site |
| + | # |
| + | def site_config(path = nil) |
| + | YAML.load_file(File.join(path, 'config', 'site.yml')) |
| + | end |
| + | |
| end | |
| class Main < Thor | |
| @@ | @@ -191,12 +205,6 @@ module Locomotive |
| end | |
| end | |
| - | # desc "pull NAME SITE_URL EMAIL PASSWORD", "Pull an existing LocomotiveCMS site powered by the engine" |
| - | # def pull(name, site_url, email, password) |
| - | # say("ERROR: \"#{name}\" directory already exists", :red) and return if File.exists?(name) |
| - | # Locomotive::Wagon.pull(name, site_url, email, password) |
| - | # end |
| - | |
| protected | |
| # From a site specified by a path, retrieve the information of the connection | |
locomotive/wagon/generators/page.rb b/lib/locomotive/wagon/generators/page.rb
+12
-6
| @@ | @@ -11,15 +11,21 @@ module Locomotive |
| argument :slug | |
| argument :target_path # path to the site | |
| + | argument :locales |
| - | attr_accessor :haml, :locales |
| + | attr_accessor :haml |
| - | def ask_for_haml_and_locales |
| - | self.locales = [] |
| - | self.haml = yes?('Do you prefer a HAML template ?') |
| + | def ask_for_haml |
| + | self.haml = yes?('Do you prefer a HAML template ?') |
| + | end |
| + | |
| + | def apply_locales? |
| + | self.locales.shift # remove the default locale |
| - | if yes?('Is your page localized ?') |
| - | self.locales = ask('What are the locales other than the default one (comma separated) ?').split(',').map(&:strip) |
| + | unless self.locales.empty? |
| + | unless yes?('Do you want to generate templates for all the locales ?') |
| + | self.locales = [] |
| + | end |
| end | |
| end | |
locomotivecms_wagon.gemspec
+1
-0
| @@ | @@ -36,6 +36,7 @@ Gem::Specification.new do |gem| |
| gem.add_dependency 'faker', '~> 0.9.5' | |
| + | gem.add_development_dependency 'rake', '0.9.2' |
| gem.add_development_dependency 'rspec' | |
| gem.add_development_dependency 'vcr' | |
| gem.add_development_dependency 'webmock', '~> 1.8.0' | |