Skip to content

Commit 0456c36

Browse files
authored
Merge pull request #924 from ExpressionEngine/feature/docsearch
Update doc search to use Meilisearch instead of Algolia
2 parents cafc8bc + 6f28f04 commit 0456c36

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

79 files changed

+1018
-800
lines changed

.github/workflows/build.yml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: Build Docs
2+
3+
on:
4+
push:
5+
branches:
6+
- 7.x
7+
- 7.dev
8+
9+
jobs:
10+
build:
11+
name: Build Documentation HTML
12+
runs-on: ubuntu-latest
13+
outputs:
14+
DOCSEARCH_INDEX: ${{ steps.setup_vars.outputs.DOCSEARCH_INDEX }}
15+
DOCS_URL: ${{ steps.setup_vars.outputs.DOCS_URL }}
16+
steps:
17+
- name: Checkout code
18+
uses: actions/checkout@v2
19+
20+
- name: Setup Variables
21+
id: setup_vars
22+
run: |
23+
if [[ "${{github.base_ref}}" == "7.x" || "${{github.ref}}" == "refs/heads/7.x" ]]; then
24+
echo "DOCSEARCH_INDEX=expressionengine7" >> "$GITHUB_OUTPUT"
25+
else
26+
echo "DOCSEARCH_INDEX=expressionengine7_staging" >> "$GITHUB_OUTPUT"
27+
fi
28+
29+
- name: Update Docsearch Index
30+
uses: richardrigutins/replace-in-files@v2
31+
with:
32+
search-text: "docsearch_index: 'expressionengine'"
33+
replacement-text: "docsearch_index: '${{steps.setup_vars.outputs.DOCSEARCH_INDEX}}'"
34+
files: ./config.yml
35+
36+
- name: Install NPM and build
37+
run: |
38+
npm install
39+
npm run build
40+
41+
- name: Archive Build files
42+
uses: actions/upload-artifact@v4
43+
with:
44+
name: EEDocs7.latest
45+
path: build

.github/workflows/publish-prod.yml

Lines changed: 0 additions & 40 deletions
This file was deleted.

.github/workflows/publish-staging.yml

Lines changed: 0 additions & 40 deletions
This file was deleted.

.github/workflows/search.yml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: Update Search
2+
3+
on:
4+
workflow_dispatch:
5+
6+
jobs:
7+
search:
8+
name: Build Search Index
9+
runs-on: ubuntu-latest
10+
steps:
11+
- name: Checkout code
12+
uses: actions/checkout@v4
13+
14+
- name: Setup Variables
15+
run: |
16+
if [[ "${{github.base_ref}}" == "7.x" || "${{github.ref}}" == "refs/heads/7.x" ]]; then
17+
echo "DOCSEARCH_INDEX=expressionengine7" >> "$GITHUB_ENV"
18+
echo "DOCS_URL=https://docs.expressionengine.com/latest" >> "$GITHUB_ENV"
19+
else
20+
echo "DOCSEARCH_INDEX=expressionengine7_staging" >> "$GITHUB_ENV"
21+
echo "::add-mask::${{secrets.STAGING_DOCS_DOMAIN}}"
22+
echo "DOCS_URL=${{secrets.STAGING_DOCS_URL}}" >> "$GITHUB_ENV"
23+
fi
24+
25+
- name: Configure Docsearch Index
26+
uses: richardrigutins/replace-in-files@v2
27+
with:
28+
search-text: "\"index_uid\": \"expressionengine\""
29+
replacement-text: "\"index_uid\": \"${{ env.DOCSEARCH_INDEX }}\""
30+
files: ./search.config.json
31+
32+
- name: Configure Docs Url
33+
uses: richardrigutins/replace-in-files@v2
34+
with:
35+
search-text: "https://docs.expressionengine.com/latest"
36+
replacement-text: ${{ env.DOCS_URL }}
37+
files: ./search.config.json
38+
39+
- name: Scrape Docs
40+
env:
41+
HOST_URL: ${{ secrets.MEILISEARCH_HOST_URL }}
42+
API_KEY: ${{ secrets.MEILISEARCH_API_KEY }}
43+
run: |
44+
docker run -t --rm \
45+
-e MEILISEARCH_HOST_URL=$HOST_URL \
46+
-e MEILISEARCH_API_KEY=$API_KEY \
47+
-v ./search.config.json:/docs-scraper/search.config.json \
48+
getmeili/docs-scraper:latest pipenv run ./docs_scraper search.config.json

README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,24 @@ To build the theme assets, run `npm run buildAssets`. You can also dynamically r
3434

3535
Manually load `/build/index.html` in your browser to view your local build. For example, `file:///Users/<username>/Documents/ExpressionEngine-User-Guide/build/index.html`. You can use the side navigation to navigate to different local files, but the search functionality always takes you to the live version at docs.expressionengine.com.
3636

