Class: Boxcab::InstallGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Defined in:
lib/generators/boxcab/install/install_generator.rb

Instance Method Summary collapse

Instance Method Details

#ask_for_base_urlObject



23
24
25
26
27
28
29
30
31
# File 'lib/generators/boxcab/install/install_generator.rb', line 23

def ask_for_base_url
  say <<-EOF

For a smoother experience, Boxcab requires the base url (http or https + ://<your domain>) of your site in production
OR if you don't have one yet your Heroku app name.

EOF
  @site_base_url = ask("What's your base url OR your Heroku app name?")
end

#ask_for_nameObject



14
15
16
17
18
19
20
21
# File 'lib/generators/boxcab/install/install_generator.rb', line 14

def ask_for_name
  say <<-EOF
You can change the name of your site which is displayed in the Boxcab editor.
Leave it blank if you don't want to change it.

EOF
  @site_name = ask("What's its name?")
end

#ask_for_site_attributesObject

FIXME (Did): disabled for now def copy_templates

template 'initializer.rb', 'config/initializers/boxcab.rb'

end



10
11
12
# File 'lib/generators/boxcab/install/install_generator.rb', line 10

def ask_for_site_attributes
  print_title "Boxcab site configuration"
end


44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/generators/boxcab/install/install_generator.rb', line 44

def print_asset_instruction
  say "\n\n"

  print_title "Boxcab JS lib installation"

  say <<-EOF
In order to enable the live editing functionality, you have to add our javascript lib.
Add the following statement in your layout or your pages you want to edit before the </head> tag.

ERB:
<%= javascript_include_tag 'boxcab' %>

HAML/SLIM
= javascript_include_tag 'boxcab'


  EOF
end


63
64
65
66
67
68
69
70
71
72
73
74
75
# File 'lib/generators/boxcab/install/install_generator.rb', line 63

def print_next_instructions
  print_title "Boxcab make pages editable"

  say <<-EOF

Please visit the following links for the next instructions:

- http://www.boxcab.io/pages/documentation/installation#setup-it
- http://www.boxcab.io/pages/documentation/usage


EOF
end

#update_siteObject



33
34
35
36
37
38
39
40
41
42
# File 'lib/generators/boxcab/install/install_generator.rb', line 33

def update_site
  attributes = {}
  attributes[:name]     = @site_name unless @site_name.strip.blank?
  attributes[:base_url] = @site_base_url unless @site_base_url.strip.blank?

  if !attributes.blank? && $boxcab_api.update_site(attributes)
    say "\n"
    say "Your Boxcab site has been updated!", [:green, :on_black, :bold]
  end
end