From 4515b855f6fc93733e88f0767ab8129fa976a162 Mon Sep 17 00:00:00 2001 From: Wesley B <62723358+wesleyboar@users.noreply.github.com> Date: Tue, 22 Oct 2024 17:04:13 -0500 Subject: [PATCH 01/28] feat: template & setting for Google search --- taccsite_cms/_settings/search.py | 1 + taccsite_cms/settings.py | 1 + taccsite_cms/settings_custom.example.py | 4 +- taccsite_cms/templates/search.html | 155 ++++++++++++++++++++++++ 4 files changed, 159 insertions(+), 2 deletions(-) create mode 100644 taccsite_cms/templates/search.html diff --git a/taccsite_cms/_settings/search.py b/taccsite_cms/_settings/search.py index ce19ba3d4..19ba969ab 100644 --- a/taccsite_cms/_settings/search.py +++ b/taccsite_cms/_settings/search.py @@ -10,6 +10,7 @@ # To support Google search # PORTAL_SEARCH_QUERY_PARAM_NAME = 'q' # PORTAL_SEARCH_INDEX_IS_AUTOMATIC = False +# GOOGLE_SEARCH_ENGINE_ID = None # (DEPRECATED) To support Elasticsearch PORTAL_SEARCH_QUERY_PARAM_NAME = 'query_string' diff --git a/taccsite_cms/settings.py b/taccsite_cms/settings.py index 19ba18801..4bdd9a5df 100644 --- a/taccsite_cms/settings.py +++ b/taccsite_cms/settings.py @@ -851,4 +851,5 @@ def get_subdirs_as_module_names(path): 'PORTAL_SOCIAL_SHARE_PLATFORMS', 'PORTAL_SEARCH_PATH', 'PORTAL_SEARCH_QUERY_PARAM_NAME', + 'GOOGLE_SEARCH_ENGINE_ID', ] diff --git a/taccsite_cms/settings_custom.example.py b/taccsite_cms/settings_custom.example.py index be0096a21..b279b850c 100644 --- a/taccsite_cms/settings_custom.example.py +++ b/taccsite_cms/settings_custom.example.py @@ -105,10 +105,10 @@ ######################## # To support Google search +PORTAL_SEARCH_PATH = '/search' PORTAL_SEARCH_QUERY_PARAM_NAME = 'q' - -# To disable Elasticsearch PORTAL_SEARCH_INDEX_IS_AUTOMATIC = False +GOOGLE_SEARCH_ENGINE_ID = None ######################## # DJANGOCMS_BLOG diff --git a/taccsite_cms/templates/search.html b/taccsite_cms/templates/search.html new file mode 100644 index 000000000..dcae060a4 --- /dev/null +++ b/taccsite_cms/templates/search.html @@ -0,0 +1,155 @@ +{% extends "base.html" %} +{% load cms_tags %} + +{% block cms_content %} + {% placeholder "content" %} + +
+
+
+

Search

