Module: Marfa::FileTemplates
- Defined in:
- lib/marfa/file_templates.rb
Instance Method Summary collapse
-
#application_rb(project_path) ⇒ Object
generates content for ‘config/application.rb’ file.
-
#bootstrap_rb(project_path) ⇒ Object
content for ‘app/bootstrap.rb’.
-
#config_ru(project_path) ⇒ Object
content for ‘config.ru’ file.
-
#marfa_rb(project_path) ⇒ Object
generates content for ‘config/marfa.rb’ file.
Instance Method Details
#application_rb(project_path) ⇒ Object
generates content for ‘config/application.rb’ file
6 7 8 9 10 |
# File 'lib/marfa/file_templates.rb', line 6 def application_rb(project_path) File.open("#{project_path}/config/application.rb", 'w') do |file| file.puts '' end end |
#bootstrap_rb(project_path) ⇒ Object
content for ‘app/bootstrap.rb’
92 93 94 95 96 97 98 99 100 101 |
# File 'lib/marfa/file_templates.rb', line 92 def bootstrap_rb(project_path) File.open("#{project_path}/app/bootstrap.rb", 'w') do |file| file.puts "require './config/application' # requiring all blocks and controllers Dir[File.dirname(__FILE__) + '/blocks/**/*.rb'].each { |file| require file } Dir[File.dirname(__FILE__) + '/controllers/**/*.rb'].each { |file| require file } " end end |
#config_ru(project_path) ⇒ Object
content for ‘config.ru’ file
105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 |
# File 'lib/marfa/file_templates.rb', line 105 def config_ru(project_path) File.open("#{project_path}/config.ru", 'w') do |file| file.puts "Encoding.default_external = Encoding::UTF_8 Encoding.default_internal = Encoding::UTF_8 require 'marfa' require File.dirname(__FILE__) + '/app/bootstrap' require File.dirname(__FILE__) + '/config/marfa' Marfa.configure_app # Controllers auto-bootstrap controllers = Object.constants.select { |c| c.to_s.include? 'Controller' } controllers.map! { |controller| Object.const_get(controller) } controllers += Marfa::Controllers.controllers_list run Rack::Cascade.new(controllers) " end end |
#marfa_rb(project_path) ⇒ Object
generates content for ‘config/marfa.rb’ file
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 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/marfa/file_templates.rb', line 14 def marfa_rb(project_path) File.open("#{project_path}/config/marfa.rb", 'w') do |file| file.puts "# Marfa configuration file Marfa.configure do |cfg| # Specifying API Server is needed cfg.api_server = '' # Views path is needed cfg.views = File.expand_path('./app/views') # Cache config cfg.cache = { enabled: false, host: '', port: 0, db: 0, expiration_time: 3600, use_device: true # use device name in page, blocks cache } # Static files content path cfg.content_path = '/images/content/' # Styles caching cfg.cache_styles = true # Blocks path cfg.block_templates_path = 'blocks' # Public folder cfg.public_folder = File.expand_path('./static') # Static files cache cfg.static_cache_control = [:public, max_age: 2_592_000] # CSRF Protection cfg.csrf_enabled = false # gem device_detector cfg.device_detector = { enabled: true, default_device: 'smartphone' } # HTML Compression cfg.html_compression_options = { enabled: true, remove_multi_spaces: true, remove_comments: true, remove_intertag_spaces: false, remove_quotes: true, compress_css: false, compress_javascript: false, simple_doctype: false, remove_script_attributes: true, remove_style_attributes: true, remove_link_attributes: true, remove_form_attributes: false, remove_input_attributes: true, remove_javascript_protocol: true, remove_http_protocol: false, remove_https_protocol: false, preserve_line_breaks: false, simple_boolean_attributes: true } # CSS Minifying cfg.minify_css = true # JS Minifying cfg.minify_js = true end " end end |