Class: Hyrax::RiiifGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- Hyrax::RiiifGenerator
- Defined in:
- lib/generators/hyrax/riiif_generator.rb
Instance Method Summary collapse
- #add_to_gemfile ⇒ Object
- #banner ⇒ Object
- #copy_initializer ⇒ Object
- #copy_unauthorized_image ⇒ Object
- #enable_riiif_in_hyrax_config ⇒ Object
- #mount_route ⇒ Object
- #override_image_url_builder_in_hyrax_config ⇒ Object
- #override_info_url_builder_in_hyrax_config ⇒ Object
Instance Method Details
#add_to_gemfile ⇒ Object
19 20 21 |
# File 'lib/generators/hyrax/riiif_generator.rb', line 19 def add_to_gemfile gem 'riiif', '~> 2.1' end |
#banner ⇒ Object
15 16 17 |
# File 'lib/generators/hyrax/riiif_generator.rb', line 15 def say_status('info', 'GENERATING RIIIF IMAGE SERVER', :blue) end |
#copy_initializer ⇒ Object
23 24 25 |
# File 'lib/generators/hyrax/riiif_generator.rb', line 23 def copy_initializer copy_file 'config/initializers/riiif.rb' end |
#copy_unauthorized_image ⇒ Object
54 55 56 |
# File 'lib/generators/hyrax/riiif_generator.rb', line 54 def copy_file 'app/assets/images/us_404.svg' end |
#enable_riiif_in_hyrax_config ⇒ Object
31 32 33 34 35 |
# File 'lib/generators/hyrax/riiif_generator.rb', line 31 def enable_riiif_in_hyrax_config insert_into_file 'config/initializers/hyrax.rb', before: /^ # config.iiif_image_server = false/ do " config.iiif_image_server = true\n" end end |
#mount_route ⇒ Object
27 28 29 |
# File 'lib/generators/hyrax/riiif_generator.rb', line 27 def mount_route route "mount Riiif::Engine => 'images', as: :riiif if Hyrax.config.iiif_image_server?" end |
#override_image_url_builder_in_hyrax_config ⇒ Object
37 38 39 40 41 42 43 |
# File 'lib/generators/hyrax/riiif_generator.rb', line 37 def override_image_url_builder_in_hyrax_config insert_into_file 'config/initializers/hyrax.rb', before: /^ # config.iiif_image_url_builder/ do " config.iiif_image_url_builder = lambda do |file_id, base_url, size, format|\n" \ " Riiif::Engine.routes.url_helpers.image_url(file_id, host: base_url, size: size)\n" \ " end\n" end end |
#override_info_url_builder_in_hyrax_config ⇒ Object
45 46 47 48 49 50 51 52 |
# File 'lib/generators/hyrax/riiif_generator.rb', line 45 def override_info_url_builder_in_hyrax_config insert_into_file 'config/initializers/hyrax.rb', before: /^ # config.iiif_info_url_builder/ do " config.iiif_info_url_builder = lambda do |file_id, base_url|\n" \ " uri = Riiif::Engine.routes.url_helpers.info_url(file_id, host: base_url)\n" \ " uri.sub(%r{/info\\.json\\Z}, '')\n" \ " end\n" end end |