+
+
+ + {{#if settings.GOOGLE_SEARCH_ENGINE_ID }} + +
+ {{else}} +

Please inform your website administrator to verify a GOOGLE_SEARCH_ENGINE_ID exists for this website.

+ {{/if}} + +
+{% endblock cms_content %} + +{% block css %} + {{ block.super }} + + +{% endblock css %} From 8607c9062c80c348ce20cc130549f67988ce4c8a Mon Sep 17 00:00:00 2001 From: Wesley B <62723358+wesleyboar@users.noreply.github.com> Date: Tue, 22 Oct 2024 18:05:34 -0500 Subject: [PATCH 02/28] fix: styles and fallback warning for Google Search --- taccsite_cms/templates/search.html | 64 ++++++++++++++++-------------- 1 file changed, 34 insertions(+), 30 deletions(-) diff --git a/taccsite_cms/templates/search.html b/taccsite_cms/templates/search.html index dcae060a4..5f0bc4a17 100644 --- a/taccsite_cms/templates/search.html +++ b/taccsite_cms/templates/search.html @@ -4,20 +4,20 @@ {% block cms_content %} {% placeholder "content" %} -
+ {% endblock cms_content %} @@ -25,11 +25,13 @@

Search

{% block css %} {{ block.super }} - + +} + {% endblock css %} From f3dc4dc14f8b81bef755d7640ddcb5b2e1593d63 Mon Sep 17 00:00:00 2001 From: Wesley B <62723358+wesleyboar@users.noreply.github.com> Date: Tue, 22 Oct 2024 18:15:36 -0500 Subject: [PATCH 03/28] enhance: move sarch CSS to its own file So that it can be loaded from CDN. Use cases are: - if search template is broken - for custom search page - for non-Core website --- taccsite_cms/static/site_cms/css/search.css | 129 +++++++++++++++++++ taccsite_cms/templates/search.html | 135 +------------------- 2 files changed, 131 insertions(+), 133 deletions(-) create mode 100644 taccsite_cms/static/site_cms/css/search.css diff --git a/taccsite_cms/static/site_cms/css/search.css b/taccsite_cms/static/site_cms/css/search.css new file mode 100644 index 000000000..ff62495f6 --- /dev/null +++ b/taccsite_cms/static/site_cms/css/search.css @@ -0,0 +1,129 @@ +#cms-search { + + /* SEARCH CONTAINER */ + + /* To remove padding from search container */ + & .gsc-control-cse { + padding: unset; + } + + + + /* TABLE OF SEARCH STATS & SORTING OPTIONS */ + + /* To remove border from search analytics, add gray background */ + & .gsc-above-wrapper-area { + --bkgd-color: var(--global-color-primary--x-light); + + background-color: var(--bkgd-color); + box-shadow: 40vw 0 var(--bkgd-color), -40vw 0 var(--bkgd-color); + } + + & .gsc-above-wrapper-area-container { + border-bottom: unset; + } + + /* To override Core-Styles tables */ + & tbody > tr:first-child > :is(td, th) { + border: unset; + padding-inline: unset; + background: unset; + vertical-align: middle; + } + + & .gsc-selected-option-container { + background: var(--global-color-primary--xx-light); + border: var(--global-border--normal); + } + + & .gsc-result-info { + padding: unset; + font-size: var(--global-font-size--medium); + } + + + + /* SUGGESTION PHRASE (after "Did you mean:") */ + + & .gs-spelling { + padding: unset; + } + & .gs-spelling a { + color: var(--global-color-accent--normal); + } + + + + /* SEARCH RESULTS */ + + /* (search result body text) */ + & .gs-snippet { + color: var(--global-color-primary--dark); + } + + /* (url under search result title) */ + & .gs-webResult div.gs-visibleUrl { + color: var(--global-color-secondary--normal); + } + + /* (search result titles) */ + & a.gs-title:link { + color: var(--global-color-accent--normal); + text-decoration: none; + text-decoration-thickness: var(--global-border-width--normal); + text-underline-offset: 0.2em; + } + & a.gs-title:link:hover { + text-decoration-line: underline; + text-decoration-style: solid; + } + + /* (push search-result description to right) */ + & .gs-image-box { + margin-right: 10px; + } + + + + /* GOOGLE PAGE NAVIGATION (at bottom) */ + + & .gsc-cursor-box { + display: flex; + justify-content: center; + margin-block: var(--global-space--large); + } + + & .gsc-cursor-current-page { + color: var(--global-color-accent--normal); + text-decoration: none; + text-decoration-thickness: var(--global-border-width--normal); + text-underline-offset: 0.2em; + } + + & .gsc-cursor-current-page:hover { + text-decoration-line: underline; + text-decoration-style: solid; + } + + + + /* GOOGLE BRANDING */ + + & .gcsc-find-more-on-google { + color: var(--global-color-accent--normal); + text-decoration: none; + text-decoration-thickness: var(--global-border-width--normal); + text-underline-offset: 0.2em; + } + + & .gcsc-find-more-on-google:hover { + text-decoration-line: underline; + text-decoration-style: solid; + } + + & .gcsc-branding-img-noclear { + vertical-align: unset; + top: 1px; + } + +} diff --git a/taccsite_cms/templates/search.html b/taccsite_cms/templates/search.html index 5f0bc4a17..a6b368bd5 100644 --- a/taccsite_cms/templates/search.html +++ b/taccsite_cms/templates/search.html @@ -1,5 +1,5 @@ {% extends "base.html" %} -{% load cms_tags %} +{% load static cms_tags %} {% block cms_content %} {% placeholder "content" %} @@ -24,136 +24,5 @@

Search

{% block css %} {{ block.super }} - - + {% endblock css %} From 3947bc24a6d6e82f7cf0bc822c1f5c8297c250d1 Mon Sep 17 00:00:00 2001 From: Wesley B <62723358+wesleyboar@users.noreply.github.com> Date: Tue, 22 Oct 2024 18:18:37 -0500 Subject: [PATCH 04/28] enhance: rename search stylesheet and ID Compared to "cms-search", "google-search" is: - more accurate - more obvious to those not familiar with Core-CMS --- .../static/site_cms/css/{search.css => google-search.css} | 2 +- taccsite_cms/templates/search.html | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) rename taccsite_cms/static/site_cms/css/{search.css => google-search.css} (99%) diff --git a/taccsite_cms/static/site_cms/css/search.css b/taccsite_cms/static/site_cms/css/google-search.css similarity index 99% rename from taccsite_cms/static/site_cms/css/search.css rename to taccsite_cms/static/site_cms/css/google-search.css index ff62495f6..898a1e137 100644 --- a/taccsite_cms/static/site_cms/css/search.css +++ b/taccsite_cms/static/site_cms/css/google-search.css @@ -1,4 +1,4 @@ -#cms-search { +#google-search { /* SEARCH CONTAINER */ diff --git a/taccsite_cms/templates/search.html b/taccsite_cms/templates/search.html index a6b368bd5..83bd24eac 100644 --- a/taccsite_cms/templates/search.html +++ b/taccsite_cms/templates/search.html @@ -4,7 +4,7 @@ {% block cms_content %} {% placeholder "content" %} -