enju_trunk_subject 1.0.4

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 (280) hide show
  1. checksums.yaml +15 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README.rdoc +3 -0
  4. data/Rakefile +36 -0
  5. data/app/controllers/classification_types_controller.rb +13 -0
  6. data/app/controllers/classifications_controller.rb +114 -0
  7. data/app/controllers/subject_has_classifications_controller.rb +97 -0
  8. data/app/controllers/subject_heading_type_has_subjects_controller.rb +80 -0
  9. data/app/controllers/subject_heading_types_controller.rb +13 -0
  10. data/app/controllers/subject_types_controller.rb +13 -0
  11. data/app/controllers/subjects_controller.rb +216 -0
  12. data/app/controllers/work_has_subjects_controller.rb +107 -0
  13. data/app/models/classification.rb +89 -0
  14. data/app/models/classification_type.rb +20 -0
  15. data/app/models/enju_subject/ability.rb +55 -0
  16. data/app/models/subject.rb +100 -0
  17. data/app/models/subject_has_classification.rb +37 -0
  18. data/app/models/subject_heading_type.rb +21 -0
  19. data/app/models/subject_heading_type_has_subject.rb +22 -0
  20. data/app/models/subject_type.rb +20 -0
  21. data/app/models/work_has_subject.rb +35 -0
  22. data/app/views/classification_types/_form.html.erb +19 -0
  23. data/app/views/classification_types/edit.html.erb +13 -0
  24. data/app/views/classification_types/index.html.erb +45 -0
  25. data/app/views/classification_types/new.html.erb +12 -0
  26. data/app/views/classification_types/show.html.erb +30 -0
  27. data/app/views/classifications/_form.html.erb +27 -0
  28. data/app/views/classifications/edit.html.erb +13 -0
  29. data/app/views/classifications/index.html.erb +54 -0
  30. data/app/views/classifications/new.html.erb +12 -0
  31. data/app/views/classifications/show.html.erb +34 -0
  32. data/app/views/manifestations/_classification_detail.html.erb +14 -0
  33. data/app/views/manifestations/_subject_detail.html.erb +14 -0
  34. data/app/views/manifestations/_subject_facet.html.erb +18 -0
  35. data/app/views/manifestations/_subject_form.html.erb +21 -0
  36. data/app/views/subject_has_classifications/edit.html.erb +30 -0
  37. data/app/views/subject_has_classifications/index.html.erb +38 -0
  38. data/app/views/subject_has_classifications/new.html.erb +32 -0
  39. data/app/views/subject_has_classifications/show.html.erb +22 -0
  40. data/app/views/subject_heading_type_has_subjects/edit.html.erb +28 -0
  41. data/app/views/subject_heading_type_has_subjects/index.html.erb +30 -0
  42. data/app/views/subject_heading_type_has_subjects/new.html.erb +27 -0
  43. data/app/views/subject_heading_type_has_subjects/show.html.erb +23 -0
  44. data/app/views/subject_heading_types/_form.html.erb +19 -0
  45. data/app/views/subject_heading_types/edit.html.erb +13 -0
  46. data/app/views/subject_heading_types/index.html.erb +43 -0
  47. data/app/views/subject_heading_types/new.html.erb +12 -0
  48. data/app/views/subject_heading_types/show.html.erb +27 -0
  49. data/app/views/subject_types/_form.html.erb +19 -0
  50. data/app/views/subject_types/edit.html.erb +13 -0
  51. data/app/views/subject_types/index.html.erb +43 -0
  52. data/app/views/subject_types/new.html.erb +12 -0
  53. data/app/views/subject_types/show.html.erb +29 -0
  54. data/app/views/subjects/_form.html.erb +42 -0
  55. data/app/views/subjects/_index.html.erb +48 -0
  56. data/app/views/subjects/_index_classification.html.erb +57 -0
  57. data/app/views/subjects/_index_work.html.erb +60 -0
  58. data/app/views/subjects/_show_work_list.html.erb +15 -0
  59. data/app/views/subjects/edit.html.erb +13 -0
  60. data/app/views/subjects/index.atom.builder +10 -0
  61. data/app/views/subjects/index.html.erb +7 -0
  62. data/app/views/subjects/index.rss.builder +29 -0
  63. data/app/views/subjects/new.html.erb +12 -0
  64. data/app/views/subjects/show.html.erb +69 -0
  65. data/app/views/subjects/show.js.erb +1 -0
  66. data/app/views/work_has_subjects/_form.html.erb +24 -0
  67. data/app/views/work_has_subjects/edit.html.erb +29 -0
  68. data/app/views/work_has_subjects/index.html.erb +31 -0
  69. data/app/views/work_has_subjects/new.html.erb +42 -0
  70. data/app/views/work_has_subjects/show.html.erb +25 -0
  71. data/config/locales/translation_en.yml +35 -0
  72. data/config/locales/translation_ja.yml +39 -0
  73. data/config/routes.rb +7 -0
  74. data/db/fixtures/classification_types.yml +7 -0
  75. data/db/fixtures/subject_types.yml +28 -0
  76. data/db/migrate/029_create_subjects.rb +28 -0
  77. data/db/migrate/142_create_classifications.rb +19 -0
  78. data/db/migrate/144_create_classification_types.rb +16 -0
  79. data/db/migrate/145_create_subject_heading_types.rb +16 -0
  80. data/db/migrate/146_create_subject_types.rb +16 -0
  81. data/db/migrate/20110913120629_add_lft_and_rgt_to_classification.rb +11 -0
  82. data/db/migrate/20140427142354_add_classifiation_identifier_to_classification.rb +6 -0
  83. data/lib/enju_subject.rb +33 -0
  84. data/lib/enju_subject/engine.rb +8 -0
  85. data/lib/enju_subject/manifestation.rb +31 -0
  86. data/lib/enju_subject/master_model.rb +41 -0
  87. data/lib/enju_subject/version.rb +3 -0
  88. data/lib/generators/enju_subject/setup/USAGE +8 -0
  89. data/lib/generators/enju_subject/setup/setup_generator.rb +10 -0
  90. data/lib/generators/enju_subject/setup/templates/db/fixtures/classification_types.yml +13 -0
  91. data/lib/generators/enju_subject/setup/templates/db/fixtures/subject_heading_types.yml +39 -0
  92. data/lib/generators/enju_subject/setup/templates/db/fixtures/subject_types.yml +28 -0
  93. data/lib/tasks/enju_subject_tasks.rake +19 -0
  94. data/spec/controllers/classification_types_controller_spec.rb +445 -0
  95. data/spec/controllers/classifications_controller_spec.rb +441 -0
  96. data/spec/controllers/subject_heading_types_controller_spec.rb +445 -0
  97. data/spec/controllers/subject_types_controller_spec.rb +447 -0
  98. data/spec/controllers/subjects_controller_spec.rb +437 -0
  99. data/spec/dummy/Rakefile +7 -0
  100. data/spec/dummy/app/assets/javascripts/application.js +9 -0
  101. data/spec/dummy/app/assets/stylesheets/application.css +7 -0
  102. data/spec/dummy/app/controllers/application_controller.rb +47 -0
  103. data/spec/dummy/app/helpers/application_helper.rb +21 -0
  104. data/spec/dummy/app/models/ability.rb +59 -0
  105. data/spec/dummy/app/models/setting.rb +4 -0
  106. data/spec/dummy/app/models/user.rb +43 -0
  107. data/spec/dummy/app/views/layouts/application.html.erb +14 -0
  108. data/spec/dummy/config.ru +4 -0
  109. data/spec/dummy/config/application.rb +46 -0
  110. data/spec/dummy/config/application.yml +38 -0
  111. data/spec/dummy/config/boot.rb +10 -0
  112. data/spec/dummy/config/database.yml +25 -0
  113. data/spec/dummy/config/environment.rb +5 -0
  114. data/spec/dummy/config/environments/development.rb +30 -0
  115. data/spec/dummy/config/environments/production.rb +60 -0
  116. data/spec/dummy/config/environments/test.rb +39 -0
  117. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  118. data/spec/dummy/config/initializers/devise.rb +207 -0
  119. data/spec/dummy/config/initializers/inflections.rb +10 -0
  120. data/spec/dummy/config/initializers/mime_types.rb +5 -0
  121. data/spec/dummy/config/initializers/secret_token.rb +7 -0
  122. data/spec/dummy/config/initializers/session_store.rb +8 -0
  123. data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
  124. data/spec/dummy/config/locales/devise.en.yml +57 -0
  125. data/spec/dummy/config/locales/en.yml +18 -0
  126. data/spec/dummy/config/locales/ja.yml +18 -0
  127. data/spec/dummy/config/routes.rb +60 -0
  128. data/spec/dummy/db/fixtures/roles.yml +25 -0
  129. data/spec/dummy/db/migrate/001_create_agents.rb +53 -0
  130. data/spec/dummy/db/migrate/005_create_manifestations.rb +56 -0
  131. data/spec/dummy/db/migrate/006_create_items.rb +24 -0
  132. data/spec/dummy/db/migrate/012_create_owns.rb +12 -0
  133. data/spec/dummy/db/migrate/015_create_creates.rb +12 -0
  134. data/spec/dummy/db/migrate/047_create_produces.rb +12 -0
  135. data/spec/dummy/db/migrate/059_create_libraries.rb +28 -0
  136. data/spec/dummy/db/migrate/069_create_shelves.rb +15 -0
  137. data/spec/dummy/db/migrate/073_create_carrier_types.rb +11 -0
  138. data/spec/dummy/db/migrate/077_create_user_groups.rb +12 -0
  139. data/spec/dummy/db/migrate/080_create_library_groups.rb +18 -0
  140. data/spec/dummy/db/migrate/112_create_frequencies.rb +12 -0
  141. data/spec/dummy/db/migrate/117_create_form_of_works.rb +12 -0
  142. data/spec/dummy/db/migrate/120_create_baskets.rb +12 -0
  143. data/spec/dummy/db/migrate/124_create_bookstores.rb +17 -0
  144. data/spec/dummy/db/migrate/125_create_donates.rb +12 -0
  145. data/spec/dummy/db/migrate/130_create_request_status_types.rb +12 -0
  146. data/spec/dummy/db/migrate/131_create_request_types.rb +12 -0
  147. data/spec/dummy/db/migrate/20080830154109_create_realizes.rb +13 -0
  148. data/spec/dummy/db/migrate/20080830172106_create_exemplifies.rb +13 -0
  149. data/spec/dummy/db/migrate/20080905191442_create_agent_types.rb +12 -0
  150. data/spec/dummy/db/migrate/20081006090811_create_subscriptions.rb +17 -0
  151. data/spec/dummy/db/migrate/20081006093246_create_subscribes.rb +14 -0
  152. data/spec/dummy/db/migrate/20081023092436_create_search_engines.rb +17 -0
  153. data/spec/dummy/db/migrate/20081025083323_create_countries.rb +28 -0
  154. data/spec/dummy/db/migrate/20081025083905_create_languages.rb +23 -0
  155. data/spec/dummy/db/migrate/20081027150907_create_picture_files.rb +15 -0
  156. data/spec/dummy/db/migrate/20081028083142_create_agent_import_files.rb +22 -0
  157. data/spec/dummy/db/migrate/20081028083208_create_resource_import_files.rb +22 -0
  158. data/spec/dummy/db/migrate/20090705133942_add_attachments_picture_to_picture_file.rb +15 -0
  159. data/spec/dummy/db/migrate/20090705212043_add_attachments_attachment_to_manifestation.rb +15 -0
  160. data/spec/dummy/db/migrate/20090719201843_create_extents.rb +12 -0
  161. data/spec/dummy/db/migrate/20090720091106_create_medium_of_performances.rb +12 -0
  162. data/spec/dummy/db/migrate/20090720091429_create_content_types.rb +12 -0
  163. data/spec/dummy/db/migrate/20090812151902_create_agent_relationship_types.rb +12 -0
  164. data/spec/dummy/db/migrate/20091012101112_add_dcndl_schema.rb +27 -0
  165. data/spec/dummy/db/migrate/20091025080447_create_licenses.rb +12 -0
  166. data/spec/dummy/db/migrate/20091202124834_create_versions.rb +18 -0
  167. data/spec/dummy/db/migrate/20091214131723_create_series_statements.rb +13 -0
  168. data/spec/dummy/db/migrate/20100129142347_create_import_requests.rb +15 -0
  169. data/spec/dummy/db/migrate/20100211105551_add_admin_networks_to_library_group.rb +9 -0
  170. data/spec/dummy/db/migrate/20100223121519_rename_series_statement_title_to_original_title.rb +13 -0
  171. data/spec/dummy/db/migrate/20100321235924_add_series_statement_identifier_to_series_statement.rb +10 -0
  172. data/spec/dummy/db/migrate/20100525124311_create_manifestation_relationships.rb +13 -0
  173. data/spec/dummy/db/migrate/20100606073747_create_agent_relationships.rb +13 -0
  174. data/spec/dummy/db/migrate/20100607044753_create_manifestation_relationship_types.rb +12 -0
  175. data/spec/dummy/db/migrate/20100814091104_add_position_to_agent_relationship.rb +11 -0
  176. data/spec/dummy/db/migrate/20100925043847_create_resource_import_results.rb +15 -0
  177. data/spec/dummy/db/migrate/20100925074559_create_agent_import_results.rb +12 -0
  178. data/spec/dummy/db/migrate/20101212070145_add_acquired_at_to_item.rb +9 -0
  179. data/spec/dummy/db/migrate/20110222073537_add_url_to_library_group.rb +9 -0
  180. data/spec/dummy/db/migrate/20110301035123_add_pub_date_to_manifestation.rb +9 -0
  181. data/spec/dummy/db/migrate/20110301121550_add_birth_date_and_death_date_to_agent.rb +11 -0
  182. data/spec/dummy/db/migrate/20110425133109_add_issn_to_series_statement.rb +9 -0
  183. data/spec/dummy/db/migrate/20110603184217_add_edit_mode_to_resource_import_file.rb +9 -0
  184. data/spec/dummy/db/migrate/20110618091240_add_periodical_to_series_statement.rb +9 -0
  185. data/spec/dummy/db/migrate/20110619064807_add_edition_string_to_manifestation.rb +9 -0
  186. data/spec/dummy/db/migrate/20110620173525_add_bookstore_id_to_item.rb +11 -0
  187. data/spec/dummy/db/migrate/20110627034940_create_series_statement_merge_lists.rb +9 -0
  188. data/spec/dummy/db/migrate/20110627035057_create_series_statement_merges.rb +12 -0
  189. data/spec/dummy/db/migrate/20110627122938_add_number_of_day_to_notify_overdue_to_user_group.rb +13 -0
  190. data/spec/dummy/db/migrate/20110820131417_create_series_has_manifestations.rb +13 -0
  191. data/spec/dummy/db/migrate/20110916053430_rename_manifestation_number_list_to_number_string.rb +13 -0
  192. data/spec/dummy/db/migrate/20110916091020_add_volume_number_to_manifestation.rb +13 -0
  193. data/spec/dummy/db/migrate/20110916103953_add_manifestaiton_id_to_series_statement.rb +10 -0
  194. data/spec/dummy/db/migrate/20110918162329_add_note_to_series_statement.rb +9 -0
  195. data/spec/dummy/db/migrate/20111009183423_add_ndc_to_manifestation.rb +9 -0
  196. data/spec/dummy/db/migrate/20111124110059_create_create_types.rb +12 -0
  197. data/spec/dummy/db/migrate/20111124110319_create_realize_types.rb +12 -0
  198. data/spec/dummy/db/migrate/20111124110355_create_produce_types.rb +12 -0
  199. data/spec/dummy/db/migrate/20111124112131_add_create_type_to_create.rb +7 -0
  200. data/spec/dummy/db/migrate/20111201121844_create_roles.rb +12 -0
  201. data/spec/dummy/db/migrate/20111201155456_create_users.rb +8 -0
  202. data/spec/dummy/db/migrate/20111201155513_add_devise_to_users.rb +49 -0
  203. data/spec/dummy/db/migrate/20111201163718_create_user_has_roles.rb +10 -0
  204. data/spec/dummy/db/migrate/20120105074911_add_isil_to_library.rb +5 -0
  205. data/spec/dummy/db/migrate/20120125152919_add_title_subseries_transcription_to_series_statement.rb +6 -0
  206. data/spec/dummy/db/migrate/20120129014038_create_budget_types.rb +12 -0
  207. data/spec/dummy/db/migrate/20120129020544_add_budget_type_id_to_item.rb +6 -0
  208. data/spec/dummy/db/migrate/20120319120638_add_content_type_id_to_manifestation.rb +6 -0
  209. data/spec/dummy/db/migrate/20120319173203_create_accepts.rb +14 -0
  210. data/spec/dummy/db/migrate/20120410104851_add_year_of_publication_to_manifestation.rb +5 -0
  211. data/spec/dummy/db/migrate/20120413072700_add_picture_meta_to_picture_file.rb +5 -0
  212. data/spec/dummy/db/migrate/20120413100352_add_fingerprint_to_picture_file.rb +5 -0
  213. data/spec/dummy/db/migrate/20120413161340_add_fingerprint_to_resource_import_file.rb +5 -0
  214. data/spec/dummy/db/migrate/20120413161403_add_fingerprint_to_agent_import_file.rb +5 -0
  215. data/spec/dummy/db/migrate/20120413170705_add_error_message_to_resource_import_file.rb +5 -0
  216. data/spec/dummy/db/migrate/20120413170720_add_error_message_to_agent_import_file.rb +5 -0
  217. data/spec/dummy/db/migrate/20120415060308_rename_resource_import_file_imported_at_to_executed_at.rb +9 -0
  218. data/spec/dummy/db/migrate/20120415164821_add_attachment_meta_to_manifestation.rb +5 -0
  219. data/spec/dummy/db/migrate/20120418081407_add_month_of_publication_to_manifestation.rb +5 -0
  220. data/spec/dummy/db/migrate/20120510140958_add_closed_to_shelf.rb +5 -0
  221. data/spec/dummy/db/migrate/20120511072422_add_agent_identifier_to_agent.rb +6 -0
  222. data/spec/dummy/db/migrate/20120602141129_add_edit_mode_to_agent_import_file.rb +5 -0
  223. data/spec/dummy/db/migrate/20130221154434_add_additional_attributes_to_user.rb +26 -0
  224. data/spec/dummy/db/migrate/20130421093852_add_periodical_to_manifestation.rb +5 -0
  225. data/spec/dummy/db/migrate/20130421155019_add_creator_string_to_series_statement.rb +7 -0
  226. data/spec/dummy/db/migrate/20130421164124_add_series_master_to_series_statement.rb +5 -0
  227. data/spec/dummy/db/migrate/20130506175303_create_identifier_types.rb +12 -0
  228. data/spec/dummy/db/migrate/20130506175834_create_identifiers.rb +15 -0
  229. data/spec/dummy/db/migrate/20130509185724_add_statement_of_responsibility_to_manifestation.rb +5 -0
  230. data/spec/dummy/db/schema.rb +901 -0
  231. data/spec/dummy/db/seeds.rb +32 -0
  232. data/spec/dummy/public/404.html +26 -0
  233. data/spec/dummy/public/422.html +26 -0
  234. data/spec/dummy/public/500.html +26 -0
  235. data/spec/dummy/public/favicon.ico +0 -0
  236. data/spec/dummy/script/rails +6 -0
  237. data/spec/dummy/spec/fixtures/subjects.yml +72 -0
  238. data/spec/dummy/test/fixtures/user_groups.yml +13 -0
  239. data/spec/dummy/test/fixtures/user_has_roles.yml +9 -0
  240. data/spec/dummy/test/fixtures/users.yml +11 -0
  241. data/spec/dummy/test/unit/user_group_test.rb +7 -0
  242. data/spec/dummy/test/unit/user_has_role_test.rb +7 -0
  243. data/spec/dummy/test/unit/user_test.rb +7 -0
  244. data/spec/factories/classification.rb +6 -0
  245. data/spec/factories/classification_type.rb +5 -0
  246. data/spec/factories/manifestation.rb +6 -0
  247. data/spec/factories/subject.rb +7 -0
  248. data/spec/factories/subject_heading_type.rb +5 -0
  249. data/spec/factories/subject_heading_type_has_subject.rb +6 -0
  250. data/spec/factories/subject_type.rb +5 -0
  251. data/spec/factories/user.rb +34 -0
  252. data/spec/fixtures/agent_types.yml +35 -0
  253. data/spec/fixtures/agents.yml +143 -0
  254. data/spec/fixtures/carrier_types.yml +51 -0
  255. data/spec/fixtures/classification_types.yml +188 -0
  256. data/spec/fixtures/classifications.yml +118 -0
  257. data/spec/fixtures/languages.yml +1901 -0
  258. data/spec/fixtures/library_groups.yml +33 -0
  259. data/spec/fixtures/manifestations.yml +22 -0
  260. data/spec/fixtures/roles.yml +21 -0
  261. data/spec/fixtures/shtsv.tsv +3 -0
  262. data/spec/fixtures/subject_heading_types.yml +39 -0
  263. data/spec/fixtures/subject_types.yml +42 -0
  264. data/spec/fixtures/subjects.yml +80 -0
  265. data/spec/fixtures/user_groups.yml +25 -0
  266. data/spec/fixtures/user_has_roles.yml +41 -0
  267. data/spec/fixtures/users.yml +69 -0
  268. data/spec/models/classification_spec.rb +46 -0
  269. data/spec/models/classification_type_spec.rb +21 -0
  270. data/spec/models/subject_heading_type_spec.rb +21 -0
  271. data/spec/models/subject_spec.rb +33 -0
  272. data/spec/models/subject_type_spec.rb +21 -0
  273. data/spec/requests/subjects_spec.rb +9 -0
  274. data/spec/routing/subject_heading_types_routing_spec.rb +35 -0
  275. data/spec/routing/subject_types_routing_spec.rb +35 -0
  276. data/spec/routing/subjects_routing_spec.rb +35 -0
  277. data/spec/spec_helper.rb +45 -0
  278. data/spec/support/controller_macros.rb +48 -0
  279. data/spec/support/devise.rb +3 -0
  280. metadata +675 -0
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env rake
2
+ # Add your own tasks in files placed in lib/tasks ending in .rake,
3
+ # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
4
+
5
+ require File.expand_path('../config/application', __FILE__)
6
+
7
+ Dummy::Application.load_tasks
@@ -0,0 +1,9 @@
1
+ // This is a manifest file that'll be compiled into including all the files listed below.
2
+ // Add new JavaScript/Coffee code in separate files in this directory and they'll automatically
3
+ // be included in the compiled file accessible from http://example.com/assets/application.js
4
+ // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
5
+ // the compiled file.
6
+ //
7
+ //= require jquery
8
+ //= require jquery_ujs
9
+ //= require_tree .
@@ -0,0 +1,7 @@
1
+ /*
2
+ * This is a manifest file that'll automatically include all the stylesheets available in this directory
3
+ * and any sub-directories. You're free to add application-wide styles to this file and they'll appear at
4
+ * the top of the compiled file, but it's generally better to create a new file per style scope.
5
+ *= require_self
6
+ *= require_tree .
7
+ */
@@ -0,0 +1,47 @@
1
+ class ApplicationController < ActionController::Base
2
+ protect_from_forgery
3
+ rescue_from CanCan::AccessDenied, :with => :render_403
4
+ rescue_from ActiveRecord::RecordNotFound, :with => :render_404
5
+
6
+ enju_biblio
7
+ enju_subject
8
+
9
+ private
10
+ def render_403
11
+ return if performed?
12
+ if user_signed_in?
13
+ respond_to do |format|
14
+ format.html {render :file => "#{Rails.root}/public/404", :status => 403}
15
+ format.xml
16
+ format.json
17
+ end
18
+ else
19
+ respond_to do |format|
20
+ format.html {redirect_to new_user_session_url}
21
+ format.xml {render :status => 403}
22
+ format.json
23
+ end
24
+ end
25
+ end
26
+
27
+ def render_404
28
+ return if performed?
29
+ respond_to do |format|
30
+ format.html {render :file => "#{Rails.root}/public/404", :status => 404}
31
+ format.xml
32
+ format.json
33
+ end
34
+ end
35
+
36
+ def solr_commit
37
+ Sunspot.commit
38
+ end
39
+
40
+ def move_position(resource, direction)
41
+ if ['higher', 'lower'].include?(direction)
42
+ resource.send("move_#{direction}")
43
+ redirect_to url_for(:controller => resource.class.to_s.pluralize.underscore)
44
+ return
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,21 @@
1
+ module ApplicationHelper
2
+ def back_to_index(options = {})
3
+ if options == nil
4
+ options = {}
5
+ else
6
+ options.reject!{|key, value| value.blank?}
7
+ options.delete(:page) if options[:page].to_i == 1
8
+ end
9
+ unless controller_name == 'test'
10
+ link_to t('page.listing', :model => t("activerecord.models.#{controller_name.singularize}")), url_for(params.merge(:controller => controller_name, :action => :index, :id => nil).merge(options))
11
+ end
12
+ end
13
+
14
+ def link_to_wikipedia(string)
15
+ link_to "Wikipedia", "http://#{I18n.locale}.wikipedia.org/wiki/#{URI.escape(string)}"
16
+ end
17
+
18
+ def current_user_role_name
19
+ current_user.try(:role).try(:name) || 'Guest'
20
+ end
21
+ end
@@ -0,0 +1,59 @@
1
+ #module EnjuSubject
2
+ class Ability
3
+ include CanCan::Ability
4
+
5
+ def initialize(user, ip_address = '0.0.0.0')
6
+ case user.try(:role).try(:name)
7
+ when 'Administrator'
8
+ can :manage, [
9
+ Classification,
10
+ Subject
11
+ ]
12
+ if LibraryGroup.site_config.network_access_allowed?(ip_address)
13
+ can [:read, :create, :update], ClassificationType
14
+ can [:destroy, :delete], ClassificationType do |classification_type|
15
+ classification_type.classifications.empty?
16
+ end
17
+ can :manage, [
18
+ Classification,
19
+ Subject,
20
+ SubjectHeadingType,
21
+ SubjectType
22
+ ]
23
+ else
24
+ can :read, [
25
+ ClassificationType,
26
+ SubjectHeadingType,
27
+ SubjectType
28
+ ]
29
+ end
30
+ can :read, Manifestation
31
+ when 'Librarian'
32
+ can :read, [
33
+ Classification,
34
+ ClassificationType,
35
+ Subject,
36
+ SubjectType,
37
+ SubjectHeadingType
38
+ ]
39
+ can :read, Manifestation
40
+ when 'User'
41
+ can :read, [
42
+ Classification,
43
+ ClassificationType,
44
+ Subject,
45
+ SubjectHeadingType
46
+ ]
47
+ can :read, Manifestation
48
+ else
49
+ can :read, [
50
+ Classification,
51
+ ClassificationType,
52
+ Subject,
53
+ SubjectHeadingType
54
+ ]
55
+ can :read, Manifestation
56
+ end
57
+ end
58
+ end
59
+ #end
@@ -0,0 +1,4 @@
1
+ class Setting < Settingslogic
2
+ source "#{Rails.root}/config/application.yml"
3
+ namespace Rails.env
4
+ end
@@ -0,0 +1,43 @@
1
+ class User < ActiveRecord::Base
2
+ # Include default devise modules. Others available are:
3
+ # :token_authenticatable, :encryptable, :confirmable, :lockable, :timeoutable and :omniauthable
4
+ devise :database_authenticatable, :registerable,
5
+ :recoverable, :rememberable, :trackable, :validatable
6
+
7
+ # Setup accessible (or protected) attributes for your model
8
+ attr_accessible :email, :password, :password_confirmation, :remember_me
9
+
10
+ has_one :user_has_role
11
+ has_one :role, :through => :user_has_role
12
+ belongs_to :user_group
13
+ belongs_to :required_role, :class_name => 'Role', :foreign_key => 'required_role_id'
14
+ has_many :sent_messages, :foreign_key => 'sender_id', :class_name => 'Message'
15
+ has_many :received_messages, :foreign_key => 'receiver_id', :class_name => 'Message'
16
+
17
+ extend FriendlyId
18
+ friendly_id :username
19
+
20
+ def send_message(status, options = {})
21
+ MessageRequest.transaction do
22
+ request = MessageRequest.new
23
+ request.sender = User.find(1)
24
+ request.receiver = self
25
+ request.message_template = MessageTemplate.localized_template(status, self.locale)
26
+ request.save_message_body(options)
27
+ request.sm_send_message!
28
+ end
29
+ end
30
+
31
+ def has_role?(role_in_question)
32
+ return false unless role
33
+ return true if role.name == role_in_question
34
+ case role.name
35
+ when 'Administrator'
36
+ return true
37
+ when 'Librarian'
38
+ return true if role_in_question == 'User'
39
+ else
40
+ false
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,14 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>Dummy</title>
5
+ <%= stylesheet_link_tag "application" %>
6
+ <%= javascript_include_tag "application" %>
7
+ <%= csrf_meta_tags %>
8
+ </head>
9
+ <body>
10
+
11
+ <%= yield %>
12
+
13
+ </body>
14
+ </html>
@@ -0,0 +1,4 @@
1
+ # This file is used by Rack-based servers to start the application.
2
+
3
+ require ::File.expand_path('../config/environment', __FILE__)
4
+ run Dummy::Application
@@ -0,0 +1,46 @@
1
+ require File.expand_path('../boot', __FILE__)
2
+
3
+ require 'rails/all'
4
+
5
+ Bundler.require
6
+ require "enju_subject"
7
+
8
+ module Dummy
9
+ class Application < Rails::Application
10
+ # Settings in config/environments/* take precedence over those specified here.
11
+ # Application configuration should go into files in config/initializers
12
+ # -- all .rb files in that directory are automatically loaded.
13
+
14
+ # Custom directories with classes and modules you want to be autoloadable.
15
+ # config.autoload_paths += %W(#{config.root}/extras)
16
+
17
+ # Only load the plugins named here, in the order given (default is alphabetical).
18
+ # :all can be used as a placeholder for all plugins not explicitly named.
19
+ # config.plugins = [ :exception_notification, :ssl_requirement, :all ]
20
+
21
+ # Activate observers that should always be running.
22
+ # config.active_record.observers = :cacher, :garbage_collector, :forum_observer
23
+
24
+ # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
25
+ # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
26
+ # config.time_zone = 'Central Time (US & Canada)'
27
+
28
+ # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
29
+ # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
30
+ # config.i18n.default_locale = :de
31
+
32
+ # Configure the default encoding used in templates for Ruby 1.9.
33
+ config.encoding = "utf-8"
34
+
35
+ # Configure sensitive parameters which will be filtered from the log file.
36
+ config.filter_parameters += [:password]
37
+
38
+ # Enable the asset pipeline
39
+ config.assets.enabled = true
40
+
41
+ # Version of your assets, change this if you want to expire all your assets
42
+ config.assets.version = '1.0'
43
+ end
44
+ end
45
+
46
+ require 'enju_biblio'
@@ -0,0 +1,38 @@
1
+ defaults: &defaults
2
+ enju:
3
+ web_hostname: localhost
4
+ web_port_number: 3000
5
+
6
+ family_name_first: true
7
+ max_number_of_results: 500
8
+ write_search_log_to_file: true
9
+ csv_charset_conversion: true
10
+
11
+ # Choose a locale from 'ca', 'de', 'fr', 'jp', 'uk', 'us'
12
+ #AMAZON_AWS_HOSTNAME = 'ecs.amazonaws.com'
13
+ amazon:
14
+ aws_hostname: ecs.amazonaws.jp
15
+ hostname: www.amazon.co.jp
16
+ access_key: REPLACE_WITH_YOUR_AMAZON_ACCESS_KEY
17
+ secret_access_key: REPLACE_WITH_YOUR_AMAZON_SECRET_ACCESS_KEY
18
+
19
+ # :google, :amazon
20
+ book_jacket:
21
+ source: :google
22
+ unknown_resource:
23
+
24
+ # :mozshot, :simpleapi, :heartrails, :thumbalizr
25
+ screenshot:
26
+ generator: :mozshot
27
+
28
+ uploaded_file:
29
+ storage: :local
30
+
31
+ development:
32
+ <<: *defaults
33
+
34
+ test:
35
+ <<: *defaults
36
+
37
+ production:
38
+ <<: *defaults
@@ -0,0 +1,10 @@
1
+ require 'rubygems'
2
+ gemfile = File.expand_path('../../../../Gemfile', __FILE__)
3
+
4
+ if File.exist?(gemfile)
5
+ ENV['BUNDLE_GEMFILE'] = gemfile
6
+ require 'bundler'
7
+ Bundler.setup
8
+ end
9
+
10
+ $:.unshift File.expand_path('../../../../lib', __FILE__)
@@ -0,0 +1,25 @@
1
+ # SQLite version 3.x
2
+ # gem install sqlite3
3
+ #
4
+ # Ensure the SQLite 3 gem is defined in your Gemfile
5
+ # gem 'sqlite3'
6
+ development:
7
+ adapter: sqlite3
8
+ database: db/development.sqlite3
9
+ pool: 5
10
+ timeout: 5000
11
+
12
+ # Warning: The database defined as "test" will be erased and
13
+ # re-generated from your development database when you run "rake".
14
+ # Do not set this db to the same as development or production.
15
+ test:
16
+ adapter: sqlite3
17
+ database: db/test.sqlite3
18
+ pool: 5
19
+ timeout: 5000
20
+
21
+ production:
22
+ adapter: sqlite3
23
+ database: db/production.sqlite3
24
+ pool: 5
25
+ timeout: 5000
@@ -0,0 +1,5 @@
1
+ # Load the rails application
2
+ require File.expand_path('../application', __FILE__)
3
+
4
+ # Initialize the rails application
5
+ Dummy::Application.initialize!
@@ -0,0 +1,30 @@
1
+ Dummy::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
+ # Log error messages when you accidentally call methods on nil.
10
+ config.whiny_nils = true
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
+ # Only use best-standards-support built into browsers
23
+ config.action_dispatch.best_standards_support = :builtin
24
+
25
+ # Do not compress assets
26
+ config.assets.compress = false
27
+
28
+ # Expands the lines which load the assets
29
+ config.assets.debug = true
30
+ end
@@ -0,0 +1,60 @@
1
+ Dummy::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
+ # Full error reports are disabled and caching is turned on
8
+ config.consider_all_requests_local = false
9
+ config.action_controller.perform_caching = true
10
+
11
+ # Disable Rails's static asset server (Apache or nginx will already do this)
12
+ config.serve_static_assets = false
13
+
14
+ # Compress JavaScripts and CSS
15
+ config.assets.compress = true
16
+
17
+ # Don't fallback to assets pipeline if a precompiled asset is missed
18
+ config.assets.compile = false
19
+
20
+ # Generate digests for assets URLs
21
+ config.assets.digest = true
22
+
23
+ # Defaults to Rails.root.join("public/assets")
24
+ # config.assets.manifest = YOUR_PATH
25
+
26
+ # Specifies the header that your server uses for sending files
27
+ # config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache
28
+ # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx
29
+
30
+ # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
31
+ # config.force_ssl = true
32
+
33
+ # See everything in the log (default is :info)
34
+ # config.log_level = :debug
35
+
36
+ # Use a different logger for distributed setups
37
+ # config.logger = SyslogLogger.new
38
+
39
+ # Use a different cache store in production
40
+ # config.cache_store = :mem_cache_store
41
+
42
+ # Enable serving of images, stylesheets, and JavaScripts from an asset server
43
+ # config.action_controller.asset_host = "http://assets.example.com"
44
+
45
+ # Precompile additional assets (application.js, application.css, and all non-JS/CSS are already added)
46
+ # config.assets.precompile += %w( search.js )
47
+
48
+ # Disable delivery errors, bad email addresses will be ignored
49
+ # config.action_mailer.raise_delivery_errors = false
50
+
51
+ # Enable threaded mode
52
+ # config.threadsafe!
53
+
54
+ # Enable locale fallbacks for I18n (makes lookups for any locale fall back to
55
+ # the I18n.default_locale when a translation can not be found)
56
+ config.i18n.fallbacks = true
57
+
58
+ # Send deprecation notices to registered listeners
59
+ config.active_support.deprecation = :notify
60
+ end