From c1745a3bed876e152c1e8156e042d5aaece584a4 Mon Sep 17 00:00:00 2001 From: Sonia Connolly Date: Tue, 30 Jan 2024 14:45:47 -0800 Subject: [PATCH 1/6] Add catalog_controller.rb hint comment to ruby snippets that go in that controller --- v8.0.0.alpha/09-general-configuration-patterns.md | 7 ++++++- v8.0.0.alpha/10-metadata-fields.md | 6 ++++++ v8.0.0.alpha/11-facet-fields.md | 7 +++++++ v8.0.0.alpha/12-search-fields.md | 4 ++++ v8.0.0.alpha/13-sort-fields.md | 4 ++++ v8.0.0.alpha/14-solr-parameters.md | 3 +++ v8.0.0.alpha/15-thumbnails.md | 1 + v8.0.0.alpha/21-apis.md | 1 + 8 files changed, 32 insertions(+), 1 deletion(-) diff --git a/v8.0.0.alpha/09-general-configuration-patterns.md b/v8.0.0.alpha/09-general-configuration-patterns.md index 28e2993..c9a03cf 100644 --- a/v8.0.0.alpha/09-general-configuration-patterns.md +++ b/v8.0.0.alpha/09-general-configuration-patterns.md @@ -14,6 +14,7 @@ The keys provided to many fields are intended to point either to a field in solr The following example will configure a facet with the field name `language_ssim` based on the key that was passed in. ```ruby +# app/controllers/catalog_controller.rb configure_blacklight do |config| config.add_facet_field 'language_ssim' end @@ -24,6 +25,7 @@ end It's typical, but not required, that the Blacklight field key matches the solr field name. This is the case in the example above. However, you can also configure a field to use a different solr field name, which is useful if you want to use the same field with different display characteristics, or if you want to keep Solr internals out of your URLs: ```ruby +# app/controllers/catalog_controller.rb configure_blacklight do |config| config.add_facet_field 'language', field: 'language_facet_ssim' end @@ -33,6 +35,7 @@ end There are a few ways to add labels to fields (as you'll notice if you're following along the example above got a default label), but one of the ways is to add a label key direction. Many of the configurations Blacklight provides take a label option. ```ruby +# app/controllers/catalog_controller.rb configure_blacklight do |config| config.add_facet_field 'language_ssim', label: 'Language' end @@ -44,6 +47,7 @@ You can control the display of elements by passing values to `if` and `unless`. ```ruby +# app/controllers/catalog_controller.rb configure_blacklight do |config| config.add_facet_field 'language_ssim', label: 'Language', if: false end @@ -56,6 +60,7 @@ You can also control display using the `if`/`unless` configurations by passing a In the example below, the language facet will only be displayed when a format of "Book" has been selected in the facets. ```ruby +# app/controllers/catalog_controller.rb configure_blacklight do |config| config.add_facet_field 'language_ssim', label: 'Language', if: -> (controller, _config, _field) do selected_formats = controller.params.dig('f', 'format') || [] @@ -66,5 +71,5 @@ end ```
- For more information about configuring Blacklight, checkout the Blacklight Wiki. + For more information about configuring Blacklight, check out the Blacklight Wiki.
diff --git a/v8.0.0.alpha/10-metadata-fields.md b/v8.0.0.alpha/10-metadata-fields.md index 7d79da2..55360dd 100644 --- a/v8.0.0.alpha/10-metadata-fields.md +++ b/v8.0.0.alpha/10-metadata-fields.md @@ -8,6 +8,7 @@ blacklight_version: v8.0.0.alpha The metadata fields that are displayed in the index (search results) and show (record view) can be configured using the `add_index_field` and `add_show_field` configuration methods in the Blacklight config. ```ruby +# app/controllers/catalog_controller.rb configure_blacklight do |config| # Index / Search Results config.add_index_field 'author_tsim', label: 'Author' @@ -55,6 +56,7 @@ There are a few configuration options that can help you format the data using Bl One common customization is to update the way that Blacklight joins multiple values by default. Blacklight's rendering pipeline uses rails' [`to_sentence`](https://apidock.com/rails/Array/to_sentence) helper (with its default options) to join multiple solr field values together, and allows you to pass in alternate options using the `separator_options` configuration option. For instance, if we wanted to separate all values by line breaks instead of the `,`s and `and` we can do that with the following configuration (the record with ID 92117465 is a good example of this in action). ```ruby +# app/controllers/catalog_controller.rb configure_blacklight do |config| # This field configuration would need to be added as it is not in the generated controller config.add_show_field 'author_addl_tsim', label: 'Additional authors', separator_options: { @@ -68,6 +70,7 @@ end It's also possible to link these values using the built-in `link_to_facet` configuration option. Two of the show fields that it might make sense to do this with (and are indexed appropriately for faceting) are the format and language fields on the show view. ```diff +# app/controllers/catalog_controller.rb - config.add_show_field 'format', label: 'Format' - config.add_show_field 'language_ssim', label: 'Language' + config.add_show_field 'format', label: 'Format', link_to_facet: true @@ -85,6 +88,7 @@ The field values can also be mapped using field configuration. There are two eas Accessors are handy when the transformation you want to make is based entirely on the data from the field (or document). One thing you might do is map names given as "last name, first name" into "first name last name" [^1]. The most basic accessor configuration is using the explicit accessor configuration: ```ruby +# app/controllers/catalog_controller.rb configure_blacklight do |config| # Index / Search Results config.add_index_field 'author_tsim', label: 'Author', accessor: :author_name @@ -120,6 +124,7 @@ end Alternatively, you can use the `values` parameter to provide document values [^2]. This is a good choice if the value varies based on the request (e.g. the values are internationalized using the user's profile, or an administrator sees additional data, etc): ```ruby +# app/controllers/catalog_controller.rb configure_blacklight do |config| # Index / Search Results config.add_index_field 'JSON', label: 'Solr Document', values: ->(field_config, document, _) { @@ -133,6 +138,7 @@ end The field values can also be rendered using a custom viewcomponent. This is a good choice if you want to render a field value in a more complex way than the default rendering pipeline. With a custom view component, you can render the field value in any way you want. ```ruby +# app/controllers/catalog_controller.rb config.add_show_field 'JSON', label: 'Solr Document', component: DetailsComponent ``` diff --git a/v8.0.0.alpha/11-facet-fields.md b/v8.0.0.alpha/11-facet-fields.md index a8e58f8..baa5295 100644 --- a/v8.0.0.alpha/11-facet-fields.md +++ b/v8.0.0.alpha/11-facet-fields.md @@ -10,6 +10,7 @@ Blacklight provides facets to help a user filter search results. Facet fields can be configured using the `add_facet_field` configuration method: ```ruby +# app/controllers/catalog_controller.rb configure_blacklight do |config| config.add_facet_field 'format', label: 'Format' end @@ -20,6 +21,7 @@ Solr calculates the number of hits for each format value. Blacklight displays th If there are many facet values, you can use `limit` to control how many appear on the search results page. ```diff +# app/controllers/catalog_controller.rb - config.add_facet_field 'subject_ssim', label: 'Topic' + config.add_facet_field 'subject_ssim', label: 'Topic', limit: 5 ``` @@ -28,12 +30,14 @@ Additional facet values are available in a modal popup. You can control whether the facet is displayed expanded by default: ```diff +# app/controllers/catalog_controller.rb - config.add_facet_field 'format', label: 'Format' + config.add_facet_field 'format', label: 'Format', collapse: false ``` You can also sort the values alphabetically [^1]: ```diff +# app/controllers/catalog_controller.rb - config.add_facet_field 'format', label: 'Format', collapse: false + config.add_facet_field 'format', label: 'Format', collapse: false, sort: 'alpha', limit: -1 ``` @@ -41,6 +45,7 @@ You can also sort the values alphabetically [^1]: If the facet data is mutually exclusive, you might consider using `single` to allow the user to toggle between values easily: ```diff +# app/controllers/catalog_controller.rb - config.add_facet_field 'pub_date_ssim', label: 'Publication Year' + config.add_facet_field 'pub_date_ssim', label: 'Publication Year', single: true ``` @@ -51,6 +56,7 @@ If the facet data is mutually exclusive, you might consider using `single` to al Blacklight also has built-in support for other types of Solr faceting. Query facets are good for providing facets based on dynamic data not directly present in the index. You can specify the "values" of a query facet and the applicable Solr query using the `query` parameter: ```ruby +# app/controllers/catalog_controller.rb config.add_facet_field 'example_query_facet_field', label: 'Publish Date', query: { years_5: { label: 'within 5 Years', fq: "pub_date_ssim:[#{Time.zone.now.year - 5 } TO *]" }, years_10: { label: 'within 10 Years', fq: "pub_date_ssim:[#{Time.zone.now.year - 10 } TO *]" }, @@ -137,6 +143,7 @@ Blacklight uses the `Blacklight::SearchState` to map a user's query parameters t Here, we'll map the language field to a single-valued `language` parameter instead of the default `f[format][]`: ```ruby +# app/controllers/catalog_controller.rb config.add_facet_field 'language_ssim', filter_class: SimpleFilterClass ``` diff --git a/v8.0.0.alpha/12-search-fields.md b/v8.0.0.alpha/12-search-fields.md index 506b396..cd6ae78 100644 --- a/v8.0.0.alpha/12-search-fields.md +++ b/v8.0.0.alpha/12-search-fields.md @@ -15,6 +15,7 @@ Blacklight provides a UI element to choose a which "search fields" to execute th If there aren't any search fields configured (or one default one like below) the `qt` parameter set in the Blacklight config's `default_solr_parameters` will be used and there will be no search field dropdown presented to the user. ```ruby +# app/controllers/catalog_controller.rb configure_blacklight do |config| config.add_search_field 'all_fields', label: 'All Fields' end @@ -23,6 +24,7 @@ end Adding an new search field to the dropdown can be accomplished by using the `add_search_field` configuration option. By default, the key passed to `add_search_field` will be passed to solr as the `qt` parameter. In the example below, this would use the `title` request handler by passing `qt=title` when querying solr (when the user chooses "Title" for the search field dropdown). ```ruby +# app/controllers/catalog_controller.rb configure_blacklight do |config| config.add_search_field 'all_fields', label: 'All Fields' config.add_search_field 'title', label: 'Title' @@ -32,6 +34,7 @@ end It's possible to use a different request handler than the key passed to `add_search_field`. This way the `search_field` parameter in the application URL will remain `title` while the solr request handler that maps to remains know to the application configuration only (allowing you to change the request handler without breaking existing urls/bookmarks). ```ruby +# app/controllers/catalog_controller.rb configure_blacklight do |config| config.add_search_field 'all_fields', label: 'All Fields' config.add_search_field 'title', label: 'Title' do |field| @@ -43,6 +46,7 @@ end A common pattern is to configure `solr_parameters` directly in the `add_search_field` configuration (and use the default search results handler). You will likely want to pass `qf` and `pf` values that are defined in your default request handler. ```ruby +# app/controllers/catalog_controller.rb configure_blacklight do |config| config.add_search_field 'all_fields', label: 'All Fields' config.add_search_field 'title', label: 'Title' do |field| diff --git a/v8.0.0.alpha/13-sort-fields.md b/v8.0.0.alpha/13-sort-fields.md index 5f5c7f8..5492070 100644 --- a/v8.0.0.alpha/13-sort-fields.md +++ b/v8.0.0.alpha/13-sort-fields.md @@ -15,6 +15,7 @@ Blacklight provides a UI element to choose a sort order for results when multipl Sort options can be configured using the `add_sort_field` configuration method. The following configuration won't display because there is only one sort option to choose from. ```ruby +# app/controllers/catalog_controller.rb configure_blacklight do |config| config.add_sort_field 'score desc', label: 'relevance' end @@ -23,6 +24,7 @@ end Even though this will not display a sort option, it still controls the default sort behavior of search results. It's often useful to supply sub sorts, even for a default score based relevancy search result as facet based results will all have the same score. We can update the default sort of our results by updating the sort field configuration and adding pub date and title sub-sorts. With the configuration below a facet only search (or simply an empty query) will be returned sorted. ```ruby +# app/controllers/catalog_controller.rb configure_blacklight do |config| config.add_sort_field 'score desc, pub_date_si desc, title_si asc', label: 'relevance' end @@ -31,6 +33,7 @@ end Adding additional sort fields is relatively straight forward. As above with the relevancy sort, it is most likely a good idea to provide sub sorts so when documents have the same relevancy score they are sorted using other criteria. ```ruby +# app/controllers/catalog_controller.rb configure_blacklight do |config| config.add_sort_field 'score desc, pub_date_si desc, title_si asc', label: 'relevance' config.add_sort_field 'pub_date_si desc, title_si asc', label: 'year' @@ -40,6 +43,7 @@ end The first value passed to `add_sort_field` will be both the sort value sent to solr as well as the parameter sent through the application url. It's possible to obscure the solr fields and their sort direction from the url by passing a key as the first parameter and passing the sort configuration explicitly as the `sort` key. ```ruby +# app/controllers/catalog_controller.rb configure_blacklight do |config| config.add_sort_field 'relevance', sort: 'score desc, pub_date_si desc, title_si asc', label: 'relevance' config.add_sort_field 'year', sort: 'pub_date_si desc, title_si asc', label: 'year' diff --git a/v8.0.0.alpha/14-solr-parameters.md b/v8.0.0.alpha/14-solr-parameters.md index 98f0665..4423258 100644 --- a/v8.0.0.alpha/14-solr-parameters.md +++ b/v8.0.0.alpha/14-solr-parameters.md @@ -42,6 +42,7 @@ In development, it can be handy to see the stored fields for a document. While y Note that this API is disabled by default, both to discourage coupling applications to the underlying Solr document format and to avoid leaking non-public information present in the document. ```ruby +# app/controllers/catalog_controller.rb ## Should the raw solr document endpoint (e.g. /catalog/:id/raw) be enabled config.raw_endpoint.enabled = true ``` @@ -51,6 +52,7 @@ config.raw_endpoint.enabled = true We can add or change the default parameters sent to Solr in the `CatalogController`. In `./app/controllers/catalog_controller.rb`, we can see the default configuration sets the number of items per search result: ```ruby +# app/controllers/catalog_controller.rb ## Default parameters to send to solr for all search-like requests. See also SearchBuilder#processed_parameters config.default_solr_params = { rows: 10 @@ -62,6 +64,7 @@ Try changing the value to 20. We can also override behavior from the requestHandler. Try adding a `qf` parameter and tweaking the fields + weights: ```ruby +# app/controllers/catalog_controller.rb ## Default parameters to send to solr for all search-like requests. See also SearchBuilder#processed_parameters config.default_solr_params = { rows: 20, diff --git a/v8.0.0.alpha/15-thumbnails.md b/v8.0.0.alpha/15-thumbnails.md index 20fd8b5..11c334a 100644 --- a/v8.0.0.alpha/15-thumbnails.md +++ b/v8.0.0.alpha/15-thumbnails.md @@ -49,6 +49,7 @@ end Sometimes, not all documents have a thumbnail. In this case, you can configure a default thumbnail to be used for documents that don't have a thumbnail. {% highlight ruby %} +# app/controllers/catalog_controller.rb config.index.default_thumbnail = 'data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIzMDAiIGhlaWdodD0iMTUwIiB2aWV3Qm94PSIwIDAgMzAwIDE1MCI-IDxyZWN0IGZpbGw9IiNkZGQiIHdpZHRoPSIzMDAiIGhlaWdodD0iMTUwIi8-IDx0ZXh0IGZpbGw9InJnYmEoMCwwLDAsMC41KSIgZm9udC1mYW1pbHk9Ikdlb3JnaWEsIHNlcmlmIiBmb250LXNpemU9IjMwIiBkeT0iMTAuNSIgZm9udC13ZWlnaHQ9Im5vcm1hbCIgeD0iNTAlIiB5PSI1MCUiIHRleHQtYW5jaG9yPSJtaWRkbGUiPjMwMMOXMTUwPC90ZXh0PiA8L3N2Zz4=' {% endhighlight%} diff --git a/v8.0.0.alpha/21-apis.md b/v8.0.0.alpha/21-apis.md index ac97fd7..226dae4 100644 --- a/v8.0.0.alpha/21-apis.md +++ b/v8.0.0.alpha/21-apis.md @@ -69,6 +69,7 @@ Note that this can be used in combination with any search query, facets, or sort To add a different API format, you can instruct Blacklight to provide alternative results. In `app/controllers/catalog_controller.rb`, add: ```diff +# app/controllers/catalog_controller.rb configure_blacklight do |config| + config.index.respond_to.csv = true end From d18cbcc5eef81ac1fae986d8e13f8b9ed5546261 Mon Sep 17 00:00:00 2001 From: Sonia Connolly Date: Tue, 30 Jan 2024 14:57:49 -0800 Subject: [PATCH 2/6] Update suggested code for super_special_facet_component.html.erb The code for FacetFieldListComponent has changed. New code copied from https://github.com/projectblacklight/blacklight/blob/main/app/components/blacklight/facet_field_list_component.html.erb --- v8.0.0.alpha/11-facet-fields.md | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/v8.0.0.alpha/11-facet-fields.md b/v8.0.0.alpha/11-facet-fields.md index baa5295..8a56aea 100644 --- a/v8.0.0.alpha/11-facet-fields.md +++ b/v8.0.0.alpha/11-facet-fields.md @@ -112,21 +112,30 @@ For this example, we want to customize the display of the facet, so we'll need t ```erb <%= render(@layout.new(facet_field: @facet_field)) do |component| %> - <% component.with(:label) do %> + <% component.with_label do %> <%= @facet_field.label %> <% end %> - <% component.with(:body) do %> + <% component.with_body do %> + <%= helpers.render(Blacklight::FacetFieldInclusiveConstraintComponent.new(facet_field: @facet_field)) %> + <%# backwards compatibility, ugh %> + <% if @layout == Blacklight::FacetFieldNoLayoutComponent && !@facet_field.in_modal? && @facet_field.modal_path %> +
+ <%= link_to t("more_#{@facet_field.key}_html", scope: 'blacklight.search.facets', default: :more_html, field_name: @facet_field.label), + @facet_field.modal_path, + data: { blacklight_modal: 'trigger' } %> +
+ <% end %> <% end %> <% end %> ``` -and then make a nice visible change: +and then make a nice visible change (the label disappears): ```diff -<% component.with(:label) do %> + <% component.with_label do %> - <%= @facet_field.label %> + -> <%= @facet_field.label %> <- <% end %> From 84db23b8de398308e0408c7362b41291ecc27f06 Mon Sep 17 00:00:00 2001 From: Sonia Connolly Date: Tue, 30 Jan 2024 15:16:41 -0800 Subject: [PATCH 3/6] Fix typos --- v8.0.0.alpha/04-helper-method-overrides.md | 6 +++--- v8.0.0.alpha/10-metadata-fields.md | 2 +- v8.0.0.alpha/11-facet-fields.md | 4 ++-- v8.0.0.alpha/12-search-fields.md | 2 +- v8.0.0.alpha/20-other-plugins.md | 2 +- v8.0.0.alpha/21-apis.md | 1 - 6 files changed, 8 insertions(+), 9 deletions(-) diff --git a/v8.0.0.alpha/04-helper-method-overrides.md b/v8.0.0.alpha/04-helper-method-overrides.md index b04f684..5093f68 100644 --- a/v8.0.0.alpha/04-helper-method-overrides.md +++ b/v8.0.0.alpha/04-helper-method-overrides.md @@ -6,7 +6,7 @@ redirect_from: /overrides/ blacklight_version: v8.0.0.alpha --- -Much of Blacklight is written in a way that is overridable, helper methods are no different. +Much of Blacklight is written in a way that is overridable. Helper methods are no different. Let's take a look at the [module that is used to help with some of the layout for Blacklight](https://github.com/projectblacklight/blacklight/blob/master/app/helpers/blacklight/layout_helper_behavior.rb). This module is mixed into the `Blacklight::BlacklightHelperBehavior` which allows us to override methods mixed in. @@ -41,7 +41,7 @@ module CustomLayoutHelper end {% endhighlight %} -Now we are free to override methods to meet our custom application needs. For example, lets override the `html_tag_attributes` method. +Now we are free to override methods to meet our custom application needs. For example, let's override the `html_tag_attributes` method. {% highlight ruby %} # app/helpers/custom_layout_helper.rb @@ -66,5 +66,5 @@ This overridden method adds an additional attribute `dir="rtl"` to display our p This is just one way that the Blacklight code can be overridden and customized. Similar patterns can be used to customize controllers and search behavior.
- For more information about overriding helpers, checkout the Blacklight Wiki. + For more information about overriding helpers, check out the Blacklight Wiki.
diff --git a/v8.0.0.alpha/10-metadata-fields.md b/v8.0.0.alpha/10-metadata-fields.md index 55360dd..3ab922a 100644 --- a/v8.0.0.alpha/10-metadata-fields.md +++ b/v8.0.0.alpha/10-metadata-fields.md @@ -22,7 +22,7 @@ The configuration patterns outlined on [General Configuration Patterns](/v8.0.0. ## Labeling via Internationalization (i18n) -All the text in Blacklight's UI are configured via rails' i18n files. While you can apply a string label directly in the Blackklight config, you can also label these in your i18n config files (e.g. in `config/locales/blacklight.en.yml`). +All the text in Blacklight's UI are configured via rails' i18n files. While you can apply a string label directly in the Blacklight config, you can also label these in your i18n config files (e.g. in `config/locales/blacklight.en.yml`). If you wanted to change the label of all `author_tsim` fields to "Creator" you can do that by adding the label to your locale file. diff --git a/v8.0.0.alpha/11-facet-fields.md b/v8.0.0.alpha/11-facet-fields.md index 8a56aea..760651c 100644 --- a/v8.0.0.alpha/11-facet-fields.md +++ b/v8.0.0.alpha/11-facet-fields.md @@ -182,7 +182,7 @@ class SimpleFilterClass < Blacklight::SearchState::FilterField new_state.reset(params) end - # Facet values set int he URL + # Facet values set in the URL def values(except: []) Array(search_state.params[key]) end @@ -200,7 +200,7 @@ end
- For more information about configuring facets in Blacklight, checkout the Blacklight Wiki. + For more information about configuring facets in Blacklight, check out the Blacklight Wiki.
[^1]: This is sorted by Solr based on the indexed term; Solr offers no control over direction, lexical vs natural sort order, etc. diff --git a/v8.0.0.alpha/12-search-fields.md b/v8.0.0.alpha/12-search-fields.md index cd6ae78..85d37e2 100644 --- a/v8.0.0.alpha/12-search-fields.md +++ b/v8.0.0.alpha/12-search-fields.md @@ -5,7 +5,7 @@ permalink: /v8.0.0.alpha/search_fields/ blacklight_version: v8.0.0.alpha --- -Blacklight provides a UI element to choose a which "search fields" to execute the search against when multiple search field options are configured. This is often used to provide a `Title`, `Author`, etc. search in addition to the default `All fields`. You can think of these as different request handlers (`qt` parameter) in solr, however; it's not uncommon to use a single request handler and configure the solr_parameters directly in the search field configuration. +Blacklight provides a UI element to choose which "search fields" to execute the search against when multiple search field options are configured. This is often used to provide a `Title`, `Author`, etc. search in addition to the default `All fields`. You can think of these as different request handlers (`qt` parameter) in solr, however; it's not uncommon to use a single request handler and configure the solr_parameters directly in the search field configuration.
Blacklight search fields dropdown diff --git a/v8.0.0.alpha/20-other-plugins.md b/v8.0.0.alpha/20-other-plugins.md index eb3dab5..f8977d0 100644 --- a/v8.0.0.alpha/20-other-plugins.md +++ b/v8.0.0.alpha/20-other-plugins.md @@ -22,5 +22,5 @@ These types of plugins provide a specific type of Blacklight application experie Blacklight plugins exist as separate software projects, and can even have adjacent communities that help maintain them.
- For more information about Blacklight plugins, checkout the Blacklight Wiki. + For more information about Blacklight plugins, check out the Blacklight Wiki.
diff --git a/v8.0.0.alpha/21-apis.md b/v8.0.0.alpha/21-apis.md index 226dae4..4a58f1e 100644 --- a/v8.0.0.alpha/21-apis.md +++ b/v8.0.0.alpha/21-apis.md @@ -56,7 +56,6 @@ http://127.0.0.1:3000/catalog/00282214.marcjson ### Search results -In addition to You can also affect which search results response formats are available, in addition to the out-of-the-box HTML, JSON, Atom and RSS feeds. Take a look at, e.g.: - [http://127.0.0.1:3000/catalog?search_field=all_fields&q=&format=marc](http://127.0.0.1:3000/catalog?search_field=all_fields&q=&format=marc) From cd990b89ed3eef2ffc233b67c7e422f13f676bee Mon Sep 17 00:00:00 2001 From: Sonia Connolly Date: Tue, 30 Jan 2024 15:32:45 -0800 Subject: [PATCH 4/6] Update static_page routes in routes.rb so that the example works in extending-catalog-controller page --- v8.0.0.alpha/18-extending-catalog-controller.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/v8.0.0.alpha/18-extending-catalog-controller.md b/v8.0.0.alpha/18-extending-catalog-controller.md index d950494..68c4c3d 100644 --- a/v8.0.0.alpha/18-extending-catalog-controller.md +++ b/v8.0.0.alpha/18-extending-catalog-controller.md @@ -14,14 +14,16 @@ First, we need to pull in the Blacklight configuration from the `CatalogControll + class StaticPagesController < CatalogController ``` -If we try to look at the home page now, we'll see a routing error (`ActionController::UrlGenerationError in StaticPages#home`). We'll also need to tell the `StaticPagesController` we want to use the catalog routes from `CatalogController` [^1]. By convention, Blacklight uses the `search_action_url` method to route to the correct place. We can override that in the controller: +If we try to look at the home page now, we'll see a routing error (`ActionController::UrlGenerationError in StaticPages#home`). We'll also need to tell the `StaticPagesController` we want to use the catalog routes from `CatalogController`. By convention, Blacklight uses the `search_action_url` method to route to the correct place. Update routes.rb to give static_pages access to those routes. ```diff -class StaticPagesController < CatalogController -+ alias_method :search_action_url, :search_catalog_url +# routes.rb ++ resource :static_pages, only: [:home], as: 'home', path: '/', controller: 'static_pages' do ++ concerns :searchable ++ end ``` -Next, we need to update the controller to make a solr query and store the result (again, by convention) in the instance variable `@response`. We can copy the way Blacklight does this for the [`CatalogController#index` action](https://github.com/projectblacklight/blacklight/blob/master/app/controllers/concerns/blacklight/catalog.rb#L27) [^2]: +Next, we need to update the controller to make a solr query and store the result (again, by convention) in the instance variable `@response`. We can copy the way Blacklight does this for the [`CatalogController#index` action](https://github.com/projectblacklight/blacklight/blob/master/app/controllers/concerns/blacklight/catalog.rb#L27) [^1]: ```diff class StaticPagesController < CatalogController @@ -56,6 +58,4 @@ class StaticPagesController < CatalogController
-[^1]: We might want the opposite if we wanted our controller to be a specialization of `CatalogController` (perhaps providing a filtered "ebooks" view or an administration view with a specialized display and tooling). If we wanted to do that, we'd add search routing to the controller in `./config/routes.rb`. - -[^2]: This index method does a little more than we need to do to add a few facets. Note, too, the `deprecated_document_list` argument coming back from the search service; in Blacklight 8, this method will return only the response. +[^1]: This index method does a little more than we need to do to add a few facets. Note, too, the `deprecated_document_list` argument coming back from the search service; in Blacklight 8, this method will return only the response. From b96fb1013c01c9b692fae33bfa7c98e8e579cd89 Mon Sep 17 00:00:00 2001 From: Sonia Connolly Date: Tue, 30 Jan 2024 15:43:08 -0800 Subject: [PATCH 5/6] Give a hint about the list of tutorial pages under the Prev/Next buttons It didn't occur to me to click on the menu icon in the upper left to get a list of tutorial pages, because I had clicked an identical menu icon to choose which version of the tutorial to view. There is no indication that the functionality of that icon has changed. --- _includes/previous_next.html | 3 +++ 1 file changed, 3 insertions(+) diff --git a/_includes/previous_next.html b/_includes/previous_next.html index 6a81dbc..b4aa1f2 100644 --- a/_includes/previous_next.html +++ b/_includes/previous_next.html @@ -19,6 +19,9 @@ Next {% endif %}
+
+ For a list of pages in the tutorial, click the menu icon on the upper left. +
{% else %} {% assign page_index = page_index | plus: 1 %} {% endif %} From 65af86f99935832f7c0b82dd61a7e719138afa6e Mon Sep 17 00:00:00 2001 From: Sonia Connolly Date: Tue, 30 Jan 2024 15:53:43 -0800 Subject: [PATCH 6/6] Add published URL to README to make repo more findable --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index cf9d273..f166ca9 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,8 @@ A Jekyll based site for tutorials on customizing Blacklight applications. +Publishes to: + ## Authors **Jessie Keck**