Class: Consently::Generators::InstallGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- Consently::Generators::InstallGenerator
- Defined in:
- lib/generators/consently/install/install_generator.rb
Instance Method Summary collapse
- #create_initializer ⇒ Object
-
#register_stimulus_controller ⇒ Object
Stimulus is how the banner releases the blocked tags, so registering the controller is part of installing, not a step in a README nobody reads.
- #show_readme ⇒ Object
Instance Method Details
#create_initializer ⇒ Object
10 11 12 |
# File 'lib/generators/consently/install/install_generator.rb', line 10 def create_initializer template "consently.rb", "config/initializers/consently.rb" end |
#register_stimulus_controller ⇒ Object
Stimulus is how the banner releases the blocked tags, so registering the controller is part of installing, not a step in a README nobody reads.
17 18 19 20 21 22 23 24 25 26 |
# File 'lib/generators/consently/install/install_generator.rb', line 17 def register_stimulus_controller index = "app/javascript/controllers/index.js" return say_status :skip, "#{index} not found - register consently-banner yourself", :yellow unless File.exist?(index) append_to_file index, <<~JS import ConsentlyBannerController from "consently/banner_controller" application.register("consently-banner", ConsentlyBannerController) JS end |
#show_readme ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/generators/consently/install/install_generator.rb', line 28 def show_readme say <<~TEXT Consently is installed. One thing left - put the helpers in your layout: <head> <%= consently_tags %> <body> <%= consently_noscript_tags %> ... <%= consently_banner %> The banner brings its own CSS; restyle it with the custom properties on .consently, or run `rails g consently:views` to take the markup over. Consent logging (optional): rails g consently:consent_log TEXT end |