incline 0.1.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (303) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +13 -0
  3. data/Gemfile +17 -0
  4. data/Gemfile.lock +186 -0
  5. data/MIT-LICENSE +20 -0
  6. data/README.rdoc +208 -0
  7. data/Rakefile +37 -0
  8. data/app/assets/fonts/incline/.keep +0 -0
  9. data/app/assets/images/incline/.keep +0 -0
  10. data/app/assets/images/incline/barcode-B.svg +181 -0
  11. data/app/assets/javascripts/incline/activate_classed_items.js +11 -0
  12. data/app/assets/javascripts/incline/application.js +30 -0
  13. data/app/assets/javascripts/incline/bootstrap-datepicker.js +1800 -0
  14. data/app/assets/javascripts/incline/datatables.js +22193 -0
  15. data/app/assets/javascripts/incline/escapeHtml.js +10 -0
  16. data/app/assets/javascripts/incline/inline_actions.js +479 -0
  17. data/app/assets/javascripts/incline/jquery.doubleScroll.js +112 -0
  18. data/app/assets/javascripts/incline/jquery.number.js +764 -0
  19. data/app/assets/javascripts/incline/regexMask.js +27 -0
  20. data/app/assets/javascripts/incline/select2/i18n/en.js +3 -0
  21. data/app/assets/javascripts/incline/select2/select2.full.js +6436 -0
  22. data/app/assets/stylesheets/incline/application.css +18 -0
  23. data/app/assets/stylesheets/incline/bootstrap-theme.min.css +5 -0
  24. data/app/assets/stylesheets/incline/custom.scss +279 -0
  25. data/app/assets/stylesheets/incline/datatables.css +494 -0
  26. data/app/assets/stylesheets/incline/datepicker3.css +790 -0
  27. data/app/assets/stylesheets/incline/select2.css +484 -0
  28. data/app/controllers/incline/access_groups_controller.rb +127 -0
  29. data/app/controllers/incline/access_test_controller.rb +30 -0
  30. data/app/controllers/incline/account_activations_controller.rb +28 -0
  31. data/app/controllers/incline/application_controller.rb +11 -0
  32. data/app/controllers/incline/contact_controller.rb +34 -0
  33. data/app/controllers/incline/password_resets_controller.rb +113 -0
  34. data/app/controllers/incline/security_controller.rb +100 -0
  35. data/app/controllers/incline/sessions_controller.rb +50 -0
  36. data/app/controllers/incline/users_controller.rb +304 -0
  37. data/app/controllers/incline/welcome_controller.rb +19 -0
  38. data/app/helpers/incline/.keep +0 -0
  39. data/app/mailers/incline/application_mailer_base.rb +11 -0
  40. data/app/mailers/incline/contact_form.rb +19 -0
  41. data/app/mailers/incline/user_mailer.rb +45 -0
  42. data/app/models/incline/access_group.rb +121 -0
  43. data/app/models/incline/access_group_group_member.rb +12 -0
  44. data/app/models/incline/access_group_user_member.rb +10 -0
  45. data/app/models/incline/action_group.rb +12 -0
  46. data/app/models/incline/action_security.rb +222 -0
  47. data/app/models/incline/contact_message.rb +37 -0
  48. data/app/models/incline/disable_info.rb +20 -0
  49. data/app/models/incline/password_reset.rb +14 -0
  50. data/app/models/incline/password_reset_request.rb +14 -0
  51. data/app/models/incline/user.rb +437 -0
  52. data/app/models/incline/user_login_history.rb +30 -0
  53. data/app/views/incline/access_groups/_details.json.jbuilder +10 -0
  54. data/app/views/incline/access_groups/_form.html.erb +19 -0
  55. data/app/views/incline/access_groups/_list.html.erb +60 -0
  56. data/app/views/incline/access_groups/_messages.json.jbuilder +6 -0
  57. data/app/views/incline/access_groups/edit.html.erb +2 -0
  58. data/app/views/incline/access_groups/index.html.erb +6 -0
  59. data/app/views/incline/access_groups/index.json.jbuilder +16 -0
  60. data/app/views/incline/access_groups/new.html.erb +2 -0
  61. data/app/views/incline/access_groups/show.html.erb +9 -0
  62. data/app/views/incline/access_groups/show.json.jbuilder +11 -0
  63. data/app/views/incline/contact/new.html.erb +22 -0
  64. data/app/views/incline/contact_form/contact.html.erb +16 -0
  65. data/app/views/incline/contact_form/contact.text.erb +13 -0
  66. data/app/views/incline/password_resets/edit.html.erb +16 -0
  67. data/app/views/incline/password_resets/new.html.erb +12 -0
  68. data/app/views/incline/security/_details.json.jbuilder +7 -0
  69. data/app/views/incline/security/_form.html.erb +20 -0
  70. data/app/views/incline/security/_list.html.erb +89 -0
  71. data/app/views/incline/security/_messages.json.jbuilder +6 -0
  72. data/app/views/incline/security/edit.html.erb +2 -0
  73. data/app/views/incline/security/index.html.erb +6 -0
  74. data/app/views/incline/security/index.json.jbuilder +16 -0
  75. data/app/views/incline/security/show.html.erb +31 -0
  76. data/app/views/incline/security/show.json.jbuilder +11 -0
  77. data/app/views/incline/sessions/new.html.erb +26 -0
  78. data/app/views/incline/user_mailer/account_activation.html.erb +7 -0
  79. data/app/views/incline/user_mailer/account_activation.text.erb +6 -0
  80. data/app/views/incline/user_mailer/invalid_password_reset.html.erb +3 -0
  81. data/app/views/incline/user_mailer/invalid_password_reset.text.erb +5 -0
  82. data/app/views/incline/user_mailer/password_reset.html.erb +8 -0
  83. data/app/views/incline/user_mailer/password_reset.text.erb +7 -0
  84. data/app/views/incline/users/_details.json.jbuilder +32 -0
  85. data/app/views/incline/users/_form.html.erb +21 -0
  86. data/app/views/incline/users/_list.html.erb +102 -0
  87. data/app/views/incline/users/_messages.json.jbuilder +6 -0
  88. data/app/views/incline/users/disable_confirm.html.erb +19 -0
  89. data/app/views/incline/users/edit.html.erb +5 -0
  90. data/app/views/incline/users/index.html.erb +6 -0
  91. data/app/views/incline/users/index.json.jbuilder +16 -0
  92. data/app/views/incline/users/new.html.erb +5 -0
  93. data/app/views/incline/users/show.html.erb +12 -0
  94. data/app/views/incline/users/show.json.jbuilder +11 -0
  95. data/app/views/incline/welcome/home.html.erb +5 -0
  96. data/app/views/layouts/application.html.erb +1 -0
  97. data/app/views/layouts/incline/_account_menu.html.erb +18 -0
  98. data/app/views/layouts/incline/_app_menu_anon.html.erb +1 -0
  99. data/app/views/layouts/incline/_app_menu_authenticated.html.erb +1 -0
  100. data/app/views/layouts/incline/_footer.html.erb +13 -0
  101. data/app/views/layouts/incline/_header.html.erb +21 -0
  102. data/app/views/layouts/incline/_html_mailer.html.erb +5 -0
  103. data/app/views/layouts/incline/_incline_app.html.erb +25 -0
  104. data/app/views/layouts/incline/_messages.html.erb +3 -0
  105. data/app/views/layouts/incline/_shim.html.erb +3 -0
  106. data/app/views/layouts/incline/_text_mailer.text.erb +1 -0
  107. data/app/views/layouts/incline/application.html.erb +1 -0
  108. data/app/views/layouts/mailer.html.erb +2 -0
  109. data/app/views/layouts/mailer.text.erb +2 -0
  110. data/bin/rails +12 -0
  111. data/bin/test_scaffold.sh +10 -0
  112. data/config/routes.rb +61 -0
  113. data/db/migrate/20170511230126_create_incline_users.rb +26 -0
  114. data/db/migrate/20170515003052_create_incline_access_groups.rb +10 -0
  115. data/db/migrate/20170515003221_create_incline_user_login_histories.rb +12 -0
  116. data/db/migrate/20170515150908_create_incline_access_group_user_members.rb +11 -0
  117. data/db/migrate/20170515151058_create_incline_access_group_group_members.rb +11 -0
  118. data/db/migrate/20170517193432_add_comments_to_incline_user.rb +5 -0
  119. data/db/migrate/20170622132700_create_incline_action_securities.rb +16 -0
  120. data/db/migrate/20170622172712_create_incline_action_groups.rb +11 -0
  121. data/db/migrate/20170622195742_add_non_standard_to_action_security.rb +5 -0
  122. data/db/migrate/20170622230422_add_visible_to_action_security.rb +5 -0
  123. data/db/seeds.rb +81 -0
  124. data/exe/new_incline_app +42 -0
  125. data/lib/generators/incline/install_generator.rb +259 -0
  126. data/lib/generators/incline/templates/_app_menu_anon.html.erb +1 -0
  127. data/lib/generators/incline/templates/_app_menu_authenticated.html.erb +1 -0
  128. data/lib/generators/incline/templates/incline_application.css +17 -0
  129. data/lib/generators/incline/templates/incline_application.html.erb +1 -0
  130. data/lib/generators/incline/templates/incline_application.js +12 -0
  131. data/lib/generators/incline/templates/incline_database.yml +25 -0
  132. data/lib/generators/incline/templates/incline_email.yml +20 -0
  133. data/lib/generators/incline/templates/incline_mailer.html.erb +2 -0
  134. data/lib/generators/incline/templates/incline_mailer.text.erb +2 -0
  135. data/lib/generators/incline/templates/incline_users.yml +64 -0
  136. data/lib/generators/incline/templates/incline_version.rb +3 -0
  137. data/lib/incline/auth_engine_base.rb +52 -0
  138. data/lib/incline/data_tables_request.rb +336 -0
  139. data/lib/incline/date_time_formats.rb +6 -0
  140. data/lib/incline/engine.rb +212 -0
  141. data/lib/incline/errors.rb +15 -0
  142. data/lib/incline/extensions/action_controller_base.rb +526 -0
  143. data/lib/incline/extensions/action_mailer_base.rb +66 -0
  144. data/lib/incline/extensions/action_view_base.rb +489 -0
  145. data/lib/incline/extensions/active_record_base.rb +308 -0
  146. data/lib/incline/extensions/application.rb +137 -0
  147. data/lib/incline/extensions/application_configuration.rb +50 -0
  148. data/lib/incline/extensions/connection_adapter.rb +55 -0
  149. data/lib/incline/extensions/date_time_value.rb +123 -0
  150. data/lib/incline/extensions/date_value.rb +77 -0
  151. data/lib/incline/extensions/decimal_value.rb +55 -0
  152. data/lib/incline/extensions/erb_scaffold_generator.rb +31 -0
  153. data/lib/incline/extensions/float_value.rb +59 -0
  154. data/lib/incline/extensions/form_builder.rb +617 -0
  155. data/lib/incline/extensions/integer_value.rb +54 -0
  156. data/lib/incline/extensions/jbuilder_generator.rb +38 -0
  157. data/lib/incline/extensions/jbuilder_template.rb +39 -0
  158. data/lib/incline/extensions/main_app.rb +40 -0
  159. data/lib/incline/extensions/numeric.rb +63 -0
  160. data/lib/incline/extensions/object.rb +31 -0
  161. data/lib/incline/extensions/resource_route_generator.rb +53 -0
  162. data/lib/incline/extensions/session.rb +113 -0
  163. data/lib/incline/extensions/string.rb +50 -0
  164. data/lib/incline/extensions/test_case.rb +764 -0
  165. data/lib/incline/extensions/time_zone_converter.rb +40 -0
  166. data/lib/incline/global_status.rb +236 -0
  167. data/lib/incline/helpers/route_hash_formatter.rb +46 -0
  168. data/lib/incline/json_log_formatter.rb +96 -0
  169. data/lib/incline/json_logger.rb +17 -0
  170. data/lib/incline/log.rb +153 -0
  171. data/lib/incline/number_formats.rb +17 -0
  172. data/lib/incline/recaptcha.rb +346 -0
  173. data/lib/incline/user_manager.rb +212 -0
  174. data/lib/incline/validators/email_validator.rb +45 -0
  175. data/lib/incline/validators/ip_address_validator.rb +32 -0
  176. data/lib/incline/validators/recaptcha_validator.rb +37 -0
  177. data/lib/incline/validators/safe_name_validator.rb +31 -0
  178. data/lib/incline/version.rb +3 -0
  179. data/lib/incline/work_path.rb +75 -0
  180. data/lib/incline.rb +197 -0
  181. data/lib/tasks/incline_tasks.rake +4 -0
  182. data/lib/templates/erb/scaffold/_form.html.erb +43 -0
  183. data/lib/templates/erb/scaffold/_list.html.erb +81 -0
  184. data/lib/templates/erb/scaffold/edit.html.erb +1 -0
  185. data/lib/templates/erb/scaffold/index.html.erb +6 -0
  186. data/lib/templates/erb/scaffold/new.html.erb +1 -0
  187. data/lib/templates/erb/scaffold/show.html.erb +34 -0
  188. data/lib/templates/jbuilder/scaffold/_details.json.jbuilder +20 -0
  189. data/lib/templates/jbuilder/scaffold/index.json.jbuilder +16 -0
  190. data/lib/templates/jbuilder/scaffold/show.json.jbuilder +16 -0
  191. data/lib/templates/rails/scaffold_controller/controller.rb +128 -0
  192. data/test/controllers/incline/access_groups_controller_test.rb +65 -0
  193. data/test/controllers/incline/access_test_controller_test.rb +53 -0
  194. data/test/controllers/incline/contact_controller_test.rb +32 -0
  195. data/test/controllers/incline/security_controller_test.rb +39 -0
  196. data/test/controllers/incline/welcome_controller_test.rb +16 -0
  197. data/test/dummy/README.rdoc +28 -0
  198. data/test/dummy/Rakefile +6 -0
  199. data/test/dummy/app/assets/images/.keep +0 -0
  200. data/test/dummy/app/assets/javascripts/application.js +12 -0
  201. data/test/dummy/app/assets/stylesheets/application.css +17 -0
  202. data/test/dummy/app/controllers/application_controller.rb +5 -0
  203. data/test/dummy/app/controllers/concerns/.keep +0 -0
  204. data/test/dummy/app/helpers/application_helper.rb +2 -0
  205. data/test/dummy/app/mailers/.keep +0 -0
  206. data/test/dummy/app/models/.keep +0 -0
  207. data/test/dummy/app/models/concerns/.keep +0 -0
  208. data/test/dummy/app/views/layouts/application.html.erb +1 -0
  209. data/test/dummy/app/views/layouts/incline/_app_menu_anon.html.erb +1 -0
  210. data/test/dummy/app/views/layouts/incline/_app_menu_authenticated.html.erb +1 -0
  211. data/test/dummy/app/views/layouts/mailer.html.erb +2 -0
  212. data/test/dummy/app/views/layouts/mailer.text.erb +2 -0
  213. data/test/dummy/bin/bundle +3 -0
  214. data/test/dummy/bin/rails +4 -0
  215. data/test/dummy/bin/rake +4 -0
  216. data/test/dummy/bin/setup +29 -0
  217. data/test/dummy/config/application.rb +38 -0
  218. data/test/dummy/config/boot.rb +5 -0
  219. data/test/dummy/config/database.yml +34 -0
  220. data/test/dummy/config/email.yml +24 -0
  221. data/test/dummy/config/environment.rb +5 -0
  222. data/test/dummy/config/environments/development.rb +45 -0
  223. data/test/dummy/config/environments/production.rb +85 -0
  224. data/test/dummy/config/environments/test.rb +44 -0
  225. data/test/dummy/config/initializers/assets.rb +11 -0
  226. data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
  227. data/test/dummy/config/initializers/cookies_serializer.rb +3 -0
  228. data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  229. data/test/dummy/config/initializers/inflections.rb +16 -0
  230. data/test/dummy/config/initializers/mime_types.rb +4 -0
  231. data/test/dummy/config/initializers/session_store.rb +3 -0
  232. data/test/dummy/config/initializers/to_time_preserves_timezone.rb +10 -0
  233. data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
  234. data/test/dummy/config/locales/en.yml +23 -0
  235. data/test/dummy/config/routes.rb +6 -0
  236. data/test/dummy/config.ru +4 -0
  237. data/test/dummy/db/schema.rb +108 -0
  238. data/test/dummy/lib/assets/.keep +0 -0
  239. data/test/dummy/log/.keep +0 -0
  240. data/test/dummy/public/404.html +67 -0
  241. data/test/dummy/public/422.html +67 -0
  242. data/test/dummy/public/500.html +66 -0
  243. data/test/dummy/public/favicon.ico +0 -0
  244. data/test/extensions/action_controller_base_extensions_test.rb +21 -0
  245. data/test/extensions/action_mailer_base_extensions_test.rb +20 -0
  246. data/test/extensions/action_view_base_extensions_test.rb +267 -0
  247. data/test/extensions/active_record_extensions_test.rb +173 -0
  248. data/test/extensions/application_configuration_extensions_test.rb +46 -0
  249. data/test/extensions/application_extensions_test.rb +23 -0
  250. data/test/extensions/connection_adapter_extensions_test.rb +54 -0
  251. data/test/extensions/date_time_value_extensions_test.rb +104 -0
  252. data/test/extensions/date_value_extensions_test.rb +102 -0
  253. data/test/extensions/decimal_value_extensions_test.rb +85 -0
  254. data/test/extensions/erb_scaffold_generator_extensions_test.rb +17 -0
  255. data/test/extensions/float_value_extensions_test.rb +78 -0
  256. data/test/extensions/form_builder_extensions_test.rb +28 -0
  257. data/test/extensions/integer_value_extensions_test.rb +78 -0
  258. data/test/extensions/jbuilder_generator_extensions_test.rb +21 -0
  259. data/test/extensions/jbuilder_template_extensions_test.rb +47 -0
  260. data/test/extensions/main_app_extensions_test.rb +55 -0
  261. data/test/extensions/numeric_extensions_test.rb +76 -0
  262. data/test/extensions/object_extensions_test.rb +104 -0
  263. data/test/extensions/session_extensions_test.rb +69 -0
  264. data/test/extensions/string_extensions_test.rb +32 -0
  265. data/test/extensions/test_case_extensions_test.rb +538 -0
  266. data/test/extensions/time_zone_converter_extensions_test.rb +10 -0
  267. data/test/fixtures/incline/access_group_group_members.yml +1 -0
  268. data/test/fixtures/incline/access_group_user_members.yml +1 -0
  269. data/test/fixtures/incline/access_groups.yml +13 -0
  270. data/test/fixtures/incline/action_groups.yml +6 -0
  271. data/test/fixtures/incline/action_securities.yml +18 -0
  272. data/test/fixtures/incline/user_login_histories.yml +1 -0
  273. data/test/fixtures/incline/users.yml +64 -0
  274. data/test/incline_test.rb +63 -0
  275. data/test/integration/incline/users_edit_test.rb +180 -0
  276. data/test/integration/incline/users_login_test.rb +105 -0
  277. data/test/integration/incline/users_signup_test.rb +147 -0
  278. data/test/integration/navigation_test.rb +11 -0
  279. data/test/lib/data_tables_request_test.rb +245 -0
  280. data/test/lib/date_time_formats_test.rb +111 -0
  281. data/test/lib/global_status_test.rb +89 -0
  282. data/test/lib/json_log_formatter_test.rb +43 -0
  283. data/test/lib/log_test.rb +36 -0
  284. data/test/lib/recaptcha_test.rb +75 -0
  285. data/test/lib/user_manager_test.rb +47 -0
  286. data/test/lib/work_path_test.rb +18 -0
  287. data/test/models/incline/access_group_group_member_test.rb +30 -0
  288. data/test/models/incline/access_group_test.rb +60 -0
  289. data/test/models/incline/access_group_user_member_test.rb +29 -0
  290. data/test/models/incline/action_group_test.rb +27 -0
  291. data/test/models/incline/action_security_test.rb +176 -0
  292. data/test/models/incline/contact_message_test.rb +66 -0
  293. data/test/models/incline/disable_info_test.rb +29 -0
  294. data/test/models/incline/password_reset_request_test.rb +35 -0
  295. data/test/models/incline/password_reset_test.rb +51 -0
  296. data/test/models/incline/user_login_history_test.rb +31 -0
  297. data/test/models/incline/user_test.rb +91 -0
  298. data/test/test_helper.rb +42 -0
  299. data/test/validators/email_validator_test.rb +102 -0
  300. data/test/validators/ip_address_validator_test.rb +107 -0
  301. data/test/validators/recaptcha_validator_test.rb +57 -0
  302. data/test/validators/safe_name_validator_test.rb +101 -0
  303. metadata +584 -0
