supplejack_api 1

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 (291) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +80 -0
  3. data/Rakefile +42 -0
  4. data/app/assets/javascripts/supplejack_api/application.js +26 -0
  5. data/app/assets/stylesheets/supplejack_api/application.css +30 -0
  6. data/app/controllers/supplejack_api/admin/base_controller.rb +24 -0
  7. data/app/controllers/supplejack_api/admin/sessions_controller.rb +25 -0
  8. data/app/controllers/supplejack_api/admin/site_activities_controller.rb +21 -0
  9. data/app/controllers/supplejack_api/admin/users_controller.rb +55 -0
  10. data/app/controllers/supplejack_api/application_controller.rb +70 -0
  11. data/app/controllers/supplejack_api/concepts_controller.rb +52 -0
  12. data/app/controllers/supplejack_api/concerns/ignore_metrics.rb +14 -0
  13. data/app/controllers/supplejack_api/concerns/records_controller_metrics.rb +26 -0
  14. data/app/controllers/supplejack_api/concerns/set_items_controller_metrics.rb +20 -0
  15. data/app/controllers/supplejack_api/concerns/user_sets_controller_metrics.rb +26 -0
  16. data/app/controllers/supplejack_api/harvester/concepts_controller.rb +41 -0
  17. data/app/controllers/supplejack_api/harvester/fragments_controller.rb +30 -0
  18. data/app/controllers/supplejack_api/harvester/records_controller.rb +68 -0
  19. data/app/controllers/supplejack_api/metrics_api_controller.rb +44 -0
  20. data/app/controllers/supplejack_api/partners_controller.rb +39 -0
  21. data/app/controllers/supplejack_api/records_controller.rb +71 -0
  22. data/app/controllers/supplejack_api/schema_controller.rb +19 -0
  23. data/app/controllers/supplejack_api/set_items_controller.rb +38 -0
  24. data/app/controllers/supplejack_api/sources_controller.rb +67 -0
  25. data/app/controllers/supplejack_api/status_controller.rb +67 -0
  26. data/app/controllers/supplejack_api/user_sets_controller.rb +97 -0
  27. data/app/controllers/supplejack_api/users_controller.rb +49 -0
  28. data/app/helpers/supplejack_api/application_helper.rb +39 -0
  29. data/app/helpers/supplejack_api/facets_helper.rb +30 -0
  30. data/app/mailers/supplejack_api/request_limit_mailer.rb +43 -0
  31. data/app/models/supplejack_api/api_concept/concept_fragment.rb +31 -0
  32. data/app/models/supplejack_api/api_record/record_fragment.rb +15 -0
  33. data/app/models/supplejack_api/concept.rb +46 -0
  34. data/app/models/supplejack_api/concept_search.rb +86 -0
  35. data/app/models/supplejack_api/concerns/queryable_by_date.rb +31 -0
  36. data/app/models/supplejack_api/concerns/record.rb +108 -0
  37. data/app/models/supplejack_api/concerns/record_fragmentable.rb +24 -0
  38. data/app/models/supplejack_api/concerns/searchable.rb +430 -0
  39. data/app/models/supplejack_api/concerns/user_set.rb +219 -0
  40. data/app/models/supplejack_api/daily_metrics.rb +20 -0
  41. data/app/models/supplejack_api/faceted_metrics.rb +55 -0
  42. data/app/models/supplejack_api/fragment.rb +82 -0
  43. data/app/models/supplejack_api/interaction_models/record.rb +60 -0
  44. data/app/models/supplejack_api/interaction_models/set.rb +13 -0
  45. data/app/models/supplejack_api/interaction_updaters/all_usage_metric.rb +41 -0
  46. data/app/models/supplejack_api/interaction_updaters/set_metrics.rb +32 -0
  47. data/app/models/supplejack_api/interaction_updaters/usage_metrics.rb +73 -0
  48. data/app/models/supplejack_api/partner.rb +24 -0
  49. data/app/models/supplejack_api/preview_record.rb +30 -0
  50. data/app/models/supplejack_api/record.rb +18 -0
  51. data/app/models/supplejack_api/record_search.rb +12 -0
  52. data/app/models/supplejack_api/schema_definition.rb +147 -0
  53. data/app/models/supplejack_api/search.rb +14 -0
  54. data/app/models/supplejack_api/set_item.rb +57 -0
  55. data/app/models/supplejack_api/site_activity.rb +59 -0
  56. data/app/models/supplejack_api/source.rb +28 -0
  57. data/app/models/supplejack_api/source_activity.rb +36 -0
  58. data/app/models/supplejack_api/source_authority.rb +42 -0
  59. data/app/models/supplejack_api/supplejack_schema.rb +37 -0
  60. data/app/models/supplejack_api/support/concept/searchable.rb +79 -0
  61. data/app/models/supplejack_api/support/concept/storable.rb +59 -0
  62. data/app/models/supplejack_api/support/fragment_helpers.rb +96 -0
  63. data/app/models/supplejack_api/support/harvestable.rb +105 -0
  64. data/app/models/supplejack_api/support/searchable.rb +115 -0
  65. data/app/models/supplejack_api/support/status_logger.rb +23 -0
  66. data/app/models/supplejack_api/support/storable.rb +49 -0
  67. data/app/models/supplejack_api/support/validation_logger.rb +23 -0
  68. data/app/models/supplejack_api/usage_metrics.rb +25 -0
  69. data/app/models/supplejack_api/user.rb +211 -0
  70. data/app/models/supplejack_api/user_activity.rb +65 -0
  71. data/app/models/supplejack_api/user_set.rb +17 -0
  72. data/app/serializers/supplejack_api/application_serializer.rb +12 -0
  73. data/app/serializers/supplejack_api/concept_record_serializer.rb +23 -0
  74. data/app/serializers/supplejack_api/concept_search_serializer.rb +12 -0
  75. data/app/serializers/supplejack_api/concept_serializer.rb +100 -0
  76. data/app/serializers/supplejack_api/concerns/record_serializable.rb +119 -0
  77. data/app/serializers/supplejack_api/concerns/search_serializable.rb +24 -0
  78. data/app/serializers/supplejack_api/record_search_serializer.rb +64 -0
  79. data/app/serializers/supplejack_api/record_serializer.rb +13 -0
  80. data/app/serializers/supplejack_api/search_serializer.rb +13 -0
  81. data/app/serializers/supplejack_api/source_authority_serializer.rb +23 -0
  82. data/app/serializers/supplejack_api/user_serializer.rb +13 -0
  83. data/app/serializers/supplejack_api/user_set_record_serializer.rb +14 -0
  84. data/app/serializers/supplejack_api/user_set_serializer.rb +77 -0
  85. data/app/services/metrics_api/v3/api.rb +30 -0
  86. data/app/services/metrics_api/v3/endpoints/facets.rb +23 -0
  87. data/app/services/metrics_api/v3/endpoints/global.rb +26 -0
  88. data/app/services/metrics_api/v3/endpoints/helpers.rb +14 -0
  89. data/app/services/metrics_api/v3/endpoints/root.rb +97 -0
  90. data/app/services/metrics_api/v3/presenters/daily_metric.rb +23 -0
  91. data/app/services/metrics_api/v3/presenters/extended_metadata.rb +41 -0
  92. data/app/services/metrics_api/v3/presenters/record.rb +26 -0
  93. data/app/services/metrics_api/v3/presenters/view.rb +28 -0
  94. data/app/views/layouts/supplejack_api/_head.html.erb +17 -0
  95. data/app/views/layouts/supplejack_api/_top_nav.html.erb +33 -0
  96. data/app/views/layouts/supplejack_api/application.html.erb +33 -0
  97. data/app/views/supplejack_api/admin/sessions/new.html.erb +25 -0
  98. data/app/views/supplejack_api/admin/shared/_links.erb +34 -0
  99. data/app/views/supplejack_api/admin/site_activities/index.csv.erb +22 -0
  100. data/app/views/supplejack_api/admin/site_activities/index.html.erb +54 -0
  101. data/app/views/supplejack_api/admin/users/edit.html.erb +16 -0
  102. data/app/views/supplejack_api/admin/users/index.csv.erb +22 -0
  103. data/app/views/supplejack_api/admin/users/index.html.erb +57 -0
  104. data/app/views/supplejack_api/admin/users/show.html.erb +33 -0
  105. data/app/views/supplejack_api/request_limit_mailer/at100percent.text.erb +13 -0
  106. data/app/views/supplejack_api/request_limit_mailer/at100percent_admin.text.erb +1 -0
  107. data/app/views/supplejack_api/request_limit_mailer/at90percent.text.erb +13 -0
  108. data/app/views/supplejack_api/request_limit_mailer/at90percent_admin.text.erb +1 -0
  109. data/app/workers/supplejack_api/daily_metrics_worker.rb +112 -0
  110. data/app/workers/supplejack_api/interaction_metrics_worker.rb +45 -0
  111. data/config/cucumber.yml +16 -0
  112. data/config/initializers/force_eagerload.rb +11 -0
  113. data/config/initializers/interaction_updaters.rb +7 -0
  114. data/config/routes.rb +81 -0
  115. data/db/binding_records.development.json +7 -0
  116. data/db/binding_records.staging.json +7 -0
  117. data/db/concepts.json +33 -0
  118. data/db/concepts_data.json +569745 -0
  119. data/db/source_authorities.json +119 -0
  120. data/lib/generators/supplejack_api/install_generator.rb +124 -0
  121. data/lib/mongoid/paperclip.rb +53 -0
  122. data/lib/mongoid/string.rb +20 -0
  123. data/lib/sunspot/mongoid.rb +51 -0
  124. data/lib/sunspot/resque_session_proxy.rb +72 -0
  125. data/lib/sunspot/sunspot_spellcheck.rb +98 -0
  126. data/lib/supplejack_api.rb +13 -0
  127. data/lib/supplejack_api/admin/sortable.rb +40 -0
  128. data/lib/supplejack_api/engine.rb +46 -0
  129. data/lib/supplejack_api/harvester_constraint.rb +28 -0
  130. data/lib/supplejack_api/stylesheets.rb +36 -0
  131. data/lib/supplejack_api/utils.rb +75 -0
  132. data/lib/supplejack_api/version.rb +11 -0
  133. data/lib/tasks/resque.rake +22 -0
  134. data/lib/url_validator.rb +38 -0
  135. data/spec/controllers/supplejack_api/admin/base_controller_spec.rb +55 -0
  136. data/spec/controllers/supplejack_api/admin/site_activities_controller_spec.rb +43 -0
  137. data/spec/controllers/supplejack_api/admin/users_controller_spec.rb +79 -0
  138. data/spec/controllers/supplejack_api/application_controller_spec.rb +133 -0
  139. data/spec/controllers/supplejack_api/concepts_controller_spec.rb +83 -0
  140. data/spec/controllers/supplejack_api/concerns/records_controller_metrics_spec.rb +60 -0
  141. data/spec/controllers/supplejack_api/harvester/concepts_controller_spec.rb +57 -0
  142. data/spec/controllers/supplejack_api/harvester/records_controller_spec.rb +138 -0
  143. data/spec/controllers/supplejack_api/metrics_api_controller_spec.rb +71 -0
  144. data/spec/controllers/supplejack_api/partners_controller_spec.rb +77 -0
  145. data/spec/controllers/supplejack_api/records_controller_spec.rb +143 -0
  146. data/spec/controllers/supplejack_api/set_items_controller_spec.rb +78 -0
  147. data/spec/controllers/supplejack_api/sources_controller_spec.rb +161 -0
  148. data/spec/controllers/supplejack_api/status_controller_spec.rb +120 -0
  149. data/spec/controllers/supplejack_api/user_sets_controller_spec.rb +233 -0
  150. data/spec/controllers/supplejack_api/users_controller_spec.rb +61 -0
  151. data/spec/dummy/README.rdoc +268 -0
  152. data/spec/dummy/Rakefile +7 -0
  153. data/spec/dummy/app/assets/javascripts/application.js +23 -0
  154. data/spec/dummy/app/assets/stylesheets/application.css +22 -0
  155. data/spec/dummy/app/controllers/application_controller.rb +10 -0
  156. data/spec/dummy/app/helpers/application_helper.rb +9 -0
  157. data/spec/dummy/app/supplejack_api/concept_schema.rb +83 -0
  158. data/spec/dummy/app/supplejack_api/record_schema.rb +64 -0
  159. data/spec/dummy/app/supplejack_api/record_schema.txt +66 -0
  160. data/spec/dummy/app/views/layouts/application.html.erb +23 -0
  161. data/spec/dummy/app/workers/supplejack_api/clear_index_buffer.rb +32 -0
  162. data/spec/dummy/app/workers/supplejack_api/flush_old_records_worker.rb +17 -0
  163. data/spec/dummy/app/workers/supplejack_api/index_buffer.rb +49 -0
  164. data/spec/dummy/app/workers/supplejack_api/index_source_worker.rb +39 -0
  165. data/spec/dummy/app/workers/supplejack_api/index_worker.rb +82 -0
  166. data/spec/dummy/app/workers/supplejack_api/store_user_activity_worker.rb +24 -0
  167. data/spec/dummy/config.ru +11 -0
  168. data/spec/dummy/config/application.rb +76 -0
  169. data/spec/dummy/config/application.yml +31 -0
  170. data/spec/dummy/config/application.yml.example +36 -0
  171. data/spec/dummy/config/boot.rb +17 -0
  172. data/spec/dummy/config/environment.rb +12 -0
  173. data/spec/dummy/config/environments/development.rb +42 -0
  174. data/spec/dummy/config/environments/production.rb +76 -0
  175. data/spec/dummy/config/environments/test.rb +46 -0
  176. data/spec/dummy/config/initializers/backtrace_silencers.rb +14 -0
  177. data/spec/dummy/config/initializers/devise.rb +214 -0
  178. data/spec/dummy/config/initializers/inflections.rb +22 -0
  179. data/spec/dummy/config/initializers/kaminari_config.rb +17 -0
  180. data/spec/dummy/config/initializers/mime_types.rb +12 -0
  181. data/spec/dummy/config/initializers/mongoid.rb +9 -0
  182. data/spec/dummy/config/initializers/quiet_logger.rb +23 -0
  183. data/spec/dummy/config/initializers/resque.rb +18 -0
  184. data/spec/dummy/config/initializers/secret_token.rb +14 -0
  185. data/spec/dummy/config/initializers/session_store.rb +15 -0
  186. data/spec/dummy/config/initializers/simple_form.rb +149 -0
  187. data/spec/dummy/config/initializers/simple_form_foundation.rb +33 -0
  188. data/spec/dummy/config/initializers/state_machine.rb +8 -0
  189. data/spec/dummy/config/initializers/sunspot.rb +32 -0
  190. data/spec/dummy/config/initializers/wrap_parameters.rb +17 -0
  191. data/spec/dummy/config/locales/devise.en.yml +63 -0
  192. data/spec/dummy/config/locales/en.yml +66 -0
  193. data/spec/dummy/config/locales/simple_form.en.yml +33 -0
  194. data/spec/dummy/config/mongoid.travis.yml +34 -0
  195. data/spec/dummy/config/mongoid.yml +36 -0
  196. data/spec/dummy/config/resque-pool.yml +18 -0
  197. data/spec/dummy/config/resque_schedule.yml +12 -0
  198. data/spec/dummy/config/routes.rb +11 -0
  199. data/spec/dummy/config/secrets.yml +8 -0
  200. data/spec/dummy/config/sunspot.yml +38 -0
  201. data/spec/dummy/db/concepts.json +37 -0
  202. data/spec/dummy/db/source_authorities.json +116 -0
  203. data/spec/dummy/public/404.html +35 -0
  204. data/spec/dummy/public/422.html +35 -0
  205. data/spec/dummy/public/500.html +34 -0
  206. data/spec/dummy/public/favicon.ico +8 -0
  207. data/spec/dummy/script/rails +6 -0
  208. data/spec/dummy/solr/collection1/conf/elevate.xml +36 -0
  209. data/spec/dummy/solr/collection1/conf/mapping-FoldToASCII.txt +3813 -0
  210. data/spec/dummy/solr/collection1/conf/schema.xml +292 -0
  211. data/spec/dummy/solr/collection1/conf/solrconfig.xml +1780 -0
  212. data/spec/dummy/solr/collection1/conf/spellings.txt +2 -0
  213. data/spec/dummy/solr/collection1/conf/stopwords.txt +58 -0
  214. data/spec/dummy/solr/collection1/conf/synonyms.txt +31 -0
  215. data/spec/factories/concepts.rb +16 -0
  216. data/spec/factories/daily_metrics.rb +10 -0
  217. data/spec/factories/faceted_metrics.rb +25 -0
  218. data/spec/factories/fragment.rb +14 -0
  219. data/spec/factories/partners.rb +14 -0
  220. data/spec/factories/record_interaction.rb +17 -0
  221. data/spec/factories/records.rb +47 -0
  222. data/spec/factories/set_interaction.rb +15 -0
  223. data/spec/factories/source_authorities.rb +19 -0
  224. data/spec/factories/sources.rb +16 -0
  225. data/spec/factories/usage_metrics.rb +20 -0
  226. data/spec/factories/user_activities.rb +14 -0
  227. data/spec/factories/user_sets.rb +27 -0
  228. data/spec/factories/users.rb +23 -0
  229. data/spec/helpers/application_helper_spec.rb +35 -0
  230. data/spec/models/concept_spec.rb +163 -0
  231. data/spec/models/fragment_spec.rb +15 -0
  232. data/spec/models/site_activity_spec.rb +103 -0
  233. data/spec/models/source_activity_spec.rb +56 -0
  234. data/spec/models/source_authority_spec.rb +42 -0
  235. data/spec/models/supplejack_api/api_concept/concept_fragment_spec.rb +189 -0
  236. data/spec/models/supplejack_api/api_record/record_fragment_spec.rb +189 -0
  237. data/spec/models/supplejack_api/concept_spec.rb +0 -0
  238. data/spec/models/supplejack_api/interaction_updaters/all_usage_metric_spec.rb +41 -0
  239. data/spec/models/supplejack_api/interaction_updaters/set_metrics_spec.rb +32 -0
  240. data/spec/models/supplejack_api/interaction_updaters/usage_metrics_spec.rb +44 -0
  241. data/spec/models/supplejack_api/partner_spec.rb +20 -0
  242. data/spec/models/supplejack_api/record_search_spec.rb +429 -0
  243. data/spec/models/supplejack_api/record_spec.rb +280 -0
  244. data/spec/models/supplejack_api/schema_definition_spec.rb +272 -0
  245. data/spec/models/supplejack_api/search_spec.rb +243 -0
  246. data/spec/models/supplejack_api/set_item_spec.rb +123 -0
  247. data/spec/models/supplejack_api/source_spec.rb +22 -0
  248. data/spec/models/supplejack_api/support/fragment_helpers_spec.rb +216 -0
  249. data/spec/models/supplejack_api/support/harvestable_spec.rb +177 -0
  250. data/spec/models/supplejack_api/support/searchable_spec.rb +85 -0
  251. data/spec/models/supplejack_api/support/storable_spec.rb +18 -0
  252. data/spec/models/supplejack_api/user_activity_spec.rb +88 -0
  253. data/spec/models/supplejack_api/user_set_spec.rb +559 -0
  254. data/spec/models/supplejack_api/user_spec.rb +348 -0
  255. data/spec/routing/concepts_routing_spec.rb +22 -0
  256. data/spec/routing/harvester_constraint_spec.rb +66 -0
  257. data/spec/routing/harvester_routing_spec.rb +51 -0
  258. data/spec/routing/partner_routing_spec.rb +34 -0
  259. data/spec/routing/records_routing_spec.rb +26 -0
  260. data/spec/routing/sets_routing_spec.rb +44 -0
  261. data/spec/routing/source_routing_spec.rb +38 -0
  262. data/spec/routing/users_routing_spec.rb +18 -0
  263. data/spec/serializers/concept_record_serializer_spec.rb +30 -0
  264. data/spec/serializers/supplejack_api/application_serializer_spec.rb +14 -0
  265. data/spec/serializers/supplejack_api/concept_search_serializer_spec.rb +34 -0
  266. data/spec/serializers/supplejack_api/concept_serializer_spec.rb +92 -0
  267. data/spec/serializers/supplejack_api/record_search_serializer_spec.rb +34 -0
  268. data/spec/serializers/supplejack_api/record_serializer_spec.rb +271 -0
  269. data/spec/serializers/supplejack_api/search_serializer_spec.rb +90 -0
  270. data/spec/serializers/supplejack_api/user_serializer_spec.rb +22 -0
  271. data/spec/serializers/supplejack_api/user_set_serializer_spec.rb +96 -0
  272. data/spec/services/metrics_api/v3/api_spec.rb +23 -0
  273. data/spec/services/metrics_api/v3/endpoints/facets_spec.rb +25 -0
  274. data/spec/services/metrics_api/v3/endpoints/global_spec.rb +22 -0
  275. data/spec/services/metrics_api/v3/endpoints/root_spec.rb +49 -0
  276. data/spec/services/metrics_api/v3/presenters/extended_metadata_spec.rb +49 -0
  277. data/spec/spec_helper.rb +70 -0
  278. data/spec/support/api/schemas/metrics/daily_metrics_metadata.json +24 -0
  279. data/spec/support/api/schemas/metrics/extended_metrics.json +26 -0
  280. data/spec/support/api/schemas/metrics/extended_response.json +6 -0
  281. data/spec/support/api/schemas/metrics/facets_response.json +6 -0
  282. data/spec/support/api/schemas/metrics/record_metadata.json +33 -0
  283. data/spec/support/api/schemas/metrics/top_level_response.json +6 -0
  284. data/spec/support/api/schemas/metrics/view_metadata.json +33 -0
  285. data/spec/support/api_schema_matcher.rb +14 -0
  286. data/spec/support/devise.rb +10 -0
  287. data/spec/workers/supplejack_api/daily_metrics_worker_spec.rb +140 -0
  288. data/spec/workers/supplejack_api/flush_old_records_worker_spec.rb +20 -0
  289. data/spec/workers/supplejack_api/index_worker_spec.rb +52 -0
  290. data/spec/workers/supplejack_api/source_index_worker_spec.rb +61 -0
  291. metadata +1231 -0
