Skip to content

Commit 2f58ee5

Browse files
committed
introduce typesense into search
1 parent 5c4b98b commit 2f58ee5

File tree

7 files changed

+149
-6
lines changed

7 files changed

+149
-6
lines changed

source/_static/css/homepage-v1.css

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

source/_static/css/homepage-v1.css.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

source/_static/js/myscript-v1.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ $(document).ready(function () {
22
// Function to set the custom theme attribute based on the current theme
33
function setCustomTheme(theme) {
44
$('body').attr('data-custom-theme', theme);
5+
$('html').attr('data-theme', theme);
56
}
67

78
// Check for a manually set theme

source/_templates/custom-nav.html

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
<script src="https://cdn.jsdelivr.net/npm/typesense-docsearch.js@3.4.0"></script>
2+
<script>
3+
window.addEventListener('load', () => {
4+
docsearch({
5+
container: '.sidebar-search-container',
6+
typesenseCollectionName: 'mm_product_docs',
7+
typesenseServerConfig: {
8+
nodes: [{ host: 'h0agqxfpir543j9lp-1.a1.typesense.net', port: '443', protocol: 'https' }],
9+
// nodes: [{ host: 'localhost', port: '8108', protocol: 'http' }],
10+
apiKey: 'ZOLa3xKupe9e7DRPhkv56g8VUoCygd00' // read-only key. will eventually expose via env var
11+
},
12+
typesenseSearchParams: {}
13+
});
14+
});
15+
</script>
16+
117
<div data-swiftype-index=false class="notification-bar sticky-top">
218
<div class="notification-bar__content">
319
<a class="notification-bar__close" data-ol-has-click-handler="">
@@ -69,7 +85,7 @@
6985
<a href="https://mattermost.com/channels/">
7086
Channels
7187
</a>
72-
</li>
88+
</li>
7389
<li class="sub-menu__links--single">
7490
<a href="https://mattermost.com/playbooks/">
7591
Playbooks
@@ -127,7 +143,7 @@
127143
<a href="https://mattermost.com/enterprise/cloud/">
128144
Cloud
129145
</a>
130-
</li>
146+
</li>
131147
</ul>
132148
</div>
133149
</div>
@@ -173,7 +189,7 @@
173189
<a href="https://mattermost.com/solutions/use-cases/integrated-security-operations/">
174190
Integrated Security Operations
175191
</a>
176-
</li>
192+
</li>
177193
<li class="sub-menu__links--single">
178194
<a href="https://mattermost.com/solutions/use-cases/out-of-band-incident-response/">
179195
Out-of-Band Incident Response
@@ -384,7 +400,7 @@
384400
<div class="sub-menu__dev-link-col">
385401
<p class="sub-menu__link-col-header sub-menu__link-col-header-space">Documentation</p>
386402
<ul>
387-
403+
388404
<li class="sub-menu__links--single">
389405
<a href="https://academy.mattermost.com/">
390406
Academy
@@ -429,7 +445,7 @@
429445
<a href="https://mattermost.com/community/">
430446
Join Community
431447
</a>
432-
</li>
448+
</li>
433449
<li class="sub-menu__links--single">
434450
<a href="https://mattermost.com/contribute/">
435451
Contribute

typesense/Dockerfile

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
from python:3
2+
3+
RUN apt-get update
4+
5+
WORKDIR /app
6+
7+
RUN pip3 install pipenv
8+
9+
COPY ./Pipfile .
10+
COPY ./Pipfile.lock .
11+
12+
RUN pipenv install --dev
13+
14+
RUN mkdir -p build/html
15+
16+
COPY . .

typesense/config.json

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
{
2+
"index_name": "mm_product_docs",
3+
"allowed_domains": [
4+
"localhost",
5+
"sphinx"
6+
],
7+
"start_urls": [
8+
{
9+
"url": "http://localhost:8000",
10+
"tags": []
11+
}
12+
],
13+
"sitemap_urls": [
14+
"http://localhost:8000/sitemap.xml"
15+
],
16+
"selectors": {
17+
"lvl1": {
18+
"selector": "article h1",
19+
"type": "css"
20+
},
21+
"lvl2": {
22+
"selector": "article h2",
23+
"type": "css"
24+
},
25+
"lvl3": {
26+
"selector": "article h3",
27+
"type": "css"
28+
},
29+
"lvl4": {
30+
"selector": "article h4",
31+
"type": "css"
32+
},
33+
"lvl5": {
34+
"selector": "article h5",
35+
"type": "css"
36+
},
37+
"text": {
38+
"selector": "article p, article li",
39+
"type": "css"
40+
}
41+
},
42+
"custom_settings": {
43+
"token_separators": [
44+
"-"
45+
],
46+
"symbols_to_index": [
47+
"@"
48+
]
49+
},
50+
"strip_chars": " .,;:#",
51+
"stop_urls": [],
52+
"scrape_start_urls": false,
53+
"nb_hits": 64729
54+
}

typesense/docker-compose.yml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
services:
2+
sphinx:
3+
build:
4+
context: ..
5+
dockerfile: typesense/Dockerfile
6+
command: bash -c "make livehtml & cd build/html && python -m http.server 8001"
7+
# bash -c" cd ../.. && make livehtml"
8+
# volumes:
9+
# - ".:/app"
10+
ports:
11+
# - "8000:8000"
12+
# - "8001:8001"
13+
- "8000:8001"
14+
15+
typesense:
16+
image: typesense/typesense:0.24.0
17+
environment:
18+
- TYPESENSE_API_KEY=your_api_key
19+
- TYPESENSE_DATA_DIR=/data
20+
- TYPESENSE_ENABLE_CORS=true
21+
ports:
22+
- "8108:8108"
23+
volumes:
24+
- typesense-data:/data
25+
26+
scraper:
27+
image: typesense/docsearch-scraper
28+
# profiles:
29+
# - optional
30+
depends_on:
31+
- sphinx
32+
volumes:
33+
- ./config.json:/app/config.json
34+
network_mode: "host"
35+
environment:
36+
- CONFIG=/app/config.json
37+
- TYPESENSE_DATA_DIR=/data
38+
- TYPESENSE_ENABLE_CORS=true
39+
# - TYPESENSE_API_KEY=your_api_key
40+
# - TYPESENSE_HOST=typesense
41+
# - TYPESENSE_PORT=8108
42+
# - TYPESENSE_PROTOCOL=http
43+
- TYPESENSE_API_KEY=${TYPESENSE_API_KEY}
44+
- TYPESENSE_HOST=${TYPESENSE_HOST}
45+
- TYPESENSE_PORT=443
46+
- TYPESENSE_PROTOCOL=https
47+
48+
49+
volumes:
50+
typesense-data:

0 commit comments

Comments
 (0)