hydra-head 3.0.0pre1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (366) hide show
  1. data/.gitignore +71 -0
  2. data/.gitmodules +6 -0
  3. data/Gemfile +4 -0
  4. data/Gemfile.lock +257 -0
  5. data/README.textile +150 -0
  6. data/README_RAILS3_CHANGES.textile +42 -0
  7. data/Rakefile +5 -0
  8. data/TESTING.textile +85 -0
  9. data/app/controllers/assets_controller.rb +117 -0
  10. data/app/controllers/contributors_controller.rb +54 -0
  11. data/app/controllers/file_assets_controller.rb +152 -0
  12. data/app/controllers/permissions_controller.rb +137 -0
  13. data/app/controllers/user_sessions_controller.rb +14 -0
  14. data/app/helpers/article_metadata_helper.rb +80 -0
  15. data/app/helpers/blacklight_helper.rb +192 -0
  16. data/app/helpers/downloads_helper.rb +19 -0
  17. data/app/helpers/generic_content_objects_helper.rb +16 -0
  18. data/app/helpers/hydra_assets_helper.rb +75 -0
  19. data/app/helpers/hydra_djatoka_helper.rb +23 -0
  20. data/app/helpers/hydra_fedora_metadata_helper.rb +365 -0
  21. data/app/helpers/hydra_helper.rb +155 -0
  22. data/app/helpers/hydra_uploader_helper.rb +18 -0
  23. data/app/helpers/inline_editable_metadata_helper.rb +15 -0
  24. data/app/helpers/javascript_includes_helper.rb +93 -0
  25. data/app/helpers/release_process_helper.rb +32 -0
  26. data/app/models/audio_asset.rb +8 -0
  27. data/app/models/file_asset.rb +111 -0
  28. data/app/models/generic_content.rb +21 -0
  29. data/app/models/generic_image.rb +62 -0
  30. data/app/models/image_asset.rb +8 -0
  31. data/app/models/mods_asset.rb +6 -0
  32. data/app/models/role_mapper.rb +22 -0
  33. data/app/models/superuser.rb +6 -0
  34. data/app/models/video_asset.rb +8 -0
  35. data/app/views/_add_assets_links.html.erb +13 -0
  36. data/app/views/_brown_sidebar.html +15 -0
  37. data/app/views/_user_util_links.html.erb +31 -0
  38. data/app/views/catalog/_citation.html.erb +11 -0
  39. data/app/views/catalog/_constraints_element.html.erb +34 -0
  40. data/app/views/catalog/_delete_partials/_default.html.erb +29 -0
  41. data/app/views/catalog/_document_list.html.erb +11 -0
  42. data/app/views/catalog/_edit_partials/_default.html.erb +64 -0
  43. data/app/views/catalog/_edit_partials/_default_details.html.erb +15 -0
  44. data/app/views/catalog/_email_form.html.erb +9 -0
  45. data/app/views/catalog/_facets.html.erb +37 -0
  46. data/app/views/catalog/_flash_msg.html.erb +17 -0
  47. data/app/views/catalog/_home.html.erb +6 -0
  48. data/app/views/catalog/_home_text.html.erb +10 -0
  49. data/app/views/catalog/_index_partials/_default.html.erb +20 -0
  50. data/app/views/catalog/_index_partials/_default_details.html.erb +11 -0
  51. data/app/views/catalog/_index_partials/_default_group.html.erb +15 -0
  52. data/app/views/catalog/_search_form.html.erb +12 -0
  53. data/app/views/catalog/_show_partials/_default.html.erb +23 -0
  54. data/app/views/catalog/_show_partials/_default_details.html.erb +12 -0
  55. data/app/views/catalog/_show_partials/_facets.html.erb +52 -0
  56. data/app/views/catalog/_sms_form.html.erb +21 -0
  57. data/app/views/catalog/_sort_and_per_page.html.erb +22 -0
  58. data/app/views/catalog/_uva_tabs.html.erb +10 -0
  59. data/app/views/catalog/about.html.erb +0 -0
  60. data/app/views/catalog/show.html.erb +48 -0
  61. data/app/views/contributors/_add_contributor_split_button.html.erb +10 -0
  62. data/app/views/contributors/_edit_conference.html.erb +29 -0
  63. data/app/views/contributors/_edit_organization.html.erb +29 -0
  64. data/app/views/contributors/_edit_person.html.erb +42 -0
  65. data/app/views/contributors/_index.html.erb +12 -0
  66. data/app/views/contributors/_new.html.erb +10 -0
  67. data/app/views/contributors/_show_conference.html.erb +22 -0
  68. data/app/views/contributors/_show_organization.html.erb +29 -0
  69. data/app/views/contributors/_show_person.html.erb +17 -0
  70. data/app/views/contributors/new.html.erb +13 -0
  71. data/app/views/downloads/index.html.erb +1 -0
  72. data/app/views/file_assets/_deletable_result.html.erb +5 -0
  73. data/app/views/file_assets/_index.html.erb +15 -0
  74. data/app/views/file_assets/_new.html.erb +2 -0
  75. data/app/views/file_assets/_result.html.erb +16 -0
  76. data/app/views/file_assets/index.html.erb +5 -0
  77. data/app/views/fluid_infusion/_uploader.html.erb +81 -0
  78. data/app/views/fluid_infusion/_uploader_generic_content_objects.js.erb +38 -0
  79. data/app/views/fluid_infusion/_uploader_js.erb +45 -0
  80. data/app/views/generic_content_objects/_edit_description.html.erb +50 -0
  81. data/app/views/generic_content_objects/_new.html.erb +0 -0
  82. data/app/views/generic_content_objects/_show_description.html.erb +68 -0
  83. data/app/views/generic_content_objects/contributors/_edit_conference.html.erb +29 -0
  84. data/app/views/generic_content_objects/contributors/_edit_organization.html.erb +29 -0
  85. data/app/views/generic_content_objects/contributors/_edit_person.html.erb +37 -0
  86. data/app/views/generic_content_objects/contributors/_new.html.erb +10 -0
  87. data/app/views/generic_content_objects/contributors/_show_conference.html.erb +22 -0
  88. data/app/views/generic_content_objects/contributors/_show_organization.html.erb +22 -0
  89. data/app/views/generic_content_objects/contributors/_show_person.html.erb +38 -0
  90. data/app/views/generic_contents/_edit.html.erb +59 -0
  91. data/app/views/generic_contents/_index.html.erb +23 -0
  92. data/app/views/generic_contents/_show.html.erb +18 -0
  93. data/app/views/generic_contents/_show_content.html.erb +4 -0
  94. data/app/views/generic_images/_edit.html.erb +59 -0
  95. data/app/views/generic_images/_index.html.erb +24 -0
  96. data/app/views/generic_images/_show.html.erb +18 -0
  97. data/app/views/generic_images/_show_all.html.erb +14 -0
  98. data/app/views/generic_images/_show_content.html.erb +7 -0
  99. data/app/views/layouts/application.html.erb +57 -0
  100. data/app/views/layouts/hydra-head.html.erb +12 -0
  101. data/app/views/mods_assets/_edit.html.erb +49 -0
  102. data/app/views/mods_assets/_edit_description.html.erb +82 -0
  103. data/app/views/mods_assets/_edit_journal.html.erb +72 -0
  104. data/app/views/mods_assets/_index.html.erb +1 -0
  105. data/app/views/mods_assets/_index_list.html.erb +37 -0
  106. data/app/views/mods_assets/_index_table.html.erb +7 -0
  107. data/app/views/mods_assets/_progress_box.html.erb +82 -0
  108. data/app/views/mods_assets/_show.html.erb +44 -0
  109. data/app/views/mods_assets/_show_description.html.erb +44 -0
  110. data/app/views/mods_assets/_show_journal.html.erb +42 -0
  111. data/app/views/mods_assets/_show_permissions.html.erb +14 -0
  112. data/app/views/permissions/_edit_person_permissions.html.erb +35 -0
  113. data/app/views/permissions/_index.html.erb +55 -0
  114. data/app/views/permissions/_new.html.erb +18 -0
  115. data/app/views/permissions/index.html.erb +1 -0
  116. data/app/views/permissions/new.html.erb +1 -0
  117. data/app/views/shared/_delete_asset_confirmation.html.erb +17 -0
  118. data/app/views/user_sessions/_login_form.html.erb +10 -0
  119. data/app/views/user_sessions/logged_out.html.erb +1 -0
  120. data/config/routes.rb +12 -0
  121. data/fedora_conf/conf/fedora.fcfg +1021 -0
  122. data/hydra-head.gemspec +70 -0
  123. data/lib/application_controller.rb +25 -0
  124. data/lib/application_helper.rb +2 -0
  125. data/lib/engine.rb +30 -0
  126. data/lib/generators/hydra/head_generator.rb +152 -0
  127. data/lib/generators/hydra/templates/config/fedora.yml +17 -0
  128. data/lib/generators/hydra/templates/config/initializers/blacklight_config.rb +246 -0
  129. data/lib/generators/hydra/templates/config/initializers/fedora_config.rb +23 -0
  130. data/lib/generators/hydra/templates/config/initializers/hydra_config.rb +29 -0
  131. data/lib/generators/hydra/templates/config/role_map_cucumber.yml +10 -0
  132. data/lib/generators/hydra/templates/config/role_map_development.yml +12 -0
  133. data/lib/generators/hydra/templates/config/role_map_production.yml +2 -0
  134. data/lib/generators/hydra/templates/config/role_map_test.yml +15 -0
  135. data/lib/generators/hydra/templates/config/solr.yml +10 -0
  136. data/lib/generators/hydra/templates/config/solr_mappings.yml +22 -0
  137. data/lib/generators/hydra/templates/fedora_conf/conf/fedora.fcfg +1021 -0
  138. data/lib/generators/hydra/templates/migrations/add_user_attributes_table.rb +15 -0
  139. data/lib/generators/hydra/templates/migrations/create_superusers.rb +12 -0
  140. data/lib/generators/hydra/templates/solr_conf/conf/schema.xml +118 -0
  141. data/lib/generators/hydra/templates/solr_conf/conf/solrconfig.xml +332 -0
  142. data/lib/generators/hydra/templates/solr_conf/solr.xml +35 -0
  143. data/lib/hydra-head.rb +29 -0
  144. data/lib/hydra-head/engine.rb +9 -0
  145. data/lib/hydra-head/routes.rb +87 -0
  146. data/lib/hydra-head/version.rb +4 -0
  147. data/lib/hydra.rb +22 -0
  148. data/lib/hydra/access_controls_enforcement.rb +236 -0
  149. data/lib/hydra/access_controls_evaluation.rb +97 -0
  150. data/lib/hydra/assets_controller_helper.rb +144 -0
  151. data/lib/hydra/catalog.rb +64 -0
  152. data/lib/hydra/common_mods_index_methods.rb +42 -0
  153. data/lib/hydra/controller.rb +7 -0
  154. data/lib/hydra/file_assets_helper.rb +144 -0
  155. data/lib/hydra/fixtures.rb +43 -0
  156. data/lib/hydra/generic_content.rb +113 -0
  157. data/lib/hydra/generic_image.rb +100 -0
  158. data/lib/hydra/image.rb +177 -0
  159. data/lib/hydra/model_methods.rb +95 -0
  160. data/lib/hydra/model_mixins.rb +2 -0
  161. data/lib/hydra/model_mixins/common_metadata.rb +24 -0
  162. data/lib/hydra/model_mixins/mods_object.rb +16 -0
  163. data/lib/hydra/mods_article.rb +505 -0
  164. data/lib/hydra/mods_dataset.rb +165 -0
  165. data/lib/hydra/mods_generic_content.rb +494 -0
  166. data/lib/hydra/mods_image.rb +494 -0
  167. data/lib/hydra/repository_controller.rb +102 -0
  168. data/lib/hydra/rights_metadata.rb +189 -0
  169. data/lib/hydra/superuser_attributes.rb +12 -0
  170. data/lib/hydra/testing_server.rb +183 -0
  171. data/lib/hydra/user.rb +22 -0
  172. data/lib/mediashelf/active_fedora_helper.rb +72 -0
  173. data/lib/railties/all_tests.rake +23 -0
  174. data/lib/railties/hydra-fixtures.rake +184 -0
  175. data/lib/railties/hydra_jetty.rake +79 -0
  176. data/lib/railties/hyhead_cucumber.rake +127 -0
  177. data/lib/railties/hyhead_rspec.rake +137 -0
  178. data/lib/stanford/searchworks_helper.rb +1338 -0
  179. data/lib/stanford/solr_helper.rb +108 -0
  180. data/lib/uva/mods_index_methods.rb +24 -0
  181. data/solr_conf/conf/schema.xml +122 -0
  182. data/solr_conf/conf/solrconfig.xml +332 -0
  183. data/solr_conf/solr.xml +35 -0
  184. data/tasks/hydra-head-fixtures.rake +54 -0
  185. data/tasks/hydra-head.rake +247 -0
  186. data/tasks/hydra_jetty.rake +79 -0
  187. data/tasks/replicator.rake +27 -0
  188. data/tasks/solrizer-fedora.rake +53 -0
  189. data/tasks/solrizer.rake +13 -0
  190. data/test_support/etc/Gemfile +29 -0
  191. data/test_support/etc/rvmrc +32 -0
  192. data/test_support/features/button_add_assets.feature +22 -0
  193. data/test_support/features/button_add_generic_content.feature +11 -0
  194. data/test_support/features/button_add_image.feature +11 -0
  195. data/test_support/features/button_add_mods_asset.feature +11 -0
  196. data/test_support/features/contributor_add.feature +39 -0
  197. data/test_support/features/file_assets_list.feature +32 -0
  198. data/test_support/features/file_upload.feature +40 -0
  199. data/test_support/features/home_page.feature +9 -0
  200. data/test_support/features/html_validity.feature +47 -0
  201. data/test_support/features/mods_asset_contributors_edit.feature +80 -0
  202. data/test_support/features/mods_asset_create.feature +12 -0
  203. data/test_support/features/mods_asset_edit.feature +33 -0
  204. data/test_support/features/mods_asset_edit_without_permission.feature +10 -0
  205. data/test_support/features/mods_asset_search_result.feature +13 -0
  206. data/test_support/features/mods_asset_show.feature +39 -0
  207. data/test_support/features/permissions_add.feature +15 -0
  208. data/test_support/features/permissions_edit.feature +63 -0
  209. data/test_support/features/step_definitions/catalog_index_steps.rb +14 -0
  210. data/test_support/features/step_definitions/create_asset_steps.rb +7 -0
  211. data/test_support/features/step_definitions/edit_metadata_steps.rb +73 -0
  212. data/test_support/features/step_definitions/file_list_steps.rb +28 -0
  213. data/test_support/features/step_definitions/hydra_metadata_steps.rb +3 -0
  214. data/test_support/features/step_definitions/hydra_steps.rb +8 -0
  215. data/test_support/features/step_definitions/inline_editable_edit_steps.rb +77 -0
  216. data/test_support/features/step_definitions/search_steps.rb +88 -0
  217. data/test_support/features/step_definitions/searching_steps.rb +22 -0
  218. data/test_support/features/step_definitions/show_document_steps.rb +85 -0
  219. data/test_support/features/step_definitions/user_steps.rb +36 -0
  220. data/test_support/features/step_definitions/web_steps.rb +219 -0
  221. data/test_support/features/support/env.rb +55 -0
  222. data/test_support/features/support/paths.rb +80 -0
  223. data/test_support/features/switch_users.feature +14 -0
  224. data/test_support/features/view_catalog_index.feature +18 -0
  225. data/test_support/fixtures/empty_file.txt +0 -0
  226. data/test_support/fixtures/hydrangea_fixture_archivist_only_mods_article.foxml.xml +1212 -0
  227. data/test_support/fixtures/hydrangea_fixture_file_asset1.foxml.xml +4946 -0
  228. data/test_support/fixtures/hydrangea_fixture_mods_article1.foxml.xml +234 -0
  229. data/test_support/fixtures/hydrangea_fixture_mods_article2.foxml.xml +177 -0
  230. data/test_support/fixtures/hydrangea_fixture_mods_article3.foxml.xml +170 -0
  231. data/test_support/fixtures/hydrangea_fixture_mods_dataset1.foxml.xml +187 -0
  232. data/test_support/fixtures/hydrangea_fixture_uploaded_svg1.foxml.xml +676 -0
  233. data/test_support/fixtures/image.jp2 +0 -0
  234. data/test_support/fixtures/libra-oa_1.foxml.xml +2324 -0
  235. data/test_support/fixtures/libra-oa_2.foxml.xml +2422 -0
  236. data/test_support/spec/controllers/assets_controller_spec.rb +113 -0
  237. data/test_support/spec/controllers/catalog_controller_spec.rb +148 -0
  238. data/test_support/spec/controllers/catalog_controller_viewing_context_spec.rb +62 -0
  239. data/test_support/spec/controllers/contributors_controller_spec.rb +47 -0
  240. data/test_support/spec/controllers/file_assets_controller_spec.rb +189 -0
  241. data/test_support/spec/controllers/hydra_controller_spec.rb +15 -0
  242. data/test_support/spec/controllers/permissions_controller_spec.rb +80 -0
  243. data/test_support/spec/controllers/user_sessions_controller_spec.rb +35 -0
  244. data/test_support/spec/generators/hydra-head_generator_spec.rb +14 -0
  245. data/test_support/spec/helpers/access_controls_enforcement_spec.rb +212 -0
  246. data/test_support/spec/helpers/access_controls_evaluation_spec.rb +35 -0
  247. data/test_support/spec/helpers/assets_controller_helper_spec.rb +71 -0
  248. data/test_support/spec/helpers/blacklight_helper_spec.rb +64 -0
  249. data/test_support/spec/helpers/file_assets_helper_spec.rb +107 -0
  250. data/test_support/spec/helpers/hydra-repository_controller_spec.rb +32 -0
  251. data/test_support/spec/helpers/hydra_assets_helper_spec.rb +195 -0
  252. data/test_support/spec/helpers/hydra_djatoka_helper_spec.rb +32 -0
  253. data/test_support/spec/helpers/hydra_fedora_metadata_helper_spec.rb +215 -0
  254. data/test_support/spec/helpers/hydra_helper_spec.rb +73 -0
  255. data/test_support/spec/helpers/hydra_model_methods_spec.rb +95 -0
  256. data/test_support/spec/helpers/hydra_uploader_helper_spec.rb +18 -0
  257. data/test_support/spec/helpers/javascript_includes_helper_spec.rb +43 -0
  258. data/test_support/spec/integration/file_asset_spec.rb +150 -0
  259. data/test_support/spec/lib/active_fedora_helper_spec.rb +56 -0
  260. data/test_support/spec/lib/catalog_spec.rb +16 -0
  261. data/test_support/spec/lib/common_mods_index_methods_spec.rb +28 -0
  262. data/test_support/spec/models/audio_asset_spec.rb +23 -0
  263. data/test_support/spec/models/file_asset_spec.rb +42 -0
  264. data/test_support/spec/models/generic_content_spec.rb +29 -0
  265. data/test_support/spec/models/generic_image_spec.rb +58 -0
  266. data/test_support/spec/models/hydra_rights_metadata_spec.rb +162 -0
  267. data/test_support/spec/models/image_asset_spec.rb +23 -0
  268. data/test_support/spec/models/mods_asset_spec.rb +29 -0
  269. data/test_support/spec/models/role_mapper_spec.rb +22 -0
  270. data/test_support/spec/models/user_spec.rb +52 -0
  271. data/test_support/spec/models/video_asset_spec.rb +23 -0
  272. data/test_support/spec/rcov.opts +3 -0
  273. data/test_support/spec/spec.opts +4 -0
  274. data/test_support/spec/spec_helper.rb +44 -0
  275. data/test_support/spec/support/matchers/helper_matcher.rb +14 -0
  276. data/test_support/spec/support/matchers/solr_matchers.rb +60 -0
  277. data/test_support/spec/unit/hydra-head-engine_spec.rb +8 -0
  278. data/test_support/spec/unit/hydra-head_spec.rb +8 -0
  279. data/test_support/spec/utilities/hydra_testing_server_spec.rb +49 -0
  280. data/test_support/spec/views/uploader.html.erb_spec.rb +30 -0
  281. data/vendor/cache/RedCloth-4.2.3.gem +0 -0
  282. data/vendor/cache/abstract-1.0.0.gem +0 -0
  283. data/vendor/cache/actionmailer-3.0.9.gem +0 -0
  284. data/vendor/cache/actionpack-3.0.9.gem +0 -0
  285. data/vendor/cache/active-fedora-2.3.3.gem +0 -0
  286. data/vendor/cache/activemodel-3.0.9.gem +0 -0
  287. data/vendor/cache/activerecord-3.0.9.gem +0 -0
  288. data/vendor/cache/activeresource-3.0.9.gem +0 -0
  289. data/vendor/cache/activesupport-3.0.9.gem +0 -0
  290. data/vendor/cache/arel-2.0.10.gem +0 -0
  291. data/vendor/cache/blacklight-3.0.0.gem +0 -0
  292. data/vendor/cache/block_helpers-0.3.3.gem +0 -0
  293. data/vendor/cache/builder-2.1.2.gem +0 -0
  294. data/vendor/cache/capybara-1.0.0.gem +0 -0
  295. data/vendor/cache/childprocess-0.2.0.gem +0 -0
  296. data/vendor/cache/columnize-0.3.4.gem +0 -0
  297. data/vendor/cache/crack-0.1.8.gem +0 -0
  298. data/vendor/cache/cucumber-1.0.2.gem +0 -0
  299. data/vendor/cache/cucumber-rails-1.0.2.gem +0 -0
  300. data/vendor/cache/curb-0.7.15.gem +0 -0
  301. data/vendor/cache/daemons-1.1.4.gem +0 -0
  302. data/vendor/cache/database_cleaner-0.6.7.gem +0 -0
  303. data/vendor/cache/diff-lcs-1.1.2.gem +0 -0
  304. data/vendor/cache/equivalent-xml-0.2.7.gem +0 -0
  305. data/vendor/cache/erubis-2.6.6.gem +0 -0
  306. data/vendor/cache/facets-2.8.4.gem +0 -0
  307. data/vendor/cache/factory_girl-1.3.3.gem +0 -0
  308. data/vendor/cache/fastercsv-1.5.4.gem +0 -0
  309. data/vendor/cache/ffi-1.0.9.gem +0 -0
  310. data/vendor/cache/gherkin-2.4.5.gem +0 -0
  311. data/vendor/cache/haml-3.1.2.gem +0 -0
  312. data/vendor/cache/httparty-0.7.8.gem +0 -0
  313. data/vendor/cache/i18n-0.5.0.gem +0 -0
  314. data/vendor/cache/jettywrapper-0.0.10.gem +0 -0
  315. data/vendor/cache/json-1.5.3.gem +0 -0
  316. data/vendor/cache/json_pure-1.5.3.gem +0 -0
  317. data/vendor/cache/kaminari-0.12.4.gem +0 -0
  318. data/vendor/cache/launchy-2.0.3.gem +0 -0
  319. data/vendor/cache/linecache-0.46.gem +0 -0
  320. data/vendor/cache/logger-1.2.8.gem +0 -0
  321. data/vendor/cache/mail-2.2.19.gem +0 -0
  322. data/vendor/cache/marc-0.4.3.gem +0 -0
  323. data/vendor/cache/mediashelf-loggable-0.4.2.gem +0 -0
  324. data/vendor/cache/mime-types-1.16.gem +0 -0
  325. data/vendor/cache/mocha-0.9.12.gem +0 -0
  326. data/vendor/cache/multipart-post-1.1.2.gem +0 -0
  327. data/vendor/cache/nokogiri-1.5.0.gem +0 -0
  328. data/vendor/cache/om-1.2.5.gem +0 -0
  329. data/vendor/cache/polyglot-0.3.1.gem +0 -0
  330. data/vendor/cache/rack-1.2.3.gem +0 -0
  331. data/vendor/cache/rack-mount-0.6.14.gem +0 -0
  332. data/vendor/cache/rack-test-0.5.7.gem +0 -0
  333. data/vendor/cache/rails-3.0.9.gem +0 -0
  334. data/vendor/cache/railties-3.0.9.gem +0 -0
  335. data/vendor/cache/rake-0.9.2.gem +0 -0
  336. data/vendor/cache/rbx-require-relative-0.0.5.gem +0 -0
  337. data/vendor/cache/rcov-0.9.9.gem +0 -0
  338. data/vendor/cache/rdoc-3.8.gem +0 -0
  339. data/vendor/cache/rsolr-1.0.2.gem +0 -0
  340. data/vendor/cache/rsolr-ext-1.0.3.gem +0 -0
  341. data/vendor/cache/rspec-2.6.0.gem +0 -0
  342. data/vendor/cache/rspec-core-2.6.4.gem +0 -0
  343. data/vendor/cache/rspec-expectations-2.6.0.gem +0 -0
  344. data/vendor/cache/rspec-mocks-2.6.0.gem +0 -0
  345. data/vendor/cache/rspec-rails-2.6.1.gem +0 -0
  346. data/vendor/cache/ruby-debug-0.10.4.gem +0 -0
  347. data/vendor/cache/ruby-debug-base-0.10.4.gem +0 -0
  348. data/vendor/cache/rubyzip-0.9.4.gem +0 -0
  349. data/vendor/cache/sanitize-2.0.3.gem +0 -0
  350. data/vendor/cache/selenium-webdriver-0.2.2.gem +0 -0
  351. data/vendor/cache/solr-ruby-0.0.8.gem +0 -0
  352. data/vendor/cache/solrizer-1.1.0.gem +0 -0
  353. data/vendor/cache/solrizer-fedora-1.1.0.gem +0 -0
  354. data/vendor/cache/sqlite3-ruby-1.2.5.gem +0 -0
  355. data/vendor/cache/stomp-1.1.9.gem +0 -0
  356. data/vendor/cache/term-ansicolor-1.0.5.gem +0 -0
  357. data/vendor/cache/thor-0.14.6.gem +0 -0
  358. data/vendor/cache/treetop-1.4.9.gem +0 -0
  359. data/vendor/cache/trollop-1.16.2.gem +0 -0
  360. data/vendor/cache/tzinfo-0.3.29.gem +0 -0
  361. data/vendor/cache/unicode-0.4.0.gem +0 -0
  362. data/vendor/cache/will_paginate-2.3.15.gem +0 -0
  363. data/vendor/cache/xml-simple-1.1.0.gem +0 -0
  364. data/vendor/cache/xpath-0.1.4.gem +0 -0
  365. data/vendor/cache/yard-0.7.2.gem +0 -0
  366. metadata +1110 -0
