-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Generators: cleanup and separate paths for BL and GBL
Had to do it.
- Loading branch information
Showing
4 changed files
with
96 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
# frozen_string_literal: true | ||
|
||
require "rails/generators" | ||
|
||
module Blacklight | ||
module Allmaps | ||
class BlacklightGenerator < Rails::Generators::Base | ||
source_root File.expand_path("templates", __dir__) | ||
|
||
desc <<-DESCRIPTION | ||
This generator makes the following changes to your application: | ||
1. Copies stylesheets to Blacklight app | ||
2. Adds Blacklight::Allmaps viewer to CatalogController | ||
3. Adds georeferenced facet to CatalogController | ||
4. Includes Blacklight::Allmaps::SolrDocument in SolrDocument | ||
DESCRIPTION | ||
|
||
def add_bl_stylesheets | ||
append_to_file "app/assets/stylesheets/blacklight.scss" do | ||
"@import 'blacklight/allmaps/base';" | ||
end | ||
end | ||
|
||
def add_bl_allmaps_viewer | ||
# Use the allmaps viewer | ||
inject_into_file "app/controllers/catalog_controller.rb", after: "#config.show.thumbnail_field = 'thumbnail_path_ss'" do | ||
"\n | ||
# Blacklight::Allmaps Viewer | ||
config.show.partials.insert(1, :blacklight_allmaps)" | ||
end | ||
end | ||
|
||
def add_bl_georeferenced_facet | ||
inject_into_file "app/controllers/catalog_controller.rb", after: "config.add_facet_field 'subject_era_ssim', label: 'Era'" do | ||
"\n config.add_facet_field 'bl_georeferenced_bsi', label: I18n.t('allmaps.bl_facet_label')" | ||
end | ||
end | ||
|
||
def include_blacklight_allmaps_solrdocument | ||
inject_into_file "app/models/solr_document.rb", after: "include Blacklight::Solr::Document" do | ||
"\n include Blacklight::Allmaps::SolrDocument" | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
lib/generators/blacklight/allmaps/geoblacklight_generator.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# frozen_string_literal: true | ||
|
||
require "rails/generators" | ||
|
||
module Blacklight | ||
module Allmaps | ||
class GeoblacklightGenerator < Rails::Generators::Base | ||
source_root File.expand_path("templates", __dir__) | ||
|
||
desc <<-DESCRIPTION | ||
This generator makes the following changes to your application: | ||
1. Adds stylesheets to application.scss | ||
2. Adds GeoBlacklight to Gemfile | ||
3. Adds Blacklight::Allmaps Tabbed Viewer to CatalogController | ||
DESCRIPTION | ||
|
||
def add_gbl_stylesheets | ||
append_to_file "app/assets/stylesheets/application.scss" do | ||
"@import 'blacklight/allmaps/base';" | ||
end | ||
end | ||
|
||
def add_geoblacklight | ||
append_to_file "Gemfile", '"geoblacklight", "~> 4.4"' | ||
end | ||
|
||
def add_gbl_tabbed_viewer | ||
# Use the tabbed viewer | ||
inject_into_file "app/controllers/catalog_controller.rb", after: "config.show.partials << \"show_default_viewer_container\"" do | ||
"\n | ||
# Blacklight::Allmaps Tabbed Viewer | ||
config.show.partials << \"show_allmaps_tabbed_viewer_container\"" | ||
end | ||
|
||
# Remove the default viewer | ||
gsub_file("app/controllers/catalog_controller.rb", "config.show.partials << \"show_default_viewer_container\"", "#config.show.partials << \"show_default_viewer_container\"") | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters