fl 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (137) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +44 -0
  3. data/Gemfile +5 -0
  4. data/Gemfile.lock +173 -0
  5. data/README.md +30 -0
  6. data/Rakefile +2 -0
  7. data/app/admin/options.rb +46 -0
  8. data/app/admin/pages.rb +55 -0
  9. data/app/admin/users.rb +34 -0
  10. data/app/assets/javascripts/active_admin.coffee.erb +20 -0
  11. data/app/assets/javascripts/application.coffee.erb +40 -0
  12. data/app/assets/javascripts/ckeditor/basepath.coffee.erb +21 -0
  13. data/app/assets/javascripts/ckeditor/config.coffee.erb +146 -0
  14. data/app/assets/javascripts/ckeditor/plugins/autogrow/plugin.js +232 -0
  15. data/app/assets/javascripts/ckeditor/plugins/autogrow/samples/autogrow.html +102 -0
  16. data/app/assets/javascripts/ckeditor/plugins/stylesheetparser/plugin.js +158 -0
  17. data/app/assets/javascripts/ckeditor/plugins/stylesheetparser/samples/assets/sample.css +70 -0
  18. data/app/assets/javascripts/ckeditor/plugins/stylesheetparser/samples/stylesheetparser.html +85 -0
  19. data/app/assets/javascripts/ckeditor/skins/minimalist/dialog.css +5 -0
  20. data/app/assets/javascripts/ckeditor/skins/minimalist/dialog_ie.css +5 -0
  21. data/app/assets/javascripts/ckeditor/skins/minimalist/dialog_ie7.css +5 -0
  22. data/app/assets/javascripts/ckeditor/skins/minimalist/dialog_ie8.css +5 -0
  23. data/app/assets/javascripts/ckeditor/skins/minimalist/dialog_iequirks.css +5 -0
  24. data/app/assets/javascripts/ckeditor/skins/minimalist/editor.css +5 -0
  25. data/app/assets/javascripts/ckeditor/skins/minimalist/editor_gecko.css +5 -0
  26. data/app/assets/javascripts/ckeditor/skins/minimalist/editor_ie.css +5 -0
  27. data/app/assets/javascripts/ckeditor/skins/minimalist/editor_ie7.css +5 -0
  28. data/app/assets/javascripts/ckeditor/skins/minimalist/editor_ie8.css +5 -0
  29. data/app/assets/javascripts/ckeditor/skins/minimalist/editor_iequirks.css +5 -0
  30. data/app/assets/javascripts/ckeditor/skins/minimalist/icons.png +0 -0
  31. data/app/assets/javascripts/ckeditor/skins/minimalist/icons_hidpi.png +0 -0
  32. data/app/assets/javascripts/ckeditor/skins/minimalist/images/arrow.png +0 -0
  33. data/app/assets/javascripts/ckeditor/skins/minimalist/images/close.png +0 -0
  34. data/app/assets/javascripts/ckeditor/skins/minimalist/images/hidpi/close.png +0 -0
  35. data/app/assets/javascripts/ckeditor/skins/minimalist/images/hidpi/lock-open.png +0 -0
  36. data/app/assets/javascripts/ckeditor/skins/minimalist/images/hidpi/lock.png +0 -0
  37. data/app/assets/javascripts/ckeditor/skins/minimalist/images/hidpi/refresh.png +0 -0
  38. data/app/assets/javascripts/ckeditor/skins/minimalist/images/lock-open.png +0 -0
  39. data/app/assets/javascripts/ckeditor/skins/minimalist/images/lock.png +0 -0
  40. data/app/assets/javascripts/ckeditor/skins/minimalist/images/refresh.png +0 -0
  41. data/app/assets/javascripts/ckeditor/skins/minimalist/readme.md +7 -0
  42. data/app/assets/javascripts/ckeditor/skins/minimalist/skin.js +10 -0
  43. data/app/assets/javascripts/ckeditor/skins/moonocolor/dialog.css +5 -0
  44. data/app/assets/javascripts/ckeditor/skins/moonocolor/dialog_ie.css +5 -0
  45. data/app/assets/javascripts/ckeditor/skins/moonocolor/dialog_ie7.css +5 -0
  46. data/app/assets/javascripts/ckeditor/skins/moonocolor/dialog_ie8.css +5 -0
  47. data/app/assets/javascripts/ckeditor/skins/moonocolor/dialog_iequirks.css +5 -0
  48. data/app/assets/javascripts/ckeditor/skins/moonocolor/editor.css +5 -0
  49. data/app/assets/javascripts/ckeditor/skins/moonocolor/editor_gecko.css +5 -0
  50. data/app/assets/javascripts/ckeditor/skins/moonocolor/editor_ie.css +5 -0
  51. data/app/assets/javascripts/ckeditor/skins/moonocolor/editor_ie7.css +5 -0
  52. data/app/assets/javascripts/ckeditor/skins/moonocolor/editor_ie8.css +5 -0
  53. data/app/assets/javascripts/ckeditor/skins/moonocolor/editor_iequirks.css +5 -0
  54. data/app/assets/javascripts/ckeditor/skins/moonocolor/icons.png +0 -0
  55. data/app/assets/javascripts/ckeditor/skins/moonocolor/icons_hidpi.png +0 -0
  56. data/app/assets/javascripts/ckeditor/skins/moonocolor/images/arrow.png +0 -0
  57. data/app/assets/javascripts/ckeditor/skins/moonocolor/images/close.png +0 -0
  58. data/app/assets/javascripts/ckeditor/skins/moonocolor/images/hidpi/close.png +0 -0
  59. data/app/assets/javascripts/ckeditor/skins/moonocolor/images/hidpi/lock-open.png +0 -0
  60. data/app/assets/javascripts/ckeditor/skins/moonocolor/images/hidpi/lock.png +0 -0
  61. data/app/assets/javascripts/ckeditor/skins/moonocolor/images/hidpi/refresh.png +0 -0
  62. data/app/assets/javascripts/ckeditor/skins/moonocolor/images/lock-open.png +0 -0
  63. data/app/assets/javascripts/ckeditor/skins/moonocolor/images/lock.png +0 -0
  64. data/app/assets/javascripts/ckeditor/skins/moonocolor/images/refresh.png +0 -0
  65. data/app/assets/javascripts/ckeditor/skins/moonocolor/images/spinner.gif +0 -0
  66. data/app/assets/javascripts/ckeditor/skins/moonocolor/readme.md +51 -0
  67. data/app/assets/javascripts/ckeditor/skins/moonocolor/skin.js +10 -0
  68. data/app/assets/javascripts/components/confirm.coffee +51 -0
  69. data/app/assets/javascripts/components/modals.coffee +29 -0
  70. data/app/assets/stylesheets/_defaults.yml +106 -0
  71. data/app/assets/stylesheets/_functions.sass.erb +75 -0
  72. data/app/assets/stylesheets/active_admin.sass +117 -0
  73. data/app/assets/stylesheets/application.sass.erb +46 -0
  74. data/app/assets/stylesheets/styles/reset.sass +139 -0
  75. data/app/assets/stylesheets/styles/structure.sass +69 -0
  76. data/app/assets/stylesheets/styles/ui/flash.sass +128 -0
  77. data/app/assets/stylesheets/styles/ui/fonts.sass +32 -0
  78. data/app/assets/stylesheets/styles/ui/modals.sass +61 -0
  79. data/app/assets/stylesheets/styles/ui/tooltips.sass +139 -0
  80. data/app/controllers/application_controller.rb +87 -0
  81. data/app/helpers/fl/application_helper.rb +53 -0
  82. data/app/helpers/fl/asset_helper.rb +50 -0
  83. data/app/helpers/fl/liquid_helper.rb +29 -0
  84. data/app/helpers/fl/meta_helper.rb +118 -0
  85. data/app/lib/active_record/concerns/base.rb +55 -0
  86. data/app/lib/active_record/concerns/seeds.rb +78 -0
  87. data/app/liquid/filters/meta_filter.rb +6 -0
  88. data/app/liquid/tags/google_analytics_tag.rb +32 -0
  89. data/app/liquid/tags/icon_tag.rb +37 -0
  90. data/app/liquid/tags/meta_tag.rb +120 -0
  91. data/app/mailers/application_mailer.rb +28 -0
  92. data/app/models/application_record.rb +3 -0
  93. data/app/models/asset.rb +95 -0
  94. data/app/models/association.rb +21 -0
  95. data/app/models/meta.rb +27 -0
  96. data/app/models/node.rb +59 -0
  97. data/app/models/profile.rb +49 -0
  98. data/app/models/user.rb +49 -0
  99. data/app/service/flash.rb +8 -0
  100. data/app/views/layouts/_admin.haml +6 -0
  101. data/app/views/layouts/_application.haml +17 -0
  102. data/app/views/layouts/base.haml +26 -0
  103. data/app/views/mailers/layouts/mailer.haml +8 -0
  104. data/app/views/mailers/layouts/mailer.text.erb +1 -0
  105. data/app/views/mailers/new_user.erb +4 -0
  106. data/bin/console +14 -0
  107. data/bin/setup +8 -0
  108. data/config/initializers/active_admin.rb +266 -0
  109. data/config/initializers/ckeditor.rb +63 -0
  110. data/config/initializers/devise.rb +279 -0
  111. data/config/initializers/friendly_id.rb +92 -0
  112. data/config/initializers/inflections.rb +20 -0
  113. data/config/initializers/liquid.rb +87 -0
  114. data/config/initializers/sass.rb +45 -0
  115. data/config/locales/devise.en.yml +62 -0
  116. data/config/locales/en.yml +13 -0
  117. data/config/puma.rb +59 -0
  118. data/config/routes.rb +56 -0
  119. data/db/migrate/20160616060637_create_nodes.rb +26 -0
  120. data/db/migrate/20160707080248_create_users.rb +52 -0
  121. data/db/migrate/20160707094704_create_slugs.rb +33 -0
  122. data/db/migrate/20160710095916_create_associations.rb +20 -0
  123. data/db/migrate/20160713061948_create_profiles.rb +27 -0
  124. data/db/migrate/20161115101221_create_assets.rb +25 -0
  125. data/db/migrate/20170725060408_create_active_admin_comments.rb +22 -0
  126. data/db/seeds.rb +81 -0
  127. data/fl.gemspec +73 -0
  128. data/lib/fl.rb +28 -0
  129. data/lib/fl/constants.rb +52 -0
  130. data/lib/fl/engine.rb +160 -0
  131. data/lib/fl/hash.rb +34 -0
  132. data/lib/generators/fl/sass_vars_generator.rb +16 -0
  133. data/lib/generators/fl/templates/sass.yml +56 -0
  134. data/lib/tasks/ckeditor.rake +37 -0
  135. data/lib/tasks/favicon.rake +37 -0
  136. data/readme/fl.jpg +0 -0
  137. metadata +416 -0
