10
11
12
13
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
|
# File 'lib/generators/voltron/upload/install_generator.rb', line 10
def inject_initializer
voltron_initialzer_path = Rails.root.join("config", "initializers", "voltron.rb")
unless File.exist? voltron_initialzer_path
unless system("cd #{Rails.root.to_s} && rails generate voltron:install")
puts "Voltron initializer does not exist. Please ensure you have the 'voltron' gem installed and run `rails g voltron:install` to create it"
return false
end
end
current_initiailzer = File.read voltron_initialzer_path
unless current_initiailzer.match(Regexp.new(/# === Voltron Upload Configuration ===/))
inject_into_file(voltron_initialzer_path, after: "Voltron.setup do |config|\n") do
"\n # === Voltron Upload Configuration ===\n\n # Whether or not calls to file_field should generate markup for dropzone uploads\n # If false, simply returns what file_field would return normally\n # config.upload.enabled = true\n\n # Global defaults for Dropzone's with a defined preview template\n # Should be a hash of keys matching a preview partial name,\n # with a value hash containing any of the Dropzone configuration options\n # found at http://www.dropzonejs.com/#configuration-options\n config.upload.previews = {\n vertical_tile: {\n thumbnailWidth: 200,\n thumbnailHeight: 175,\n dictRemoveFile: 'Remove',\n dictCancelUpload: 'Cancel'\n },\n \n horizontal_tile: {\n dictRemoveFile: 'Remove',\n dictCancelUpload: 'Cancel'\n }\n }\n"
end
end
end
|