polygallery 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (168) hide show
  1. checksums.yaml +7 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README.rdoc +3 -0
  4. data/Rakefile +34 -0
  5. data/app/assets/images/polygallery/thumbnail-missing.jpg +0 -0
  6. data/app/assets/javascripts/polygallery/application.js +13 -0
  7. data/app/assets/javascripts/polygallery/galleries.js +2 -0
  8. data/app/assets/javascripts/polygallery/init.js +17 -0
  9. data/app/assets/javascripts/polygallery/photos.js +2 -0
  10. data/app/assets/javascripts/polygallery/polygallery.js.coffee +4 -0
  11. data/app/assets/stylesheets/polygallery/application.css +15 -0
  12. data/app/assets/stylesheets/polygallery/galleries.css +4 -0
  13. data/app/assets/stylesheets/polygallery/photos.css +4 -0
  14. data/app/controllers/polygallery/application_controller.rb +4 -0
  15. data/app/controllers/polygallery/galleries_controller.rb +6 -0
  16. data/app/controllers/polygallery/photos_controller.rb +6 -0
  17. data/app/helpers/polygallery/application_helper.rb +4 -0
  18. data/app/helpers/polygallery/galleries_helper.rb +4 -0
  19. data/app/helpers/polygallery/photos_helper.rb +4 -0
  20. data/app/models/polygallery/gallery.rb +22 -0
  21. data/app/models/polygallery/photo.rb +10 -0
  22. data/app/models/polygallery/polygallery.rb +7 -0
  23. data/app/views/layouts/polygallery/application.html.erb +14 -0
  24. data/app/views/polygallery/galleries/_fields_for.html.haml +5 -0
  25. data/app/views/polygallery/galleries/_simple_fields_for.html.haml +25 -0
  26. data/app/views/polygallery/photos/_fields_for.html.haml +3 -0
  27. data/app/views/polygallery/photos/_simple_fields_for.html.haml +9 -0
  28. data/config/routes.rb +6 -0
  29. data/db/migrate/20140803171516_create_polygallery_galleries.rb +12 -0
  30. data/db/migrate/20140803171534_create_polygallery_photos.rb +12 -0
  31. data/lib/generators/polygallery/install/install_generator.rb +37 -0
  32. data/lib/generators/polygallery/install/templates/polygallery_migration.rb +20 -0
  33. data/lib/polygallery.rb +6 -0
  34. data/lib/polygallery/engine.rb +10 -0
  35. data/lib/polygallery/glue.rb +9 -0
  36. data/lib/polygallery/has_polygallery.rb +46 -0
  37. data/lib/polygallery/railtie.rb +25 -0
  38. data/lib/polygallery/validators.rb +37 -0
  39. data/lib/polygallery/validators/polygallery_presence_validator.rb +30 -0
  40. data/lib/polygallery/version.rb +3 -0
  41. data/lib/polygallery/view_helpers.rb +21 -0
  42. data/lib/tasks/polygallery_tasks.rake +4 -0
  43. data/test/controllers/polygallery/galleries_controller_test.rb +9 -0
  44. data/test/controllers/polygallery/photos_controller_test.rb +9 -0
  45. data/test/dummy/README.rdoc +28 -0
  46. data/test/dummy/Rakefile +6 -0
  47. data/test/dummy/app/assets/javascripts/application.js +16 -0
  48. data/test/dummy/app/assets/javascripts/bootstrap.min.js +6 -0
  49. data/test/dummy/app/assets/javascripts/events.js +2 -0
  50. data/test/dummy/app/assets/javascripts/home.js +2 -0
  51. data/test/dummy/app/assets/stylesheets/application.css +17 -0
  52. data/test/dummy/app/assets/stylesheets/bootstrap-theme.min.css +5 -0
  53. data/test/dummy/app/assets/stylesheets/bootstrap.min.css +5 -0
  54. data/test/dummy/app/assets/stylesheets/events.css +4 -0
  55. data/test/dummy/app/assets/stylesheets/home.css +4 -0
  56. data/test/dummy/app/controllers/application_controller.rb +5 -0
  57. data/test/dummy/app/controllers/events_controller.rb +19 -0
  58. data/test/dummy/app/controllers/home_controller.rb +7 -0
  59. data/test/dummy/app/helpers/application_helper.rb +2 -0
  60. data/test/dummy/app/helpers/events_helper.rb +2 -0
  61. data/test/dummy/app/helpers/home_helper.rb +2 -0
  62. data/test/dummy/app/models/event.rb +5 -0
  63. data/test/dummy/app/views/home/index.html.haml +32 -0
  64. data/test/dummy/app/views/layouts/application.html.haml +21 -0
  65. data/test/dummy/bin/bundle +3 -0
  66. data/test/dummy/bin/rails +4 -0
  67. data/test/dummy/bin/rake +4 -0
  68. data/test/dummy/config.ru +4 -0
  69. data/test/dummy/config/application.rb +24 -0
  70. data/test/dummy/config/boot.rb +5 -0
  71. data/test/dummy/config/database.yml +85 -0
  72. data/test/dummy/config/environment.rb +5 -0
  73. data/test/dummy/config/environments/development.rb +37 -0
  74. data/test/dummy/config/environments/production.rb +83 -0
  75. data/test/dummy/config/environments/test.rb +39 -0
  76. data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
  77. data/test/dummy/config/initializers/cookies_serializer.rb +3 -0
  78. data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  79. data/test/dummy/config/initializers/inflections.rb +16 -0
  80. data/test/dummy/config/initializers/mime_types.rb +4 -0
  81. data/test/dummy/config/initializers/reload_lib.rb +9 -0
  82. data/test/dummy/config/initializers/session_store.rb +3 -0
  83. data/test/dummy/config/initializers/simple_form.rb +145 -0
  84. data/test/dummy/config/initializers/simple_form_bootstrap.rb +96 -0
  85. data/test/dummy/config/initializers/simple_form_fileinput.rb +15 -0
  86. data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
  87. data/test/dummy/config/locales/en.yml +23 -0
  88. data/test/dummy/config/locales/simple_form.en.yml +26 -0
  89. data/test/dummy/config/routes.rb +7 -0
  90. data/test/dummy/config/secrets.yml +22 -0
  91. data/test/dummy/db/migrate/20140803170839_create_events.rb +9 -0
  92. data/test/dummy/db/schema.rb +46 -0
  93. data/test/dummy/lib/templates/haml/scaffold/_form.html.haml +10 -0
  94. data/test/dummy/log/development.log +5483 -0
  95. data/test/dummy/public/404.html +67 -0
  96. data/test/dummy/public/422.html +67 -0
  97. data/test/dummy/public/500.html +66 -0
  98. data/test/dummy/public/favicon.ico +0 -0
  99. data/test/dummy/public/fonts/glyphicons-halflings-regular.eot +0 -0
  100. data/test/dummy/public/fonts/glyphicons-halflings-regular.svg +229 -0
  101. data/test/dummy/public/fonts/glyphicons-halflings-regular.ttf +0 -0
  102. data/test/dummy/public/fonts/glyphicons-halflings-regular.woff +0 -0
  103. data/test/dummy/test/controllers/events_controller_test.rb +7 -0
  104. data/test/dummy/test/controllers/home_controller_test.rb +7 -0
  105. data/test/dummy/test/fixtures/events.yml +7 -0
  106. data/test/dummy/test/helpers/events_helper_test.rb +4 -0
  107. data/test/dummy/test/helpers/home_helper_test.rb +4 -0
  108. data/test/dummy/test/models/event_test.rb +7 -0
  109. data/test/dummy/tmp/cache/assets/development/sprockets/05c0a42e9725c8eb8a83324cfdce4a16 +0 -0
  110. data/test/dummy/tmp/cache/assets/development/sprockets/13fe41fee1fe35b49d145bcc06610705 +0 -0
  111. data/test/dummy/tmp/cache/assets/development/sprockets/1c9faaf28d05409b88ad3113374d613c +0 -0
  112. data/test/dummy/tmp/cache/assets/development/sprockets/1e1c73f8892119a4dbc6ead7718b4472 +0 -0
  113. data/test/dummy/tmp/cache/assets/development/sprockets/1ecd715c01db7b05e5fc97838c7bdac7 +0 -0
  114. data/test/dummy/tmp/cache/assets/development/sprockets/23a02f793bdc3b6a6cbd015f184c6f6c +0 -0
  115. data/test/dummy/tmp/cache/assets/development/sprockets/2757fae967a52701ef3724ae5a76c4a8 +0 -0
  116. data/test/dummy/tmp/cache/assets/development/sprockets/2822de3b22c28bd5e718c9bf500457b2 +0 -0
  117. data/test/dummy/tmp/cache/assets/development/sprockets/2f5173deea6c795b8fdde723bb4b63af +0 -0
  118. data/test/dummy/tmp/cache/assets/development/sprockets/30e3552cad42917377b8675173b87d6d +0 -0
  119. data/test/dummy/tmp/cache/assets/development/sprockets/311df7a951cd5c960bea25b750d24073 +0 -0
  120. data/test/dummy/tmp/cache/assets/development/sprockets/357970feca3ac29060c1e3861e2c0953 +0 -0
  121. data/test/dummy/tmp/cache/assets/development/sprockets/39bcd7e5a58fb6e7114bbae6ac577fe6 +0 -0
  122. data/test/dummy/tmp/cache/assets/development/sprockets/3df3a0e2cf2fc334a9e6292941bae875 +0 -0
  123. data/test/dummy/tmp/cache/assets/development/sprockets/3edcdce4b73dab626737716f1fc4d97d +0 -0
  124. data/test/dummy/tmp/cache/assets/development/sprockets/40fc2f3d2a468a00e463f1d313cb1683 +0 -0
  125. data/test/dummy/tmp/cache/assets/development/sprockets/4d1647c172443398b0d023245fb13877 +0 -0
  126. data/test/dummy/tmp/cache/assets/development/sprockets/4daff1d5b8e6da6d2ed55886db193ef2 +0 -0
  127. data/test/dummy/tmp/cache/assets/development/sprockets/4ea33e825e6e38bd22dccab488a0255b +0 -0
  128. data/test/dummy/tmp/cache/assets/development/sprockets/61cd6f9b2dc23f35478fc14d5fb4f7df +0 -0
  129. data/test/dummy/tmp/cache/assets/development/sprockets/650d6a1ba71368c14b9fced6b6180b2d +0 -0
  130. data/test/dummy/tmp/cache/assets/development/sprockets/65dccf676de4439612547abc6451ba65 +0 -0
  131. data/test/dummy/tmp/cache/assets/development/sprockets/69bda14eaa1d8ad1ea1235abb619e366 +0 -0
  132. data/test/dummy/tmp/cache/assets/development/sprockets/6f562a48c0e855e0e4fdab624ba41eb9 +0 -0
  133. data/test/dummy/tmp/cache/assets/development/sprockets/7be9086c960bb4384c9d23a52e489f29 +0 -0
  134. data/test/dummy/tmp/cache/assets/development/sprockets/86f909bf5baee50515afadaa3ce2df8f +0 -0
  135. data/test/dummy/tmp/cache/assets/development/sprockets/88f812810562f1bc315ee991f8a30c4e +0 -0
  136. data/test/dummy/tmp/cache/assets/development/sprockets/8e5a9738e9bc15478e026d98335454f9 +0 -0
  137. data/test/dummy/tmp/cache/assets/development/sprockets/8f8936f164170e095c5ca2d0c2ae6127 +0 -0
  138. data/test/dummy/tmp/cache/assets/development/sprockets/a11d7eb71230eda394161e35aefa0a24 +0 -0
  139. data/test/dummy/tmp/cache/assets/development/sprockets/a32fea9e0a124a0fbd82afec0c27e0d4 +0 -0
  140. data/test/dummy/tmp/cache/assets/development/sprockets/a995a3b95e4a7b0e5b9fa7c49efd6b74 +0 -0
  141. data/test/dummy/tmp/cache/assets/development/sprockets/a9f028f7a492b5907ed80268be8f50f4 +0 -0
  142. data/test/dummy/tmp/cache/assets/development/sprockets/b878faf942403e313a5b103e5d80488e +0 -0
  143. data/test/dummy/tmp/cache/assets/development/sprockets/ba56eb60d599a0ca3d2f6b67772774c2 +0 -0
  144. data/test/dummy/tmp/cache/assets/development/sprockets/c0a32ddd5941d7ff3aca0ad92298608c +0 -0
  145. data/test/dummy/tmp/cache/assets/development/sprockets/c54e257d17c58c802e2870d68ff1bd39 +0 -0
  146. data/test/dummy/tmp/cache/assets/development/sprockets/c6d68ddd2f21544d3a6ac67934487535 +0 -0
  147. data/test/dummy/tmp/cache/assets/development/sprockets/c79813a3ee7359e3d7880d6b671f6f6d +0 -0
  148. data/test/dummy/tmp/cache/assets/development/sprockets/c9e5e8280743d98ec882539be0f91af5 +0 -0
  149. data/test/dummy/tmp/cache/assets/development/sprockets/cbe9afc48460e8e0bc42c314d5e594a0 +0 -0
  150. data/test/dummy/tmp/cache/assets/development/sprockets/cffd775d018f68ce5dba1ee0d951a994 +0 -0
  151. data/test/dummy/tmp/cache/assets/development/sprockets/d771ace226fc8215a3572e0aa35bb0d6 +0 -0
  152. data/test/dummy/tmp/cache/assets/development/sprockets/e01ccf02ec6a0fb2cb7189161c5850c5 +0 -0
  153. data/test/dummy/tmp/cache/assets/development/sprockets/e928c77266ca2960fa4a7fbb56b4e034 +0 -0
  154. data/test/dummy/tmp/cache/assets/development/sprockets/edbef6e0d0a4742346cf479f2c522eb0 +0 -0
  155. data/test/dummy/tmp/cache/assets/development/sprockets/ee77497db62576e6878e7815e80e8b5a +0 -0
  156. data/test/dummy/tmp/cache/assets/development/sprockets/f644fd75cbead0e58c847aa16546e2a8 +0 -0
  157. data/test/dummy/tmp/cache/assets/development/sprockets/f7cbd26ba1d28d48de824f0e94586655 +0 -0
  158. data/test/dummy/tmp/cache/assets/development/sprockets/fe0a04f09eb0c97bcc18973678e986a3 +0 -0
  159. data/test/fixtures/polygallery/galleries.yml +11 -0
  160. data/test/fixtures/polygallery/photos.yml +7 -0
  161. data/test/helpers/polygallery/galleries_helper_test.rb +6 -0
  162. data/test/helpers/polygallery/photos_helper_test.rb +6 -0
  163. data/test/integration/navigation_test.rb +10 -0
  164. data/test/models/polygallery/gallery_test.rb +9 -0
  165. data/test/models/polygallery/photo_test.rb +9 -0
  166. data/test/polygallery_test.rb +7 -0
  167. data/test/test_helper.rb +15 -0
  168. metadata +461 -0
