class SeoOptimizer::RobotsFilesGenerator
Public Instance Methods
create_controller_files()
click to toggle source
# File lib/generators/seo_optimizer/robots_files/robots_files_generator.rb, line 10 def create_controller_files prod_variable = Rails.configuration.sitemap_config_variable rescue raise(SeoOptimizer::Error, setup_error_message) url = prod_variable[:production_url] raise SeoOptimizer::Error, replace_url_error if !url || url == 'https://YOUR-PRODUCTION-URL.com' site_map_xml robots_text end
Private Instance Methods
replace_url_error()
click to toggle source
# File lib/generators/seo_optimizer/robots_files/robots_files_generator.rb, line 37 def replace_url_error ' Please replace https://YOUR-PRODUCTION-URL.com by your production url in application.rb, check the doc https://github.com/RonanLOUARN/seo_optimizer for more infos. ' end
robots_text()
click to toggle source
# File lib/generators/seo_optimizer/robots_files/robots_files_generator.rb, line 21 def robots_text routing_code = %(get 'robots.:format', to: 'robots#show') route routing_code %x(rm -f public/robots.txt) template 'robots_controller_template.erb', File.join('app/controllers', 'robots_controller.rb') %x(mkdir -p app/views/robots) template 'robots_show_template.erb', File.join('app/views/robots', 'show.txt.erb') end
setup_error_message()
click to toggle source
# File lib/generators/seo_optimizer/robots_files/robots_files_generator.rb, line 44 def setup_error_message ' Please type "rails generate seo_optimizer:setups" in terminal, check the doc https://github.com/RonanLOUARN/seo_optimizer for more infos. ' end
site_map_xml()
click to toggle source
# File lib/generators/seo_optimizer/robots_files/robots_files_generator.rb, line 30 def site_map_xml routing_code = %(get 'sitemap.xml', to: 'sitemaps#show', as: :sitemap, defaults: { format: :xml }) route routing_code template 'sitemaps_controller_template.erb', File.join('app/controllers', 'sitemaps_controller.rb') template 'sitemaps_task_template.erb', File.join('lib/tasks/sitemap', 'generate.rake') end