class Locomotive::Wagon::Generators::PublicForm
Protected Class Methods
source_root()
click to toggle source
# File lib/locomotive/wagon/generators/public_form.rb, line 89 def self.source_root File.join(File.dirname(__FILE__), '..', '..', '..', '..', 'generators', 'public_form') end
Public Instance Methods
add_metafields()
click to toggle source
# File lib/locomotive/wagon/generators/public_form.rb, line 56 def add_metafields append_to_file 'config/site.yml', <<-YAML metafields: google: recaptcha_site_key: "<GOOGLE SITE KEY>" recaptcha_secret: "<GOOGLE SECRET>" YAML end
add_metafields_schema()
click to toggle source
# File lib/locomotive/wagon/generators/public_form.rb, line 40 def add_metafields_schema append_to_file 'config/metafields_schema.yml', <<-YAML google: label: Google API Integration fields: recaptcha_site_key: hint: reCAPTCHA - Site key type: string hint: "Visit: https://developers.google.com/recaptcha/intro" recaptcha_secret: hint: reCAPTCHA - Secret key type: string YAML end
create_content_type()
click to toggle source
# File lib/locomotive/wagon/generators/public_form.rb, line 15 def create_content_type slug = ask("What's the slug of the content type? (ex.: user_messages)") @content_type_slug = slug = slug.underscore file_path = File.join(content_types_path, slug) template "content_type.yml.tt", "#{file_path}.yml", { name: slug.humanize, slug: slug } end
create_page_form()
click to toggle source
# File lib/locomotive/wagon/generators/public_form.rb, line 27 def create_page_form slug = ask("What's the slug of your page? (ex.: contact-us)") slug = slug.dasherize file_path = File.join(pages_path, slug) template "page.liquid.tt", "#{file_path}.liquid", { title: slug.humanize, handle: slug.underscore, content_type: @content_type_slug } end
print_next_instructions()
click to toggle source
# File lib/locomotive/wagon/generators/public_form.rb, line 66 def print_next_instructions say <<-TEXT Congratulations, your public form has been generated with success! In order to complete the Google reCAPTCHA configuration, visit https://developers.google.com/recaptcha/intro. Create a developer account if you don't have one and register your site. Once done, copy and paste your Google SITE KEY and Google SECRET KEY in the config/site.yml file. TEXT end
Protected Instance Methods
content_types_path()
click to toggle source
# File lib/locomotive/wagon/generators/public_form.rb, line 81 def content_types_path File.join(target_path, 'app', 'content_types') end
pages_path()
click to toggle source
# File lib/locomotive/wagon/generators/public_form.rb, line 85 def pages_path File.join(target_path, 'app', 'views', 'pages') end