@@ -0,0 +1,5 @@
1
+ # Load the Rails application.
2
+ require File.expand_path('../application', __FILE__)
3
+
4
+ # Initialize the Rails application.
5
+ Rails.application.initialize!
@@ -0,0 +1,37 @@
1
+ Rails.application.configure do
2
+ # Settings specified here will take precedence over those in config/application.rb.
3
+
4
+ # In the development environment your application's code is reloaded on
5
+ # every request. This slows down response time but is perfect for development
6
+ # since you don't have to restart the web server when you make code changes.
7
+ config.cache_classes = false
8
+
9
+ # Do not eager load code on boot.
10
+ config.eager_load = false
11
+
12
+ # Show full error reports and disable caching.
13
+ config.consider_all_requests_local = true
14
+ config.action_controller.perform_caching = false
15
+
16
+ # Don't care if the mailer can't send.
17
+ config.action_mailer.raise_delivery_errors = false
18
+
19
+ # Print deprecation notices to the Rails logger.
20
+ config.active_support.deprecation = :log
21
+
22
+ # Raise an error on page load if there are pending migrations.
23
+ config.active_record.migration_error = :page_load
24
+
25
+ # Debug mode disables concatenation and preprocessing of assets.
26
+ # This option may cause significant delays in view rendering with a large
27
+ # number of complex assets.
28
+ config.assets.debug = true
29
+
30
+ # Adds additional error checking when serving assets at runtime.
31
+ # Checks for improperly declared sprockets dependencies.
32
+ # Raises helpful error messages.
33
+ config.assets.raise_runtime_errors = true
34
+
35
+ # Raises error for missing translations
36
+ # config.action_view.raise_on_missing_translations = true
37
+ end
@@ -0,0 +1,83 @@
1
+ Rails.application.configure do
2
+ # Settings specified here will take precedence over those in config/application.rb.
3
+
4
+ # Code is not reloaded between requests.
5
+ config.cache_classes = true
6
+
7
+ # Eager load code on boot. This eager loads most of Rails and
8
+ # your application in memory, allowing both threaded web servers
9
+ # and those relying on copy on write to perform better.
10
+ # Rake tasks automatically ignore this option for performance.
11
+ config.eager_load = true
12
+
13
+ # Full error reports are disabled and caching is turned on.
14
+ config.consider_all_requests_local = false
15
+ config.action_controller.perform_caching = true
16
+
17
+ # Enable Rack::Cache to put a simple HTTP cache in front of your application
18
+ # Add `rack-cache` to your Gemfile before enabling this.
19
+ # For large-scale production use, consider using a caching reverse proxy like nginx, varnish or squid.
20
+ # config.action_dispatch.rack_cache = true
21
+
22
+ # Disable Rails's static asset server (Apache or nginx will already do this).
23
+ config.serve_static_assets = false
24
+
25
+ # Compress JavaScripts and CSS.
26
+ config.assets.js_compressor = :uglifier
27
+ # config.assets.css_compressor = :sass
28
+
29
+ # Do not fallback to assets pipeline if a precompiled asset is missed.
30
+ config.assets.compile = false
31
+
32
+ # Generate digests for assets URLs.
33
+ config.assets.digest = true
34
+
35
+ # Version of your assets, change this if you want to expire all your assets.
36
+ config.assets.version = '1.0'
37
+
38
+ # Specifies the header that your server uses for sending files.
39
+ # config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache
40
+ # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx
41
+
42
+ # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
43
+ # config.force_ssl = true
44
+
45
+ # Set to :debug to see everything in the log.
46
+ config.log_level = :info
47
+
48
+ # Prepend all log lines with the following tags.
49
+ # config.log_tags = [ :subdomain, :uuid ]
50
+
51
+ # Use a different logger for distributed setups.
52
+ # config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new)
53
+
54
+ # Use a different cache store in production.
55
+ # config.cache_store = :mem_cache_store
56
+
57
+ # Enable serving of images, stylesheets, and JavaScripts from an asset server.
58
+ # config.action_controller.asset_host = "http://assets.example.com"
59
+
60
+ # Precompile additional assets.
61
+ # application.js, application.css, and all non-JS/CSS in app/assets folder are already added.
62
+ # config.assets.precompile += %w( search.js )
63
+
64
+ # Ignore bad email addresses and do not raise email delivery errors.
65
+ # Set this to true and configure the email server for immediate delivery to raise delivery errors.
66
+ # config.action_mailer.raise_delivery_errors = false
67
+
68
+ # Enable locale fallbacks for I18n (makes lookups for any locale fall back to
69
+ # the I18n.default_locale when a translation cannot be found).
70
+ config.i18n.fallbacks = true
71
+
72
+ # Send deprecation notices to registered listeners.
73
+ config.active_support.deprecation = :notify
74
+
75
+ # Disable automatic flushing of the log to improve performance.
76
+ # config.autoflush_log = false
77
+
78
+ # Use default logging formatter so that PID and timestamp are not suppressed.
79
+ config.log_formatter = ::Logger::Formatter.new
80
+
81
+ # Do not dump schema after migrations.
82
+ config.active_record.dump_schema_after_migration = false
83
+ end
@@ -0,0 +1,39 @@
1
+ Rails.application.configure do
2
+ # Settings specified here will take precedence over those in config/application.rb.
3
+
4
+ # The test environment is used exclusively to run your application's
5
+ # test suite. You never need to work with it otherwise. Remember that
6
+ # your test database is "scratch space" for the test suite and is wiped
7
+ # and recreated between test runs. Don't rely on the data there!
8
+ config.cache_classes = true
9
+
10
+ # Do not eager load code on boot. This avoids loading your whole application
11
+ # just for the purpose of running a single test. If you are using a tool that
12
+ # preloads Rails for running tests, you may have to set it to true.
13
+ config.eager_load = false
14
+
15
+ # Configure static asset server for tests with Cache-Control for performance.
16
+ config.serve_static_assets = true
17
+ config.static_cache_control = 'public, max-age=3600'
18
+
19
+ # Show full error reports and disable caching.
20
+ config.consider_all_requests_local = true
21
+ config.action_controller.perform_caching = false
22
+
23
+ # Raise exceptions instead of rendering exception templates.
24
+ config.action_dispatch.show_exceptions = false
25
+
26
+ # Disable request forgery protection in test environment.
27
+ config.action_controller.allow_forgery_protection = false
28
+
29
+ # Tell Action Mailer not to deliver emails to the real world.
30
+ # The :test delivery method accumulates sent emails in the
31
+ # ActionMailer::Base.deliveries array.
32
+ config.action_mailer.delivery_method = :test
33
+
34
+ # Print deprecation notices to the stderr.
35
+ config.active_support.deprecation = :stderr
36
+
37
+ # Raises error for missing translations
38
+ # config.action_view.raise_on_missing_translations = true
39
+ end
@@ -0,0 +1,7 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
4
+ # Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ }
5
+
6
+ # You can also remove all the silencers if you're trying to debug a problem that might stem from framework code.
7
+ # Rails.backtrace_cleaner.remove_silencers!
@@ -0,0 +1,3 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ Rails.application.config.action_dispatch.cookies_serializer = :json
@@ -0,0 +1,4 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # Configure sensitive parameters which will be filtered from the log file.
4
+ Rails.application.config.filter_parameters += [:password]
@@ -0,0 +1,16 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # Add new inflection rules using the following format. Inflections
4
+ # are locale specific, and you may define rules for as many different
5
+ # locales as you wish. All of these examples are active by default:
6
+ # ActiveSupport::Inflector.inflections(:en) do |inflect|
7
+ # inflect.plural /^(ox)$/i, '\1en'
8
+ # inflect.singular /^(ox)en/i, '\1'
9
+ # inflect.irregular 'person', 'people'
10
+ # inflect.uncountable %w( fish sheep )
11
+ # end
12
+
13
+ # These inflection rules are supported but not enabled by default:
14
+ # ActiveSupport::Inflector.inflections(:en) do |inflect|
15
+ # inflect.acronym 'RESTful'
16
+ # end
@@ -0,0 +1,4 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # Add new mime types for use in respond_to blocks:
4
+ # Mime::Type.register "text/richtext", :rtf
@@ -0,0 +1,9 @@
1
+ if Rails.env == "development"
2
+ lib_reloader = ActiveSupport::FileUpdateChecker.new(Dir["lib/**/*"]) do
3
+ Rails.application.reload_routes! # or do something better here
4
+ end
5
+
6
+ ActionDispatch::Callbacks.to_prepare do
7
+ lib_reloader.execute_if_updated
8
+ end
9
+ end
@@ -0,0 +1,3 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ Rails.application.config.session_store :cookie_store, key: '_dummy_session'
@@ -0,0 +1,145 @@
1
+ # Use this setup block to configure all options available in SimpleForm.
2
+ SimpleForm.setup do |config|
3
+ # Wrappers are used by the form builder to generate a
4
+ # complete input. You can remove any component from the
5
+ # wrapper, change the order or even add your own to the
6
+ # stack. The options given below are used to wrap the
7
+ # whole input.
8
+ config.wrappers :default, class: :input,
9
+ hint_class: :field_with_hint, error_class: :field_with_errors do |b|
10
+ ## Extensions enabled by default
11
+ # Any of these extensions can be disabled for a
12
+ # given input by passing: `f.input EXTENSION_NAME => false`.
13
+ # You can make any of these extensions optional by
14
+ # renaming `b.use` to `b.optional`.
15
+
16
+ # Determines whether to use HTML5 (:email, :url, ...)
17
+ # and required attributes
18
+ b.use :html5
19
+
20
+ # Calculates placeholders automatically from I18n
21
+ # You can also pass a string as f.input placeholder: "Placeholder"
22
+ b.use :placeholder
23
+
24
+ ## Optional extensions
25
+ # They are disabled unless you pass `f.input EXTENSION_NAME => :lookup`
26
+ # to the input. If so, they will retrieve the values from the model
27
+ # if any exists. If you want to enable the lookup for any of those
28
+ # extensions by default, you can change `b.optional` to `b.use`.
29
+
30
+ # Calculates maxlength from length validations for string inputs
31
+ b.optional :maxlength
32
+
33
+ # Calculates pattern from format validations for string inputs
34
+ b.optional :pattern
35
+
36
+ # Calculates min and max from length validations for numeric inputs
37
+ b.optional :min_max
38
+
39
+ # Calculates readonly automatically from readonly attributes
40
+ b.optional :readonly
41
+
42
+ ## Inputs
43
+ b.use :label_input
44
+ b.use :hint, wrap_with: { tag: :span, class: :hint }
45
+ b.use :error, wrap_with: { tag: :span, class: :error }
46
+ end
47
+
48
+ # The default wrapper to be used by the FormBuilder.
49
+ config.default_wrapper = :default
50
+
51
+ # Define the way to render check boxes / radio buttons with labels.
52
+ # Defaults to :nested for bootstrap config.
53
+ # inline: input + label
54
+ # nested: label > input
55
+ config.boolean_style = :nested
56
+
57
+ # Default class for buttons
58
+ config.button_class = 'btn'
59
+
60
+ # Method used to tidy up errors. Specify any Rails Array method.
61
+ # :first lists the first message for each field.
62
+ # Use :to_sentence to list all errors for each field.
63
+ # config.error_method = :first
64
+
65
+ # Default tag used for error notification helper.
66
+ config.error_notification_tag = :div
67
+
68
+ # CSS class to add for error notification helper.
69
+ config.error_notification_class = 'alert alert-error'
70
+
71
+ # ID to add for error notification helper.
72
+ # config.error_notification_id = nil
73
+
74
+ # Series of attempts to detect a default label method for collection.
75
+ # config.collection_label_methods = [ :to_label, :name, :title, :to_s ]
76
+
77
+ # Series of attempts to detect a default value method for collection.
78
+ # config.collection_value_methods = [ :id, :to_s ]
79
+
80
+ # You can wrap a collection of radio/check boxes in a pre-defined tag, defaulting to none.
81
+ # config.collection_wrapper_tag = nil
82
+
83
+ # You can define the class to use on all collection wrappers. Defaulting to none.
84
+ # config.collection_wrapper_class = nil
85
+
86
+ # You can wrap each item in a collection of radio/check boxes with a tag,
87
+ # defaulting to :span. Please note that when using :boolean_style = :nested,
88
+ # SimpleForm will force this option to be a label.
89
+ # config.item_wrapper_tag = :span
90
+
91
+ # You can define a class to use in all item wrappers. Defaulting to none.
92
+ # config.item_wrapper_class = nil
93
+
94
+ # How the label text should be generated altogether with the required text.
95
+ # config.label_text = lambda { |label, required| "#{required} #{label}" }
96
+
97
+ # You can define the class to use on all labels. Default is nil.
98
+ config.label_class = 'control-label'
99
+
100
+ # You can define the class to use on all forms. Default is simple_form.
101
+ # config.form_class = :simple_form
102
+
103
+ # You can define which elements should obtain additional classes
104
+ # config.generate_additional_classes_for = [:wrapper, :label, :input]
105
+
106
+ # Whether attributes are required by default (or not). Default is true.
107
+ # config.required_by_default = true
108
+
109
+ # Tell browsers whether to use the native HTML5 validations (novalidate form option).
110
+ # These validations are enabled in SimpleForm's internal config but disabled by default
111
+ # in this configuration, which is recommended due to some quirks from different browsers.
112
+ # To stop SimpleForm from generating the novalidate option, enabling the HTML5 validations,
113
+ # change this configuration to true.
114
+ config.browser_validations = false
115
+
116
+ # Collection of methods to detect if a file type was given.
117
+ # config.file_methods = [ :mounted_as, :file?, :public_filename ]
118
+
119
+ # Custom mappings for input types. This should be a hash containing a regexp
120
+ # to match as key, and the input type that will be used when the field name
121
+ # matches the regexp as value.
122
+ # config.input_mappings = { /count/ => :integer }
123
+
124
+ # Custom wrappers for input types. This should be a hash containing an input
125
+ # type as key and the wrapper that will be used for all inputs with specified type.
126
+ # config.wrapper_mappings = { string: :prepend }
127
+
128
+ # Default priority for time_zone inputs.
129
+ # config.time_zone_priority = nil
130
+
131
+ # Default priority for country inputs.
132
+ # config.country_priority = nil
133
+
134
+ # When false, do not use translations for labels.
135
+ # config.translate_labels = true
136
+
137
+ # Automatically discover new inputs in Rails' autoload path.
138
+ # config.inputs_discovery = true
139
+
140
+ # Cache SimpleForm inputs discovery
141
+ # config.cache_discovery = !Rails.env.development?
142
+
143
+ # Default class for inputs
144
+ # config.input_class = nil
145
+ end
@@ -0,0 +1,96 @@
1
+ # Use this setup block to configure all options available in SimpleForm.
2
+ SimpleForm.setup do |config|
3
+ config.wrappers :bootstrap, :tag => 'div', :class => 'form-group', :error_class => 'error' do |b|
4
+ b.use :html5
5
+ b.use :placeholder
6
+ b.use :label
7
+ b.wrapper :tag => 'div', :class => 'controls' do |ba|
8
+ ba.use :input
9
+ ba.use :error, :wrap_with => { :tag => :span, :class => 'help-inline text-danger' }
10
+ ba.use :hint, :wrap_with => { :tag => :p, :class => 'help-block' }
11
+ end
12
+ end
13
+
14
+ config.wrappers :bootstrap_checkbox, :tag => :div, :class => "checkbox", :error_class => 'has-error' do |b|
15
+ b.use :html5
16
+
17
+ b.wrapper :tag => :label do |ba|
18
+ ba.use :input
19
+ ba.use :label_text
20
+ end
21
+
22
+ b.use :hint, :wrap_with => {:tag => :p, :class => "help-block"}
23
+ b.use :error, :wrap_with => {:tag => :span, :class => "help-block text-danger"}
24
+ end
25
+
26
+ config.wrappers :bootstrap_radio, :tag => :div, :class => 'radio', :error_class => 'has-error' do |b|
27
+ b.use :html5
28
+
29
+ b.wrapper :tag => :label do |ba|
30
+ ba.use :input
31
+ ba.use :label_text
32
+ end
33
+
34
+ b.use :hint, :wrap_with => {:tag => :p, :class => "help-block"}
35
+ b.use :error, :wrap_with => {:tag => :span, :class => "help-block text-danger"}
36
+ end
37
+
38
+ config.wrappers :prepend, :tag => 'div', :class => "control-group", :error_class => 'error' do |b|
39
+ b.use :html5
40
+ b.use :placeholder
41
+ b.use :label
42
+ b.wrapper :tag => 'div', :class => 'controls' do |input|
43
+ input.wrapper :tag => 'div', :class => 'input-prepend' do |prepend|
44
+ prepend.use :input
45
+ end
46
+ input.use :hint, :wrap_with => { :tag => 'span', :class => 'help-block' }
47
+ input.use :error, :wrap_with => { :tag => 'span', :class => 'help-inline' }
48
+ end
49
+ end
50
+
51
+ config.wrappers :append, :tag => 'div', :class => "control-group", :error_class => 'error' do |b|
52
+ b.use :html5
53
+ b.use :placeholder
54
+ b.use :label
55
+ b.wrapper :tag => 'div', :class => 'controls' do |input|
56
+ input.wrapper :tag => 'div', :class => 'input-append' do |append|
57
+ append.use :input
58
+ end
59
+ input.use :hint, :wrap_with => { :tag => 'span', :class => 'help-block' }
60
+ input.use :error, :wrap_with => { :tag => 'span', :class => 'help-inline' }
61
+ end
62
+ end
63
+
64
+ # Wrappers for forms and inputs using the Twitter Bootstrap toolkit.
65
+ # Check the Bootstrap docs (http://twitter.github.com/bootstrap)
66
+ # to learn about the different styles for forms and inputs,
67
+ # buttons and other elements.
68
+ config.default_wrapper = :bootstrap
69
+ config.boolean_style = :inline
70
+ config.wrapper_mappings = {:boolean => :bootstrap_checkbox, :radio => :bootstrap_radio}
71
+ end
72
+
73
+
74
+ # TEMPORARY FIX FOR SIMPLEFORM INPUTS ON BOOTSTRAP 3
75
+ %w[
76
+ CollectionSelectInput
77
+ DateTimeInput
78
+ FileInput
79
+ GroupedCollectionSelectInput
80
+ NumericInput
81
+ PasswordInput
82
+ RangeInput
83
+ StringInput
84
+ TextInput
85
+ PriorityInput
86
+ ].each do |input_type|
87
+ superclass = "SimpleForm::Inputs::#{input_type}".constantize
88
+
89
+ new_class = Class.new(superclass) do
90
+ def input_html_classes
91
+ super.push('form-control')
92
+ end
93
+ end
94
+
95
+ Object.const_set(input_type, new_class)
96
+ end