newspaper_works 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (461) hide show
  1. checksums.yaml +7 -0
  2. data/.fcrepo_wrapper +4 -0
  3. data/.gitignore +43 -0
  4. data/.rubocop.yml +143 -0
  5. data/.solr_wrapper +8 -0
  6. data/.travis.yml +50 -0
  7. data/Gemfile +47 -0
  8. data/LICENSE +203 -0
  9. data/README.md +159 -0
  10. data/Rakefile +38 -0
  11. data/app/actors/hyrax/actors/newspaper_article_actor.rb +8 -0
  12. data/app/actors/hyrax/actors/newspaper_container_actor.rb +8 -0
  13. data/app/actors/hyrax/actors/newspaper_issue_actor.rb +8 -0
  14. data/app/actors/hyrax/actors/newspaper_page_actor.rb +8 -0
  15. data/app/actors/hyrax/actors/newspaper_title_actor.rb +8 -0
  16. data/app/actors/newspaper_works/actors/newspaper_works_upload_actor.rb +88 -0
  17. data/app/assets/config/newspaper_works_manifest.js +2 -0
  18. data/app/assets/images/newspaper_works/.keep +0 -0
  19. data/app/assets/javascripts/newspaper_works/autocomplete_fix.js +33 -0
  20. data/app/assets/javascripts/newspaper_works/ocr_search.js.erb +6 -0
  21. data/app/assets/javascripts/newspaper_works/thumbnail_highlights.js.erb +102 -0
  22. data/app/assets/javascripts/newspaper_works.js +4 -0
  23. data/app/assets/stylesheets/newspaper_works/_issue_search.scss +13 -0
  24. data/app/assets/stylesheets/newspaper_works/_issues_calendar.scss +18 -0
  25. data/app/assets/stylesheets/newspaper_works/_newspaper_works.scss +4 -0
  26. data/app/assets/stylesheets/newspaper_works/_newspapers_search.scss +38 -0
  27. data/app/assets/stylesheets/newspaper_works/_search_results.scss +12 -0
  28. data/app/controllers/hyrax/newspaper_articles_controller.rb +14 -0
  29. data/app/controllers/hyrax/newspaper_containers_controller.rb +14 -0
  30. data/app/controllers/hyrax/newspaper_issues_controller.rb +14 -0
  31. data/app/controllers/hyrax/newspaper_pages_controller.rb +14 -0
  32. data/app/controllers/hyrax/newspaper_titles_controller.rb +13 -0
  33. data/app/controllers/newspaper_works/newspapers_controller.rb +117 -0
  34. data/app/controllers/newspaper_works/newspapers_search_controller.rb +26 -0
  35. data/app/forms/hyrax/newspaper_article_form.rb +11 -0
  36. data/app/forms/hyrax/newspaper_container_form.rb +11 -0
  37. data/app/forms/hyrax/newspaper_issue_form.rb +11 -0
  38. data/app/forms/hyrax/newspaper_page_form.rb +15 -0
  39. data/app/forms/hyrax/newspaper_title_form.rb +12 -0
  40. data/app/forms/newspaper_works/newspaper_core_form_data.rb +17 -0
  41. data/app/helpers/hyrax/newspaper_articles_helper.rb +5 -0
  42. data/app/helpers/hyrax/newspaper_containers_helper.rb +5 -0
  43. data/app/helpers/hyrax/newspaper_issues_helper.rb +5 -0
  44. data/app/helpers/hyrax/newspaper_pages_helper.rb +5 -0
  45. data/app/helpers/newspaper_works/application_helper.rb +5 -0
  46. data/app/helpers/newspaper_works/breadcrumb_helper.rb +92 -0
  47. data/app/helpers/newspaper_works/newspaper_works_helper_behavior.rb +103 -0
  48. data/app/helpers/newspaper_works/newspapers_helper.rb +5 -0
  49. data/app/indexers/concerns/newspaper_works/indexes_full_text.rb +17 -0
  50. data/app/indexers/concerns/newspaper_works/indexes_place_of_publication.rb +67 -0
  51. data/app/indexers/concerns/newspaper_works/indexes_publication_date_range.rb +35 -0
  52. data/app/indexers/concerns/newspaper_works/indexes_relationships.rb +125 -0
  53. data/app/indexers/newspaper_article_indexer.rb +16 -0
  54. data/app/indexers/newspaper_container_indexer.rb +18 -0
  55. data/app/indexers/newspaper_issue_indexer.rb +26 -0
  56. data/app/indexers/newspaper_page_indexer.rb +9 -0
  57. data/app/indexers/newspaper_title_indexer.rb +19 -0
  58. data/app/indexers/newspaper_works/newspaper_core_indexer.rb +21 -0
  59. data/app/jobs/newspaper_works/application_job.rb +4 -0
  60. data/app/jobs/newspaper_works/compose_issue_pdf_job.rb +13 -0
  61. data/app/jobs/newspaper_works/create_issue_pages_job.rb +19 -0
  62. data/app/mailers/newspaper_works/application_mailer.rb +8 -0
  63. data/app/models/concerns/newspaper_works/blacklight_iiif_search/annotation_behavior.rb +82 -0
  64. data/app/models/concerns/newspaper_works/blacklight_iiif_search/search_behavior.rb +27 -0
  65. data/app/models/concerns/newspaper_works/newspaper_core_metadata.rb +67 -0
  66. data/app/models/concerns/newspaper_works/place_of_publication_behavior.rb +15 -0
  67. data/app/models/concerns/newspaper_works/scanned_media_metadata.rb +43 -0
  68. data/app/models/concerns/newspaper_works/solr/document.rb +25 -0
  69. data/app/models/file_set.rb +10 -0
  70. data/app/models/newspaper_article.rb +158 -0
  71. data/app/models/newspaper_container.rb +86 -0
  72. data/app/models/newspaper_issue.rb +115 -0
  73. data/app/models/newspaper_page.rb +70 -0
  74. data/app/models/newspaper_title.rb +111 -0
  75. data/app/models/newspaper_works/application_record.rb +6 -0
  76. data/app/models/newspaper_works/derivative_attachment.rb +8 -0
  77. data/app/models/newspaper_works/ingest_file_relation.rb +14 -0
  78. data/app/presenters/hyrax/newspaper_article_presenter.rb +38 -0
  79. data/app/presenters/hyrax/newspaper_container_presenter.rb +11 -0
  80. data/app/presenters/hyrax/newspaper_issue_presenter.rb +62 -0
  81. data/app/presenters/hyrax/newspaper_page_presenter.rb +72 -0
  82. data/app/presenters/hyrax/newspaper_title_presenter.rb +86 -0
  83. data/app/presenters/newspaper_works/iiif_manifest_presenter_behavior.rb +29 -0
  84. data/app/presenters/newspaper_works/issue_info_presenter.rb +29 -0
  85. data/app/presenters/newspaper_works/newspaper_core_presenter.rb +9 -0
  86. data/app/presenters/newspaper_works/persistent_url_presenter_behavior.rb +16 -0
  87. data/app/presenters/newspaper_works/place_of_publication_presenter_behavior.rb +8 -0
  88. data/app/presenters/newspaper_works/scanned_media_presenter.rb +7 -0
  89. data/app/presenters/newspaper_works/title_info_presenter.rb +13 -0
  90. data/app/search_builders/concerns/newspaper_works/exclude_models.rb +16 -0
  91. data/app/search_builders/concerns/newspaper_works/highlight_search_params.rb +14 -0
  92. data/app/search_builders/newspaper_works/newspapers_search_builder.rb +26 -0
  93. data/app/services/hyrax/article_genre_service.rb +9 -0
  94. data/app/services/newspaper_works/jp2_derivative_service.rb +120 -0
  95. data/app/services/newspaper_works/newspaper_page_derivative_service.rb +91 -0
  96. data/app/services/newspaper_works/pdf_derivative_service.rb +45 -0
  97. data/app/services/newspaper_works/pluggable_derivative_service.rb +114 -0
  98. data/app/services/newspaper_works/text_extraction_derivative_service.rb +56 -0
  99. data/app/services/newspaper_works/text_formats_from_alto_service.rb +77 -0
  100. data/app/services/newspaper_works/tiff_derivative_service.rb +54 -0
  101. data/app/validators/newspaper_works/publication_date_start_end_validator.rb +48 -0
  102. data/app/validators/newspaper_works/publication_date_validator.rb +16 -0
  103. data/app/views/catalog/_index_gallery_newspaper_article_wrapper.html.erb +9 -0
  104. data/app/views/catalog/_index_gallery_newspaper_page_wrapper.html.erb +9 -0
  105. data/app/views/catalog/_index_header_gallery_newspaper_article.html.erb +23 -0
  106. data/app/views/catalog/_index_header_gallery_newspaper_page.html.erb +23 -0
  107. data/app/views/catalog/_index_header_list_newspaper_article.html.erb +7 -0
  108. data/app/views/catalog/_index_header_list_newspaper_page.html.erb +7 -0
  109. data/app/views/catalog/_snippets_more.html.erb +16 -0
  110. data/app/views/catalog/_thumbnail_list_newspaper_article.html.erb +6 -0
  111. data/app/views/catalog/_thumbnail_list_newspaper_page.html.erb +6 -0
  112. data/app/views/hyrax/file_sets/_actions.html.erb +45 -0
  113. data/app/views/hyrax/newspaper_articles/_newspaper_article.html.erb +2 -0
  114. data/app/views/hyrax/newspaper_articles/show.html.erb +1 -0
  115. data/app/views/hyrax/newspaper_containers/_newspaper_container.html.erb +2 -0
  116. data/app/views/hyrax/newspaper_containers/show.html.erb +1 -0
  117. data/app/views/hyrax/newspaper_issues/_newspaper_issue.html.erb +2 -0
  118. data/app/views/hyrax/newspaper_issues/show.html.erb +1 -0
  119. data/app/views/hyrax/newspaper_pages/_newspaper_page.html.erb +2 -0
  120. data/app/views/hyrax/newspaper_pages/show.html.erb +1 -0
  121. data/app/views/hyrax/newspaper_titles/_all_front_pages_form.html.erb +5 -0
  122. data/app/views/hyrax/newspaper_titles/_issue_search_form.html.erb +33 -0
  123. data/app/views/hyrax/newspaper_titles/_issues_calendar.html.erb +63 -0
  124. data/app/views/hyrax/newspaper_titles/_newspaper_title.html.erb +2 -0
  125. data/app/views/hyrax/newspaper_titles/show.html.erb +54 -0
  126. data/app/views/newspaper_works/base/_attribute_rows.html.erb +42 -0
  127. data/app/views/newspaper_works/base/_attributes.html.erb +16 -0
  128. data/app/views/newspaper_works/base/_metadata.html.erb +6 -0
  129. data/app/views/newspaper_works/base/_newspaper_hierarchy.html.erb +14 -0
  130. data/app/views/newspaper_works/base/_persistent_url.html.erb +1 -0
  131. data/app/views/newspaper_works/base/_show.html.erb +45 -0
  132. data/app/views/newspaper_works/newspapers_search/_date_fields.html.erb +29 -0
  133. data/app/views/newspaper_works/newspapers_search/_facet_layout.html.erb +8 -0
  134. data/app/views/newspaper_works/newspapers_search/_facet_limit.html.erb +17 -0
  135. data/app/views/newspaper_works/newspapers_search/_front_pages_input.html.erb +5 -0
  136. data/app/views/newspaper_works/newspapers_search/_keyword_input.html.erb +18 -0
  137. data/app/views/newspaper_works/newspapers_search/_newspapers_facets.html.erb +5 -0
  138. data/app/views/newspaper_works/newspapers_search/_newspapers_search_form.html.erb +13 -0
  139. data/app/views/newspaper_works/newspapers_search/_newspapers_search_help.html.erb +8 -0
  140. data/app/views/newspaper_works/newspapers_search/search.html.erb +13 -0
  141. data/app/views/records/edit_fields/_alternate_title.html.erb +4 -0
  142. data/app/views/records/edit_fields/_genre.html.erb +4 -0
  143. data/app/views/records/edit_fields/_place_of_publication.html.erb +14 -0
  144. data/app/views/records/edit_fields/_subtitle.html.erb +4 -0
  145. data/bin/rails +13 -0
  146. data/config/fcrepo_wrapper_test.yml +5 -0
  147. data/config/initializers/assets.rb +2 -0
  148. data/config/locales/newspaper_article.de.yml +12 -0
  149. data/config/locales/newspaper_article.en.yml +12 -0
  150. data/config/locales/newspaper_article.es.yml +12 -0
  151. data/config/locales/newspaper_article.fr.yml +12 -0
  152. data/config/locales/newspaper_article.it.yml +12 -0
  153. data/config/locales/newspaper_article.pt-BR.yml +12 -0
  154. data/config/locales/newspaper_article.zh.yml +12 -0
  155. data/config/locales/newspaper_container.de.yml +8 -0
  156. data/config/locales/newspaper_container.en.yml +8 -0
  157. data/config/locales/newspaper_container.es.yml +8 -0
  158. data/config/locales/newspaper_container.fr.yml +8 -0
  159. data/config/locales/newspaper_container.it.yml +8 -0
  160. data/config/locales/newspaper_container.pt-BR.yml +8 -0
  161. data/config/locales/newspaper_container.zh.yml +8 -0
  162. data/config/locales/newspaper_issue.de.yml +8 -0
  163. data/config/locales/newspaper_issue.en.yml +8 -0
  164. data/config/locales/newspaper_issue.es.yml +8 -0
  165. data/config/locales/newspaper_issue.fr.yml +8 -0
  166. data/config/locales/newspaper_issue.it.yml +8 -0
  167. data/config/locales/newspaper_issue.pt-BR.yml +8 -0
  168. data/config/locales/newspaper_issue.zh.yml +8 -0
  169. data/config/locales/newspaper_page.de.yml +15 -0
  170. data/config/locales/newspaper_page.en.yml +15 -0
  171. data/config/locales/newspaper_page.es.yml +15 -0
  172. data/config/locales/newspaper_page.fr.yml +15 -0
  173. data/config/locales/newspaper_page.it.yml +15 -0
  174. data/config/locales/newspaper_page.pt-BR.yml +15 -0
  175. data/config/locales/newspaper_page.zh.yml +15 -0
  176. data/config/locales/newspaper_title.de.yml +8 -0
  177. data/config/locales/newspaper_title.en.yml +8 -0
  178. data/config/locales/newspaper_title.es.yml +8 -0
  179. data/config/locales/newspaper_title.fr.yml +8 -0
  180. data/config/locales/newspaper_title.it.yml +8 -0
  181. data/config/locales/newspaper_title.pt-BR.yml +8 -0
  182. data/config/locales/newspaper_title.zh.yml +8 -0
  183. data/config/locales/newspaper_works.de.yml +50 -0
  184. data/config/locales/newspaper_works.en.yml +52 -0
  185. data/config/locales/newspaper_works.es.yml +52 -0
  186. data/config/locales/newspaper_works.fr.yml +52 -0
  187. data/config/locales/newspaper_works.it.yml +52 -0
  188. data/config/locales/newspaper_works.pt-BR.yml +52 -0
  189. data/config/locales/newspaper_works.zh.yml +52 -0
  190. data/config/routes.rb +9 -0
  191. data/config/solr_wrapper_test.yml +9 -0
  192. data/config/test-fixture/solr-config/_rest_managed.json +3 -0
  193. data/config/test-fixture/solr-config/admin-extra.html +31 -0
  194. data/config/test-fixture/solr-config/elevate.xml +36 -0
  195. data/config/test-fixture/solr-config/mapping-ISOLatin1Accent.txt +246 -0
  196. data/config/test-fixture/solr-config/protwords.txt +21 -0
  197. data/config/test-fixture/solr-config/schema.xml +366 -0
  198. data/config/test-fixture/solr-config/scripts.conf +24 -0
  199. data/config/test-fixture/solr-config/solrconfig.xml +322 -0
  200. data/config/test-fixture/solr-config/spellings.txt +2 -0
  201. data/config/test-fixture/solr-config/stopwords.txt +58 -0
  202. data/config/test-fixture/solr-config/stopwords_en.txt +58 -0
  203. data/config/test-fixture/solr-config/synonyms.txt +31 -0
  204. data/config/test-fixture/solr-config/xslt/example.xsl +132 -0
  205. data/config/test-fixture/solr-config/xslt/example_atom.xsl +67 -0
  206. data/config/test-fixture/solr-config/xslt/example_rss.xsl +66 -0
  207. data/config/test-fixture/solr-config/xslt/luke.xsl +337 -0
  208. data/config/vendor/imagemagick-6-policy.xml +76 -0
  209. data/db/migrate/20181214181358_create_newspaper_works_derivative_attachments.rb +12 -0
  210. data/db/migrate/20190107165909_create_newspaper_works_ingest_file_relations.rb +11 -0
  211. data/lib/generators/newspaper_works/assets_generator.rb +29 -0
  212. data/lib/generators/newspaper_works/blacklight_advanced_search_generator.rb +44 -0
  213. data/lib/generators/newspaper_works/blacklight_iiif_search_generator.rb +41 -0
  214. data/lib/generators/newspaper_works/catalog_controller_generator.rb +60 -0
  215. data/lib/generators/newspaper_works/install_generator.rb +97 -0
  216. data/lib/generators/newspaper_works/templates/annotation_behavior.rb +6 -0
  217. data/lib/generators/newspaper_works/templates/config/authorities/newspaper_article_genres.yml +86 -0
  218. data/lib/generators/newspaper_works/templates/config/initializers/newspaper_works.rb +12 -0
  219. data/lib/generators/newspaper_works/templates/config/initializers/patch_blacklight_advanced_search.rb +74 -0
  220. data/lib/generators/newspaper_works/templates/custom_search_builder.rb +23 -0
  221. data/lib/generators/newspaper_works/templates/newspaper_works.scss +1 -0
  222. data/lib/generators/newspaper_works/templates/newspaper_works_helper.rb +3 -0
  223. data/lib/generators/newspaper_works/templates/search_behavior.rb +6 -0
  224. data/lib/newspaper_works/configuration.rb +14 -0
  225. data/lib/newspaper_works/data/fileset_helper.rb +25 -0
  226. data/lib/newspaper_works/data/path_helper.rb +40 -0
  227. data/lib/newspaper_works/data/work_derivatives.rb +314 -0
  228. data/lib/newspaper_works/data/work_file.rb +92 -0
  229. data/lib/newspaper_works/data/work_files.rb +181 -0
  230. data/lib/newspaper_works/data.rb +35 -0
  231. data/lib/newspaper_works/engine.rb +42 -0
  232. data/lib/newspaper_works/errors.rb +14 -0
  233. data/lib/newspaper_works/ingest/base_ingest.rb +69 -0
  234. data/lib/newspaper_works/ingest/base_publication_info.rb +35 -0
  235. data/lib/newspaper_works/ingest/batch_ingest_helper.rb +44 -0
  236. data/lib/newspaper_works/ingest/batch_issue_ingester.rb +129 -0
  237. data/lib/newspaper_works/ingest/chronam_publication_info.rb +133 -0
  238. data/lib/newspaper_works/ingest/from_command.rb +52 -0
  239. data/lib/newspaper_works/ingest/image_ingest_issues.rb +43 -0
  240. data/lib/newspaper_works/ingest/issue_images.rb +51 -0
  241. data/lib/newspaper_works/ingest/lc_publication_info.rb +144 -0
  242. data/lib/newspaper_works/ingest/named_issue_metadata.rb +60 -0
  243. data/lib/newspaper_works/ingest/ndnp/batch_ingester.rb +64 -0
  244. data/lib/newspaper_works/ingest/ndnp/batch_xml_ingest.rb +72 -0
  245. data/lib/newspaper_works/ingest/ndnp/container_ingest.rb +99 -0
  246. data/lib/newspaper_works/ingest/ndnp/container_ingester.rb +84 -0
  247. data/lib/newspaper_works/ingest/ndnp/container_metadata.rb +87 -0
  248. data/lib/newspaper_works/ingest/ndnp/issue_ingest.rb +81 -0
  249. data/lib/newspaper_works/ingest/ndnp/issue_ingester.rb +101 -0
  250. data/lib/newspaper_works/ingest/ndnp/issue_metadata.rb +96 -0
  251. data/lib/newspaper_works/ingest/ndnp/ndnp_asset_helper.rb +20 -0
  252. data/lib/newspaper_works/ingest/ndnp/ndnp_mets_helper.rb +70 -0
  253. data/lib/newspaper_works/ingest/ndnp/page_ingest.rb +47 -0
  254. data/lib/newspaper_works/ingest/ndnp/page_ingester.rb +157 -0
  255. data/lib/newspaper_works/ingest/ndnp/page_metadata.rb +112 -0
  256. data/lib/newspaper_works/ingest/ndnp.rb +21 -0
  257. data/lib/newspaper_works/ingest/newspaper_issue_ingest.rb +56 -0
  258. data/lib/newspaper_works/ingest/newspaper_page_ingest.rb +6 -0
  259. data/lib/newspaper_works/ingest/page_image.rb +52 -0
  260. data/lib/newspaper_works/ingest/path_enumeration.rb +52 -0
  261. data/lib/newspaper_works/ingest/pdf_images.rb +85 -0
  262. data/lib/newspaper_works/ingest/pdf_issue.rb +20 -0
  263. data/lib/newspaper_works/ingest/pdf_issues.rb +39 -0
  264. data/lib/newspaper_works/ingest/pdf_pages.rb +114 -0
  265. data/lib/newspaper_works/ingest/pub_finder.rb +89 -0
  266. data/lib/newspaper_works/ingest/publication_info.rb +44 -0
  267. data/lib/newspaper_works/ingest.rb +90 -0
  268. data/lib/newspaper_works/issue_pdf_composer.rb +111 -0
  269. data/lib/newspaper_works/logging.rb +54 -0
  270. data/lib/newspaper_works/page_finder.rb +62 -0
  271. data/lib/newspaper_works/resource_fetcher.rb +78 -0
  272. data/lib/newspaper_works/text_extraction/alto_reader.rb +122 -0
  273. data/lib/newspaper_works/text_extraction/page_ocr.rb +100 -0
  274. data/lib/newspaper_works/text_extraction/render_alto.rb +84 -0
  275. data/lib/newspaper_works/text_extraction/word_coords_builder.rb +30 -0
  276. data/lib/newspaper_works/text_extraction.rb +10 -0
  277. data/lib/newspaper_works/version.rb +3 -0
  278. data/lib/newspaper_works.rb +19 -0
  279. data/lib/tasks/newspaper_works_tasks.rake +39 -0
  280. data/newspaper_works.gemspec +49 -0
  281. data/spec/.keep.txt +1 -0
  282. data/spec/actors/newspaper_works/actors/newspaper_works_upload_actor_spec.rb +69 -0
  283. data/spec/controllers/catalog_controller_spec.rb +63 -0
  284. data/spec/controllers/newspaper_works/newspapers_controller_spec.rb +114 -0
  285. data/spec/controllers/newspaper_works/newspapers_search_controller_spec.rb +21 -0
  286. data/spec/factories/ability.rb +6 -0
  287. data/spec/factories/newspaper_issue.rb +7 -0
  288. data/spec/factories/newspaper_issue_ingest.rb +6 -0
  289. data/spec/factories/newspaper_page.rb +7 -0
  290. data/spec/factories/newspaper_page_ingest.rb +6 -0
  291. data/spec/factories/newspaper_page_solr_document.rb +12 -0
  292. data/spec/factories/newspaper_title.rb +8 -0
  293. data/spec/factories/uploaded_pdf_file.rb +9 -0
  294. data/spec/factories/user.rb +13 -0
  295. data/spec/features/front_pages_for_title_spec.rb +19 -0
  296. data/spec/features/newspaper_title_search_spec.rb +30 -0
  297. data/spec/features/newspapers_search_spec.rb +49 -0
  298. data/spec/features/search_results_thumbnail_highlights_spec.rb +33 -0
  299. data/spec/features_shared.rb +71 -0
  300. data/spec/fixtures/files/4.1.07.jp2 +0 -0
  301. data/spec/fixtures/files/4.1.07.tiff +0 -0
  302. data/spec/fixtures/files/README.md +7 -0
  303. data/spec/fixtures/files/alto-2-0.xsd +714 -0
  304. data/spec/fixtures/files/broken-truncated.pdf +0 -0
  305. data/spec/fixtures/files/credits.md +16 -0
  306. data/spec/fixtures/files/lowres-gray-via-ndnp-sample.tiff +0 -0
  307. data/spec/fixtures/files/minimal-1-page.pdf +0 -0
  308. data/spec/fixtures/files/minimal-2-page.pdf +0 -0
  309. data/spec/fixtures/files/minimal-alto.xml +31 -0
  310. data/spec/fixtures/files/ndnp-alto-sample.xml +24 -0
  311. data/spec/fixtures/files/ndnp-sample1-json.json +1 -0
  312. data/spec/fixtures/files/ndnp-sample1-txt.txt +1 -0
  313. data/spec/fixtures/files/ndnp-sample1.pdf +0 -0
  314. data/spec/fixtures/files/ocr_alto.xml +202 -0
  315. data/spec/fixtures/files/ocr_alto_scaled_4pts_per_px.xml +202 -0
  316. data/spec/fixtures/files/ocr_color.tiff +0 -0
  317. data/spec/fixtures/files/ocr_gray.jp2 +0 -0
  318. data/spec/fixtures/files/ocr_gray.tiff +0 -0
  319. data/spec/fixtures/files/ocr_mono.tiff +0 -0
  320. data/spec/fixtures/files/page1.tiff +0 -0
  321. data/spec/fixtures/files/resource_mocks/chronam/http404-expected +0 -0
  322. data/spec/fixtures/files/resource_mocks/chronam/sn84038814.rdf +1028 -0
  323. data/spec/fixtures/files/resource_mocks/chronam/sn93059126.rdf +36 -0
  324. data/spec/fixtures/files/resource_mocks/chronam/sn94051019.rdf +37 -0
  325. data/spec/fixtures/files/resource_mocks/geonames/Chicopee +1104 -0
  326. data/spec/fixtures/files/resource_mocks/geonames/Denver +1104 -0
  327. data/spec/fixtures/files/resource_mocks/geonames/Marysville +279 -0
  328. data/spec/fixtures/files/resource_mocks/geonames/Marysville2 +279 -0
  329. data/spec/fixtures/files/resource_mocks/geonames/SLC +1104 -0
  330. data/spec/fixtures/files/resource_mocks/lccn/sn2099999999 +1 -0
  331. data/spec/fixtures/files/resource_mocks/lccn/sn82014496 +2 -0
  332. data/spec/fixtures/files/resource_mocks/lccn/sn83020109 +1 -0
  333. data/spec/fixtures/files/resource_mocks/lccn/sn83021453 +2 -0
  334. data/spec/fixtures/files/resource_mocks/lccn/sn83045396 +2 -0
  335. data/spec/fixtures/files/resource_mocks/lccn/sn84038814 +2 -0
  336. data/spec/fixtures/files/resource_mocks/lccn/sn93059126 +1 -0
  337. data/spec/fixtures/files/resource_mocks/lccn/sn94051019 +1 -0
  338. data/spec/fixtures/files/resource_mocks/lccn/sn99999999 +1 -0
  339. data/spec/fixtures/files/resource_mocks/urls.json +82 -0
  340. data/spec/fixtures/files/sample-4page-issue.pdf +0 -0
  341. data/spec/fixtures/files/sample-color-newsletter.pdf +0 -0
  342. data/spec/fixtures/files/thumbnail.jpg +0 -0
  343. data/spec/forms/hyrax/newspaper_article_form_spec.rb +33 -0
  344. data/spec/forms/hyrax/newspaper_container_form_spec.rb +30 -0
  345. data/spec/forms/hyrax/newspaper_issue_form_spec.rb +31 -0
  346. data/spec/forms/hyrax/newspaper_page_form_spec.rb +28 -0
  347. data/spec/forms/hyrax/newspaper_title_form_spec.rb +31 -0
  348. data/spec/forms/newspaper_works/newspaper_core_form_data_spec.rb +12 -0
  349. data/spec/helpers/newspaper_works/breadcrumb_helper_spec.rb +82 -0
  350. data/spec/helpers/newspaper_works_helper_spec.rb +57 -0
  351. data/spec/indexers/concerns/newspaper_works/indexes_full_text_spec.rb +31 -0
  352. data/spec/indexers/concerns/newspaper_works/indexes_place_of_publication_spec.rb +53 -0
  353. data/spec/indexers/concerns/newspaper_works/indexes_publication_date_range_spec.rb +39 -0
  354. data/spec/indexers/concerns/newspaper_works/indexes_relationships_spec.rb +86 -0
  355. data/spec/indexers/newspaper_article_indexer_spec.rb +29 -0
  356. data/spec/indexers/newspaper_issue_indexer_spec.rb +19 -0
  357. data/spec/indexers/newspaper_title_indexer_spec.rb +22 -0
  358. data/spec/indexers/newspaper_works/newspaper_core_indexer_spec.rb +23 -0
  359. data/spec/lib/newspaper_works/configuration_spec.rb +18 -0
  360. data/spec/lib/newspaper_works/data/work_derivatives_spec.rb +245 -0
  361. data/spec/lib/newspaper_works/data/work_file_spec.rb +99 -0
  362. data/spec/lib/newspaper_works/data/work_files_spec.rb +224 -0
  363. data/spec/lib/newspaper_works/ingest/batch_issue_ingester_spec.rb +158 -0
  364. data/spec/lib/newspaper_works/ingest/chronam_publication_info_spec.rb +35 -0
  365. data/spec/lib/newspaper_works/ingest/from_command_spec.rb +75 -0
  366. data/spec/lib/newspaper_works/ingest/image_ingest_issues_spec.rb +62 -0
  367. data/spec/lib/newspaper_works/ingest/ingest_shared.rb +75 -0
  368. data/spec/lib/newspaper_works/ingest/issue_images_spec.rb +65 -0
  369. data/spec/lib/newspaper_works/ingest/lc_publication_info_spec.rb +34 -0
  370. data/spec/lib/newspaper_works/ingest/ndnp/batch_ingester_spec.rb +131 -0
  371. data/spec/lib/newspaper_works/ingest/ndnp/batch_xml_ingest_spec.rb +64 -0
  372. data/spec/lib/newspaper_works/ingest/ndnp/container_ingest_spec.rb +44 -0
  373. data/spec/lib/newspaper_works/ingest/ndnp/container_ingester_spec.rb +126 -0
  374. data/spec/lib/newspaper_works/ingest/ndnp/container_metadata_spec.rb +36 -0
  375. data/spec/lib/newspaper_works/ingest/ndnp/issue_ingest_spec.rb +108 -0
  376. data/spec/lib/newspaper_works/ingest/ndnp/issue_ingester_spec.rb +155 -0
  377. data/spec/lib/newspaper_works/ingest/ndnp/issue_metadata_spec.rb +84 -0
  378. data/spec/lib/newspaper_works/ingest/ndnp/page_ingest_spec.rb +79 -0
  379. data/spec/lib/newspaper_works/ingest/ndnp/page_ingester_spec.rb +184 -0
  380. data/spec/lib/newspaper_works/ingest/ndnp/page_metadata_spec.rb +85 -0
  381. data/spec/lib/newspaper_works/ingest/newspaper_issue_ingest_spec.rb +83 -0
  382. data/spec/lib/newspaper_works/ingest/newspaper_page_ingest_spec.rb +77 -0
  383. data/spec/lib/newspaper_works/ingest/page_image_spec.rb +29 -0
  384. data/spec/lib/newspaper_works/ingest/pdf_images_spec.rb +32 -0
  385. data/spec/lib/newspaper_works/ingest/pdf_issue_spec.rb +29 -0
  386. data/spec/lib/newspaper_works/ingest/pdf_issues_spec.rb +62 -0
  387. data/spec/lib/newspaper_works/ingest/pdf_pages_spec.rb +110 -0
  388. data/spec/lib/newspaper_works/ingest/pub_finder_spec.rb +58 -0
  389. data/spec/lib/newspaper_works/ingest/publication_info_spec.rb +61 -0
  390. data/spec/lib/newspaper_works/ingest_spec.rb +45 -0
  391. data/spec/lib/newspaper_works/issue_pdf_composer_spec.rb +101 -0
  392. data/spec/lib/newspaper_works/logging_spec.rb +53 -0
  393. data/spec/lib/newspaper_works/page_finder_spec.rb +53 -0
  394. data/spec/lib/newspaper_works/resource_fetcher_spec.rb +65 -0
  395. data/spec/lib/newspaper_works/text_extraction/alto_reader_spec.rb +49 -0
  396. data/spec/lib/newspaper_works/text_extraction/page_ocr_spec.rb +84 -0
  397. data/spec/lib/newspaper_works/text_extraction/render_alto_spec.rb +54 -0
  398. data/spec/lib/newspaper_works/text_extraction/word_coords_builder_spec.rb +30 -0
  399. data/spec/lib/tasks/newspaper_works_rake_spec.rb +124 -0
  400. data/spec/misc_shared.rb +109 -0
  401. data/spec/model_shared.rb +134 -0
  402. data/spec/models/concerns/newspaper_works/blacklight_iiif_search/annotation_behavior_spec.rb +45 -0
  403. data/spec/models/concerns/newspaper_works/blacklight_iiif_search/search_behavior_spec.rb +27 -0
  404. data/spec/models/concerns/newspaper_works/newspaper_core_metadata_spec.rb +45 -0
  405. data/spec/models/concerns/newspaper_works/place_of_publication_behavior_spec.rb +17 -0
  406. data/spec/models/concerns/newspaper_works/scanned_media_metadata_spec.rb +35 -0
  407. data/spec/models/newspaper_article_spec.rb +73 -0
  408. data/spec/models/newspaper_container_spec.rb +111 -0
  409. data/spec/models/newspaper_issue_spec.rb +91 -0
  410. data/spec/models/newspaper_page_spec.rb +44 -0
  411. data/spec/models/newspaper_title_spec.rb +116 -0
  412. data/spec/models/newspaper_works/derivative_attachment_spec.rb +37 -0
  413. data/spec/models/newspaper_works/ingest_file_relation_spec.rb +56 -0
  414. data/spec/models/solr_document_spec.rb +14 -0
  415. data/spec/ndnp_shared.rb +48 -0
  416. data/spec/presenters/hyrax/newspaper_article_presenter_spec.rb +53 -0
  417. data/spec/presenters/hyrax/newspaper_container_presenter_spec.rb +20 -0
  418. data/spec/presenters/hyrax/newspaper_issue_presenter_spec.rb +65 -0
  419. data/spec/presenters/hyrax/newspaper_page_presenter_spec.rb +75 -0
  420. data/spec/presenters/hyrax/newspaper_title_presenter_spec.rb +153 -0
  421. data/spec/presenters/newspaper_works/iiif_manifest_presenter_behavior_spec.rb +32 -0
  422. data/spec/presenters/newspaper_works/issue_info_presenter_spec.rb +51 -0
  423. data/spec/presenters/newspaper_works/newspaper_core_presenter_spec.rb +22 -0
  424. data/spec/presenters/newspaper_works/persistent_url_presenter_behavior_spec.rb +24 -0
  425. data/spec/presenters/newspaper_works/place_of_publication_presenter_behavior_spec.rb +17 -0
  426. data/spec/presenters/newspaper_works/scanned_media_presenter_spec.rb +18 -0
  427. data/spec/presenters/newspaper_works/title_info_presenter_spec.rb +23 -0
  428. data/spec/routing/route_spec.rb +52 -0
  429. data/spec/search_builders/custom_search_builder_spec.rb +34 -0
  430. data/spec/search_builders/newspaper_works/newspapers_search_builder_spec.rb +33 -0
  431. data/spec/services/hyrax/article_genre_service_spec.rb +12 -0
  432. data/spec/services/hyrax/resource_types_service_spec.rb +12 -0
  433. data/spec/services/newspaper_works/jp2_derivative_service_spec.rb +62 -0
  434. data/spec/services/newspaper_works/newspaper_page_derivative_service_spec.rb +125 -0
  435. data/spec/services/newspaper_works/pdf_derivative_service_spec.rb +62 -0
  436. data/spec/services/newspaper_works/pluggable_derivative_service_spec.rb +204 -0
  437. data/spec/services/newspaper_works/text_extraction_derivative_service_spec.rb +82 -0
  438. data/spec/services/newspaper_works/text_formats_from_alto_service_spec.rb +129 -0
  439. data/spec/services/newspaper_works/tiff_derivative_service_spec.rb +58 -0
  440. data/spec/spec_helper.rb +261 -0
  441. data/spec/support/controller_level_helpers.rb +28 -0
  442. data/spec/test_app_templates/lib/generators/test_app_generator.rb +22 -0
  443. data/spec/views/catalog/_index_gallery_newspaper_page_wrapper.html.erb_spec.rb +36 -0
  444. data/spec/views/catalog/_index_header_list_newspaper_page.html.erb_spec.rb +26 -0
  445. data/spec/views/catalog/_thumbnail_list_newspaper_page.html.erb_spec.rb +35 -0
  446. data/spec/views/hyrax/newspaper_titles/_all_front_pages_form.html.erb_spec.rb +16 -0
  447. data/spec/views/hyrax/newspaper_titles/_issue_search_form.html.erb_spec.rb +33 -0
  448. data/spec/views/hyrax/newspaper_titles/_issues_calendar.html.erb_spec.rb +37 -0
  449. data/spec/views/hyrax/newspaper_titles/show.html.erb_spec.rb +87 -0
  450. data/spec/views/newspaper_works/base/_attribute_rows.html.erb_spec.rb +60 -0
  451. data/spec/views/newspaper_works/base/_newspaper_hierarchy.html.erb_spec.rb +80 -0
  452. data/spec/views/newspaper_works/base/_show.html.erb_spec.rb +78 -0
  453. data/spec/views/newspaper_works/newspapers_search/search.html.erb_spec.rb +54 -0
  454. data/spec/views/records/edit_fields/_place_of_publication.html.erb_spec.rb +26 -0
  455. data/tasks/newspaperworks_dev.rake +26 -0
  456. data/test/integration/navigation_test.rb +7 -0
  457. data/test/lib/generators/newspaper_works/install_generator_test.rb +16 -0
  458. data/test/newspaper_works_test.rb +7 -0
  459. data/test/test_helper.rb +17 -0
  460. data/tmp/.keep +0 -0
  461. metadata +1037 -0
