Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FEAT: Add Meilisearch in theme. #200

Merged
merged 28 commits into from
Feb 21, 2023
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
4ffe844
Replace the searchfield
Revathyvenugopal162 Feb 15, 2023
189ed28
ADD the env variables
Revathyvenugopal162 Feb 15, 2023
c58d9cf
Add the dict
Revathyvenugopal162 Feb 15, 2023
9298b85
Try to add the env variable
Revathyvenugopal162 Feb 15, 2023
1febdbd
Try to add uids
Revathyvenugopal162 Feb 15, 2023
7b1c04c
MAking the search field
Revathyvenugopal162 Feb 15, 2023
976e523
Add the styles
Revathyvenugopal162 Feb 15, 2023
9a66b06
Deploy changes to dev
Revathyvenugopal162 Feb 15, 2023
aeea248
Change the width
Revathyvenugopal162 Feb 15, 2023
0ee4dd9
Get the pydata if miliesearch not present
Revathyvenugopal162 Feb 15, 2023
71c33c6
Change the theme_options
Revathyvenugopal162 Feb 16, 2023
bd9fc4e
Add the search button
Revathyvenugopal162 Feb 16, 2023
045f0ac
Add the first value in dict
Revathyvenugopal162 Feb 16, 2023
4eaa23f
Update src/ansys_sphinx_theme/theme/ansys_sphinx_theme/static/css/mei…
Revathyvenugopal162 Feb 16, 2023
cc91235
Add the styles
Revathyvenugopal162 Feb 17, 2023
de58751
Merge branch 'feat/meiliserch' of https://github.com/ansys/ansys-sphi…
Revathyvenugopal162 Feb 17, 2023
d96e0f8
Add the dark theme
Revathyvenugopal162 Feb 17, 2023
6053b4f
Adjust the searchbar width
Revathyvenugopal162 Feb 17, 2023
fd3f306
Add the documenttation
Revathyvenugopal162 Feb 17, 2023
955ce3a
Add the docstrings
Revathyvenugopal162 Feb 17, 2023
0e6c51e
Update doc/source/user_guide/options.rst
Revathyvenugopal162 Feb 17, 2023
030180f
Add the searchbar styling
Revathyvenugopal162 Feb 20, 2023
e87f78d
Merge branch 'feat/meiliserch' of https://github.com/ansys/ansys-sphi…
Revathyvenugopal162 Feb 20, 2023
a8f8637
Update .github/workflows/ci_cd.yml
akaszynski Feb 21, 2023
66526c8
Fix Zoom problem
Revathyvenugopal162 Feb 21, 2023
2be13ba
Merge branch 'feat/meiliserch' of https://github.com/ansys/ansys-sphi…
Revathyvenugopal162 Feb 21, 2023
3b550fd
Update src/ansys_sphinx_theme/theme/ansys_sphinx_theme/static/css/mei…
Revathyvenugopal162 Feb 21, 2023
0c2d0a0
Merge branch 'main' into feat/meiliserch
Revathyvenugopal162 Feb 21, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .github/workflows/ci_cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ env:
PACKAGE_NAME: 'ansys-sphinx-theme'
PACKAGE_NAMESPACE: 'ansys_sphinx_theme'
DOCUMENTATION_CNAME: 'sphinxdocs.ansys.com'
MEILISEARCH_HOST_NAME: ${{ secrets.MEILISEARCH_HOST_NAME}}
MEILISEARCH_API_KEY: ${{ secrets.MEILISEARCH_API_KEY}}

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
Expand Down Expand Up @@ -49,7 +51,7 @@ jobs:

doc-deploy-development:
name: Doc dev version deploy
if: ${{ github.ref == 'refs/heads/main' }}
#if: ${{ github.ref == 'refs/heads/main' }}
akaszynski marked this conversation as resolved.
Show resolved Hide resolved
runs-on: ubuntu-latest
needs: doc-build
steps:
Expand Down
12 changes: 12 additions & 0 deletions doc/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@
html_logo = ansys_logo_black
html_theme = "ansys_sphinx_theme"


# In the html_context dictionary in conf.py
html_context = {
"github_user": "ansys",
"github_repo": "ansys-sphinx-theme",
Expand All @@ -62,6 +64,16 @@
"json_url": f"https://{cname}/release/versions.json",
"version_match": get_version_match(__version__),
},
"use_meilisearch": {
"host": os.getenv("MEILISEARCH_HOST_NAME"),
"api_key": os.getenv("MEILISEARCH_API_KEY", ""),
"index_uids": {
"ansys-ansys-sphinx-theme-sphinx-docs": "ansys-sphinx-theme",
"pyansys-docs-all-public": "PyAnsys",
"pyaedt": "pyaedt",
"pymapdl": "pymapdl",
},
},
}

html_short_title = html_title = "Ansys Sphinx Theme"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<!-- Debugging: html_theme_options = {{ html_theme_options }} -->
<!-- Include the MeiliSearch CSS stylesheet -->
{% if theme_use_meilisearch %}
<link href="{{ pathto('_static/css/meilisearch.css', 1) }}" rel="stylesheet">