@@ -0,0 +1,14 @@
1
+ # The majority of the Supplejack API code is Crown copyright (C) 2014, New Zealand Government,
2
+ # and is licensed under the GNU General Public License, version 3.
3
+ # One component is a third party component. See https://github.com/DigitalNZ/supplejack_api for details.
4
+ #
5
+ # Supplejack was created by DigitalNZ at the National Library of NZ and
6
+ # the Department of Internal Affairs. http://digitalnz.org/supplejack
7
+
8
+ # Be sure to restart your server when you modify this file.
9
+
10
+ # You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
11
+ # Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ }
12
+
13
+ # You can also remove all the silencers if you're trying to debug a problem that might stem from framework code.
14
+ # Rails.backtrace_cleaner.remove_silencers!
@@ -0,0 +1,214 @@
1
+ # The majority of the Supplejack API code is Crown copyright (C) 2014, New Zealand Government,
2
+ # and is licensed under the GNU General Public License, version 3.
3
+ # One component is a third party component. See https://github.com/DigitalNZ/supplejack_api for details.
4
+ #
5
+ # Supplejack was created by DigitalNZ at the National Library of NZ and
6
+ # the Department of Internal Affairs. http://digitalnz.org/supplejack
7
+
8
+ # Use this hook to configure devise mailer, warden hooks and so forth. The first
9
+ # four configuration values can also be set straight in your models.
10
+ Devise.setup do |config|
11
+ # ==> Mailer Configuration
12
+ # Configure the e-mail address which will be shown in Devise::Mailer,
13
+ # note that it will be overwritten if you use your own mailer class with default "from" parameter.
14
+ config.mailer_sender = ENV['DEVISE_MAILER']
15
+
16
+ # Configure the class responsible to send e-mails.
17
+ # config.mailer = "Devise::Mailer"
18
+
19
+ # ==> ORM configuration
20
+ # Load and configure the ORM. Supports :active_record (default) and
21
+ # :mongoid (bson_ext recommended) by default. Other ORMs may be
22
+ # available as additional gems.
23
+ require 'devise/orm/mongoid'
24
+
25
+ # ==> Configuration for any authentication mechanism
26
+ # Configure which keys are used when authenticating a user. The default is
27
+ # just :email. You can configure it to use [:username, :subdomain], so for
28
+ # authenticating a user, both parameters are required. Remember that those
29
+ # parameters are used only when authenticating and not when retrieving from
30
+ # session. If you need permissions, you should implement that in a before filter.
31
+ # You can also supply a hash where the value is a boolean determining whether
32
+ # or not authentication should be aborted when the value is not present.
33
+ # config.authentication_keys = [ :email ]
34
+
35
+ # Configure parameters from the request object used for authentication. Each entry
36
+ # given should be a request method and it will automatically be passed to the
37
+ # find_for_authentication method and considered in your model lookup. For instance,
38
+ # if you set :request_keys to [:subdomain], :subdomain will be used on authentication.
39
+ # The same considerations mentioned for authentication_keys also apply to request_keys.
40
+ # config.request_keys = []
41
+
42
+ # Configure which authentication keys should be case-insensitive.
43
+ # These keys will be downcased upon creating or modifying a user and when used
44
+ # to authenticate or find a user. Default is :email.
45
+ config.case_insensitive_keys = [ :email ]
46
+
47
+ # Configure which authentication keys should have whitespace stripped.
48
+ # These keys will have whitespace before and after removed upon creating or
49
+ # modifying a user and when used to authenticate or find a user. Default is :email.
50
+ config.strip_whitespace_keys = [ :email ]
51
+
52
+ # Tell if authentication through request.params is enabled. True by default.
53
+ # config.params_authenticatable = true
54
+
55
+ # Tell if authentication through HTTP Basic Auth is enabled. False by default.
56
+ # config.http_authenticatable = false
57
+
58
+ # If http headers should be returned for AJAX requests. True by default.
59
+ # config.http_authenticatable_on_xhr = true
60
+
61
+ # The realm used in Http Basic Authentication. "Application" by default.
62
+ # config.http_authentication_realm = "Application"
63
+
64
+ # It will change confirmation, password recovery and other workflows
65
+ # to behave the same regardless if the e-mail provided was right or wrong.
66
+ # Does not affect registerable.
67
+ # config.paranoid = true
68
+
69
+ # ==> Configuration for :database_authenticatable
70
+ # For bcrypt, this is the cost for hashing the password and defaults to 10. If
71
+ # using other encryptors, it sets how many times you want the password re-encrypted.
72
+ #
73
+ # Limiting the stretches to just one in testing will increase the performance of
74
+ # your test suite dramatically. However, it is STRONGLY RECOMMENDED to not use
75
+ # a value less than 10 in other environments.
76
+ config.stretches = Rails.env.test? ? 1 : 10
77
+
78
+ # Setup a pepper to generate the encrypted password.
79
+ # config.pepper = "6d79aa00806fb0acc2a80da1e2b8ab7ea38c340bcec33386dfc1f383de4ed498291b11c9830b0ad046939e4699abdb5d403b8d1ada79719a683b9a05595fd461"
80
+
81
+ # ==> Configuration for :confirmable
82
+ # A period that the user is allowed to access the website even without
83
+ # confirming his account. For instance, if set to 2.days, the user will be
84
+ # able to access the website for two days without confirming his account,
85
+ # access will be blocked just in the third day. Default is 0.days, meaning
86
+ # the user cannot access the website without confirming his account.
87
+ # config.allow_unconfirmed_access_for = 2.days
88
+
89
+ # Defines which key will be used when confirming an account
90
+ # config.confirmation_keys = [ :email ]
91
+
92
+ # ==> Configuration for :rememberable
93
+ # The time the user will be remembered without asking for credentials again.
94
+ # config.remember_for = 2.weeks
95
+
96
+ # If true, extends the user's remember period when remembered via cookie.
97
+ # config.extend_remember_period = false
98
+
99
+ # Options to be passed to the created cookie. For instance, you can set
100
+ # :secure => true in order to force SSL only cookies.
101
+ # config.cookie_options = {}
102
+
103
+ # ==> Configuration for :validatable
104
+ # Range for password length. Default is 6..128.
105
+ # config.password_length = 6..128
106
+
107
+ # Email regex used to validate email formats. It simply asserts that
108
+ # an one (and only one) @ exists in the given string. This is mainly
109
+ # to give user feedback and not to assert the e-mail validity.
110
+ # config.email_regexp = /\A[^@]+@[^@]+\z/
111
+
112
+ # ==> Configuration for :timeoutable
113
+ # The time you want to timeout the user session without activity. After this
114
+ # time the user will be asked for credentials again. Default is 30 minutes.
115
+ # config.timeout_in = 30.minutes
116
+
117
+ # ==> Configuration for :lockable
118
+ # Defines which strategy will be used to lock an account.
119
+ # :failed_attempts = Locks an account after a number of failed attempts to sign in.
120
+ # :none = No lock strategy. You should handle locking by yourself.
121
+ # config.lock_strategy = :failed_attempts
122
+
123
+ # Defines which key will be used when locking and unlocking an account
124
+ # config.unlock_keys = [ :email ]
125
+
126
+ # Defines which strategy will be used to unlock an account.
127
+ # :email = Sends an unlock link to the user email
128
+ # :time = Re-enables login after a certain amount of time (see :unlock_in below)
129
+ # :both = Enables both strategies
130
+ # :none = No unlock strategy. You should handle unlocking by yourself.
131
+ # config.unlock_strategy = :both
132
+
133
+ # Number of authentication tries before locking an account if lock_strategy
134
+ # is failed attempts.
135
+ # config.maximum_attempts = 20
136
+
137
+ # Time interval to unlock the account if :time is enabled as unlock_strategy.
138
+ # config.unlock_in = 1.hour
139
+
140
+ # ==> Configuration for :recoverable
141
+ #
142
+ # Defines which key will be used when recovering the password for an account
143
+ # config.reset_password_keys = [ :email ]
144
+
145
+ # Time interval you can reset your password with a reset password key.
146
+ # Don't put a too small interval or your users won't have the time to
147
+ # change their passwords.
148
+ config.reset_password_within = 2.hours
149
+
150
+ # ==> Configuration for :encryptable
151
+ # Allow you to use another encryption algorithm besides bcrypt (default). You can use
152
+ # :sha1, :sha512 or encryptors from others authentication tools as :clearance_sha1,
153
+ # :authlogic_sha512 (then you should set stretches above to 20 for default behavior)
154
+ # and :restful_authentication_sha1 (then you should set stretches to 10, and copy
155
+ # REST_AUTH_SITE_KEY to pepper)
156
+ # config.encryptor = :sha512
157
+
158
+ # ==> Configuration for :token_authenticatable
159
+ # Defines name of the authentication token params key
160
+ # config.token_authentication_key = :api_key
161
+
162
+ # If true, authentication through token does not store user in session and needs
163
+ # to be supplied on each request. Useful if you are using the token as API token.
164
+ # config.stateless_token = true
165
+ config.skip_session_storage << :token_auth
166
+
167
+ # ==> Scopes configuration
168
+ # Turn scoped views on. Before rendering "sessions/new", it will first check for
169
+ # "users/sessions/new". It's turned off by default because it's slower if you
170
+ # are using only default views.
171
+ config.scoped_views = true
172
+
173
+ # Configure the default scope given to Warden. By default it's the first
174
+ # devise role declared in your routes (usually :user).
175
+ # config.default_scope = :user
176
+
177
+ # Configure sign_out behavior.
178
+ # Sign_out action can be scoped (i.e. /users/sign_out affects only :user scope).
179
+ # The default is true, which means any logout action will sign out all active scopes.
180
+ # config.sign_out_all_scopes = true
181
+
182
+ # ==> Navigation configuration
183
+ # Lists the formats that should be treated as navigational. Formats like
184
+ # :html, should redirect to the sign in page when the user does not have
185
+ # access, but formats like :xml or :json, should return 401.
186
+ #
187
+ # If you have any extra navigational formats, like :iphone or :mobile, you
188
+ # should add them to the navigational formats lists.
189
+ #
190
+ # The :"*/*" and "*/*" formats below is required to match Internet
191
+ # Explorer requests.
192
+ # config.navigational_formats = [:"*/*", "*/*", :html]
193
+
194
+ # The default HTTP method used to sign out a resource. Default is :delete.
195
+ config.sign_out_via = :delete
196
+
197
+ # ==> OmniAuth
198
+ # Add a new OmniAuth provider. Check the wiki for more information on setting
199
+ # up on your models and hooks.
200
+ # config.omniauth :github, 'APP_ID', 'APP_SECRET', :scope => 'user,public_repo'
201
+
202
+ # ==> Warden configuration
203
+ # If you want to use other strategies, that are not supported by Devise, or
204
+ # change the failure app, you can configure them inside the config.warden block.
205
+ #
206
+ # config.warden do |manager|
207
+ # manager.intercept_401 = false
208
+ # manager.default_strategies(:scope => :user).unshift :some_external_strategy
209
+ # end
210
+
211
+ config.router_name = :supplejack_api
212
+
213
+ config.secret_key = 'b2510510cac145b70663d56b9489f9e42f61e09bf15608a5bbffd037c44fa53cacf8e8daf1b9ef9b721de902b93cba9ef1fb0395478175288bfd4f12ac5b5aae'
214
+ end
@@ -0,0 +1,22 @@
1
+ # The majority of the Supplejack API code is Crown copyright (C) 2014, New Zealand Government,
2
+ # and is licensed under the GNU General Public License, version 3.
3
+ # One component is a third party component. See https://github.com/DigitalNZ/supplejack_api for details.
4
+ #
5
+ # Supplejack was created by DigitalNZ at the National Library of NZ and
6
+ # the Department of Internal Affairs. http://digitalnz.org/supplejack
7
+
8
+ # Be sure to restart your server when you modify this file.
9
+
10
+ # Add new inflection rules using the following format
11
+ # (all these examples are active by default):
12
+ # ActiveSupport::Inflector.inflections do |inflect|
13
+ # inflect.plural /^(ox)$/i, '\1en'
14
+ # inflect.singular /^(ox)en/i, '\1'
15
+ # inflect.irregular 'person', 'people'
16
+ # inflect.uncountable %w( fish sheep )
17
+ # end
18
+ #
19
+ # These inflection rules are supported but not enabled by default:
20
+ # ActiveSupport::Inflector.inflections do |inflect|
21
+ # inflect.acronym 'RESTful'
22
+ # end
@@ -0,0 +1,17 @@
1
+ # The majority of the Supplejack code is Crown copyright (C) 2014, New Zealand Government,
2
+ # and is licensed under the GNU General Public License, version 3.
3
+ # Some components are third party components licensed under the GPL or MIT licenses
4
+ # or otherwise publicly available. See https://github.com/DigitalNZ/supplejack_api for details.
5
+ #
6
+ # Supplejack was created by DigitalNZ at the National Library of NZ and
7
+ # the Department of Internal Affairs. http://digitalnz.org/supplejack
8
+
9
+ Kaminari.configure do |config|
10
+ config.default_per_page = 100
11
+ # config.window = 4
12
+ # config.outer_window = 0
13
+ # config.left = 0
14
+ # config.right = 0
15
+ # config.page_method_name = :page
16
+ # config.param_name = :page
17
+ end
@@ -0,0 +1,12 @@
1
+ # The majority of the Supplejack API code is Crown copyright (C) 2014, New Zealand Government,
2
+ # and is licensed under the GNU General Public License, version 3.
3
+ # One component is a third party component. See https://github.com/DigitalNZ/supplejack_api for details.
4
+ #
5
+ # Supplejack was created by DigitalNZ at the National Library of NZ and
6
+ # the Department of Internal Affairs. http://digitalnz.org/supplejack
7
+
8
+ # Be sure to restart your server when you modify this file.
9
+
10
+ # Add new mime types for use in respond_to blocks:
11
+ # Mime::Type.register "text/richtext", :rtf
12
+ # Mime::Type.register_alias "text/html", :iphone
@@ -0,0 +1,9 @@
1
+ module BSON
2
+ class ObjectId
3
+ def as_json(*args)
4
+ to_s
5
+ end
6
+
7
+ alias :to_json :as_json
8
+ end
9
+ end
@@ -0,0 +1,23 @@
1
+ # The majority of the Supplejack API code is Crown copyright (C) 2014, New Zealand Government,
2
+ # and is licensed under the GNU General Public License, version 3.
3
+ # One component is a third party component. See https://github.com/DigitalNZ/supplejack_api for details.
4
+ #
5
+ # Supplejack was created by DigitalNZ at the National Library of NZ and
6
+ # the Department of Internal Affairs. http://digitalnz.org/supplejack
7
+
8
+ # Increase log level for the "/status" url to prevent logging spam
9
+ # as this url is accessed very often on UAT
10
+
11
+ Rails::Rack::Logger.class_eval do
12
+ def call_with_quiet_logger(env)
13
+ old_logger_level, level = Rails.logger.level, Logger::ERROR
14
+
15
+ Rails.logger.level = level if env['PATH_INFO'].start_with?('/status')
16
+ call_without_quiet_logger(env)
17
+
18
+ ensure
19
+
20
+ Rails.logger.level = old_logger_level
21
+ end
22
+ alias_method_chain :call, :quiet_logger
23
+ end
@@ -0,0 +1,18 @@
1
+ # The majority of the Supplejack API code is Crown copyright (C) 2014, New Zealand Government,
2
+ # and is licensed under the GNU General Public License, version 3.
3
+ # One component is a third party component. See https://github.com/DigitalNZ/supplejack_api for details.
4
+ #
5
+ # Supplejack was created by DigitalNZ at the National Library of NZ and
6
+ # the Department of Internal Affairs. http://digitalnz.org/supplejack
7
+
8
+ require 'resque/server'
9
+ require 'resque_scheduler'
10
+ require 'resque_scheduler/server'
11
+
12
+ Resque::Server.use Rack::Auth::Basic do |username, password|
13
+ username == ENV['RESQUE_USER'] && password == ENV['RESQUE_PASS']
14
+ end
15
+
16
+ Resque.schedule = YAML.load_file(File.join(Rails.root.to_s, 'config/resque_schedule.yml'))
17
+
18
+ Resque.inline = Rails.env.test?
@@ -0,0 +1,14 @@
1
+ # The majority of the Supplejack API code is Crown copyright (C) 2014, New Zealand Government,
2
+ # and is licensed under the GNU General Public License, version 3.
3
+ # One component is a third party component. See https://github.com/DigitalNZ/supplejack_api for details.
4
+ #
5
+ # Supplejack was created by DigitalNZ at the National Library of NZ and
6
+ # the Department of Internal Affairs. http://digitalnz.org/supplejack
7
+
8
+ # Be sure to restart your server when you modify this file.
9
+
10
+ # Your secret key for verifying the integrity of signed cookies.
11
+ # If you change this key, all old signed cookies will become invalid!
12
+ # Make sure the secret is at least 30 characters and all random,
13
+ # no regular words or you'll be exposed to dictionary attacks.
14
+ Dummy::Application.config.secret_token = 'd91180094c72f0d6001cfbc9e6277eab2cacdfabf7f1fb498f543ca0926714547f0698830cf72e33b651aa51f11df397ac49f9a6a692b5a3bbacdbfd781e6491'
@@ -0,0 +1,15 @@
1
+ # The majority of the Supplejack API code is Crown copyright (C) 2014, New Zealand Government,
2
+ # and is licensed under the GNU General Public License, version 3.
3
+ # One component is a third party component. See https://github.com/DigitalNZ/supplejack_api for details.
4
+ #
5
+ # Supplejack was created by DigitalNZ at the National Library of NZ and
6
+ # the Department of Internal Affairs. http://digitalnz.org/supplejack
7
+
8
+ # Be sure to restart your server when you modify this file.
9
+
10
+ Dummy::Application.config.session_store :cookie_store, key: '_dummy_session'
11
+
12
+ # Use the database for sessions instead of the cookie-based default,
13
+ # which shouldn't be used to store highly confidential information
14
+ # (create the session table with "rails generate session_migration")
15
+ # Dummy::Application.config.session_store :active_record_store
@@ -0,0 +1,149 @@
1
+ # The majority of the Supplejack API code is Crown copyright (C) 2014, New Zealand Government,
2
+ # and is licensed under the GNU General Public License, version 3.
3
+ # One component is a third party component. See https://github.com/DigitalNZ/supplejack_api for details.
4
+ #
5
+ # Supplejack was created by DigitalNZ at the National Library of NZ and
6
+ # the Department of Internal Affairs. http://digitalnz.org/supplejack
7
+
8
+ # Use this setup block to configure all options available in SimpleForm.
9
+ SimpleForm.setup do |config|
10
+ # Wrappers are used by the form builder to generate a
11
+ # complete input. You can remove any component from the
12
+ # wrapper, change the order or even add your own to the
13
+ # stack. The options given below are used to wrap the
14
+ # whole input.
15
+ config.wrappers :default, :class => :input,
16
+ :hint_class => :field_with_hint, :error_class => :field_with_errors do |b|
17
+ ## Extensions enabled by default
18
+ # Any of these extensions can be disabled for a
19
+ # given input by passing: `f.input EXTENSION_NAME => false`.
20
+ # You can make any of these extensions optional by
21
+ # renaming `b.use` to `b.optional`.
22
+
23
+ # Determines whether to use HTML5 (:email, :url, ...)
24
+ # and required attributes
25
+ b.use :html5
26
+
27
+ # Calculates placeholders automatically from I18n
28
+ # You can also pass a string as f.input :placeholder => "Placeholder"
29
+ b.use :placeholder
30
+
31
+ ## Optional extensions
32
+ # They are disabled unless you pass `f.input EXTENSION_NAME => :lookup`
33
+ # to the input. If so, they will retrieve the values from the model
34
+ # if any exists. If you want to enable the lookup for any of those
35
+ # extensions by default, you can change `b.optional` to `b.use`.
36
+
37
+ # Calculates maxlength from length validations for string inputs
38
+ b.optional :maxlength
39
+
40
+ # Calculates pattern from format validations for string inputs
41
+ b.optional :pattern
42
+
43
+ # Calculates min and max from length validations for numeric inputs
44
+ b.optional :min_max
45
+
46
+ # Calculates readonly automatically from readonly attributes
47
+ b.optional :readonly
48
+
49
+ ## Inputs
50
+ b.use :label_input
51
+ b.use :hint, :wrap_with => { :tag => :span, :class => :hint }
52
+ b.use :error, :wrap_with => { :tag => :span, :class => :error }
53
+ end
54
+
55
+ # The default wrapper to be used by the FormBuilder.
56
+ config.default_wrapper = :default
57
+
58
+ # Define the way to render check boxes / radio buttons with labels.
59
+ # Defaults to :nested for bootstrap config.
60
+ # :inline => input + label
61
+ # :nested => label > input
62
+ config.boolean_style = :nested
63
+
64
+ # Default class for buttons
65
+ config.button_class = 'btn'
66
+
67
+ # Method used to tidy up errors. Specify any Rails Array method.
68
+ # :first lists the first message for each field.
69
+ # Use :to_sentence to list all errors for each field.
70
+ # config.error_method = :first
71
+
72
+ # Default tag used for error notification helper.
73
+ config.error_notification_tag = :div
74
+
75
+ # CSS class to add for error notification helper.
76
+ config.error_notification_class = 'alert alert-error'
77
+
78
+ # ID to add for error notification helper.
79
+ # config.error_notification_id = nil
80
+
81
+ # Series of attempts to detect a default label method for collection.
82
+ # config.collection_label_methods = [ :to_label, :name, :title, :to_s ]
83
+
84
+ # Series of attempts to detect a default value method for collection.
85
+ # config.collection_value_methods = [ :id, :to_s ]
86
+
87
+ # You can wrap a collection of radio/check boxes in a pre-defined tag, defaulting to none.
88
+ # config.collection_wrapper_tag = nil
89
+
90
+ # You can define the class to use on all collection wrappers. Defaulting to none.
91
+ # config.collection_wrapper_class = nil
92
+
93
+ # You can wrap each item in a collection of radio/check boxes with a tag,
94
+ # defaulting to :span. Please note that when using :boolean_style = :nested,
95
+ # SimpleForm will force this option to be a label.
96
+ # config.item_wrapper_tag = :span
97
+
98
+ # You can define a class to use in all item wrappers. Defaulting to none.
99
+ # config.item_wrapper_class = nil
100
+
101
+ # How the label text should be generated altogether with the required text.
102
+ # config.label_text = lambda { |label, required| "#{required} #{label}" }
103
+
104
+ # You can define the class to use on all labels. Default is nil.
105
+ config.label_class = 'control-label'
106
+
107
+ # You can define the class to use on all forms. Default is simple_form.
108
+ # config.form_class = :simple_form
109
+
110
+ # You can define which elements should obtain additional classes
111
+ # config.generate_additional_classes_for = [:wrapper, :label, :input]
112
+
113
+ # Whether attributes are required by default (or not). Default is true.
114
+ # config.required_by_default = true
115
+
116
+ # Tell browsers whether to use default HTML5 validations (novalidate option).
117
+ # Default is enabled.
118
+ config.browser_validations = false
119
+
120
+ # Collection of methods to detect if a file type was given.
121
+ # config.file_methods = [ :mounted_as, :file?, :public_filename ]
122
+
123
+ # Custom mappings for input types. This should be a hash containing a regexp
124
+ # to match as key, and the input type that will be used when the field name
125
+ # matches the regexp as value.
126
+ # config.input_mappings = { /count/ => :integer }
127
+
128
+ # Custom wrappers for input types. This should be a hash containing an input
129
+ # type as key and the wrapper that will be used for all inputs with specified type.
130
+ # config.wrapper_mappings = { :string => :prepend }
131
+
132
+ # Default priority for time_zone inputs.
133
+ # config.time_zone_priority = nil
134
+
135
+ # Default priority for country inputs.
136
+ # config.country_priority = nil
137
+
138
+ # Default size for text inputs.
139
+ # config.default_input_size = 50
140
+
141
+ # When false, do not use translations for labels.
142
+ # config.translate_labels = true
143
+
144
+ # Automatically discover new inputs in Rails' autoload path.
145
+ # config.inputs_discovery = true
146
+
147
+ # Cache SimpleForm inputs discovery
148
+ # config.cache_discovery = !Rails.env.development?
149
+ end