@@ -0,0 +1,116 @@
1
+ # Generated via
2
+ # `rails generate hyrax:work NewspaperTitle`
3
+ require 'spec_helper'
4
+ require 'model_shared'
5
+
6
+ RSpec.describe NewspaperTitle do
7
+ before(:all) do
8
+ @fixture = model_fixtures(described_class)
9
+ end
10
+
11
+ # shared behaviors
12
+ it_behaves_like('a work and PCDM object')
13
+ it_behaves_like('a persistent work type')
14
+
15
+ describe 'Metadata and properties' do
16
+ it 'class has expected properties' do
17
+ expect(@fixture).to respond_to(:edition_name)
18
+ expect(@fixture).to respond_to(:frequency)
19
+ expect(@fixture).to respond_to(:preceded_by)
20
+ expect(@fixture).to respond_to(:succeeded_by)
21
+ expect(@fixture).to respond_to(:publication_date_start)
22
+ expect(@fixture).to respond_to(:publication_date_end)
23
+ end
24
+ end
25
+
26
+ describe 'Relationship methods' do
27
+ it 'has expected test fixture' do
28
+ expect(@fixture).to be_an_instance_of(described_class)
29
+ end
30
+
31
+ it 'can get issues' do
32
+ issues = @fixture.issues
33
+ expect(issues).to be_an_instance_of(Array)
34
+ # our test fixture is non-empty
35
+ expect(issues.length).to be > 0
36
+ issues.each do |e|
37
+ expect(e).to be_an_instance_of(NewspaperIssue)
38
+ end
39
+ end
40
+ end
41
+
42
+ it 'can get containers' do
43
+ containers = @fixture.containers
44
+ expect(containers).to be_an_instance_of(Array)
45
+ expect(containers.length).to be > 0
46
+ containers.each do |e|
47
+ expect(e).to be_an_instance_of(NewspaperContainer)
48
+ end
49
+ end
50
+
51
+ describe 'publication_date_start' do
52
+ it "is not valid with bad date format" do
53
+ nt = described_class.new(title: ["Breaking News!"],
54
+ publication_date_start: "06/21/1978")
55
+ expect(nt).not_to be_valid
56
+ end
57
+
58
+ it "is valid with proper date format" do
59
+ nt = described_class.new(title: ["Breaking News!"],
60
+ publication_date_start: "1978-06-21")
61
+ expect(nt).to be_valid
62
+ end
63
+
64
+ it "is valid with a year" do
65
+ nt = described_class.new(title: ["Breaking News!"],
66
+ publication_date_start: "1978")
67
+ expect(nt).to be_valid
68
+ end
69
+
70
+ it "is valid with a year and month" do
71
+ nt = described_class.new(title: ["Breaking News!"],
72
+ publication_date_start: "1978-06")
73
+ expect(nt).to be_valid
74
+ end
75
+
76
+ it "is not valid with start date after end date" do
77
+ nt = described_class.new(title: ["Breaking News!"],
78
+ publication_date_start: "1978-06-01",
79
+ publication_date_end: "1977-06-01")
80
+ expect(nt).not_to be_valid
81
+ end
82
+
83
+ it "is valid with start date before end date" do
84
+ nt = described_class.new(title: ["Breaking News!"],
85
+ publication_date_start: "1978-06-01",
86
+ publication_date_end: "1979-06-01")
87
+ expect(nt).to be_valid
88
+ end
89
+ end
90
+
91
+ describe 'publication_date_end' do
92
+ it "is not valid with bad date format" do
93
+ nt = described_class.new(title: ["Breaking News!"],
94
+ publication_date_end: "06/21/1978")
95
+ expect(nt).not_to be_valid
96
+ end
97
+
98
+ it "is valid with proper date format" do
99
+ nt = described_class.new(title: ["Breaking News!"],
100
+ publication_date_end: "1978-06-21")
101
+ expect(nt).to be_valid
102
+ end
103
+
104
+ it "is valid with a year" do
105
+ nt = described_class.new(title: ["Breaking News!"],
106
+ publication_date_end: "1978")
107
+ expect(nt).to be_valid
108
+ end
109
+
110
+ it "is valid with proper a year and month" do
111
+ nt = described_class.new(title: ["Breaking News!"],
112
+ publication_date_end: "1978-06")
113
+ expect(nt).to be_valid
114
+ end
115
+ end
116
+ end
@@ -0,0 +1,37 @@
1
+ require 'spec_helper'
2
+
3
+ module NewspaperWorks
4
+ RSpec.describe DerivativeAttachment, type: :model do
5
+ it "requires some columns to be considered complete" do
6
+ model = described_class.create
7
+ # attempt save without required data; expect failure
8
+ expect { model.save! }.to raise_exception(ActiveRecord::RecordInvalid)
9
+ end
10
+
11
+ it "saves when constructed with all field values" do
12
+ model = described_class.create(
13
+ fileset_id: 'a1b2c3d4e5',
14
+ path: '/path/to/somefile',
15
+ destination_name: 'txt'
16
+ )
17
+ # attempt save without required data; expect failure
18
+ expect { model.save! }.not_to raise_exception(ActiveRecord::RecordInvalid)
19
+ end
20
+
21
+ it "saves when all fields completely set" do
22
+ model = described_class.create
23
+ model.fileset_id = 'someid123'
24
+ model.path = '/path/to/somefile'
25
+ model.destination_name = 'txt'
26
+ expect { model.save! }.not_to raise_exception(ActiveRecord::RecordInvalid)
27
+ end
28
+
29
+ it "saves when only path, destination_name set" do
30
+ model = described_class.create
31
+ model.fileset_id = nil
32
+ model.path = '/path/to/somefile'
33
+ model.destination_name = 'txt'
34
+ expect { model.save! }.not_to raise_exception(ActiveRecord::RecordInvalid)
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,56 @@
1
+ require 'spec_helper'
2
+
3
+ module NewspaperWorks
4
+ RSpec.describe IngestFileRelation, type: :model do
5
+ def make_test_records
6
+ # two unique values
7
+ described_class.create(
8
+ file_path: '/some/path/to/this',
9
+ derivative_path: '/some/path/to/that'
10
+ )
11
+ described_class.create(
12
+ file_path: '/some/path/to/this',
13
+ derivative_path: '/some/path/to/other_thing'
14
+ )
15
+ # a duplicate will save, presumption is that dupes are filtered on query:
16
+ described_class.create(
17
+ file_path: '/some/path/to/this',
18
+ derivative_path: '/some/path/to/other_thing'
19
+ )
20
+ end
21
+
22
+ it "will not save unless record is complete" do
23
+ model = described_class.create
24
+ # attempt save without required data; expect failure
25
+ expect { model.save! }.to raise_exception(ActiveRecord::RecordInvalid)
26
+ model2 = described_class.create
27
+ model2.file_path = '/path/to/sourcefile.tiff'
28
+ expect { model2.save! }.to raise_exception(ActiveRecord::RecordInvalid)
29
+ model3 = described_class.create
30
+ model3.derivative_path = '/path/to/sourcefile.tiff'
31
+ expect { model3.save! }.to raise_exception(ActiveRecord::RecordInvalid)
32
+ end
33
+
34
+ it "will save sufficiently constructed record" do
35
+ model = described_class.create(
36
+ file_path: '/path/to/this',
37
+ derivative_path: '/path/to/that'
38
+ )
39
+ expect { model.save! }.not_to raise_exception(ActiveRecord::RecordInvalid)
40
+ end
41
+
42
+ it "will save when all fields completely set" do
43
+ model = described_class.create
44
+ model.file_path = '/path/to/sourcefile.tiff'
45
+ model.derivative_path = '/path/to/derived.jp2'
46
+ expect { model.save! }.not_to raise_exception(ActiveRecord::RecordInvalid)
47
+ end
48
+
49
+ it "can query derivative paths for primary file" do
50
+ make_test_records
51
+ result = described_class.derivatives_for_file('/some/path/to/this')
52
+ expect(result).to be_an Array
53
+ expect(result.size).to eq 2
54
+ end
55
+ end
56
+ end
@@ -0,0 +1,14 @@
1
+ require 'spec_helper'
2
+ RSpec.describe SolrDocument do
3
+ let(:solr_doc) { described_class.new(id: 'foo', file_set_ids_ssim: ['bar']) }
4
+
5
+ describe 'file_set_ids' do
6
+ it 'responds to #file_set_ids' do
7
+ expect(solr_doc).to respond_to(:file_set_ids)
8
+ end
9
+
10
+ it 'returns the correct value' do
11
+ expect(solr_doc.file_set_ids).to eq(['bar'])
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,48 @@
1
+ require 'newspaper_works_fixtures'
2
+
3
+ RSpec.shared_context "ndnp fixture setup", shared_context: :metadata do
4
+ let(:ndnp_fixture_path) do
5
+ path = File.join(NewspaperWorksFixtures.file_fixtures, 'ndnp')
6
+ whitelist = Hyrax.config.whitelisted_ingest_dirs
7
+ whitelist.push(path) unless whitelist.include?(path)
8
+ path
9
+ end
10
+
11
+ # `batch_local` example issue:
12
+ let(:issue1) do
13
+ File.join(
14
+ ndnp_fixture_path,
15
+ 'batch_local/sn85058233/17082901001/1935080201/1935080201.xml'
16
+ )
17
+ end
18
+
19
+ # `batch_test_ver01` example issue:
20
+ let(:issue2) do
21
+ File.join(
22
+ ndnp_fixture_path,
23
+ 'batch_test_ver01/data/sn85025202/00279557281/1857021401/1857021401.xml'
24
+ )
25
+ end
26
+
27
+ let(:reel1) do
28
+ File.join(
29
+ ndnp_fixture_path,
30
+ 'batch_test_ver01/data/sn84038814/00279557177/00279557177.xml'
31
+ )
32
+ end
33
+
34
+ # reel with no explicit reel number, but containing it in mets/@LABEL
35
+ let(:reel2) do
36
+ File.join(
37
+ ndnp_fixture_path,
38
+ 'batch_test_ver01/data/sn85025202/00279557281/00279557281_1.xml'
39
+ )
40
+ end
41
+
42
+ let(:batch1) do
43
+ File.join(
44
+ ndnp_fixture_path,
45
+ 'batch_test_ver01/data/BATCH_1.xml'
46
+ )
47
+ end
48
+ end
@@ -0,0 +1,53 @@
1
+ require 'spec_helper'
2
+ require_relative '../newspaper_works/newspaper_core_presenter_spec'
3
+ require_relative '../newspaper_works/scanned_media_presenter_spec'
4
+
5
+ RSpec.describe Hyrax::NewspaperArticlePresenter do
6
+ let(:solr_document) { SolrDocument.new(attributes) }
7
+ let(:request) { double(host: 'example.org') }
8
+ let(:ability) { nil }
9
+ let(:presenter) { described_class.new(solr_document, ability, request) }
10
+
11
+ let(:attributes) do
12
+ { "author" => '888888',
13
+ "photographer" => ['foo', 'bar'],
14
+ "genre" => ["Editorials"],
15
+ "volume" => ["volume 1"],
16
+ "edition_number" => ["1"],
17
+ "issue_number" => ['1'],
18
+ "geographic_coverage" => ["wide"],
19
+ "extent" => ["vast"],
20
+ "publication_date" => ["2017-08-25"],
21
+ 'page_ids_ssim' => ['foo'],
22
+ 'page_titles_ssim' => ['bar'] }
23
+ end
24
+
25
+ it_behaves_like "a newspaper core presenter"
26
+ it_behaves_like "a scanned media presenter"
27
+
28
+ subject { described_class.new(double, double) }
29
+
30
+ it { is_expected.to delegate_method(:author).to(:solr_document) }
31
+ it { is_expected.to delegate_method(:photographer).to(:solr_document) }
32
+ it { is_expected.to delegate_method(:genre).to(:solr_document) }
33
+ it { is_expected.to delegate_method(:volume).to(:solr_document) }
34
+ it { is_expected.to delegate_method(:edition_number).to(:solr_document) }
35
+ it { is_expected.to delegate_method(:issue_number).to(:solr_document) }
36
+ it { is_expected.to delegate_method(:geographic_coverage).to(:solr_document) }
37
+ it { is_expected.to delegate_method(:extent).to(:solr_document) }
38
+ it { is_expected.to respond_to(:publication_date) }
39
+
40
+ describe 'object relationship methods' do
41
+ describe '#page_ids' do
42
+ it 'returns the correct value' do
43
+ expect(presenter.page_ids).to eq ['foo']
44
+ end
45
+ end
46
+
47
+ describe '#page_title' do
48
+ it 'returns the correct value' do
49
+ expect(presenter.page_titles).to eq ['bar']
50
+ end
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,20 @@
1
+ require 'spec_helper'
2
+ require_relative '../newspaper_works/newspaper_core_presenter_spec'
3
+
4
+ RSpec.describe Hyrax::NewspaperContainerPresenter do
5
+ let(:solr_document) { SolrDocument.new(attributes) }
6
+
7
+ let(:attributes) do
8
+ { "extent" => ["1st"],
9
+ "publication_date_start" => ["2017-08-25"],
10
+ "publication_date_end" => ["2017-08-30"] }
11
+ end
12
+
13
+ it_behaves_like "a newspaper core presenter"
14
+
15
+ subject { described_class.new(double, double) }
16
+
17
+ it { is_expected.to delegate_method(:extent).to(:solr_document) }
18
+ it { is_expected.to delegate_method(:publication_date_start).to(:solr_document) }
19
+ it { is_expected.to delegate_method(:publication_date_end).to(:solr_document) }
20
+ end
@@ -0,0 +1,65 @@
1
+ require 'spec_helper'
2
+ require_relative '../newspaper_works/newspaper_core_presenter_spec'
3
+
4
+ RSpec.describe Hyrax::NewspaperIssuePresenter do
5
+ let(:ability) { double 'Ability' }
6
+ let(:request) { double(host: 'example.org') }
7
+ let(:solr_document) { SolrDocument.new(attributes) }
8
+ let(:presenter) { described_class.new(solr_document, ability, request) }
9
+
10
+ let(:attributes) do
11
+ { "id" => '123456',
12
+ "volume_tesim" => ['8'],
13
+ "edition_number_tesim" => ['1'],
14
+ "issue_number_tesim" => ['1st issue'],
15
+ "extent_tesim" => ["4 pages"],
16
+ "publication_date_dtsi" => "2017-08-25T00:00:00Z",
17
+ "publication_unique_id_ssi" => "sn1234567" }
18
+ end
19
+
20
+ it_behaves_like "a newspaper core presenter"
21
+
22
+ subject { described_class.new(double, double) }
23
+
24
+ it { is_expected.to delegate_method(:volume).to(:solr_document) }
25
+ it { is_expected.to delegate_method(:edition_number).to(:solr_document) }
26
+ it { is_expected.to delegate_method(:issue_number).to(:solr_document) }
27
+ it { is_expected.to delegate_method(:extent).to(:solr_document) }
28
+ it { is_expected.to respond_to(:publication_date) }
29
+
30
+ describe '#iiif_viewer?' do
31
+ let(:current_ability) { ability }
32
+ let(:work_presenter) { Hyrax::NewspaperPagePresenter.new(solr_document, nil) }
33
+ let(:work_presenters) { [work_presenter] }
34
+ let(:iiif_enabled) { true }
35
+ let(:work_model_name) { 'NewspaperPage' }
36
+
37
+ before do
38
+ allow(Hyrax.config).to receive(:iiif_image_server?).and_return(iiif_enabled)
39
+ allow(presenter).to receive(:work_presenters).and_return(work_presenters)
40
+ allow(presenter).to receive(:current_ability).and_return(current_ability)
41
+ allow(work_presenter).to receive(:iiif_viewer?).and_return(true)
42
+ allow(work_presenter).to receive(:model_name).and_return(work_model_name)
43
+ allow(current_ability).to receive(:can?).with(:read, solr_document.id).and_return(true)
44
+ end
45
+
46
+ subject { presenter.iiif_viewer? }
47
+
48
+ it { is_expected.to be true }
49
+
50
+ context 'when iiif_image_server? config not set' do
51
+ let(:iiif_enabled) { false }
52
+ it { is_expected.to be false }
53
+ end
54
+
55
+ context 'when work_presenter is not a NewspaperPagePresenter' do
56
+ let(:work_model_name) { 'foo' }
57
+ it { is_expected.to be false }
58
+ end
59
+ end
60
+
61
+ describe '#persistent_url' do
62
+ subject { presenter.persistent_url }
63
+ it { is_expected.to include '/newspapers/sn1234567/2017-08-25/ed-1' }
64
+ end
65
+ end
@@ -0,0 +1,75 @@
1
+ require 'spec_helper'
2
+ require_relative '../newspaper_works/scanned_media_presenter_spec'
3
+
4
+ RSpec.describe Hyrax::NewspaperPagePresenter do
5
+ let(:ability) { double 'Ability' }
6
+ let(:request) { double(host: 'example.org') }
7
+ let(:solr_document) { SolrDocument.new(attributes) }
8
+ let(:attributes) do
9
+ { "id" => "page1",
10
+ "height" => "1000px",
11
+ "width" => "800px",
12
+ "issue_id_ssi" => "issue1",
13
+ "issue_edition_number_ssi" => '1',
14
+ "publication_date_dtsi" => "2017-08-25T00:00:00Z",
15
+ "publication_unique_id_ssi" => "sn1234567",
16
+ 'is_following_page_of_ssi' => 'foo',
17
+ 'is_preceding_page_of_ssi' => 'bar',
18
+ 'container_id_ssi' => 'baz',
19
+ 'container_title_ssi' => 'quux',
20
+ 'article_ids_ssim' => ['123456'],
21
+ 'article_titles_ssim' => ['Test Title'] }
22
+ end
23
+
24
+ let(:presenter) { described_class.new(solr_document, ability, request) }
25
+
26
+ it_behaves_like "a scanned media presenter"
27
+
28
+ subject { described_class.new(solr_document, double) }
29
+
30
+ it { is_expected.to delegate_method(:height).to(:solr_document) }
31
+ it { is_expected.to delegate_method(:width).to(:solr_document) }
32
+
33
+ describe '#persistent_url' do
34
+ subject { presenter.persistent_url }
35
+ it { is_expected.to include '/newspapers/sn1234567/2017-08-25/ed-1/seq-1' }
36
+ end
37
+
38
+ describe 'object relationship methods' do
39
+ describe '#previous_page_id' do
40
+ it 'returns the correct value' do
41
+ expect(subject.previous_page_id).to eq 'foo'
42
+ end
43
+ end
44
+
45
+ describe '#next_page_id' do
46
+ it 'returns the correct value' do
47
+ expect(subject.next_page_id).to eq 'bar'
48
+ end
49
+ end
50
+
51
+ describe '#container_id' do
52
+ it 'returns the correct value' do
53
+ expect(subject.container_id).to eq 'baz'
54
+ end
55
+ end
56
+
57
+ describe '#container_title' do
58
+ it 'returns the correct value' do
59
+ expect(subject.container_title).to eq 'quux'
60
+ end
61
+ end
62
+
63
+ describe '#article_ids' do
64
+ it 'returns the correct value' do
65
+ expect(subject.article_ids).to eq ['123456']
66
+ end
67
+ end
68
+
69
+ describe '#article_titles' do
70
+ it 'returns the correct value' do
71
+ expect(subject.article_titles).to eq ['Test Title']
72
+ end
73
+ end
74
+ end
75
+ end
@@ -0,0 +1,153 @@
1
+ require 'spec_helper'
2
+ require_relative '../newspaper_works/newspaper_core_presenter_spec'
3
+
4
+ RSpec.describe Hyrax::NewspaperTitlePresenter do
5
+ # use before(:all) so we only create fixtures once
6
+ before(:all) do
7
+ @publication = NewspaperTitle.new
8
+ @publication.title = ["Wall Street Journal"]
9
+ @publication.edition_name = "1st"
10
+ @publication.frequency = ["often"]
11
+ @publication.preceded_by = ["Something"]
12
+ @publication.succeeded_by = ["Something Else"]
13
+ @publication.lccn = "sn1234567"
14
+
15
+ issue1 = NewspaperIssue.new
16
+ issue1.title = ['February 13, 2016']
17
+ issue1.resource_type = ["newspaper"]
18
+ issue1.language = ["eng"]
19
+ issue1.held_by = "Marriott Library"
20
+ issue1.publication_date = '2016-02-13'
21
+ @publication.members.push issue1
22
+
23
+ issue2 = NewspaperIssue.new
24
+ issue2.title = ['February 13, 2019']
25
+ issue2.resource_type = ["newspaper"]
26
+ issue2.language = ["eng"]
27
+ issue2.held_by = "Marriott Library"
28
+ issue2.publication_date = '2019-02-13'
29
+ @publication.members.push issue2
30
+
31
+ issue3 = NewspaperIssue.new
32
+ issue3.title = ['March 5, 2019']
33
+ issue3.resource_type = ["newspaper"]
34
+ issue3.language = ["eng"]
35
+ issue3.held_by = "Marriott Library"
36
+ issue3.publication_date = '2019-03-05'
37
+ @publication.members.push issue3
38
+
39
+ issue1.save!
40
+ issue2.save!
41
+ issue3.save!
42
+ @publication.save!
43
+ @issues = [issue1, issue2, issue3]
44
+ end
45
+
46
+ let(:solr_document) { SolrDocument.find(@publication.id) }
47
+ let(:request) { double(host: 'example.org', base_url: 'http://example.org', params: {}) }
48
+ let(:user_key) { 'a_user_key' }
49
+ let(:ability) { double Ability }
50
+ let(:presenter) { described_class.new(solr_document, ability, request) }
51
+
52
+ subject { presenter }
53
+
54
+ it { is_expected.to delegate_method(:alternative_title).to(:solr_document) }
55
+ it { is_expected.to delegate_method(:issn).to(:solr_document) }
56
+ it { is_expected.to delegate_method(:lccn).to(:solr_document) }
57
+ it { is_expected.to delegate_method(:oclcnum).to(:solr_document) }
58
+ it { is_expected.to delegate_method(:held_by).to(:solr_document) }
59
+
60
+ it { is_expected.to delegate_method(:edition_name).to(:solr_document) }
61
+ it { is_expected.to delegate_method(:frequency).to(:solr_document) }
62
+ it { is_expected.to delegate_method(:preceded_by).to(:solr_document) }
63
+ it { is_expected.to delegate_method(:succeeded_by).to(:solr_document) }
64
+
65
+ describe 'title_search_params' do
66
+ subject { presenter.title_search_params }
67
+ it 'will return solr query parameters for locating issues of the title' do
68
+ expect(subject).to contain_exactly([:f, "publication_title_ssi" => ["Wall Street Journal"]])
69
+ end
70
+ end
71
+
72
+ describe 'front_page_search_params' do
73
+ subject { presenter.front_page_search_params }
74
+ it 'will return solr query parameters for locating every first page associated with the title' do
75
+ expect(subject).to contain_exactly([:f, "publication_title_ssi" => ["Wall Street Journal"],
76
+ "first_page_bsi" => [true]],
77
+ [:sort, "publication_date_dtsi asc"])
78
+ end
79
+ end
80
+
81
+ describe '#issues' do
82
+ subject { presenter.issues }
83
+ it 'will return a all member issues for the earliest year when no year param is provided' do
84
+ expect(subject.pluck("id")).to contain_exactly(@issues[0].id)
85
+ end
86
+
87
+ it 'will return all member issues for a given year when a year param is provided' do
88
+ allow(request).to receive(:params).and_return(year: 2019)
89
+ expect(subject.pluck("id")).to contain_exactly(@issues[1].id, @issues[2].id)
90
+ end
91
+ end
92
+
93
+ describe '#issue_years' do
94
+ subject { presenter.issue_years }
95
+ it "will return a sorted list of years with no nil values" do
96
+ allow(presenter).to receive(:all_title_issue_dates).and_return(['2017-01-01T00:00:00Z', nil, '2016-01-01', '2001-12-01', '2017-12-10'])
97
+ is_expected.to eq [2001, 2016, 2017]
98
+ end
99
+ end
100
+
101
+ describe '#prev_year' do
102
+ subject { presenter.prev_year }
103
+ it "will return nil if the current year is earliest" do
104
+ is_expected.to be nil
105
+ end
106
+
107
+ it "will return the previous year if the current year isn't earliest" do
108
+ allow(request).to receive(:params).and_return(year: 2019)
109
+ is_expected.to eq 2016
110
+ end
111
+ end
112
+
113
+ describe '#next_year' do
114
+ subject { presenter.next_year }
115
+ it "will return the next year if the current year isn't latest" do
116
+ is_expected.to be 2019
117
+ end
118
+
119
+ it "will return nil if the current year is latest" do
120
+ allow(request).to receive(:params).and_return(year: 2019)
121
+ is_expected.to eq nil
122
+ end
123
+ end
124
+
125
+ describe '#year' do
126
+ subject { presenter.year }
127
+ it "will return the earliest issue year if no year is provided" do
128
+ is_expected.to eq 2016
129
+ end
130
+
131
+ it "will return the param year if provided" do
132
+ allow(request).to receive(:params).and_return(year: 2019)
133
+ is_expected.to eq 2019
134
+ end
135
+ end
136
+
137
+ describe '#all_title_issues' do
138
+ subject { presenter.all_title_issues }
139
+ it 'will return a all member issues' do
140
+ expect(subject.pluck("id")).to contain_exactly(@issues[0].id, @issues[1].id, @issues[2].id)
141
+ end
142
+ end
143
+
144
+ describe '#publication_unique_id' do
145
+ subject { presenter.publication_unique_id }
146
+ it { is_expected.to eq ['sn1234567'] }
147
+ end
148
+
149
+ describe '#persistent_url' do
150
+ subject { presenter.persistent_url }
151
+ it { is_expected.to include '/newspapers/sn1234567' }
152
+ end
153
+ end
@@ -0,0 +1,32 @@
1
+ require 'spec_helper'
2
+
3
+ RSpec.describe NewspaperWorks::IiifManifestPresenterBehavior do
4
+ let(:attributes) do
5
+ { "id" => "abc123",
6
+ "title_tesim" => ['Page the first'],
7
+ "page_number_tesim" => ['20'],
8
+ "section_tesim" => ['B'] }
9
+ end
10
+ let(:solr_document) { SolrDocument.new(attributes) }
11
+ let(:presenter) { Hyrax::NewspaperPagePresenter.new(solr_document, nil) }
12
+ let(:test_request) { ActionDispatch::TestRequest.new({}) }
13
+
14
+ before { allow(presenter).to receive(:request).and_return(test_request) }
15
+
16
+ describe '#search_service' do
17
+ it 'returns the correct URL for the IIIF Search service' do
18
+ expect(presenter.search_service).to include('abc123/iiif_search')
19
+ end
20
+ end
21
+
22
+ describe '#manifest_metadata' do
23
+ subject { presenter.manifest_metadata }
24
+
25
+ it { is_expected.not_to be_falsey }
26
+
27
+ it 'returns the correct metadata array for the manifest' do
28
+ expect(subject.map { |v| v["label"] }).to include('Page number')
29
+ expect(subject.map { |v| v["value"] }).to include(['B'])
30
+ end
31
+ end
32
+ end