<!-- Create a search bar form with a text input and a dropdown selector for the search index -->
<form class="bd-search d-flex align-items-center" action="{{ pathto('search') }}" method="get">
<input type="search" placeholder="Search" class="form-control" id="search-bar-input" autofocus />

{% if theme_use_meilisearch.index_uids %}
<select id="indexUidSelector" class="index-select">
{% for index_uid, index_name in theme_use_meilisearch.index_uids.items() %}
<option value="{{ index_uid }}">{{ index_name }}</option>
{% endfor %}
</select>
{% endif %}
<i class="fa-solid fa-magnifying-glass"></i>
<!-- Include the MeiliSearch JavaScript library for the search bar -->
<script src="https://cdn.jsdelivr.net/npm/docs-searchbar.js@latest/dist/cdn/docs-searchbar.min.js"></script>
<script>
// Initialize the MeiliSearch search bar with the given API key and index UID
let theSearchBar = docsSearchBar({
hostUrl: "{{ theme_use_meilisearch.host }}" ,
apiKey: "{{ theme_use_meilisearch.api_key }}" ,
indexUid: "{{ theme_use_meilisearch.index_uids.items()|first|first }}",
inputSelector: '#search-bar-input, #indexUidSelector',
enableDarkMode: 'auto',
debug: true // Set debug to true if you want to inspect the dropdown
});

document.getElementById('indexUidSelector').addEventListener('change', function() {
theSearchBar.indexUid = this.value;
theSearchBar.inputSelector = '#docs-searchbar-suggestion, #indexUidSelector';
});

// Set the focus on the search bar input
document.getElementById('docs-searchbar-suggestion').focus();
</script>
</form>
{% else %}
{%- extends "pydata_sphinx_theme/components/search-field.html" -%}
{% endif %}

Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
@import "https://cdn.jsdelivr.net/npm/docs-searchbar.js@latest/dist/cdn/docs-searchbar.min.css";
@import "https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/css/all.min.css";

div [data-ds-theme] .searchbox {
margin: auto;
display: block;
width: 600px;
}

.dsb-suggestions {
width: 580px;
}

.docs-searchbar-suggestion--category-header {
background-color: #d9d9d9;
border-radius: 7px;
text-align: center;
}

.docs-searchbar-suggestion--subcategory-column-text {
color: black;
}

div [data-ds-theme] .searchbox input {
height: 32px;
border-radius: 8px;
font-size: 18px;
font-family: "Open Sans", sans-serif;
box-shadow: 0px 0px 8px darkgrey;
}

.docs-searchbar-footer {
display: none;
}

[class*="docs-searchbar-suggestion"] {
text-decoration: none;
}

.docs-searchbar-suggestion--highlight {
box-shadow: none !important;
}

.container {
display: flex;
justify-content: center;
align-items: center;
}

.index-select {
color: #555;
background: #fff;
height: 32px;
border-radius: 8px;
font-size: 18px;
font-family: "Open Sans", sans-serif;
border: 0;
box-shadow: 0px 0px 8px darkgrey;
padding: 0 10px 0px 10px;
}

.meilisearch-autocomplete {
text-align: center;
color: var(--pst-color-text-base);
}

#search-bar-input{
width: 150%;
background-color: var(--pst-color-background);
border: 1px solid var(--pst-color-border);
border-radius: .25rem;
color: var(--pst-color-text-base);
font-size: var(--pst-font-size-icon);
position: relative;
Revathyvenugopal162 marked this conversation as resolved.
Show resolved Hide resolved
}

.meilisearch-autocomplete::before {
content: "\f002";
font-family: "Font Awesome 6 Free"; /* The Font Awesome font family */
position: absolute;
left: 8px;
top: 50%;
transform: translateY(-50%);
font-size: 1rem;
color: var(--pst-color-border);
}

.index-select {
color: #555;
flex-direction: column;
background: #fff;
height: 2.5rem;
border-radius: 8px;
font-size: 20px;
font-family: "Open Sans", sans-serif;
box-shadow: 0px 0px 20px darkgrey;
margin-left: 13rem;
}

.meilisearch-autocomplete .dsb-dropdown-menu [class^=dsb-dataset-] {
position: relative;
border: 1px solid #d9d9d9;
background: #fff;
border-radius: 4px;
overflow: auto;
padding: 0 8px 8px;
width: 130%;
}

.meilisearch-autocomplete .docs-searchbar-suggestion {
width: 130%;
}

.meilisearch-autocomplete .docs-searchbar-suggestion--highlight {
color: var(--pst-color-info);
background: var(--pst-color-background);
padding: 0 .05em;
}

.meilisearch-autocomplete .docs-searchbar-suggestion--subcategory-column {
width: 50%;
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ hidden_icons =
additional_breadcrumbs =
use_edit_page_button = True
switcher =
use_meilisearch=
RobPasMue marked this conversation as resolved.
Show resolved Hide resolved