6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
# File 'lib/odania_static_pages/generator/jekyll.rb', line 6
def init
puts 'Initliazing jekyll pages'
puts
setup_generator
FileUtils.mkdir_p @pages_path unless File.exist? @pages_path
unless File.exist? @jekyll_config_file
FileUtils.cp File.join(@config.base_dir, 'templates', 'jekyll', 'example_config.yml'), @jekyll_config_file
setup_generator
end
FileUtils.mkdir_p @generator_config.full_common_folder unless File.exist? @generator_config.full_common_folder
puts 'Initialize Gemfile'
gemfile_template = File.join(@config.base_dir, 'templates', 'jekyll', 'Gemfile.erb')
= @generator_config.
File.write File.join(@generator_config.full_common_folder, 'Gemfile'), ERB.new(File.read(gemfile_template)).result(binding)
puts 'Copying Dockerfile'
FileUtils.cp File.join(@config.base_dir, 'templates', 'live', 'Dockerfile'), File.join(@config.output_path, 'Dockerfile')
puts 'Install gems'
puts `cd #{@generator_config.full_common_folder} && bundle check`
puts `cd #{@generator_config.full_common_folder} && bundle install --path ~/.gems` unless $?.success?
@jekyll_config['pages'].each do |page|
relative_page_path = @generator_config.page_path page
relative_page_path += page['baseurl'] unless page['baseurl'].empty?
page_path = File.join @pages_path, relative_page_path
puts '*' * 100
puts "Processing #{relative_page_path} => #{page_path}"
unless File.directory? page_path
puts "Creating page #{page['name']}"
`cd #{@pages_path} && octopress new #{relative_page_path}`
end
page_config = @generator_config.prepare_config page
current_config_file = File.join page_path, '_config.yml'
current_config = YAML.load_file current_config_file
unless current_config.eql? page_config
puts ' -> Updating config'
File.write current_config_file, YAML.dump(page_config)
end
@generator_config.link @config.base_dir, page_path, page
puts
end
end
|