@@ -0,0 +1,20 @@
1
+ class CreateAssociations < ActiveRecord::Migration::Current
2
+ include ActiveRecord::Concerns::Base
3
+
4
+ #########################################
5
+ #########################################
6
+
7
+ # Up
8
+ def up
9
+ setup_uuid
10
+ create_table table, uuid do |t|
11
+ t.references :associatiable, { polymorphic: true }.merge!(uuid(:type)) # => http://stackoverflow.com/a/29257570/1143732
12
+ t.references :associated, { polymorphic: true }.merge!(uuid(:type)) # => http://stackoverflow.com/a/29257570/1143732
13
+ t.timestamps
14
+ end
15
+ end
16
+
17
+ #########################################
18
+ #########################################
19
+
20
+ end
@@ -0,0 +1,27 @@
1
+ class CreateProfiles < ActiveRecord::Migration::Current
2
+ include ActiveRecord::Concerns::Base
3
+
4
+ # Up
5
+ def up
6
+ setup_uuid
7
+ create_table table, uuid do |t|
8
+
9
+ # => General
10
+ t.references :user, { references: :user }.merge!(uuid(:type)) # => Should be used to create custom references but always adds "_id" to name
11
+ t.string :slug
12
+ t.string :name
13
+ t.integer :role, default: 0
14
+
15
+ # => Extras
16
+ t.boolean :public, default: 0
17
+ t.boolean :is_destroyable
18
+
19
+ # => Timestamps
20
+ t.timestamps
21
+ end
22
+ end
23
+
24
+ #########################################
25
+ #########################################
26
+
27
+ end
@@ -0,0 +1,25 @@
1
+ class CreateAssets < ActiveRecord::Migration::Current
2
+ include ActiveRecord::Concerns::Base
3
+
4
+ #########################################
5
+ #########################################
6
+
7
+ # => Up
8
+ def up
9
+ create_table table do |t|
10
+ t.references :assetable, polymorphic: true
11
+ t.string :data_file_name, null: false
12
+ t.integer :data_file_size
13
+ t.string :data_content_type # => needs to be different than content_type otherwise infinite recursion
14
+ t.string :data_fingerprint
15
+ t.integer :width
16
+ t.integer :height
17
+ t.timestamp :data_updated_at
18
+ t.timestamps
19
+ end
20
+ end
21
+
22
+ #########################################
23
+ #########################################
24
+
25
+ end
@@ -0,0 +1,22 @@
1
+ class CreateActiveAdminComments < ActiveRecord::Migration::Current
2
+ include ActiveRecord::Concerns::Base
3
+
4
+ #########################################
5
+ #########################################
6
+
7
+ # => Up
8
+ def up
9
+ create_table table do |t|
10
+ t.references :resource, polymorphic: true
11
+ t.references :author, polymorphic: true
12
+ t.string :namespace
13
+ t.text :body
14
+ t.timestamps
15
+ end
16
+ add_index table, [:namespace]
17
+ end
18
+
19
+ #########################################
20
+ #########################################
21
+
22
+ end
data/db/seeds.rb ADDED
@@ -0,0 +1,81 @@
1
+ ########################################
2
+ ########################################
3
+ ########################################
4
+ ## _____ _ ##
5
+ ## / ___| | | ##
6
+ ## \ `--. ___ ___ __| |___ ##
7
+ ## `--. \/ _ \/ _ \/ _` / __| ##
8
+ ## /\__/ / __/ __/ (_| \__ \ ##
9
+ ## \____/ \___|\___|\__,_|___/ ##
10
+ ## ##
11
+ ########################################
12
+ ########################################
13
+ ########################################
14
+
15
+ # => Functions etc
16
+ include ActiveRecord::Concerns::Seeds
17
+
18
+ ########################################
19
+ ########################################
20
+
21
+ # => Data
22
+ Rails.application.secrets[:seeds].each do |model, refs|
23
+ iterate model, refs
24
+ end
25
+
26
+ ########################################
27
+ ########################################
28
+
29
+ # => Users
30
+ User.create!(email: 'admin@example.com', password: 'password', password_confirmation: 'password', send_email: true) unless User.all.any?
31
+
32
+ ########################################
33
+ ########################################
34
+
35
+ # => Files
36
+ ## Seeds ##
37
+ seeds = Rails.root.join('db', 'seeds')
38
+
39
+ ## ./db/seeds Exists? ##
40
+ if Dir.exists? seeds
41
+
42
+ ## Each Folder ##
43
+ Dir.foreach seeds do |meta|
44
+
45
+ ## Ignore ##
46
+ next if meta == '.' or meta == '..'
47
+
48
+ ## Files ##
49
+ folder = Rails.root.join('db', 'seeds', meta, '*')
50
+
51
+ ## Files? ##
52
+ unless Dir[folder].empty?
53
+
54
+ ## Each File ##
55
+ Dir.foreach Rails.root.join('db', 'seeds', meta) do |file|
56
+
57
+ ## Ignore ##
58
+ next if file == '.' or file == '..'
59
+
60
+ ## Items ##
61
+ ## https://stackoverflow.com/a/25999578/1143732 ##
62
+ attrs = Hash.new
63
+ attrs[:slug] = File.basename(file, ".*").gsub(%r(^([0-9][d-])), '')
64
+ attrs[:html] = Nokogiri::HTML::DocumentFragment.parse File.read(Rails.root.join('db', 'seeds', meta, file))
65
+
66
+ ## Attributes ##
67
+ %w(title date).each do |item|
68
+ attrs[item.to_sym] = attrs[:html].at(item).unlink.text if attrs[:html].at(item)
69
+ end
70
+
71
+ ## Create ##
72
+ create ["meta", meta.titleize.singularize].join("_"), {slug: attrs[:slug], ref: (attrs[:title] || attrs[:slug]), val: attrs[:html].to_html, created_at: (attrs[:date].to_datetime if attrs[:date]) }.compact
73
+
74
+ end
75
+ end
76
+ end
77
+ end
78
+
79
+ ########################################
80
+ ########################################
81
+ ########################################
data/fl.gemspec ADDED
@@ -0,0 +1,73 @@
1
+ #encoding: utf-8
2
+ ##############################################################
3
+ ##############################################################
4
+ ## _____ _ ##
5
+ ## | ___| | ##
6
+ ## | |_ | | ##
7
+ ## | _| | | ##
8
+ ## | | | |____ ##
9
+ ## \_| \_____/ ##
10
+ ## ##
11
+ ##############################################################
12
+ ##############################################################
13
+
14
+ # => Constants
15
+ require_relative 'lib/fl/constants'
16
+
17
+ ##############################################################
18
+ ##############################################################
19
+
20
+ ## Specs ##
21
+ Gem::Specification.new do |spec|
22
+
23
+ ## Info ##
24
+ spec.name = "fl"
25
+ spec.authors = ["R.Peck"]
26
+ spec.email = ["rpeck@fl.co.uk"]
27
+ spec.homepage = FL::COMPANY::URL
28
+ spec.version = FL::VERSION::STRING
29
+ spec.platform = Gem::Platform::RUBY
30
+
31
+ ## Summary ##
32
+ spec.summary = %q{FL Framework for Rails → Helpers / Frontend}
33
+ spec.description = %q{FL Framework for Rails → Helpers / Frontend}
34
+
35
+ ##############################################################
36
+ ##############################################################
37
+
38
+ ## Files ##
39
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
40
+ spec.bindir = "exe"
41
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
42
+ spec.require_paths = ["lib"]
43
+
44
+ ##############################################################
45
+ ##############################################################
46
+
47
+ ## Dev ##
48
+ spec.add_development_dependency "bundler", "~> 1.12"
49
+ spec.add_development_dependency "rake", "~> 10.0"
50
+
51
+ ## Prod ##
52
+ spec.add_dependency "rails", ">= 5" # => Rails
53
+ spec.add_dependency "rails-assets-animate-css" # => Animate-CSS
54
+ spec.add_dependency "autoprefixer-rails" # => Autoprefixer
55
+ spec.add_dependency "font-awesome-rails" # => Icons
56
+ spec.add_dependency "activeadmin" # => ActiveAdmin
57
+
58
+ ## Backend ##
59
+ spec.add_dependency 'bootstrap', '~> 4.0.0.beta' # => Bootstrap (tooltips)
60
+ spec.add_dependency 'liquid' # => Liquid
61
+ spec.add_dependency 'ckeditor' # => CKEditor
62
+ spec.add_dependency 'nilify_blanks' # => Nilify Blanks
63
+ spec.add_dependency "paperclip" # => Paperclip
64
+ spec.add_dependency "rmagick" # => RMagick
65
+ spec.add_dependency "friendly_id" # => FriendlyID
66
+ spec.add_dependency "devise" # => Devise
67
+ spec.add_dependency "exception_handler" # => ExceptionHandler
68
+ spec.add_dependency "responders" # => Responders (used in controller)
69
+
70
+ ##############################################################
71
+ ##############################################################
72
+
73
+ end
data/lib/fl.rb ADDED
@@ -0,0 +1,28 @@
1
+ ########################################
2
+ ########################################
3
+ ## _____ _ ##
4
+ ## | ___| | ##
5
+ ## | |_ | | ##
6
+ ## | _| | | ##
7
+ ## | | | |____ ##
8
+ ## \_| \_____/ ##
9
+ ########################################
10
+ ########################################
11
+
12
+ # => Dependencies
13
+ # => http://stackoverflow.com/a/24768678/1143732
14
+ Gem.loaded_specs['fl'].dependencies.each do |d|
15
+ require d.name
16
+ end
17
+
18
+ ########################################
19
+ ########################################
20
+
21
+ # => Files
22
+ require_relative 'fl/constants'
23
+ require_relative 'fl/hash'
24
+ require_relative 'fl/engine' if defined? Rails
25
+
26
+ ########################################
27
+ ########################################
28
+ ########################################
@@ -0,0 +1,52 @@
1
+ ##############################################################
2
+ ##############################################################
3
+ ## _____ _ ##
4
+ ## | ___| | ##
5
+ ## | |_ | | ##
6
+ ## | _| | | ##
7
+ ## | | | |____ ##
8
+ ## \_| \_____/ ##
9
+ ## ##
10
+ ##############################################################
11
+ ##############################################################
12
+
13
+ # => FL
14
+ module FL
15
+
16
+ ###########################################################
17
+ ###########################################################
18
+
19
+ # => Paperclip (Assets)
20
+ FILE = :data
21
+
22
+ ###########################################################
23
+ ###########################################################
24
+
25
+ # => Company
26
+ # => FL::COMPANY::NAME
27
+ module COMPANY
28
+ NAME = 'Frontline Utilities LTD',
29
+ NUMBER = '07037173',
30
+ VAT = 'GB121358444',
31
+ URL = 'https://www.fl.co.uk',
32
+ FUSION = 'flutils',
33
+ ADDRESS = '3 Dearnford Avenue, Bromborough, Wirral, CH62 6DX, United Kingdom'
34
+ end
35
+
36
+ ###########################################################
37
+ ###########################################################
38
+
39
+ # => Version
40
+ # => https://github.com/rails/rails/blob/master/version.rb
41
+ module VERSION
42
+ MAJOR = 0
43
+ MINOR = 3
44
+ TINY = 0
45
+ PRE = nil
46
+ STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".")
47
+ end
48
+
49
+ ###########################################################
50
+ ###########################################################
51
+
52
+ end
data/lib/fl/engine.rb ADDED
@@ -0,0 +1,160 @@
1
+ ##############################################################
2
+ ##############################################################
3
+ ## _____ _ ##
4
+ ## | ___| | ##
5
+ ## | |_ | | ##
6
+ ## | _| | | ##
7
+ ## | | | |____ ##
8
+ ## \_| \_____/ ##
9
+ ## ##
10
+ ##############################################################
11
+ ##############################################################
12
+
13
+ # => FL
14
+ module FL
15
+
16
+ ####################################
17
+ ####################################
18
+
19
+ # => Engine
20
+ class Engine < Rails::Engine
21
+
22
+ # => Migrations
23
+ # => This has to be kept in an initializer (to access app)
24
+ # => https://blog.pivotal.io/labs/labs/leave-your-migrations-in-your-rails-engines
25
+ initializer :migrations do |app|
26
+ config.paths["db/migrate"].expanded.each do |expanded_path|
27
+ app.config.paths["db/migrate"] << expanded_path
28
+ end
29
+ end
30
+
31
+ # => SASS Vars
32
+ # => http://stackoverflow.com/a/4081810/1143732
33
+ config.before_initialize do |app|
34
+ Rails::Generators.invoke("fl:sass_vars") if !File.exist?("#{app.root}/config/sass.yml") && File.basename($0) != 'rake'
35
+ end
36
+
37
+ # => ExceptionHandler
38
+ config.exception_handler = {
39
+ email: false,
40
+ db: nil,
41
+ dev: false
42
+ }
43
+
44
+ # => Migration Concerns
45
+ #config.paths.add "lib/active_record/concerns"#, eager_load: true
46
+
47
+ # => Assets
48
+ config.assets.precompile << %w(application.css application.js)
49
+
50
+ # => Equivalent of application.rb
51
+ # => Needs before_initialize otherwise is overwritten
52
+ # => A file at lib/blorgh/engine.rb, which is identical in function to a standard Rails application's config/application.rb file
53
+ # => http://guides.rubyonrails.org/engines.html#generating-an-engine
54
+ config.before_initialize do |app|
55
+
56
+ # => TimeZone
57
+ app.config.time_zone = Rails.application.secrets.app[:time_zone] || "GMT"
58
+
59
+ ###########################################
60
+ ###########################################
61
+
62
+ # => Email
63
+ # => https://sendgrid.com/docs/Integrate/Frameworks/rubyonrails.html
64
+ # => http://apidock.com/rails/ActionMailer/Base/default/class
65
+ app.config.action_mailer.logger = nil
66
+ app.config.action_mailer.delivery_method = :smtp
67
+ app.config.action_mailer.default_options = { from: "#{Rails.application.secrets.app[:name]} <#{Rails.application.secrets.app[:email]}>" }
68
+ app.config.action_mailer.smtp_settings = {
69
+ user_name: Rails.application.secrets.mail[:user],
70
+ password: Rails.application.secrets.mail[:pass],
71
+ address: Rails.application.secrets.mail[:host],
72
+ port: Rails.application.secrets.mail[:port],
73
+ authentication: Rails.application.secrets.mail[:auth] || :plain,
74
+ enable_starttls_auto: Rails.application.secrets.mail[:ttls] || true,
75
+ openssl_verify_mode: Rails.application.secrets.mail[:openssl] || nil,
76
+ domain: Rails.application.secrets.app[:domain]
77
+ }
78
+
79
+ ###########################################
80
+ ###########################################
81
+
82
+ # => Sanitized
83
+ # => http://api.rubyonrails.org/classes/ActionView/Helpers/SanitizeHelper.html
84
+ config.action_view.sanitized_allowed_tags = %w(div span p b strong i u section img h1 h2 h3 h4 br font table form input iframe audio hr ol ul li em script button a title style link meta large blockquote tbody tr td)
85
+ config.action_view.sanitized_allowed_attributes = %w(id class rel type style name title src alt value accept-charset data method action type data-allow-remember-me data-original-title data-amount data-currency data-description data-image data-product data-key data-label data-locale data-name href bgcolor content data-city data-coords rowspan valign)
86
+
87
+ # => Paperclip Interpolation
88
+ # => This is required because referencing config.assets.prefix directly does not inherit environment
89
+ Paperclip.interpolates :asset_path do |attachment, style|
90
+ Rails.application.config.assets.prefix
91
+ end
92
+
93
+ # => Paperclip Defaults
94
+ # => http://stackoverflow.com/a/7949067/1143732
95
+ app.config.paperclip_defaults = {
96
+ preserve_files: false,
97
+ default_style: :medium,
98
+ keep_old_files: true,
99
+ styles: { large: "x850", medium: "x450", thumb: "x200"},
100
+ url: Rails.application.secrets[:app].try(:paperclip).try(:url) || '/assets/:attachment/:id/:style/:basename.:extension',
101
+ path: Rails.application.secrets[:app].try(:paperclip).try(:path) || ':rails_root/public:url'
102
+ }
103
+
104
+ # => Pusher
105
+ if Gem.loaded_specs.has_key? "pusher"
106
+ %i(app_id key secret cluster encrypted logger).each do |item|
107
+ Pusher.send item.to_s + "=", Rails.application.secrets[:pusher][item]
108
+ end
109
+ end
110
+
111
+ # => FriendlyID
112
+ FriendlyId::Slug.table_name = :slugs
113
+
114
+ # => Devise - https://github.com/plataformatec/devise/issues/2209#issuecomment-12381713
115
+ app.config.to_prepare do
116
+ DeviseController.respond_to :html, :json
117
+ end
118
+
119
+ ###########################################
120
+ ###########################################
121
+
122
+ # => Base URL
123
+ # => https://github.com/rails-api/active_model_serializers/blob/master/docs/general/getting_started.md#rails-integration
124
+ Rails.application.routes.default_url_options = { host: Rails.application.secrets.app[:domain] }
125
+
126
+ # => Partials using Namespacing
127
+ # => As referenced in this pull request: https://github.com/rails/rails/pull/5625
128
+ # => https://github.com/rails/rails/blob/master/actionview/lib/action_view/base.rb#L151
129
+ app.config.action_view.prefix_partial_path_with_controller_namespace = false
130
+
131
+ # => Responders
132
+ # => https://github.com/plataformatec/responders#flashresponder
133
+ app.config.responders.flash_keys = [ :success, :failure ]
134
+
135
+ # => Markdown (for CKEditor skins)
136
+ # => https://github.com/rails/sprockets/blob/99444c0a280cc93e33ddf7acfe961522dec3dcf5/guides/extending_sprockets.md#register-mime-types
137
+ config.before_initialize do |app|
138
+ Sprockets.register_mime_type 'text/markdown', extensions: ['.md']
139
+ end
140
+
141
+ ###########################################
142
+ ###########################################
143
+
144
+ # => Asset Prefix
145
+ # => Devise doesn't work with just base path
146
+ # => Added leading slash for CKEditor (check for update to remove leading slash)
147
+ # => https://github.com/galetahub/ckeditor/compare/master...richpeck:patch-1
148
+
149
+ # => If you change this, run "rake tmp:clear" for CKEditor basepath
150
+ config.assets.prefix = "/" + (Rails.env.development? ? Rails.env : "")
151
+
152
+ ###########################################
153
+ ###########################################
154
+
155
+ end
156
+ end
157
+ end
158
+
159
+ ########################################
160
+ ########################################