@@ -0,0 +1,25 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title><%= full_title(yield(:title)) %></title>
5
+ <%= stylesheet_link_tag 'application', media: 'all' %>
6
+ <%= yield :styles %>
7
+ <script type="text/javascript">
8
+ var application_root_offset='<%= (root_url[-1] == '/' ? root_url[0...-1] : root_url).gsub("'", "\\'") %>';
9
+ </script>
10
+ <%= javascript_include_tag 'application' %>
11
+ <%= yield :scripts %>
12
+ <%= csrf_meta_tags %>
13
+ <%= render 'layouts/incline/shim' %>
14
+ </head>
15
+ <body>
16
+ <%= render 'layouts/incline/header' %>
17
+ <div id="incline_body_container" class="container">
18
+ <%= render 'layouts/incline/messages' %>
19
+ <%= yield %>
20
+ </div>
21
+ <div id="incline_dynamic_alerts"></div>
22
+ <%= render 'layouts/incline/footer' %>
23
+ <%= Incline::Recaptcha.script_block %>
24
+ </body>
25
+ </html>
@@ -0,0 +1,3 @@
1
+ <% flash.each do |message_type, message| %>
2
+ <%= render_alert(message_type, message) %>
3
+ <% end %>
@@ -0,0 +1,3 @@
1
+ <!--[if lt IE 9]>
2
+ <script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/r29/html5.min.js"></script>
3
+ <![endif]-->
@@ -0,0 +1 @@
1
+ <%= yield %>
@@ -0,0 +1 @@
1
+ <%= render 'layouts/incline/incline_app' %>
@@ -0,0 +1,2 @@
1
+ <%= render 'layouts/incline/html_mailer' %>
2
+
@@ -0,0 +1,2 @@
1
+ <%= render 'layouts/incline/text_mailer' %>
2
+
data/bin/rails ADDED
@@ -0,0 +1,12 @@
1
+ #!/usr/bin/env ruby
2
+ # This command will automatically be run when you run "rails" with Rails 4 gems installed from the root of your application.
3
+
4
+ ENGINE_ROOT = File.expand_path('../..', __FILE__)
5
+ ENGINE_PATH = File.expand_path('../../lib/incline/engine', __FILE__)
6
+
7
+ # Set up gems listed in the Gemfile.
8
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
9
+ require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE'])
10
+
11
+ require 'rails/all'
12
+ require 'rails/engine/commands'
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env bash
2
+
3
+ ORIG_PATH=$PWD
4
+ cd test/dummy
5
+ rails generate scaffold some_item name:string item_type:string quantity:integer is_used:boolean last_received:date
6
+ rake db:migrate
7
+ rails server
8
+ rake db:rollback
9
+ rails destroy scaffold some_item
10
+ cd $ORIG_PATH
data/config/routes.rb ADDED
@@ -0,0 +1,61 @@
1
+ Incline::Engine.routes.draw do
2
+
3
+ # user management
4
+ get 'signup' => 'users#new'
5
+ post 'signup' => 'users#create'
6
+ resources :users, except: [ :new, :create ] do
7
+ member do
8
+ get 'disable', action: :disable_confirm
9
+ match 'disable', via: [ :put, :patch ]
10
+ match 'enable', via: [ :put, :patch ]
11
+ match 'promote', via: [ :put, :patch ]
12
+ match 'demote', via: [ :put, :patch ]
13
+ post 'locate'
14
+ end
15
+ collection do
16
+ match 'api', via: [ :get, :post ]
17
+ end
18
+ end
19
+
20
+ # login/logout
21
+ get 'login' => 'sessions#new'
22
+ post 'login' => 'sessions#create'
23
+ delete 'logout' => 'sessions#destroy'
24
+
25
+ # account activation route
26
+ get 'activate/:id' => 'account_activations#edit', as: :edit_account_activation
27
+
28
+ # password reset routes
29
+ resources :password_resets, only: [ :new, :create, :edit, :update ]
30
+
31
+ # contact routes
32
+ get 'contact' => 'contact#new'
33
+ post 'contact' => 'contact#create'
34
+
35
+ # access groups
36
+ resources :access_groups do
37
+ member do
38
+ post 'locate'
39
+ end
40
+ collection do
41
+ match 'api', via: [ :get, :post ]
42
+ end
43
+ end
44
+
45
+ # security
46
+ get 'security' => 'security#index', as: :index_security
47
+ get 'security/:id' => 'security#show', as: :security
48
+ match 'security/:id' => 'security#update', via: [ :patch, :put ]
49
+ get 'security/:id/edit' => 'security#edit', as: :edit_security
50
+ post 'security/:id/locate' => 'security#locate', as: :locate_security
51
+ match 'security/api' => 'security#api', via: [ :get, :post ], as: :api_security
52
+
53
+ if Rails.env.test?
54
+ get 'test/require_anon' => 'access_test#test_require_anon', as: :test_require_anon
55
+ get 'test/allow_anon' => 'access_test#test_allow_anon', as: :test_allow_anon
56
+ get 'test/require_admin' => 'access_test#test_require_admin', as: :test_require_admin
57
+ get 'test/require_user' => 'access_test#test_require_user', as: :test_require_user
58
+ get 'test/require_group' => 'access_test#test_require_group', as: :test_require_group
59
+ end
60
+
61
+ end
@@ -0,0 +1,26 @@
1
+ class CreateInclineUsers < ActiveRecord::Migration
2
+ def change
3
+ create_table :incline_users do |t|
4
+ t.string :name, null: false, limit: 100
5
+ t.string :email, null: false, limit: 250
6
+ t.boolean :activated, null: false, default: false
7
+ t.boolean :enabled, null: false, default: true
8
+ t.boolean :system_admin, null: false, default: false
9
+ t.string :activation_digest, limit: 100
10
+ t.string :password_digest, limit: 100
11
+ t.string :remember_digest, limit: 100
12
+ t.string :reset_digest, limit: 100
13
+ t.datetime :activated_at
14
+ t.datetime :reset_sent_at
15
+ t.string :disabled_by, limit: 250
16
+ t.datetime :disabled_at
17
+ t.string :disabled_reason, limit: 200
18
+ t.datetime :last_login_at
19
+ t.string :last_login_ip, limit: 64
20
+
21
+ t.timestamps null: false
22
+ end
23
+ add_index :incline_users, :email, unique: true, name: 'ux_incline_users_email'
24
+ end
25
+ end
26
+
@@ -0,0 +1,10 @@
1
+ class CreateInclineAccessGroups < ActiveRecord::Migration
2
+ def change
3
+ create_table :incline_access_groups do |t|
4
+ t.string :name, null: false, limit: 100
5
+
6
+ t.timestamps null: false
7
+ end
8
+ add_index :incline_access_groups, :name, unique: true, name: 'ux_incline_access_groups_name'
9
+ end
10
+ end
@@ -0,0 +1,12 @@
1
+ class CreateInclineUserLoginHistories < ActiveRecord::Migration
2
+ def change
3
+ create_table :incline_user_login_histories do |t|
4
+ t.belongs_to :user, null: false, index: true, foreign_key: true
5
+ t.string :ip_address, null: false, limit: 64
6
+ t.boolean :successful
7
+ t.string :message, limit: 200
8
+
9
+ t.timestamps null: false
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,11 @@
1
+ class CreateInclineAccessGroupUserMembers < ActiveRecord::Migration
2
+ def change
3
+ create_table :incline_access_group_user_members do |t|
4
+ t.integer :group_id, null: false, index: true
5
+ t.integer :member_id, null: false, index: true
6
+
7
+ t.timestamps null: false
8
+ end
9
+ add_index :incline_access_group_user_members, [ :group_id, :member_id ], unique: true, name: 'ux_incline_access_group_user_members'
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ class CreateInclineAccessGroupGroupMembers < ActiveRecord::Migration
2
+ def change
3
+ create_table :incline_access_group_group_members do |t|
4
+ t.integer :group_id, null: false, index: true
5
+ t.integer :member_id, null: false, index: true
6
+
7
+ t.timestamps null: false
8
+ end
9
+ add_index :incline_access_group_group_members, [ :group_id, :member_id ], unique: true, name: 'ux_incline_access_group_group_members'
10
+ end
11
+ end
@@ -0,0 +1,5 @@
1
+ class AddCommentsToInclineUser < ActiveRecord::Migration
2
+ def change
3
+ add_column :incline_users, :comments, :text
4
+ end
5
+ end
@@ -0,0 +1,16 @@
1
+ class CreateInclineActionSecurities < ActiveRecord::Migration
2
+ def change
3
+ create_table :incline_action_securities do |t|
4
+ t.string :controller_name, null: false, limit: 200
5
+ t.string :action_name, null: false, limit: 200
6
+ t.text :path, null: false
7
+ t.boolean :allow_anon
8
+ t.boolean :require_anon
9
+ t.boolean :require_admin
10
+ t.boolean :unknown_controller
11
+
12
+ t.timestamps null: false
13
+ end
14
+ add_index :incline_action_securities, [:controller_name, :action_name ], unique: true, name: 'ux_incline_action_securities'
15
+ end
16
+ end
@@ -0,0 +1,11 @@
1
+ class CreateInclineActionGroups < ActiveRecord::Migration
2
+ def change
3
+ create_table :incline_action_groups do |t|
4
+ t.belongs_to :action_security, null: false, index: true, foreign_key: true
5
+ t.belongs_to :access_group, null: false, index: true, foreign_key: true
6
+
7
+ t.timestamps null: false
8
+ end
9
+ add_index :incline_action_groups, [ :action_security_id, :access_group_id ], unique: true, name: 'ux_incline_action_groups'
10
+ end
11
+ end
@@ -0,0 +1,5 @@
1
+ class AddNonStandardToActionSecurity < ActiveRecord::Migration
2
+ def change
3
+ add_column :incline_action_securities, :non_standard, :boolean
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ class AddVisibleToActionSecurity < ActiveRecord::Migration
2
+ def change
3
+ add_column :incline_action_securities, :visible, :boolean
4
+ end
5
+ end
data/db/seeds.rb ADDED
@@ -0,0 +1,81 @@
1
+ require 'securerandom'
2
+
3
+ Incline::Recaptcha::pause_for do
4
+
5
+ Incline::User::ensure_admin_exists!
6
+
7
+ # For development purposes, we want to add a bunch of enabled users and a handful of disabled users.
8
+ if Rails.env.development?
9
+ admin_user = Incline::User.where(system_admin: true, enabled: true).first
10
+ unless Incline::User.where(enabled: true).count >= 100
11
+ print "Creating enabled test users...\n"
12
+ 100.times do |n|
13
+ name = Faker::Name.name
14
+ email = "user-#{n+1}@example.com"
15
+ password = 'password'
16
+ r = SecureRandom.random_number
17
+ activated = (r < 0.8) ? (5 + (r * 25).to_i).days.ago : nil
18
+ created = (activated ? activated : (5 + (r * 25).to_i).days.ago) - 1.hour
19
+
20
+ u = Incline::User.create!(
21
+ name: name,
22
+ email: email,
23
+ password: password,
24
+ password_confirmation: password,
25
+ activated: !!activated,
26
+ activated_at: activated,
27
+ created_at: created,
28
+ recaptcha: 'na'
29
+ )
30
+ if activated
31
+ hist =
32
+ if SecureRandom.random_number < 0.25
33
+ :fail
34
+ elsif SecureRandom.random_number < 0.5
35
+ :mix
36
+ else
37
+ :success
38
+ end
39
+
40
+ r += 0.2 if r < 0.2
41
+ while activated < Time.now
42
+
43
+ success,message = if hist == :fail
44
+ [ false, 'Invalid email or password.' ]
45
+ elsif hist == :success
46
+ [ true, 'User logged in successfully.' ]
47
+ elsif SecureRandom.random_number <= 0.5
48
+ [ false, 'Invalid email or password.' ]
49
+ else
50
+ [ true, 'User logged in successfully.' ]
51
+ end
52
+
53
+ u.login_histories.create!(ip_address: '127.0.0.1', successful: success, message: message, created_at: activated)
54
+
55
+ activated += r.days
56
+ end
57
+ end
58
+ end
59
+ end
60
+ unless Incline::User.where(enabled: false).count >= 5
61
+ print "Creating disabled test users...\n"
62
+ 5.times do |n|
63
+ name = Faker::Name.name
64
+ email = "disabled-#{n+1}@example.com"
65
+ password = 'password'
66
+ u = Incline::User.create!(
67
+ name: name,
68
+ email: email,
69
+ password: password,
70
+ password_confirmation: password,
71
+ enabled: false,
72
+ disabled_by: admin_user.email,
73
+ disabled_at: ((n * 2.5).to_i + 1).days.ago,
74
+ disabled_reason: 'For testing',
75
+ recaptcha: 'na'
76
+ )
77
+ end
78
+ end
79
+ end
80
+
81
+ end
@@ -0,0 +1,42 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ ##
4
+ # Script to generate a new rails app using the Incline gem.
5
+
6
+ if Object.const_defined?(:Rails)
7
+
8
+ ## Template for 'rails new' ##
9
+ require 'incline/version'
10
+
11
+ # Add the incline gem.
12
+ gem 'incline', "~> #{Incline::VERSION}"
13
+
14
+ # Install the gem.
15
+ run 'bundle install'
16
+
17
+ # Add a root route.
18
+ route "root 'incline/welcome#home'"
19
+
20
+ # Perform the Incline install.
21
+ generate 'incline:install'
22
+
23
+ # Create & migrate the db.
24
+ run 'rake db:migrate', capture: true
25
+
26
+ # Initialize git repo and push to github.
27
+ run 'git init', capture: true
28
+ run 'git add -A', capture: true
29
+ run 'git commit -m "Initialize repo"', capture: true
30
+
31
+ else
32
+
33
+ if ARGV.count < 1
34
+ puts "Usage: $0 app_name [rails-options]\n"
35
+ else
36
+ args = %w(rails new)
37
+ args += ARGV.to_a
38
+ args += [ '-m', File.expand_path(__FILE__), '--skip-turbolinks', '--skip-spring', '--skip-bundle' ]
39
+ Kernel.exec *args
40
+ end
41
+
42
+ end
@@ -0,0 +1,259 @@
1
+ require 'rails/generators'
2
+
3
+ module Incline
4
+
5
+ class InstallGenerator < ::Rails::Generators::Base
6
+
7
+ desc "This generator will update your application for use with the Incline gem."
8
+
9
+ class_option :mount_path, type: :string, default: 'incline', desc: 'Determines where the Incline engine will mount its routes.'
10
+ class_option :force_copy, type: :boolean, default: true, desc: 'Determines if certain files will be forcibly copied.'
11
+ class_option :json_logger, type: :boolean, default: true, desc: 'Determines if the JSON logger should be enabled.'
12
+
13
+ source_root File.expand_path('../templates', __FILE__)
14
+
15
+ def install_module
16
+
17
+ mount_path = options[:mount_path] || 'incline'
18
+ # trim off leading '/', './', or '../'.
19
+ # also trim off trailing '/'.
20
+ mount_path = mount_path.to_s.gsub('\\','/').gsub(/^\.*\//, '').gsub(/\/+$/, '')
21
+ mount_path = 'incline' if mount_path.blank?
22
+ @mount_path = '/' + mount_path
23
+
24
+ copy_files
25
+ add_version
26
+ config_app
27
+ config_logger if options[:json_logger]
28
+ config_routes
29
+ config_gitignore
30
+ config_secrets
31
+
32
+ end
33
+
34
+
35
+ private
36
+
37
+ def copy_files
38
+ # We just copy these files outright because they override the default behaviors and shouldn't need modification
39
+ force = options[:force_copy] ? { force: true } : { skip: true }
40
+ {
41
+ 'incline_application.js' => 'app/assets/javascripts/application.js',
42
+ 'incline_application.css' => 'app/assets/stylesheets/application.css',
43
+ 'incline_application.html.erb' => 'app/views/layouts/application.html.erb',
44
+ 'incline_mailer.html.erb' => 'app/views/layouts/mailer.html.erb',
45
+ 'incline_mailer.text.erb' => 'app/views/layouts/mailer.text.erb',
46
+ 'incline_users.yml' => 'test/fixtures/incline/users.yml',
47
+ }.each do |source,destination|
48
+ copy_file source, destination, force
49
+ end
50
+
51
+ # We copy these files if they don't exist.
52
+ {
53
+ 'incline_email.yml' => 'config/email.yml',
54
+ 'incline_database.yml' => 'config/database.yml',
55
+ '_app_menu_anon.html.erb' => 'app/views/layouts/incline/_app_menu_anon.html.erb',
56
+ '_app_menu_authenticated.html.erb' => 'app/views/layouts/incline/_app_menu_authenticated.html.erb',
57
+ }.each do |source,destination|
58
+ copy_file source, destination, skip: true
59
+ end
60
+ end
61
+
62
+ def config_app
63
+ if File.exist?('config/application.rb')
64
+ contents = File.read('config/application.rb')
65
+ changed = false
66
+ unless contents =~ /def\s+app_name\s/ && contents =~ /def\s+app_version\s/
67
+ match = (/module\s+([a-z0-9_:]*)\s+class\s+application/i).match(File.read('config/application.rb'))
68
+ if match
69
+ new_data = ''
70
+ unless contents =~ /def\s+app_name\s/
71
+ new_data += <<-EOD
72
+
73
+ # This is your application name. Set it as appropriate.
74
+ def app_name
75
+ "#{match[1]}"
76
+ end
77
+
78
+ EOD
79
+ end
80
+ unless contents =~ /def\s+app_version\s/
81
+ new_data += <<-EOD
82
+
83
+ # This is your application version. Change it in 'version.rb'.
84
+ def app_version
85
+ #{match[1]}::VERSION
86
+ end
87
+
88
+ EOD
89
+ end
90
+ changed = true
91
+ insert_into_file 'config/application.rb', new_data, after: /class\s+Application\s+<\s+(::)?Rails::Application\n/m
92
+ end
93
+ end
94
+
95
+ unless contents =~ /require_relative\s*['"]\.\/version['"]/
96
+ changed = true
97
+ prepend_to_file 'config/application.rb', "require_relative './version'\n"
98
+ end
99
+
100
+ unless changed
101
+ say_status :ok, 'config/application.rb', :blue
102
+ end
103
+ else
104
+ say_status :missing, 'config/application.rb', :red
105
+ end
106
+ end
107
+
108
+ def add_version
109
+ # Make sure a version.rb file exists.
110
+ template 'incline_version.rb', 'config/version.rb', skip: true
111
+ end
112
+
113
+ def config_logger
114
+ # Change the production environment to use JsonLogFormatter instead of Logger::Formatter
115
+ # NOTE: We are switching to using Incline::JsonLogger but we will leave this gsub in place
116
+ # to keep the options open for the end user (if they want to change loggers, but use the same formatter).
117
+ # The log formatter must be set after the logger.
118
+ gsub_file 'config/environments/production.rb', /\n\s*config\.log_formatter\s*=\s*(::)?Logger::Formatter.new/m, <<-EOS
119
+
120
+ # config.log_formatter = ::Logger::Formatter.new
121
+
122
+ # Incline::JsonLogFormatter also includes the PID and timestamp, plus it makes the log easier to parse.
123
+ # If you want to revert to using the standard formatter above, uncomment that line and comment out this line instead.
124
+ config.log_formatter = ::Incline::JsonLogFormatter.new
125
+ EOS
126
+
127
+ %w(config/environments/development.rb config/environments/test.rb config/environments/production.rb).each do |cfg|
128
+ if File.exist?(cfg)
129
+ contents = File.read(cfg)
130
+
131
+ if contents =~ /\n\s*config.logger\s*=/m
132
+ # a logger is already explicitly configured.
133
+ say_status :ok, cfg, :blue
134
+ elsif contents =~ /\n\s*config.log_formatter\s*=/m
135
+ # a log formatter is configured, so configure a logger with rotation and use the existing formatter.
136
+ gsub_file cfg, /\n\s*config.log_formatter\s*=([^\n]*)/m, <<-EOS
137
+
138
+ config.logger = ::ActiveSupport::Logger(config.paths['log'].first, 2, 5.megabytes)
139
+ config.logger.formatter =\\1
140
+ EOS
141
+ else
142
+ # no log formatter or logger is configured, so configure a JsonLogger with rotation.
143
+ insert_into_file cfg, "\n config.logger = ::Incline::JsonLogger.new(config.paths['log'].first, 2, 5.megabytes)\n", before: /end\s*\Z/m
144
+ end
145
+ else
146
+ say_status :missing, cfg, :red
147
+ end
148
+ end
149
+ end
150
+
151
+ def config_routes
152
+ if File.exist?('config/routes.rb')
153
+ contents = File.read('config/routes.rb')
154
+ if contents =~ /mount\s*(::)?Incline::Engine/
155
+ say_status :ok, 'config/routes.rb', :blue
156
+ else
157
+ insert_into_file 'config/routes.rb', "\n mount ::Incline::Engine => #{@mount_path.inspect}\n", after: /routes\.draw\s*(do|\{)/
158
+ end
159
+ else
160
+ say_status :missing, 'config/routes.rb', :red
161
+ end
162
+ end
163
+
164
+ def config_gitignore
165
+ if File.exist?('.gitignore')
166
+ contents = File.read('.gitignore')
167
+ changed = false
168
+
169
+ unless contents =~ /^\*\*\/\.byebug\*$/
170
+ changed = true
171
+ append_to_file '.gitignore', "\n**/.byebug*\n"
172
+ end
173
+
174
+ unless contents =~ /^config\/secrets\.yml$/
175
+ changed = true
176
+ append_to_file '.gitignore', "\nconfig/secrets.yml\n"
177
+ end
178
+
179
+ unless changed
180
+ say_status :ok, '.gitignore', :blue
181
+ end
182
+ else
183
+ unless options[:pretend]
184
+ File.write '.gitignore', <<-EOF
185
+ **/.byebug*
186
+ .bundle/
187
+ config/secrets.yml
188
+ db/*.sqlite3
189
+ db/*.sqlite3-journal
190
+ log/*.log
191
+ tmp/
192
+ vendor/bundle/
193
+ EOF
194
+ end
195
+ say_status :create, '.gitignore', :green
196
+ end
197
+ end
198
+
199
+ def config_secrets
200
+ if File.exist?('config/secrets.yml')
201
+ contents = File.read('config/secrets.yml')
202
+ changed = false
203
+ missing_alias = /^(default:\s*\n)/m
204
+ valid_alias = /^default:\s+&default\s*\n/m
205
+
206
+ unless contents =~ valid_alias
207
+ if contents =~ missing_alias
208
+ # section exists, but is missing the &default label
209
+ flag = $1
210
+ changed = true
211
+ contents.gsub! /^#{flag}/, "default: &default\n"
212
+ else
213
+ # section does not exist.
214
+ changed = true
215
+ to_insert = <<-EOF
216
+ default: &default
217
+ # define your recaptcha keys.
218
+ recaptcha_public:
219
+ recaptcha_private:
220
+ # define your email credentials.
221
+ email:
222
+ user: no-reply@example.com
223
+ password: MySecretPassword
224
+
225
+ EOF
226
+
227
+ contents = to_insert + contents
228
+ end
229
+ end
230
+
231
+ # now ensure the three environments are set to inherit from default.
232
+ %w(development test production).each do |section|
233
+ missing_alias = /^(#{section}:\s*\n)/m
234
+ valid_alias = /^#{section}:\s*\n <<:\s*\*default\s*\n/m
235
+ unless contents =~ valid_alias
236
+ if contents =~ missing_alias
237
+ flag = $1
238
+ changed = true
239
+ contents.gsub! /^#{flag}/, "\\0 <<: *default\n"
240
+ else
241
+ say_status :missing, "config/secrets.yml [#{section}]", :red
242
+ end
243
+ end
244
+ end
245
+
246
+ if changed
247
+ unless options[:pretend]
248
+ File.write 'config/secrets.yml', contents
249
+ end
250
+ say_status :modify, 'config/secrets.yml', :green
251
+ else
252
+ say_status :ok, 'config/secrets.yml', :blue
253
+ end
254
+ end
255
+ end
256
+
257
+
258
+ end
259
+ end
@@ -0,0 +1 @@
1
+ <!-- add list items <li> to build the menu for anonymous and authenticated users -->
@@ -0,0 +1 @@
1
+ <!-- add list items <li> to build the menu for authenticated users -->