@@ -0,0 +1,102 @@
1
+ require "mediashelf/active_fedora_helper"
2
+ # Hydra-repository Contoller is a controller layer mixin. It is in the controller scope: request params, session etc.
3
+ #
4
+ # NOTE: Be careful when creating variables here as they may be overriding something that already exists.
5
+ # The ActionController docs: http://api.rubyonrails.org/classes/ActionController/Base.html
6
+ #
7
+ # Override these methods in your own controller for customizations:
8
+ #
9
+ # class HomeController < ActionController::Base
10
+ #
11
+ # include Stanford::SolrHelper
12
+ #
13
+ # def solr_search_params
14
+ # super.merge :per_page=>10
15
+ # end
16
+ #
17
+ # end
18
+ #
19
+ module Hydra::RepositoryController
20
+
21
+ include MediaShelf::ActiveFedoraHelper
22
+
23
+
24
+
25
+
26
+ def self.included(c)
27
+ if c.respond_to?(:helper_method)
28
+ c.helper_method :solr_name
29
+ c.helper_method :format_pid
30
+ end
31
+ end
32
+
33
+
34
+ #
35
+ # This method converts pid strings into xhtml safe IDs, since xhmlt expects namespaces to be defined.
36
+ # I.E. hydrus:123 = hydrus_123
37
+ def format_pid(pid)
38
+ pid.gsub(":", "_")
39
+ end
40
+
41
+
42
+
43
+ def solr_name(field_name, field_type = :text)
44
+ ::ActiveFedora::SolrService.solr_name(field_name, field_type)
45
+ end
46
+
47
+ # Uses submitted params Hash to figure out what Model to load
48
+ # params should contain :content_type and :id
49
+ def load_document_from_params
50
+ af_model = retrieve_af_model(params[:content_type])
51
+ unless af_model
52
+ af_model = ModsAsset
53
+ end
54
+ return af_model.find(params[:id])
55
+ end
56
+
57
+ # Returns a list of datastreams for download.
58
+ # Uses user's roles and "mime_type" value in submitted params to decide what to return.
59
+ # if you pass the optional argument of :canonical=>true, it will return the canonical datastream for this object (a single object not a hash of datastreams)
60
+ def downloadables(fedora_object=@fedora_object, opts={})
61
+ if opts[:canonical]
62
+ mime_type = opts[:mime_type] ? opts[:mime_type] : "application/pdf"
63
+ result = filter_datastreams_for_mime_type(fedora_object.datastreams, mime_type).sort.first[1]
64
+ elsif editor?
65
+ if params["mime_type"] == "all"
66
+ result = fedora_object.datastreams
67
+ else
68
+ result = Hash[]
69
+ fedora_object.datastreams.each_pair do |dsid,ds|
70
+ if !ds.new_object?
71
+ mime_type = ds.attributes["mimeType"] ? ds.attributes["mimeType"] : ""
72
+ if mime_type.include?("pdf") || ds.label.include?("_TEXT.xml") || ds.label.include?("_METS.xml")
73
+ result[dsid] = ds
74
+ end
75
+ end
76
+ end
77
+ end
78
+ else
79
+ result = Hash[]
80
+ fedora_object.datastreams.each_pair do |dsid,ds|
81
+ if ds.attributes["mimeType"].include?("pdf")
82
+ result[dsid] = ds
83
+ end
84
+ end
85
+ end
86
+ # puts "downloadables result: #{result}"
87
+ return result
88
+ end
89
+
90
+ private
91
+
92
+ def filter_datastreams_for_mime_type(datastreams_hash, mime_type)
93
+ result = Hash[]
94
+ datastreams_hash.each_pair do |dsid,ds|
95
+ ds_mime_type = ds.attributes["mimeType"] ? ds.attributes["mimeType"] : ""
96
+ if ds_mime_type == mime_type
97
+ result[dsid] = ds
98
+ end
99
+ end
100
+ return result
101
+ end
102
+ end
@@ -0,0 +1,189 @@
1
+ require "active-fedora"
2
+ module Hydra
3
+ class RightsMetadata < ActiveFedora::NokogiriDatastream
4
+
5
+ set_terminology do |t|
6
+ t.root(:path=>"rightsMetadata", :xmlns=>"http://hydra-collab.stanford.edu/schemas/rightsMetadata/v1", :schema=>"http://github.com/projecthydra/schemas/tree/v1/rightsMetadata.xsd")
7
+ t.copyright {
8
+ t.machine {
9
+ t.uvalicense
10
+ t.cclicense
11
+ t.license
12
+ }
13
+ t.human_readable(:path=>"human")
14
+ t.license(:proxy=>[:machine, :license ])
15
+ t.cclicense(:proxy=>[:machine, :cclicense ])
16
+ }
17
+ t.access {
18
+ t.human_readable(:path=>"human")
19
+ t.machine {
20
+ t.group
21
+ t.person
22
+ }
23
+ t.person(:proxy=>[:machine, :person])
24
+ t.group(:proxy=>[:machine, :group])
25
+ # accessor :access_person, :term=>[:access, :machine, :person]
26
+ }
27
+ t.discover_access(:ref=>[:access], :attributes=>{:type=>"discover"})
28
+ t.read_access(:ref=>[:access], :attributes=>{:type=>"read"})
29
+ t.edit_access(:ref=>[:access], :attributes=>{:type=>"edit"})
30
+ # A bug in OM prevnts us from declaring proxy terms at the root of a Terminology
31
+ # t.access_person(:proxy=>[:access,:machine,:person])
32
+ # t.access_group(:proxy=>[:access,:machine,:group])
33
+
34
+ t.embargo {
35
+ t.human_readable(:path=>"human")
36
+ t.machine{
37
+ t.date(:type =>"release")
38
+ }
39
+ t.embargo_release_date(:proxy => [:machine, :date])
40
+ }
41
+ end
42
+
43
+ # Generates an empty Mods Article (used when you call ModsArticle.new without passing in existing xml)
44
+ def self.xml_template
45
+ builder = Nokogiri::XML::Builder.new do |xml|
46
+ xml.rightsMetadata(:version=>"0.1", "xmlns"=>"http://hydra-collab.stanford.edu/schemas/rightsMetadata/v1") {
47
+ xml.copyright {
48
+ xml.human
49
+ xml.machine {
50
+ xml.uvalicense "no"
51
+ }
52
+ }
53
+ xml.access(:type=>"discover") {
54
+ xml.human
55
+ xml.machine
56
+ }
57
+ xml.access(:type=>"read") {
58
+ xml.human
59
+ xml.machine
60
+ }
61
+ xml.access(:type=>"edit") {
62
+ xml.human
63
+ xml.machine
64
+ }
65
+ xml.embargo{
66
+ xml.human
67
+ xml.machine
68
+ }
69
+ }
70
+ end
71
+ return builder.doc
72
+ end
73
+
74
+ # Returns the permissions for the selected person/group
75
+ # If new_access_level is provided, updates the selected person/group access_level to the one specified
76
+ # A new_access_level of "none" will remove all access_levels for the selected person/group
77
+ # @param [Hash] selector hash in format {type => identifier}
78
+ # @param new_access_level (default nil)
79
+ # @return Hash in format {type => access_level}.
80
+ #
81
+ # ie.
82
+ # permissions({:person=>"person123"})
83
+ # => {"person123"=>"edit"}
84
+ # permissions({:person=>"person123"}, "read")
85
+ # => {"person123"=>"read"}
86
+ # permissions({:person=>"person123"})
87
+ # => {"person123"=>"read"}
88
+ def permissions(selector, new_access_level=nil)
89
+
90
+ type = selector.keys.first.to_sym
91
+ actor = selector.values.first
92
+ if new_access_level.nil?
93
+ xpath = self.class.terminology.xpath_for(:access, type, actor)
94
+ nodeset = self.find_by_terms(xpath)
95
+ if nodeset.empty?
96
+ return "none"
97
+ else
98
+ return nodeset.first.ancestors("access").first.attributes["type"].text
99
+ end
100
+ else
101
+ remove_all_permissions(selector)
102
+ unless new_access_level == "none"
103
+ access_type_symbol = "#{new_access_level}_access".to_sym
104
+ result = self.update_values([access_type_symbol, type] => {"-1"=>actor})
105
+ end
106
+ self.dirty = true
107
+ return new_access_level
108
+ end
109
+
110
+ end
111
+
112
+ # Reports on which groups have which permissions
113
+ # @return Hash in format {group_name => group_permissions, group_name => group_permissions}
114
+ def groups
115
+ return quick_search_by_type(:group)
116
+ end
117
+
118
+ # Reports on which groups have which permissions
119
+ # @return Hash in format {person_name => person_permissions, person_name => person_permissions}
120
+ def individuals
121
+ return quick_search_by_type(:person)
122
+ end
123
+
124
+ # Updates permissions for all of the persons and groups in a hash
125
+ # @param ex. {"group"=>{"group1"=>"discover","group2"=>"edit"}, "person"=>{"person1"=>"read","person2"=>"discover"}}
126
+ # Currently restricts actor type to group or person. Any others will be ignored
127
+ def update_permissions(params)
128
+ params.fetch("group", {}).each_pair {|group_id, access_level| self.permissions({"group"=>group_id}, access_level)}
129
+ params.fetch("person", {}).each_pair {|group_id, access_level| self.permissions({"person"=>group_id}, access_level)}
130
+ end
131
+
132
+ # @param [Symbol] symbol (either :group or :person)
133
+ # @return
134
+ # This method limits the response to known access levels. Probably runs a bit faster than .permissions().
135
+ def quick_search_by_type(type)
136
+ result = {}
137
+ [{:discover_access=>"discover"},{:read_access=>"read"},{:edit_access=>"edit"}].each do |access_levels_hash|
138
+ access_level = access_levels_hash.keys.first
139
+ access_level_name = access_levels_hash.values.first
140
+ self.find_by_terms(*[access_level, type]).each do |entry|
141
+ result[entry.text] = access_level_name
142
+ end
143
+ end
144
+ return result
145
+ end
146
+
147
+ attr_reader :embargo_release_date
148
+ def embargo_release_date=(release_date)
149
+ release_date = release_date.to_s if release_date.is_a? Date
150
+ begin
151
+ Date.parse(release_date)
152
+ rescue
153
+ return "INVALID DATE"
154
+ end
155
+ self.update_values({[:embargo,:machine,:date]=>release_date})
156
+ end
157
+ def embargo_release_date(opts={})
158
+ embargo_release_date = self.find_by_terms(*[:embargo,:machine,:date]).first ? self.find_by_terms(*[:embargo,:machine,:date]).first.text : nil
159
+ if opts[:format] && opts[:format] == :solr_date
160
+ embargo_release_date << "T23:59:59Z"
161
+ end
162
+ embargo_release_date
163
+ end
164
+ def under_embargo?
165
+ (embargo_release_date && Date.today < embargo_release_date.to_date) ? true : false
166
+ end
167
+
168
+ def to_solr(solr_doc=Hash.new)
169
+ super(solr_doc)
170
+ ::Solrizer::Extractor.insert_solr_field_value(solr_doc, "embargo_release_date_dt", embargo_release_date(:format=>:solr_date)) if embargo_release_date
171
+ solr_doc
172
+ end
173
+
174
+
175
+
176
+
177
+
178
+ private
179
+ # Purge all access given group/person
180
+ def remove_all_permissions(selector)
181
+ type = selector.keys.first.to_sym
182
+ actor = selector.values.first
183
+ xpath = self.class.terminology.xpath_for(:access, type, actor)
184
+ nodes_to_purge = self.find_by_terms(xpath)
185
+ nodes_to_purge.each {|node| node.remove}
186
+ end
187
+
188
+ end
189
+ end
@@ -0,0 +1,12 @@
1
+ module Hydra::SuperuserAttributes
2
+
3
+ def can_be_superuser?
4
+ Superuser.find_by_user_id(self.id) ? true : false
5
+ end
6
+
7
+ def is_being_superuser?(session=nil)
8
+ return false if session.nil?
9
+ session[:superuser_mode] ? true : false
10
+ end
11
+
12
+ end
@@ -0,0 +1,183 @@
1
+ # The ASF licenses this file to You under the Apache License, Version 2.0
2
+ # (the "License"); you may not use this file except in compliance with
3
+ # the License. You may obtain a copy of the License at
4
+ #
5
+ # http://www.apache.org/licenses/LICENSE-2.0
6
+ #
7
+ # Unless required by applicable law or agreed to in writing, software
8
+ # distributed under the License is distributed on an "AS IS" BASIS,
9
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10
+ # See the License for the specific language governing permissions and
11
+ # limitations under the License.
12
+
13
+
14
+ module Hydra
15
+ # A singleton class for starting/stopping a Jetty server for testing purposes
16
+ # The behavior of TestSolrServer can be modified prior to start() by changing
17
+ # port, solr_home, and quiet properties.
18
+ #
19
+ # This class is based on Blacklight's TestSolrServer
20
+ class TestingServer
21
+ require 'singleton'
22
+ include Singleton
23
+ require 'win32/process' if RUBY_PLATFORM =~ /mswin32/
24
+ attr_accessor :port, :jetty_home, :solr_home, :quiet, :fedora_home, :base_path
25
+
26
+ # configure the singleton with some defaults
27
+ def initialize(params = {})
28
+ @pid = nil
29
+ if defined?(Rails.root)
30
+ @base_path = Rails.root
31
+ else
32
+ @base_path = "."
33
+ end
34
+ end
35
+
36
+ class << self
37
+ def configure(params = {})
38
+ hydra_server = self.instance
39
+ hydra_server.quiet = params[:quiet].nil? ? true : params[:quiet]
40
+ if defined?(Rails.root)
41
+ base_path = Rails.root
42
+ else
43
+ base_path = "."
44
+ end
45
+ hydra_server.jetty_home = params[:jetty_home] || File.expand_path(File.join(base_path, 'jetty'))
46
+ hydra_server.solr_home = params[:solr_home] || File.join( hydra_server.jetty_home, "solr")
47
+ hydra_server.fedora_home = params[:fedora_home] || File.join( hydra_server.jetty_home, "fedora","default")
48
+ hydra_server.port = params[:jetty_port] || 8888
49
+ return hydra_server
50
+ end
51
+
52
+ def wrap(params = {})
53
+ error = false
54
+ hydra_server = self.configure(params)
55
+ begin
56
+ puts "starting Hydra jetty server on #{RUBY_PLATFORM}"
57
+ hydra_server.start
58
+ sleep params[:startup_wait] || 5
59
+ yield
60
+ rescue
61
+ error = true
62
+ ensure
63
+ puts "stopping Hydra jetty server"
64
+ hydra_server.stop
65
+ end
66
+
67
+ return error
68
+ end
69
+ end
70
+
71
+ def jetty_command
72
+ "java -Djetty.port=#{@port} -Dsolr.solr.home=#{@solr_home} -Dfedora.home=#{@fedora_home} -jar start.jar"
73
+ end
74
+
75
+ def start
76
+ puts "jetty_home: #{@jetty_home}"
77
+ puts "solr_home: #{@solr_home}"
78
+ puts "fedora_home: #{@fedora_home}"
79
+ puts "jetty_command: #{jetty_command}"
80
+ if pid
81
+ begin
82
+ Process.kill(0,pid)
83
+ raise("Server is already running with PID #{pid}")
84
+ rescue Errno::ESRCH
85
+ STDERR.puts("Removing stale PID file at #{pid_path}")
86
+ File.delete(pid_path)
87
+ end
88
+ end
89
+ Dir.chdir(@jetty_home) do
90
+ self.send "#{platform}_process".to_sym
91
+ end
92
+ mkpath(pid_dir) unless File.directory?(pid_dir)
93
+ begin
94
+ f = File.new(pid_path, "w")
95
+ rescue Errno::ENOENT, Errno::EACCES
96
+ f = File.new(File.join(@base_path,'tmp',pid_file),"w")
97
+ end
98
+ f.puts "#{@pid}"
99
+ f.close
100
+ end
101
+
102
+ def stop
103
+ puts "stopping"
104
+ if pid
105
+ begin
106
+ self.send "#{platform}_stop".to_sym
107
+ rescue Errno::ESRCH
108
+ STDERR.puts("Removing stale PID file at #{pid_path}")
109
+ end
110
+ FileUtils.rm(pid_path)
111
+ end
112
+ end
113
+
114
+ def win_process
115
+ @pid = Process.create(
116
+ :app_name => jetty_command,
117
+ :creation_flags => Process::DETACHED_PROCESS,
118
+ :process_inherit => false,
119
+ :thread_inherit => true,
120
+ :cwd => "#{@jetty_home}"
121
+ ).process_id
122
+ end
123
+
124
+ def platform
125
+ case RUBY_PLATFORM
126
+ when /mswin32/
127
+ return 'win'
128
+ else
129
+ return 'nix'
130
+ end
131
+ end
132
+
133
+ def nix_process
134
+ @pid = fork do
135
+ STDERR.close if @quiet
136
+ exec jetty_command
137
+ end
138
+ end
139
+
140
+ # stop a running solr server
141
+ def win_stop
142
+ Process.kill(1, @pid)
143
+ end
144
+
145
+ def nix_stop
146
+ Process.kill('TERM',pid)
147
+ end
148
+
149
+ def pid_path
150
+ File.join(pid_dir, pid_file)
151
+ end
152
+
153
+ def pid_file
154
+ @pid_file || 'hydra-jetty.pid'
155
+ end
156
+
157
+ def pid_dir
158
+ File.expand_path(@pid_dir || File.join(@base_path,'tmp','pids'))
159
+ end
160
+
161
+ def pid
162
+ @pid || File.open( pid_path ) { |f| return f.gets.to_i } if File.exist?(pid_path)
163
+ end
164
+
165
+ end # class TestingServer
166
+ end # module Hydra
167
+
168
+ #
169
+ # puts "hello"
170
+ # SOLR_PARAMS = {
171
+ # :quiet => ENV['SOLR_CONSOLE'] ? false : true,
172
+ # :jetty_home => ENV['SOLR_JETTY_HOME'] || File.expand_path('../../jetty'),
173
+ # :jetty_port => ENV['SOLR_JETTY_PORT'] || 8888,
174
+ # :solr_home => ENV['SOLR_HOME'] || File.expand_path('test')
175
+ # }
176
+ #
177
+ # # wrap functional tests with a test-specific Solr server
178
+ # got_error = TestSolrServer.wrap(SOLR_PARAMS) do
179
+ # puts `ps aux | grep start.jar`
180
+ # end
181
+ #
182
+ # raise "test failures" if got_error
183
+ #