37+
## Using DocSearch Locally
38+
39+
First you will need to choose a docsearch index name to use for your local testing and set that in `config.yml`
40+
41+
Then you will need to build the docs and serve a local copy. For simplicity's sake we recommend using the node http-server like this `npx http-server -o`
42+
43+
Next you will need to update all the urls in `search.config.json` to point at your local copy of the documentation. Do a find/replace on `https://docs.expressionengine.com/latest` => `http://localhost:8080`. You will also need to update the `allowed_domains` array to include this new url. (If you are on a mac you may need to use `http://host.docker.internal:8080` instead so that the scraper container can connect to the docs on your local http-server.)
44+
45+
Finally you can scrape your local docs with the following docker command
46+
47+
```
48+
docker run -t --rm --network=host \
49+
-e MEILISEARCH_HOST_URL=https://docsearch.expressionengine.com \
50+
-e MEILISEARCH_API_KEY={{ SECRET_KEY }} \
51+
-v ./search.config.json:/docs-scraper/search.config.json \
52+
getmeili/docs-scraper:latest pipenv run ./docs_scraper search.config.json
53+
```
54+
3755
## Contributing
3856

3957
See something that needs fixing? Want to improve the user guide or make it more helpful? Great! Check out [CONTRIBUTING.md](CONTRIBUTING.md) for details.

config.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,5 @@ themeDir: theme
88
customVariables:
99
current_version: '7'
1010
current_year: 2024
11+
docsearch_index: 'expressionengine'
12+
docsearch_public_key: '7d283b55c1d7c0e5f340c71b5dfc751d8dc625708f29e582134f7643bc95dbd7'

docs/development/control-panel-js/globals.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,56 +20,56 @@ The elements of global `EE` JavaScript objects could vary depending on the Contr
2020

2121
To add the element to global object, call [`ee()->javascript->set_global()`](development/legacy/libraries/javascript.md#set_globalvar-val--) function.
2222

23-
### `BASE`
23+
## `BASE`
2424

2525
Control Panel base URL.
2626

2727
$.get(EE.BASE + '&C=login&M=lock_cp');
2828

29-
### `CSRF_TOKEN`
29+
## `CSRF_TOKEN`
3030

3131
The current [Cross Site Request Forgery](development/guidelines/security.md#cross-site-request-forgery) token
3232

3333
headers: { 'X-CSRF-TOKEN': EE.CSRF_TOKEN },
3434

35-
### `PATH_CP_GBL_IMG`
35+
## `PATH_CP_GBL_IMG`
3636

3737
Path to `themes/ee/asset/img` directory
3838

39-
### `THEME_URL`
39+
## `THEME_URL`
4040

4141
URL to `themes/ee/cp` folder
4242

43-
### `username`
43+
## `username`
4444

4545
Username of currently logged in member
4646

47-
### `lang`
47+
## `lang`
4848

4949
Object of language strings available for JavaScript function in member's preferred language
5050

5151
text: EE.lang.loading
5252

53-
### `hasRememberMe`
53+
## `hasRememberMe`
5454

5555
Indicates whether the "remember me" checkbox was toggled on when member logged in.
5656

57-
### `cp.appVer`
57+
## `cp.appVer`
5858

5959
The version number of ExpressionEngine release.
6060
data: {
6161
appVer: EE.cp.appVer,
6262
}
6363

64-
### `site_id`
64+
## `site_id`
6565

6666
ID of MSM site that is currently active in Control Panel
6767

68-
### `site_name`
68+
## `site_name`
6969

7070
The configured site name
7171

72-
### `site_url`
72+
## `site_url`
7373

7474
The URL to the site's front-end
7575

@@ -81,7 +81,7 @@ The URL to the site's front-end
8181
}
8282
]
8383

84-
### `fileManagerCompatibilityMode`
84+
## `fileManagerCompatibilityMode`
8585

8686
Indicates whether File Manager is running in [Compatibility Mode](control-panel/file-manager/file-manager.md#compatibility-mode).
8787

docs/development/extension-hooks/api/channel-fields.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ lang: php
1313

1414
# Channel Fields API Extension Hooks
1515

16-
### `custom_field_modify_data(EE_Fieldtype $ft, $method, $data)`
16+
## `custom_field_modify_data(EE_Fieldtype $ft, $method, $data)`
1717

1818
| Parameter | Type | Description |
1919
| --------- | -------- | --------------------------------------------------- |

docs/development/extension-hooks/api/template-structure.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@
99

1010
# Template Structure API Extension Hooks
1111

12-
### `template_types`
12+
## `template_types`
1313

1414
See the Output library's [template_types](development/extension-hooks/cp/design.md#template_types).

docs/development/extension-hooks/cp/admin-content.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ lang: php
1313

1414
# Admin Content Controller Extension Hooks
1515

16-
[TOC=3]
16+
[TOC=2]
1717

18-
### `category_delete($cat_ids)`
18+
## `category_delete($cat_ids)`
1919

2020
| Parameter | Type | Description |
2121
| --------- | ------- | ----------------------------------- |
@@ -28,7 +28,7 @@ How it's called:
2828

2929
ee()->extensions->call('category_delete', $cat_ids);
3030

31-
### `category_save($cat_id, $data)`
31+
## `category_save($cat_id, $data)`
3232

3333
| Parameter | Type | Description |
3434
| --------------- | ------- | -------------------- |
@@ -42,6 +42,6 @@ How it's called:
4242

4343
ee()->extensions->call('category_save', $cat_id, $category_data);
4444

45-
### `foreign_character_conversion_array`
45+
## `foreign_character_conversion_array`
4646

4747
See Content_publish's `foreign_character_conversion_array`.

0 commit comments

Comments
 (0)