Skip to content

Commit

Permalink
Merge pull request #275 from projectblacklight/fix_config_suggestion
Browse files Browse the repository at this point in the history
Simply documented and tested config to activate range limit facet
  • Loading branch information
seanaery authored Nov 13, 2024
2 parents 7820e67 + b9caef7 commit 9ba9922
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 17 deletions.
28 changes: 13 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ package.json-based use will additionally need to point to the matching unreleaes
You have at least one solr field you want to display as a range limit, that's why you've installed this plugin. In your CatalogController, the facet configuration should look like:

```ruby
config.add_facet_field 'pub_date', label: 'Publication Year', **default_range_config
config.add_facet_field 'pub_date', label: 'Publication Year', range: true
```

You should now get range limit display. More complicated configuration is available if desired, see Range Facet Configuration below.
Expand All @@ -92,20 +92,18 @@ Note that a drill-down will never require the second request, because boundaries
There are some additional configuration options that can be passed in facet config in the `range_config` key. You can pass some or all of them like this:

```ruby
config.add_facet_field 'pub_date', label: 'Publication Year',
**default_range_config.deep_merge(
range_config: {
num_segments: 6,
assumed_boundaries: [1100, Time.now.year + 2],
segments: true,
chart_js: true,
textual_facets: true,
textual_facets_collapsible: true,
chart_segment_border_color: "rgba(0,0,0, 0.5)",
chart_segment_bg_color: "#ccddcc",
chart_aspect_ratio: "2"
}
)
config.add_facet_field 'pub_date', label: 'Publication Year', range_config: {
num_segments: 6,
assumed_boundaries: [1100, Time.now.year + 2],
segments: true,
chart_js: true,
textual_facets: true,
textual_facets_collapsible: true,
chart_segment_border_color: "rgba(0,0,0, 0.5)",
chart_segment_bg_color: "#ccddcc",
chart_aspect_ratio: "2"
}
)
```

* **:num_segments** :
Expand Down
2 changes: 1 addition & 1 deletion spec/features/blacklight_range_limit_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
before do
CatalogController.blacklight_config = Blacklight::Configuration.new
CatalogController.configure_blacklight do |config|
config.add_facet_field 'pub_date_si', **CatalogController.default_range_config
config.add_facet_field 'pub_date_si', range: true
config.default_solr_params[:'facet.field'] = config.facet_fields.keys
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def fixtures

def inject_into_catalog_controller
inject_into_file 'app/controllers/catalog_controller.rb', after: /config.add_facet_field 'format'.*$/ do
"\n config.add_facet_field 'pub_date_si', label: 'Publication Date Sort', **default_range_config"
"\n config.add_facet_field 'pub_date_si', label: 'Publication Date Sort', range: true"
end
end
end

0 comments on commit 9ba9922

Please sign in to comment.