From 798d320f5fd2c71671dfbcbf366ea94fd01c7880 Mon Sep 17 00:00:00 2001 From: Rajat Gupta Date: Tue, 19 Sep 2023 00:45:58 -0400 Subject: [PATCH 1/2] search --- ...p => HWJMAContentTypeSelectCheckboxes.php} | 2 +- .../hwjma_theme/includes/block.theme.inc | 24 ++ .../hwjma_theme/includes/layout.theme.inc | 51 +++- .../hwjma_theme/includes/navigation.theme.inc | 26 ++ .../hwjma_theme/includes/node.theme.inc | 253 ++++++++++++++++++ .../includes/suggestions.theme.inc | 24 ++ .../hwjma_theme/includes/views.theme.inc | 190 +++++++++++++ ...ma-include-all-checkbox-multiple.html.twig | 49 ++++ ...content-type--content-type-facet.html.twig | 30 +++ ...-search-facets-daterange-form--2.html.twig | 18 ++ .../node/node--search-result.html.twig | 112 ++++++++ .../node--search-short-description.html.twig | 82 ++++++ .../03-components/site/_search-results.scss | 20 +- .../source/default/js/custom/custom-theme.js | 6 +- 14 files changed, 872 insertions(+), 15 deletions(-) rename web/modules/highwire/hwjma_search/src/Plugin/facets/widget/{BPSContentTypeSelectCheckboxes.php => HWJMAContentTypeSelectCheckboxes.php} (98%) create mode 100644 web/themes/highwire/hwjma_theme/apps/drupal-default/hwjma_theme/templates/facets/facets-item-list--hwjma-include-all-checkbox-multiple.html.twig create mode 100644 web/themes/highwire/hwjma_theme/apps/drupal-default/hwjma_theme/templates/facets/facets-result-item--hwjmacheckbox-content-type--content-type-facet.html.twig create mode 100644 web/themes/highwire/hwjma_theme/apps/drupal-default/hwjma_theme/templates/form/form--hwjma-search-facets-daterange-form--2.html.twig create mode 100644 web/themes/highwire/hwjma_theme/apps/drupal-default/hwjma_theme/templates/node/node--search-result.html.twig create mode 100644 web/themes/highwire/hwjma_theme/apps/drupal-default/hwjma_theme/templates/node/node--search-short-description.html.twig diff --git a/web/modules/highwire/hwjma_search/src/Plugin/facets/widget/BPSContentTypeSelectCheckboxes.php b/web/modules/highwire/hwjma_search/src/Plugin/facets/widget/HWJMAContentTypeSelectCheckboxes.php similarity index 98% rename from web/modules/highwire/hwjma_search/src/Plugin/facets/widget/BPSContentTypeSelectCheckboxes.php rename to web/modules/highwire/hwjma_search/src/Plugin/facets/widget/HWJMAContentTypeSelectCheckboxes.php index c5b162ca5..56a3c99e7 100644 --- a/web/modules/highwire/hwjma_search/src/Plugin/facets/widget/BPSContentTypeSelectCheckboxes.php +++ b/web/modules/highwire/hwjma_search/src/Plugin/facets/widget/HWJMAContentTypeSelectCheckboxes.php @@ -16,7 +16,7 @@ * description = @Translation("A configurable widget that shows a list of checkboxes"), * ) */ -class hwjmaContentTypeSelectCheckboxes extends LinksWidget { +class HWJMAContentTypeSelectCheckboxes extends LinksWidget { /** * {@inheritdoc} diff --git a/web/themes/highwire/hwjma_theme/apps/drupal-default/hwjma_theme/includes/block.theme.inc b/web/themes/highwire/hwjma_theme/apps/drupal-default/hwjma_theme/includes/block.theme.inc index 030524c84..9535fb633 100755 --- a/web/themes/highwire/hwjma_theme/apps/drupal-default/hwjma_theme/includes/block.theme.inc +++ b/web/themes/highwire/hwjma_theme/apps/drupal-default/hwjma_theme/includes/block.theme.inc @@ -316,3 +316,27 @@ function hwjma_preprocess_block__mainpagecontent(&$variables) { $variables['content']['#markup'] = t($temp_markup); } +/** + * Process Keywords right sidebar block content + */ +function hwjma_preprocess_block__entity_field__node__test_type(&$variables) { + $journals_sidebar['items']['block_heading'] = $variables['label']; + $journals_sidebar['items']['show_test_type_block'] = TRUE; + $data_arr = $variables['content']['field']['#items']; + $journals_sidebar['items']['listing_items'] = array(); + if (!empty($data_arr)) { + foreach ($data_arr as $dataKey => $data) { + $url_object = Url::fromUri('internal:/search'); + $url_options['query'] = ['query' => ""]; + $url_options['query']['f'][] = 'chapter_type:test-review-item-test-review'; + $url_options['query']['f'][] = 'test_type:' . $data->getValue()['first']; + $url_object->setOptions($url_options); + $path = $url_object->toString(); + $journals_sidebar['items']['listing_items'][$dataKey]['url'] = $path; + $journals_sidebar['items']['listing_items'][$dataKey]['title'] = $data->getValue()['first']; + } + } else { + $journals_sidebar['items']['show_test_type_block'] = FALSE; + } + $variables['journals_sidebar'] = $journals_sidebar; +} diff --git a/web/themes/highwire/hwjma_theme/apps/drupal-default/hwjma_theme/includes/layout.theme.inc b/web/themes/highwire/hwjma_theme/apps/drupal-default/hwjma_theme/includes/layout.theme.inc index 9e71ae35d..aca9132e8 100755 --- a/web/themes/highwire/hwjma_theme/apps/drupal-default/hwjma_theme/includes/layout.theme.inc +++ b/web/themes/highwire/hwjma_theme/apps/drupal-default/hwjma_theme/includes/layout.theme.inc @@ -31,6 +31,12 @@ function hwjma_theme(array $existing, $type, $theme, $path) { 'template' => 'facet-block', 'variables' => ['title' => '', 'facet' => '', 'contextual_links' => '', 'facet_id' => ''], ], + 'facet_block__modal' => [ + 'base hook' => 'facet_block', + ], + 'facet_block__collapse' => [ + 'base hook' => 'facet_block', + ], ]; } @@ -437,4 +443,47 @@ function hwjma_preprocess_menu__main__sidebar(&$variables) { } // Add 'is_active' flag to active links. hwjma_preprocess_menu__sidebar($variables); -} \ No newline at end of file +} + +/** + * Implements hook_preprocess_THEME(). + */ +function hwjma_preprocess_highwire_personalization_manage_saved_search(&$variables) { + // Add icon & class to myaccount label run. + if (!empty($variables['search_label']) && !empty($variables['execute_label']) && !empty($variables['search_link'])) { + $variables['search_link']['#title'] = [ + 'title' => [ + '#markup' => $variables['search_label'], + ], + 'icon' => [ + '#type' => 'hwjma_icon', + '#icon' => 'search-o', + '#extra_classes' => 'fa-search', + '#prefix' => '', + ], + 'execute_title' => [ + '#markup' => $variables['execute_label'], + '#suffix' => '', + ], + ]; + } +} + +/** + * Implements hook_preprocess__THEME(). + */ +function hwjma_preprocess_highwire_personalization_manage_marker(&$variables) { + $node = $variables['marker_link']['#node']; + if ($node == NULL) { + $nid = ($variables['marker_link']['#url'])->getrouteParameters()['node']; + $node = Node::load($nid); + } + if ($node) { + $variables = search_result($variables, $node); + $variables['result']['url'] = \Drupal::service('path_alias.manager')->getAliasByPath('/node/' . $variables['result']['id']); + $variables['marker_link_date'] = $variables['element']['#created']; + $variables['marker_link'] = ($variables['element']['links']['#items']['delete']['#url'])->toString(); + $variables['marker_popupdata'] = 'Are you sure remove your favourite ' . $variables['result']['title'] . '?'; + $variables['modaltargetid'] = "favorite-action" . uniqid(); + } +} \ No newline at end of file diff --git a/web/themes/highwire/hwjma_theme/apps/drupal-default/hwjma_theme/includes/navigation.theme.inc b/web/themes/highwire/hwjma_theme/apps/drupal-default/hwjma_theme/includes/navigation.theme.inc index 494ff58b8..6388d180f 100755 --- a/web/themes/highwire/hwjma_theme/apps/drupal-default/hwjma_theme/includes/navigation.theme.inc +++ b/web/themes/highwire/hwjma_theme/apps/drupal-default/hwjma_theme/includes/navigation.theme.inc @@ -5,4 +5,30 @@ * Functions to support theming menu navigation in the Particle theme. */ +use Drupal\search\SearchPageInterface; +/** + * Implements hook_preprocess_breadcrumb(). + */ +function hwjma_preprocess_breadcrumb(&$variables) { + // Taken from Umami theme + // We are creating a variable for the Current Page Title, to allow us to print + // it after the breadcrumbs loop has run. + $route_match = Drupal::routeMatch(); + // Search page titles aren't resolved using the title_resolver service - it + // will always return 'Search' instead of 'Search for [term]', which would + // give us a breadcrumb of Home >> Search >> Search. + // @todo Revisit after https://www.drupal.org/project/drupal/issues/2359901 + // @todo Revisit after https://www.drupal.org/project/drupal/issues/2403359 + $entity = $route_match->getParameter('entity'); + if ($entity instanceof SearchPageInterface) { + $variables['current_page_title'] = $entity->getPlugin()->suggestedTitle(); + } + else { + $variables['current_page_title'] = Drupal::service('title_resolver')->getTitle(Drupal::request(), $route_match->getRouteObject()); + } + // Since we are printing the 'Current Page Title', add the URL cache context. + // If we don't, then we might end up with something like + // "Home > Articles" on the Recipes page, which should read "Home > Recipes". + $variables['#cache']['contexts'][] = 'url'; +} \ No newline at end of file diff --git a/web/themes/highwire/hwjma_theme/apps/drupal-default/hwjma_theme/includes/node.theme.inc b/web/themes/highwire/hwjma_theme/apps/drupal-default/hwjma_theme/includes/node.theme.inc index 10c785f6d..46aa93c73 100755 --- a/web/themes/highwire/hwjma_theme/apps/drupal-default/hwjma_theme/includes/node.theme.inc +++ b/web/themes/highwire/hwjma_theme/apps/drupal-default/hwjma_theme/includes/node.theme.inc @@ -680,3 +680,256 @@ function hwjma_preprocess_node__journal_issue__issue_list_item(&$variables) { $variables['cover_date'] = $custom_meta; } + +/** + * Implements hook_preprocess__THEME(). + */ +function hwjma_preprocess_node__search_result(&$variables) { + $node = $variables['node']; + if ($node !== NULL) { + $variables = search_result($variables, $node); + } +} + +/** + * Function for search result + */ +function search_result($variables, $node) { + $content = $variables['content']; + + $node_type = $node->getType(); + $result = []; + + // Add access icon placeholder. + $access_icon_placeholder = [ + '#type' => 'access_icon_placeholder', + '#apath' => $node->get('apath')->getString(), + '#context' => $node_type . ':search_result', + '#access_icon' => 'hwjma_access_icon', + ]; + $entity_type = 'node'; + $view_mode = 'search_short_description'; + $short_text = render(\Drupal::entityTypeManager()->getViewBuilder($entity_type)->view($node, $view_mode)); + + $access_icon_render = \Drupal::service('renderer')->render($access_icon_placeholder); + $variables['access_icon_placeholder'] = $access_icon_render; + + // Add item id. + $result['id'] = $node->id(); + + // Add title & Link to content. + foreach (['label' => 'title', 'url' => 'url'] as $drupal => $pl) { + if (!empty($variables[$drupal])) { + $result[$pl] = $variables[$drupal]; + } + } + + // Add node fields. + $result += hwjma_get_node_fields($variables, ['subtitle' => 'subTitle']); + + // Add type label + $result['type'] = hwjma_get_node_type_lable($node_type); + + $title = $node->get('title_plain')->getString() ? $node->get('title_plain')->getString() : ''; + $html_entity_decoded_title = html_entity_decode($title); + $result['title'] = $html_entity_decoded_title; + // Grab node title for img alt attribute. + $img_alt_text = $node->get('title_plain')->value ? $node->get('title_plain')->value : HighWireContent::processTitle($node->get('title')->value); + $title_without_html = strip_tags($img_alt_text); + $result['img_alt_text'] = $title_without_html; + $result['short_description'] = $short_text; + + // Add fields based on node type. + $theme_path = base_path() . drupal_get_path('theme', 'hwjma'); + + switch ($node_type) { + case HW_NODE_TYPE_BOOK: + case HW_NODE_TYPE_REFERENCE: + $result += hwjma_get_node_fields($variables, ['cover_image' => 'img', 'hwmd_abstract_book' => 'desc']); + break; + case in_array($node_type, HW_NODE_TYPE_BOOK_CHUNK): + $result['img'] = $theme_path . '/images/icon-chapter.svg'; + $result += hwjma_get_node_fields($variables, ['parent_book' => 'source', 'hwmd_abstract_book' => 'desc']); + break; + case HW_NODE_TYPE_ARTICLE: + $result['img'] = $theme_path . '/images/icon-article.svg'; + $result += hwjma_get_node_fields($variables, ['parent_journal' => 'source', 'hwmd_abstract_article_toc' => 'desc']); + break; + case HW_NODE_TYPE_CLINICAL_GUIDELINE: + $result['img'] = $theme_path . '/images/icon-guideline.svg'; + $result += hwjma_get_node_fields($variables, ['parent_book' => 'source', 'hwmd_abstract_book' => 'desc']); + break; + case HW_NODE_TYPE_PRESCRIBING_GUIDELINE: + $result['img'] = $theme_path . '/images/icon-prescribing.svg'; + $result += hwjma_get_node_fields($variables, ['parent_book' => 'source', 'hwmd_abstract_book' => 'desc']); + break; + case HW_NODE_TYPE_PATIENT_EDUCATION: + $result['img'] = $theme_path . '/images/icon-patient-education.svg'; + $result += hwjma_get_node_fields($variables, ['parent_book' => 'source', 'hwmd_abstract_book' => 'desc']); + break; + case HW_NODE_TYPE_PROCEDURE: + $result['img'] = $theme_path . '/images/icon-procedure.svg'; + $result += hwjma_get_node_fields($variables, ['parent_book' => 'source', 'hwmd_abstract_book' => 'desc']); + break; + case in_array($node_type, HW_NODE_TYPE_REFERENCE_CHUNK): + $result['img'] = $theme_path . '/images/icon-reference.svg'; + $result += hwjma_get_node_fields($variables, ['parent_book' => 'source', 'hwmd_abstract_book' => 'desc']); + break; + case HW_NODE_TYPE_JOURNAL: + $result += hwjma_get_node_fields($variables, ['journal_current_issue' => 'img']); + $result += hwjma_get_node_pseudo_fields($variables, ['field_journal_description' => 'desc']); + if (!empty($result['img']) && !empty($variables['url'])) { + $result['img']['#prefix'] = ''; + $result['img']['#suffix'] = ''; + } + break; + default: + break; + } + + if ($node_type == HW_NODE_TYPE_ISSUE) { + $result += hwjma_get_node_fields($variables, ['variant_cover_image' => 'img', 'issue_title' => 'title', 'volume' => 'volume', 'issue' => 'issue',]); + $result += hwjma_get_node_pseudo_fields($variables, ['description' => 'desc']); + if (!empty($result['img']) && !empty($variables['url'])) { + $result['img']['#prefix'] = ''; + $result['img']['#suffix'] = ''; + } + } + + // Add cover placeholder for books / journals. + if ($node_type == HW_NODE_TYPE_BOOK || $node_type == HW_NODE_TYPE_JOURNAL) { + if (empty($result['img']) && !empty($variables['cover_placeholder'])) { + if (empty($variables['cover_placeholder']['#url']) && !empty($variables['url'])) { + $variables['cover_placeholder']['#url'] = $variables['url']; + $plain_title = strip_tags($variables['node']->getTitle()); + $variables['cover_placeholder']['#sr_text'] = t('Go to @title', ['@title' => $plain_title]); + } + $result['img'] = $variables['cover_placeholder']; + } + } + $img_alt = ''; + $img_title = ''; + $media_url = '/themes/highwire/hwjma_theme/dist/app-drupal/assets/images/250X350.png'; + + if ($node_type == 'journal_article') { + $parent_journal = $node->get('parent_journal')->getValue(); + $parent_journal_nid = $parent_journal[0]['target_id']; + if (!empty($parent_journal_nid)) { + $node = Node::load($parent_journal_nid); + $source_title = $node->getTitle(); + $source_url = $node->toUrl()->toString(); + $nid_journal_info = \Drupal::entityTypeManager()->getStorage('node')->loadByProperties([ + 'type' => 'journal_info', + 'field_journal' => $node->id()]); + foreach ($nid_journal_info as $nid) { + $node = $nid; + $parent_journal_img = $node->get('field_journal_cover_image')->getValue(); + $image_tid = $parent_journal_img[0]['target_id']; + if (!empty($image_tid)) { + $file = File::load($image_tid); + $path = $file->getFileUri(); + $media_url = file_create_url($path); + } + } + } + } + + if ($node_type == 'item_chapter') { + $nid = $node->id(); + $options = ['absolute' => TRUE]; + $url_object = Url::fromRoute('entity.node.canonical', ['node' => $nid], $options); + $chapter_url = $url_object->toString(); + $parent = $node->get('parent')->getValue(); + $parent_nid = $parent[0]['target_id']; + $parent_issue_url = null; + if (!empty($parent_nid)) { + $node = Node::load($parent_nid); + $url_object = Url::fromRoute('entity.node.canonical', ['node' => $parent_nid], $options); + $parent_url = $url_object->toString(); + } + $source_title = $node->get('title')->getstring(); + $source_url = $node->toUrl()->toString(); + } + + if($node->hasField('variant_cover_image') && !$node->get('variant_cover_image')->isEmpty()) { + $imagefield = $node->get('variant_cover_image')->getValue(); + //check if node has image + if (!empty($imagefield)) { + $img_alt = $node->cover_image->alt; + $img_title = $node->cover_image->title; + $fileid = $imagefield[0]['target_id']; + if (!empty($fileid)) { + $file = File::load($fileid); + if (!empty($file)) { + $path = $file->getFileUri(); + $media_url = file_create_url($path); + } + } + } + } + if($node->hasField('cover_image') && !$node->get('cover_image')->isEmpty()) { + $imagefield = $node->get('cover_image')->getValue(); + //check if node has image + if (!empty($imagefield)) { + $img_alt = $node->cover_image->alt; + $img_title = $node->cover_image->title; + $fileid = $imagefield[0]['target_id']; + if (!empty($fileid)) { + $file = File::load($fileid); + if (!empty($file)) { + $path = $file->getFileUri(); + $media_url = file_create_url($path); + } + } + } + } + if ($node_type == 'journal') { + $node_id = $node->id(); + $info_nodes = \Drupal::entityTypeManager()->getStorage('node')->loadByProperties([ + 'type' => 'journal_info', + 'field_journal' => $node_id + ]); + $media_url = '/themes/highwire/hwjma_theme/dist/app-drupal/assets/images/250X350.png'; + if (!empty($info_nodes)) { + $journal_info = reset($info_nodes); + if (!$journal_info->get('field_journal_cover_image')->isEmpty()) { + $node_cover_image = $journal_info->get('field_journal_cover_image')->getValue(); + $image_tid = $node_cover_image[0]['target_id']; + if (!empty($image_tid)) { + $file = File::load($image_tid); + $path = $file->getFileUri(); + $media_url = file_create_url($path); + } + } + } + } + $result['img'] = $media_url; + if ($source_title) { + $result['source'] = TRUE; + $result['source_title'] = $source_title; + $result['source_url'] = $source_url; + } + $variables['result'] = $result; + return $variables; +} + +/** + * @file + * Functions to support theming node entities in the Particle theme. + */ +function hwjma_get_node_type_lable($key) { + $typeArry = [ + 'journal' => 'Journal', + 'journal_article' => 'Journal Article', + 'journal_fragment' => 'Journal Fragment', + 'journal_issue' => 'Journal Issue', + 'journal_volume' => 'Journal Volume', + 'item_test_review' => 'Test Review', + 'item_monograph' => 'Monograph', + 'media' => 'Media', + 'item_report_guideline' => 'Reports and Guidelines', + 'item_chapter' => 'Chapter', + ]; + return $typeArry[$key]; +} + diff --git a/web/themes/highwire/hwjma_theme/apps/drupal-default/hwjma_theme/includes/suggestions.theme.inc b/web/themes/highwire/hwjma_theme/apps/drupal-default/hwjma_theme/includes/suggestions.theme.inc index 3bd999ec0..a2863950f 100755 --- a/web/themes/highwire/hwjma_theme/apps/drupal-default/hwjma_theme/includes/suggestions.theme.inc +++ b/web/themes/highwire/hwjma_theme/apps/drupal-default/hwjma_theme/includes/suggestions.theme.inc @@ -91,4 +91,28 @@ function hwjma_theme_suggestions_menu_alter(array &$suggestions, array $variable $suggestions[] = 'menu__sidebar'; $suggestions[] = 'menu__' . $variables['menu_name'] . '__sidebar'; } +} + +/** + * Implements hook_theme_suggestions_HOOK_alter(). + */ +function hwjma_theme_suggestions_facet_block_alter(array &$suggestions, array $variables) { + // Add different facet block styles for specific facets. + if (!empty($variables['facet_id'])) { + switch ($variables['facet_id']) { + case 'keywords': + case 'authors_full_name': + case 'member_network': + case 'article_type': + case 'publication_title': + case 'subject': + case 'content_type_facet': + $suggestions[] = 'facet_block__modal'; + break; + + case 'hwjma_search_date_filter': + $suggestions[] = 'facet_block__collapse'; + break; + } + } } \ No newline at end of file diff --git a/web/themes/highwire/hwjma_theme/apps/drupal-default/hwjma_theme/includes/views.theme.inc b/web/themes/highwire/hwjma_theme/apps/drupal-default/hwjma_theme/includes/views.theme.inc index e696da09b..1c6e59d64 100755 --- a/web/themes/highwire/hwjma_theme/apps/drupal-default/hwjma_theme/includes/views.theme.inc +++ b/web/themes/highwire/hwjma_theme/apps/drupal-default/hwjma_theme/includes/views.theme.inc @@ -55,3 +55,193 @@ function hwjma_preprocess_views_view__homepage_highlights_carousel(&$variables) $variables['issue'][$node->id()]['paragraph']['text'] = $vol_issue; } } + +/** + * Implements hook_preprocess_views_view__ID__DISPLAY(). + */ +function hwjma_preprocess_views_view__search__page(&$variables) { + $current_user = \Drupal::currentUser(); + $request = \Drupal::request(); + $view = $variables['view']; + $total = isset($view->total_rows) ? $view->total_rows : count($view->result); + $variables['resultsCount'] = $total; + $variables['searchText'] = ''; + if (isset($_GET['query'])) { + $variables['searchTerm'] = !empty($_GET['query']) ? $_GET['query'] : t('all content'); + $variables['blankSearch'] = !empty($_GET['query']) ? $_GET['query'] : t(''); + $variables['searchText'] = !empty($_GET['query']) ? 'Your search for ' . $variables['searchTerm'] . ' returned ' . $variables['resultsCount'] . ' results' : ''; + } + + $header_inline_items = [ + 'highwire_personalization_save_search' => 'save_search', + ]; + foreach ($header_inline_items as $key => $var) { + if (!empty($variables['header'][$key])) { + $variables[$var] = $variables['header'][$key]; + unset($variables['header'][$key]); + } + } + + // Add exposed filter form if there is more than one result. + if ($total > 0) { + $form_state = new \Drupal\Core\Form\FormState(); + $form_state->setFormState([ + 'view' => $view, + 'display' => $view->display_handler->display, + 'exposed_form_plugin' => $view->display_handler->getPlugin('exposed_form'), + 'method' => 'get', + 'rerender' => TRUE, + 'no_redirect' => TRUE, + 'always_process' => TRUE, // This is important for handle the form status. + ]); + $build_info = $form_state->getBuildInfo(); + $build_info['args']['items_per_page'] = TRUE; + $form_state->setBuildInfo($build_info); + $form = \Drupal::formBuilder()->buildForm('Drupal\views\Form\ViewsExposedForm', $form_state); + + // Build 'Sort by' as HTML links due to bug: https://www.drupal.org/project/drupal/issues/2823541 + $params = $request->query->all(); + $current_sort_by = $request->query->get('sort_by') ?? 'search_api_relevance'; + $sort_by_options = array_keys($form['sort_by']['#options']); + + foreach ($sort_by_options as $sort) { + if ($current_sort_by == $sort) { + $sort_by_output[] = ['button' => [ + 'title' => $form['sort_by']['#options'][$sort], + 'text' => $form['sort_by']['#options'][$sort], + ]]; + } + else { + $params['sort_by'] = $sort; + $params['page'] = 0; + $sort_by_output[] = ['button' => [ + 'title' => $form['sort_by']['#options'][$sort], + 'href' => $request->getPathInfo() . '?' . http_build_query($params), + 'text' => $form['sort_by']['#options'][$sort], + ]]; + } + } + $variables['order_by'] = $sort_by_output; + + unset($form['sort_by']); + $form['sort_by']['#markup'] = rtrim($sort_by_output, '| '); + $form['sort_by']['#allowed_tags'] = ['a']; + + // Build 'Items per page' as HTML links due to bug: https://www.drupal.org/project/drupal/issues/2823541 + if (!empty($form['items_per_page'])) { + $query = $request->query->all(); + if (isset($query['page'])) { + unset($query['page']); + } + $url = Url::fromUserInput($request->getPathInfo(), ['query' => $query]); + $show_per_page_arr = array(); + $params = $request->query->all(); + if (!empty($form['items_per_page']['#options'])) { + foreach ($form['items_per_page']['#options'] as $show_per_page_options) { + $params['items_per_page'] = $show_per_page_options; + $show_per_page_arr[] = ['button' => [ + 'title' => $show_per_page_options, + 'href' => $request->getPathInfo() . '?' . http_build_query($params), + 'text' => $show_per_page_options, + ]]; + } + } + $variables['page_count'] = $show_per_page_arr; + } + } + + // Add facet blocks. + $facet_blocks = [ + 'content_type_facet' => 'Include content types...', + 'keywords' => 'Keywords', + 'author' => 'Author', + 'article_type' => 'Article Type', + 'journal_title_facet' => 'Journol Title', + ]; + + $facets_render = []; + $block_manager = \Drupal::service('plugin.manager.block'); + foreach ($facet_blocks as $facet_plugin_id => $facet_label) { + $plugin_block = $block_manager->createInstance('facet_block:' . $facet_plugin_id); + $access_result = $plugin_block->access($current_user); + if (!(is_object($access_result) && $access_result->isForbidden() || is_bool($access_result) && !$access_result)) { + $render = $plugin_block->build(); + + // Don't add placeholder containers for ajax facets if ajax is not enabled. + // Ajax placeholders will be set up as a container with class 'facet-empty'. + if (!$view->display_handler->ajaxEnabled() && !empty($render[0]['#type']) && $render[0]['#type'] == 'container' && !empty($render[0]['#attributes']['class']) && in_array('facet-empty', $render[0]['#attributes']['class'])) { + continue; + } + + if (!empty($render)) { + $facets_render[$facet_plugin_id] = [ + '#theme' => 'facet_block', + '#facet' => $render, + '#facet_id' => $facet_plugin_id, + '#title' => $facet_label, + ]; + if (isset($render['#contextual_links'])) { + $facets_render[$facet_plugin_id]['#contextual_links'] = $render['#contextual_links']; + } + } + } + } + + $plugin_block = $block_manager->createInstance('hwjma_search_date_filter'); + $access_result = $plugin_block->access(\Drupal::currentUser()); + if (!(is_object($access_result) && $access_result->isForbidden() || is_bool($access_result) && !$access_result)) { + $render = $plugin_block->build(); + if ((!empty($render) && !empty($total)) || !empty($render['active_items']['#items'])) { + $facets_render['hwjma_search_date_filter'] = [ + '#theme' => 'facet_block', + '#facet' => $render, + '#facet_id' => 'hwjma_search_date_filter', + '#title' => 'Publication Date', + ]; + } + } + + if (!empty($facets_render)) { + foreach ($facets_render as $key => $value) { + if ($key == 'test_type' || $key == 'test_publisher' || $key == 'show_registered_tests_only') { + $facets_render[$key] += ['show_facet' => FALSE]; + } + else { + $facets_render[$key] += ['show_facet' => TRUE]; + } + } + + $url = $request->getUri(); + $url_components = parse_url($url); + + parse_str($url_components['query'], $params); + + if (!empty($params['f'])) { + foreach ($params['f'] as $key => $value) { + if ($value == 'content_type_facet:test-review-item-test-review') { + $facets_render['test_type']['show_facet'] = TRUE; + $facets_render['test_publisher']['show_facet'] = TRUE; + $facets_render['show_registered_tests_only']['show_facet'] = TRUE; + break; + } + } + } + } + if (!empty($facets_render)) { + if (isset($facets_render['content_type_facet'])) { + $facets_render['content_type_facet']['#suffix'] = 'Filter results by...'; + $facets_render['content_type_facet']['#facet__heading'] = 'Include content types...'; + } + $variables['facets'] = $facets_render; + } +} + +/** + * Implements hook_preprocess_facets_item_list__HOOK(). + */ +function hwjma_preprocess_facets_item_list__hwjmacheckbox_content_type(&$variables) { + if ($variables['facet']->getName() == "Show registered tests only") { + $variables['items'][0]['value']['#title']['#value'] = "Show registered tests only"; + $variables['items'][0]['value']['#title']['#raw_value'] = "Show registered tests only"; + } +} \ No newline at end of file diff --git a/web/themes/highwire/hwjma_theme/apps/drupal-default/hwjma_theme/templates/facets/facets-item-list--hwjma-include-all-checkbox-multiple.html.twig b/web/themes/highwire/hwjma_theme/apps/drupal-default/hwjma_theme/templates/facets/facets-item-list--hwjma-include-all-checkbox-multiple.html.twig new file mode 100644 index 000000000..7f92310e3 --- /dev/null +++ b/web/themes/highwire/hwjma_theme/apps/drupal-default/hwjma_theme/templates/facets/facets-item-list--hwjma-include-all-checkbox-multiple.html.twig @@ -0,0 +1,49 @@ +{# +/** + * @file + * Default theme implementation for a facets item list. + * + * Available variables: + * - items: A list of items. Each item contains: + * - attributes: HTML attributes to be applied to each list item. + * - value: The content of the list element. + * - title: The title of the list. + * - list_type: The tag for list element ("ul" or "ol"). + * - wrapper_attributes: HTML attributes to be applied to the list wrapper. + * - attributes: HTML attributes to be applied to the list. + * - empty: A message to display when there are no items. Allowed value is a + * string or render array. + * - context: A list of contextual data associated with the list. May contain: + * - list_style: The ID of the widget plugin this facet uses. + * - facet: The facet for this result item. + * - id: the machine name for the facet. + * - label: The facet label. + * + * @see facets_preprocess_facets_item_list() + * + * @ingroup themeable + */ +#} +{% if facet.widget.type %} +
+ {% include "@components/modal/_modal-popup.twig" with { + items: items, + list_type: list_type, + attributes: attributes, + modalPopup: { + modalButton_click: true, + editions: true, + class: 'facet-modal-click', + modal_type: 'modal-medium-tablet', + href: "#", + title: title, + buttonText: title, + modaltargetid: facet.id, + modalHeading: { + text: "Filter by " ~ title, + class: "modal-title" + }, + } + } only %} +
+{% endif %} \ No newline at end of file diff --git a/web/themes/highwire/hwjma_theme/apps/drupal-default/hwjma_theme/templates/facets/facets-result-item--hwjmacheckbox-content-type--content-type-facet.html.twig b/web/themes/highwire/hwjma_theme/apps/drupal-default/hwjma_theme/templates/facets/facets-result-item--hwjmacheckbox-content-type--content-type-facet.html.twig new file mode 100644 index 000000000..25426d6c4 --- /dev/null +++ b/web/themes/highwire/hwjma_theme/apps/drupal-default/hwjma_theme/templates/facets/facets-result-item--hwjmacheckbox-content-type--content-type-facet.html.twig @@ -0,0 +1,30 @@ +{# +/** + * @file + * Default theme implementation of a facet result item. + * + * Available variables: + * - value: The item value. + * - raw_value: The raw item value. + * - show_count: If this facet provides count. + * - count: The amount of results. + * - is_active: The item is active. + * - facet: The facet for this result item. + * - id: the machine name for the facet. + * - label: The facet label. + * + * @ingroup themeable + */ +#} +{% set content_types = { + 'Include all': 'Include all', + 'journal': 'Journal', + 'journal_article': 'Journal Articles' +} %} +{% if is_active %} + (-) +{% endif %} +{{ content_types[value] }} +{% if show_count %} + {{ count }} +{% endif %} \ No newline at end of file diff --git a/web/themes/highwire/hwjma_theme/apps/drupal-default/hwjma_theme/templates/form/form--hwjma-search-facets-daterange-form--2.html.twig b/web/themes/highwire/hwjma_theme/apps/drupal-default/hwjma_theme/templates/form/form--hwjma-search-facets-daterange-form--2.html.twig new file mode 100644 index 000000000..ad534164e --- /dev/null +++ b/web/themes/highwire/hwjma_theme/apps/drupal-default/hwjma_theme/templates/form/form--hwjma-search-facets-daterange-form--2.html.twig @@ -0,0 +1,18 @@ +{# +/** + * @file + * Theme override for a 'form' element. + * + * Available variables + * - attributes: A list of HTML attributes for the wrapper element. + * - children: The child elements of the form. + * + * @see template_preprocess_form() + */ +#} +
+ Publication date + + {{ children }} + +
\ No newline at end of file diff --git a/web/themes/highwire/hwjma_theme/apps/drupal-default/hwjma_theme/templates/node/node--search-result.html.twig b/web/themes/highwire/hwjma_theme/apps/drupal-default/hwjma_theme/templates/node/node--search-result.html.twig new file mode 100644 index 000000000..28cf27425 --- /dev/null +++ b/web/themes/highwire/hwjma_theme/apps/drupal-default/hwjma_theme/templates/node/node--search-result.html.twig @@ -0,0 +1,112 @@ +{# +/** + * @file + * Theme override to display a node. + * + * Available variables: + * - node: The node entity with limited access to object properties and methods. + Only "getter" methods (method names starting with "get", "has", or "is") + and a few common methods such as "id" and "label" are available. Calling + other methods (such as node.delete) will result in an exception. + * - label: The title of the node. + * - content: All node items. Use {{ content }} to print them all, + * or print a subset such as {{ content.field_example }}. Use + * {{ content|without('field_example') }} to temporarily suppress the printing + * of a given child element. + * - author_picture: The node author user entity, rendered using the "compact" + * view mode. + * - metadata: Metadata for this node. + * - date: Themed creation date field. + * - author_name: Themed author name field. + * - url: Direct URL of the current node. + * - display_submitted: Whether submission information should be displayed. + * - attributes: HTML attributes for the containing element. + * The attributes.class element may contain one or more of the following + * classes: + * - node: The current template type (also known as a "theming hook"). + * - node--type-[type]: The current node type. For example, if the node is an + * "Article" it would result in "node--type-article". Note that the machine + * name will often be in a short form of the human readable label. + * - node--view-mode-[view_mode]: The View Mode of the node; for example, a + * teaser would result in: "node--view-mode-teaser", and + * full: "node--view-mode-full". + * The following are controlled through the node publishing options. + * - node--promoted: Appears on nodes promoted to the front page. + * - node--sticky: Appears on nodes ordered above other non-sticky nodes in + * teaser listings. + * - node--unpublished: Appears on unpublished nodes visible only to site + * admins. + * - title_attributes: Same as attributes, except applied to the main title + * tag that appears in the template. + * - content_attributes: Same as attributes, except applied to the main + * content tag that appears in the template. + * - author_attributes: Same as attributes, except applied to the author of + * the node tag that appears in the template. + * - title_prefix: Additional output populated by modules, intended to be + * displayed in front of the main title tag that appears in the template. + * - title_suffix: Additional output populated by modules, intended to be + * displayed after the main title tag that appears in the template. + * - view_mode: View mode; for example, "teaser" or "full". + * - teaser: Flag for the teaser state. Will be true if view_mode is 'teaser'. + * - page: Flag for the full page state. Will be true if view_mode is 'full'. + * - readmore: Flag for more state. Will be true if the teaser content of the + * node cannot hold the main body content. + * - logged_in: Flag for authenticated user status. Will be true when the + * current user is a logged-in member. + * - is_admin: Flag for admin user status. Will be true when the current user + * is an administrator. + * + * @ingroup templates + * + * @see template_preprocess_node() + * + * @todo Remove the id attribute (or make it a class), because if that gets + * rendered twice on a page this is invalid CSS for example: two lists + * in different view modes. + */ +#} +{% include "@components/site/_search-result-middle.twig" with { + favorite_loop: [{ + image: { + src: result.img, + href: result.url, + title: result.title + }, + fav_action: { + date: marker_link_date, + href: marker_link, + text: "Remove from favourites", + popupdata: marker_popupdata, + }, + card_heading: [{ + heading: { + text: result.type, + level:6 + } + }], + card_heading_link: [{ + anchorHead: { + level:4 , + button: { + href: result.url, + title: result.title, + text: result.title + } + } + }], + card_description: [{ + paragraph: { + class: 'search-result__description', + text: result.short_description + } + }], + card_link: result.img, + source: result.source, + sourceLink: { + href: result.source_url, + title: result.source_title, + text: result.source_title + }, + access_icon_placeholder: access_icon_placeholder + }] +} only %} \ No newline at end of file diff --git a/web/themes/highwire/hwjma_theme/apps/drupal-default/hwjma_theme/templates/node/node--search-short-description.html.twig b/web/themes/highwire/hwjma_theme/apps/drupal-default/hwjma_theme/templates/node/node--search-short-description.html.twig new file mode 100644 index 000000000..73fa19231 --- /dev/null +++ b/web/themes/highwire/hwjma_theme/apps/drupal-default/hwjma_theme/templates/node/node--search-short-description.html.twig @@ -0,0 +1,82 @@ +{# +/** + * @file + * Theme override to display a node. + * + * Available variables: + * - node: The node entity with limited access to object properties and methods. + Only "getter" methods (method names starting with "get", "has", or "is") + and a few common methods such as "id" and "label" are available. Calling + other methods (such as node.delete) will result in an exception. + * - label: The title of the node. + * - content: All node items. Use {{ content }} to print them all, + * or print a subset such as {{ content.field_example }}. Use + * {{ content|without('field_example') }} to temporarily suppress the printing + * of a given child element. + * - author_picture: The node author user entity, rendered using the "compact" + * view mode. + * - metadata: Metadata for this node. + * - date: Themed creation date field. + * - author_name: Themed author name field. + * - url: Direct URL of the current node. + * - display_submitted: Whether submission information should be displayed. + * - attributes: HTML attributes for the containing element. + * The attributes.class element may contain one or more of the following + * classes: + * - node: The current template type (also known as a "theming hook"). + * - node--type-[type]: The current node type. For example, if the node is an + * "Article" it would result in "node--type-article". Note that the machine + * name will often be in a short form of the human readable label. + * - node--view-mode-[view_mode]: The View Mode of the node; for example, a + * teaser would result in: "node--view-mode-teaser", and + * full: "node--view-mode-full". + * The following are controlled through the node publishing options. + * - node--promoted: Appears on nodes promoted to the front page. + * - node--sticky: Appears on nodes ordered above other non-sticky nodes in + * teaser listings. + * - node--unpublished: Appears on unpublished nodes visible only to site + * admins. + * - title_attributes: Same as attributes, except applied to the main title + * tag that appears in the template. + * - content_attributes: Same as attributes, except applied to the main + * content tag that appears in the template. + * - author_attributes: Same as attributes, except applied to the author of + * the node tag that appears in the template. + * - title_prefix: Additional output populated by modules, intended to be + * displayed in front of the main title tag that appears in the template. + * - title_suffix: Additional output populated by modules, intended to be + * displayed after the main title tag that appears in the template. + * - view_mode: View mode; for example, "teaser" or "full". + * - teaser: Flag for the teaser state. Will be true if view_mode is 'teaser'. + * - page: Flag for the full page state. Will be true if view_mode is 'full'. + * - readmore: Flag for more state. Will be true if the teaser content of the + * node cannot hold the main body content. + * - logged_in: Flag for authenticated user status. Will be true when the + * current user is a logged-in member. + * - is_admin: Flag for admin user status. Will be true when the current user + * is an administrator. + * + * @ingroup templates + * + * @see template_preprocess_node() + * + * @todo Remove the id attribute (or make it a class), because if that gets + * rendered twice on a page this is invalid CSS for example: two lists + * in different view modes. + */ +#} +{% + set classes = [ + node.bundle|clean_class, + node.isPromoted() ? 'is-promoted', + node.isSticky() ? 'is-sticky', + not node.isPublished() ? 'is-unpublished', + view_mode ? view_mode|clean_class, + 'clearfix', + ] +%} +{% block node_content %} + + {{ content }} + +{% endblock %} \ No newline at end of file diff --git a/web/themes/highwire/hwjma_theme/source/default/_patterns/03-components/site/_search-results.scss b/web/themes/highwire/hwjma_theme/source/default/_patterns/03-components/site/_search-results.scss index bd8797d1c..7150cf1fc 100755 --- a/web/themes/highwire/hwjma_theme/source/default/_patterns/03-components/site/_search-results.scss +++ b/web/themes/highwire/hwjma_theme/source/default/_patterns/03-components/site/_search-results.scss @@ -225,8 +225,8 @@ margin-bottom: 10px; } } - - .facets-widget-bpscheckbox_content_type { + + .facets-widget-hwjmacheckbox_content_type { & { border-bottom: 1px solid $info-light; padding-bottom: 5px; @@ -317,12 +317,12 @@ } } - .facets-widget-bps_include_all_checkbox_multiple { + .facets-widget-hwjma_include_all_checkbox_multiple { border-bottom: 1px solid $info-light; - &+.facets-widget-bpscheckbox_content_type { + &+.facets-widget-hwjmacheckbox_content_type { margin-bottom: 0; padding: 0; - .item-list__bpscheckbox_content_type { + .item-list__hwjmacheckbox_content_type { margin-bottom: 0; } } @@ -357,12 +357,12 @@ .modal-body { padding: 0 !important; overflow: visible; - .bps-checkbox-multiple-group { + .hwjma-checkbox-multiple-group { overflow: auto; max-height: 54vh; padding-left: 0; } - .bps-checkbox-multiple-facet { + .hwjma-checkbox-multiple-facet { list-style: none; padding: 0; margin: 0; @@ -427,7 +427,7 @@ display: none; } } - .bps-checkbox-multiple-facet { + .hwjma-checkbox-multiple-facet { padding-left: 25px; border-bottom: 1px solid $info-light; padding-top: 5px; @@ -449,7 +449,7 @@ } } - .bps-facets-form-actions { + .hwjma-facets-form-actions { @extend .modal-footer; padding-bottom: 0; @@ -489,7 +489,7 @@ content: '\e931'; } -.facets-widget-bps-search-facets-daterange { +.facets-widget-hwjma-search-facets-daterange { border-bottom: 1px solid $info-light; &.active { diff --git a/web/themes/highwire/hwjma_theme/source/default/js/custom/custom-theme.js b/web/themes/highwire/hwjma_theme/source/default/js/custom/custom-theme.js index 0c5c11fd3..0bfe506c2 100755 --- a/web/themes/highwire/hwjma_theme/source/default/js/custom/custom-theme.js +++ b/web/themes/highwire/hwjma_theme/source/default/js/custom/custom-theme.js @@ -80,7 +80,7 @@ jQuery(document).ready(function ($) { $(window).on( 'resize orientationchange', createSlick ); // Search Result Date Range Toggle - $('.facets-widget-bps-search-facets-daterange .facet-modal-click').on('click', function (event) { + $('.facets-widget-hwjma-search-facets-daterange .facet-modal-click').on('click', function (event) { event.preventDefault(); $(this).toggleClass('open'); $(this).next('.facets-date-range').slideToggle(); @@ -114,8 +114,8 @@ jQuery(document).ready(function ($) { }); // Search result popup filter wrap item - $('.bps-checkbox-multiple-facet').each(function() { - $(this).find('li.facet-item').wrapAll("
    • "); + $('.hwjma-checkbox-multiple-facet').each(function() { + $(this).find('li.facet-item').wrapAll("
      • "); }); }); From 3750124c4cacae50fbe8a8cd03846a885bfced55 Mon Sep 17 00:00:00 2001 From: Rajat Gupta Date: Tue, 19 Sep 2023 00:47:48 -0400 Subject: [PATCH 2/2] search --- config/sync/core.extension.yml | 1 + config/sync/facets.facet.article_type.yml | 66 ++++++++++++++++ config/sync/facets.facet.author.yml | 72 +++++++++++++++++ .../sync/facets.facet.content_type_facet.yml | 59 ++++++++++++++ .../sync/facets.facet.journal_title_facet.yml | 66 ++++++++++++++++ config/sync/facets.facet.keywords.yml | 66 ++++++++++++++++ ...search_api__views_page__search__page_1.yml | 9 +++ ...highwire_markup.markup.abstract_search.yml | 17 +++- config/sync/search_api.index.hwjma.yml | 79 ++++++++++++++++++- config/sync/views.view.search.yml | 30 +++++-- 10 files changed, 458 insertions(+), 7 deletions(-) create mode 100644 config/sync/facets.facet.article_type.yml create mode 100644 config/sync/facets.facet.author.yml create mode 100644 config/sync/facets.facet.content_type_facet.yml create mode 100644 config/sync/facets.facet.journal_title_facet.yml create mode 100644 config/sync/facets.facet.keywords.yml create mode 100644 config/sync/facets.facet_source.search_api__views_page__search__page_1.yml diff --git a/config/sync/core.extension.yml b/config/sync/core.extension.yml index af1e79b5f..8321e7a3e 100755 --- a/config/sync/core.extension.yml +++ b/config/sync/core.extension.yml @@ -33,6 +33,7 @@ module: elasticentityquery: 0 entityqueue: 0 facets: 0 + facets_taxonomy_tree: 0 field: 0 field_group: 0 field_ui: 0 diff --git a/config/sync/facets.facet.article_type.yml b/config/sync/facets.facet.article_type.yml new file mode 100644 index 000000000..391bc33ed --- /dev/null +++ b/config/sync/facets.facet.article_type.yml @@ -0,0 +1,66 @@ +uuid: ffc02c67-78e4-4800-9ab1-e7c111f0447a +langcode: en +status: true +dependencies: + config: + - search_api.index.hwjma + - views.view.search + module: + - search_api +id: article_type +name: article-type +url_alias: article_type +weight: 0 +min_count: 1 +show_only_one_result: false +field_identifier: article_type +facet_source_id: 'search_api:views_page__search__page_1' +widget: + type: hwjma_include_all_checkbox_multiple + config: + show_numbers: true + soft_limit: '0' + soft_limit_settings: + show_less_label: 'Show less' + show_more_label: 'Show more' + separate_active_items: 1 + display_active_items_summary: 1 +query_operator: or +use_hierarchy: false +expand_hierarchy: false +enable_parent_when_child_gets_disabled: true +hard_limit: 50 +exclude: false +only_visible_when_facet_source_is_visible: true +processor_configs: + count_widget_order: + processor_id: count_widget_order + weights: + sort: 30 + settings: + sort: DESC + hwjma_facet_result_count_alpha: + processor_id: hwjma_facet_result_count_alpha + weights: + sort: 50 + settings: + sort: ASC + insert_missing_active_results_processor: + processor_id: insert_missing_active_results_processor + weights: + build: -25 + settings: { } + last_result_clear_facet_processor: + processor_id: last_result_clear_facet_processor + weights: + build: 25 + settings: { } + url_processor_handler: + processor_id: url_processor_handler + weights: + pre_query: 50 + build: 15 + settings: { } +empty_behavior: + behavior: none +show_title: true diff --git a/config/sync/facets.facet.author.yml b/config/sync/facets.facet.author.yml new file mode 100644 index 000000000..3c7974d74 --- /dev/null +++ b/config/sync/facets.facet.author.yml @@ -0,0 +1,72 @@ +uuid: d7b2bedb-3584-4279-9c41-69ed41637eb6 +langcode: en +status: true +dependencies: + config: + - search_api.index.hwjma + - views.view.search + module: + - search_api +id: author +name: Author +url_alias: author +weight: 0 +min_count: 1 +show_only_one_result: false +field_identifier: authors_full_name +facet_source_id: 'search_api:views_page__search__page_1' +widget: + type: hwjma_include_all_checkbox_multiple + config: + show_numbers: true + soft_limit: '0' + soft_limit_settings: + show_less_label: 'Show less' + show_more_label: 'Show more' + separate_active_items: 1 + display_active_items_summary: 1 +query_operator: or +use_hierarchy: false +expand_hierarchy: false +enable_parent_when_child_gets_disabled: true +hard_limit: 0 +exclude: false +only_visible_when_facet_source_is_visible: true +processor_configs: + active_widget_order: + processor_id: active_widget_order + weights: + sort: 20 + settings: + sort: ASC + count_widget_order: + processor_id: count_widget_order + weights: + sort: 30 + settings: + sort: DESC + display_value_widget_order: + processor_id: display_value_widget_order + weights: + sort: 40 + settings: + sort: ASC + insert_missing_active_results_processor: + processor_id: insert_missing_active_results_processor + weights: + build: -25 + settings: { } + last_result_clear_facet_processor: + processor_id: last_result_clear_facet_processor + weights: + build: 25 + settings: { } + url_processor_handler: + processor_id: url_processor_handler + weights: + pre_query: 50 + build: 15 + settings: { } +empty_behavior: + behavior: none +show_title: true diff --git a/config/sync/facets.facet.content_type_facet.yml b/config/sync/facets.facet.content_type_facet.yml new file mode 100644 index 000000000..e4a66e95f --- /dev/null +++ b/config/sync/facets.facet.content_type_facet.yml @@ -0,0 +1,59 @@ +uuid: 1e211c47-efbd-4129-b5bf-2f429081fc4b +langcode: en +status: true +dependencies: + config: + - search_api.index.hwjma + - views.view.search + module: + - search_api +id: content_type_facet +name: 'Content type facet' +url_alias: content_type_facet +weight: -5 +min_count: 0 +show_only_one_result: false +field_identifier: type +facet_source_id: 'search_api:views_page__search__page_1' +widget: + type: hwjmacheckbox_content_type + config: + show_numbers: true + soft_limit: '0' + soft_limit_settings: + show_less_label: 'Show less' + show_more_label: 'Show more' + show_reset_link: 1 + reset_text: 'Include all' + reset_id: content_types_reset + show_reset_count: 0 +query_operator: or +use_hierarchy: true +expand_hierarchy: true +enable_parent_when_child_gets_disabled: true +hard_limit: 0 +exclude: false +only_visible_when_facet_source_is_visible: true +processor_configs: + display_value_widget_order: + processor_id: display_value_widget_order + weights: + sort: 40 + settings: + sort: ASC + exclude_specified_items: + processor_id: exclude_specified_items + weights: + build: 50 + settings: + exclude: 'journal_fragment,journal_volume,relationship,journal_issue,society,journal_info' + regex: false + url_processor_handler: + processor_id: url_processor_handler + weights: + pre_query: 50 + build: 15 + settings: { } +empty_behavior: + behavior: none +show_title: false diff --git a/config/sync/facets.facet.journal_title_facet.yml b/config/sync/facets.facet.journal_title_facet.yml new file mode 100644 index 000000000..b97b15fa4 --- /dev/null +++ b/config/sync/facets.facet.journal_title_facet.yml @@ -0,0 +1,66 @@ +uuid: 582282ad-e536-4158-b6ee-0d4f78b4f787 +langcode: en +status: true +dependencies: + config: + - search_api.index.hwjma + - views.view.search + module: + - search_api +id: journal_title_facet +name: 'Journal Title' +url_alias: journal_title_facet +weight: 0 +min_count: 1 +show_only_one_result: false +field_identifier: journal_title +facet_source_id: 'search_api:views_page__search__page_1' +widget: + type: hwjma_include_all_checkbox_multiple + config: + show_numbers: true + soft_limit: '0' + soft_limit_settings: + show_less_label: 'Show less' + show_more_label: 'Show more' + separate_active_items: 1 + display_active_items_summary: 1 +query_operator: or +use_hierarchy: false +expand_hierarchy: false +enable_parent_when_child_gets_disabled: true +hard_limit: 50 +exclude: false +only_visible_when_facet_source_is_visible: true +processor_configs: + count_widget_order: + processor_id: count_widget_order + weights: + sort: 30 + settings: + sort: DESC + hwjma_facet_result_count_alpha: + processor_id: hwjma_facet_result_count_alpha + weights: + sort: 50 + settings: + sort: ASC + insert_missing_active_results_processor: + processor_id: insert_missing_active_results_processor + weights: + build: -25 + settings: { } + last_result_clear_facet_processor: + processor_id: last_result_clear_facet_processor + weights: + build: 25 + settings: { } + url_processor_handler: + processor_id: url_processor_handler + weights: + pre_query: 50 + build: 15 + settings: { } +empty_behavior: + behavior: none +show_title: true diff --git a/config/sync/facets.facet.keywords.yml b/config/sync/facets.facet.keywords.yml new file mode 100644 index 000000000..6d8bb367e --- /dev/null +++ b/config/sync/facets.facet.keywords.yml @@ -0,0 +1,66 @@ +uuid: 91857e38-09c4-41ff-a1c9-6d6dbefca0be +langcode: en +status: true +dependencies: + config: + - search_api.index.hwjma + - views.view.search + module: + - search_api +id: keywords +name: keywords +url_alias: keywords +weight: 0 +min_count: 1 +show_only_one_result: false +field_identifier: first +facet_source_id: 'search_api:views_page__search__page_1' +widget: + type: hwjma_include_all_checkbox_multiple + config: + show_numbers: true + soft_limit: '0' + soft_limit_settings: + show_less_label: 'Show less' + show_more_label: 'Show more' + separate_active_items: 1 + display_active_items_summary: 1 +query_operator: or +use_hierarchy: false +expand_hierarchy: false +enable_parent_when_child_gets_disabled: true +hard_limit: 0 +exclude: false +only_visible_when_facet_source_is_visible: true +processor_configs: + count_widget_order: + processor_id: count_widget_order + weights: + sort: 30 + settings: + sort: DESC + hwjma_facet_result_count_alpha: + processor_id: hwjma_facet_result_count_alpha + weights: + sort: 50 + settings: + sort: ASC + insert_missing_active_results_processor: + processor_id: insert_missing_active_results_processor + weights: + build: -25 + settings: { } + last_result_clear_facet_processor: + processor_id: last_result_clear_facet_processor + weights: + build: 25 + settings: { } + url_processor_handler: + processor_id: url_processor_handler + weights: + pre_query: 50 + build: 15 + settings: { } +empty_behavior: + behavior: none +show_title: true diff --git a/config/sync/facets.facet_source.search_api__views_page__search__page_1.yml b/config/sync/facets.facet_source.search_api__views_page__search__page_1.yml new file mode 100644 index 000000000..7510cef41 --- /dev/null +++ b/config/sync/facets.facet_source.search_api__views_page__search__page_1.yml @@ -0,0 +1,9 @@ +uuid: 4037e8ae-d45f-492f-9aee-c9f10739c197 +langcode: en +status: true +dependencies: { } +id: search_api__views_page__search__page_1 +name: 'search_api:views_page__search__page_1' +filter_key: null +url_processor: query_string +breadcrumb: { } diff --git a/config/sync/highwire_markup.markup.abstract_search.yml b/config/sync/highwire_markup.markup.abstract_search.yml index 45285bcf2..248f0ce42 100644 --- a/config/sync/highwire_markup.markup.abstract_search.yml +++ b/config/sync/highwire_markup.markup.abstract_search.yml @@ -5,6 +5,21 @@ dependencies: { } id: abstract_search label: 'Abstract Search' profile_id: abstract -configuration: { } +configuration: + - + markup_processors_settings: + markup_processors: truncate + processor_config: + config: + max_length: '350' + word_safe: '1' + min_wordsafe_length: '10' + add_ellipsis: '1' + strip_tags: '1' + allowable_tags: '

            ' + toggle_full_text: '1' + text_collapsed: 'Show full content' + text_expanded: 'Hide full content' + weight: '1' dw_logging: null exists_field: has_abstract diff --git a/config/sync/search_api.index.hwjma.yml b/config/sync/search_api.index.hwjma.yml index de0673220..5a60d02b9 100644 --- a/config/sync/search_api.index.hwjma.yml +++ b/config/sync/search_api.index.hwjma.yml @@ -8,11 +8,18 @@ dependencies: - search_api - highwire_search config: + - field.storage.node.apath + - field.storage.node.article_type + - field.storage.node.authors_full_name + - field.storage.node.chapter_type - field.storage.node.corpus - - field.storage.node.date_epub_version - field.storage.node.early_release + - field.storage.node.date_epub_version - field.storage.node.issue + - field.storage.node.journal_title + - field.storage.node.keywords - field.storage.node.date_ppub + - field.storage.node.title_plain - field.storage.node.version_current - field.storage.node.volume - search_api.server.hwjma_solr @@ -44,6 +51,38 @@ name: HWJMA description: '' read_only: false field_settings: + apath: + label: Apath + datasource_id: 'entity:node' + property_path: apath + type: string + dependencies: + config: + - field.storage.node.apath + article_type: + label: article-type + datasource_id: 'entity:node' + property_path: article_type + type: text + dependencies: + config: + - field.storage.node.article_type + authors_full_name: + label: authors-full-name + datasource_id: 'entity:node' + property_path: authors_full_name + type: string + dependencies: + config: + - field.storage.node.authors_full_name + chapter_type_facet: + label: chapter-type-facet + datasource_id: 'entity:node' + property_path: chapter_type + type: string + dependencies: + config: + - field.storage.node.chapter_type corpus: label: Corpus datasource_id: 'entity:node' @@ -84,6 +123,14 @@ field_settings: dependencies: config: - field.storage.node.early_release + first: + label: 'keywords » Text' + datasource_id: 'entity:node' + property_path: 'keywords:first' + type: string + dependencies: + config: + - field.storage.node.keywords fulltext_search: label: 'Full Text Search' property_path: rendered_item @@ -103,6 +150,14 @@ field_settings: dependencies: config: - field.storage.node.issue + journal_title: + label: journal-title + datasource_id: 'entity:node' + property_path: journal_title + type: string + dependencies: + config: + - field.storage.node.journal_title status: label: Published datasource_id: 'entity:node' @@ -111,6 +166,14 @@ field_settings: dependencies: module: - node + title_plain: + label: title-plain + datasource_id: 'entity:node' + property_path: title_plain + type: text + dependencies: + config: + - field.storage.node.title_plain type: label: 'Content type' datasource_id: 'entity:node' @@ -153,6 +216,16 @@ processor_settings: add_url: { } aggregated_field: { } freebird_search_substitute_date: + date_epub_version: + enabled: '' + target: '' + condition: '' + substitute: '' + date_ppub: + enabled: '' + target: '' + condition: '' + substitute: '' date_ppub_facet: enabled: 1 target: journal_article @@ -164,7 +237,11 @@ processor_settings: html_filter: all_fields: false fields: + - article_type + - authors_full_name + - first - fulltext_search + - journal_title title: true alt: true tags: diff --git a/config/sync/views.view.search.yml b/config/sync/views.view.search.yml index efa202854..9b16144cf 100644 --- a/config/sync/views.view.search.yml +++ b/config/sync/views.view.search.yml @@ -55,14 +55,14 @@ display: first: '« First' last: 'Last »' expose: - items_per_page: false + items_per_page: true items_per_page_label: 'Items per page' - items_per_page_options: '5, 10, 25, 50' + items_per_page_options: '10, 50, 100' items_per_page_options_all: false items_per_page_options_all_label: '- All -' offset: false offset_label: Offset - quantity: 9 + quantity: 3 style: type: default options: @@ -74,8 +74,12 @@ display: options: view_modes: 'entity:node': - journal_article: default - journal_issue: default + journal: search_result + journal_article: search_result + journal_fragment: default + journal_info: default + journal_issue: search_result + journal_volume: default fields: search_api_id: table: search_api_index_hwjma @@ -266,6 +270,18 @@ display: expose: label: '' plugin_id: search_api + title_plain: + id: title_plain + table: search_api_index_hwjma + field: title_plain + relationship: none + group_type: group + admin_label: '' + order: ASC + exposed: true + expose: + label: Title + plugin_id: search_api date_ppub_facet: id: date_ppub_facet table: search_api_index_hwjma @@ -319,6 +335,10 @@ display: max_links: 100 path: search exposed_block: true + cache: + type: none + defaults: + cache: false cache_metadata: max-age: -1 contexts: