Skip to content

Commit 8f0fcc3

Browse files
s-gbzkara
authored andcommitted
feat(docs-infra): Add opensearch description (angular#25479)
Enables Chrome users to search angular.io and its subdomains from the browsers navigation bar. Not sure if compatible with Firefox yet. The queried term in the URL is removed after closing the search-results. PR Close angular#25479
1 parent ca1e56d commit 8f0fcc3

File tree

7 files changed

+26
-1
lines changed

7 files changed

+26
-1
lines changed

.circleci/config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ jobs:
150150
- restore_cache:
151151
key: *cache_key
152152
- run: yarn install --frozen-lockfile --non-interactive
153-
- run: ./aio/scripts/build-artifacts.sh $AIO_SNAPSHOT_ARTIFACT_PATH
153+
- run: ./aio/scripts/build-artifacts.sh $AIO_SNAPSHOT_ARTIFACT_PATH $CIRCLE_PR_NUMBER $CIRCLE_SHA1
154154
- store_artifacts:
155155
path: *aio_preview_artifact_path
156156
# The `destination` needs to be kept in synch with the value of

aio/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
"presetup-local": "yarn presetup",
2929
"setup-local": "yarn aio-use-local && yarn example-use-local",
3030
"postsetup-local": "yarn postsetup",
31+
"set-opensearch-url": "node --eval \"const sh = require('shelljs'); sh.set('-e'); sh.sed('-i', /PLACEHOLDER_URL/g, process.argv[1], 'dist/assets/opensearch.xml');\"",
3132
"test-pwa-score-localhost": "concurrently --kill-others --success first \"http-server dist -p 4200 --silent\" \"yarn test-pwa-score http://localhost:4200 90\"",
3233
"test-pwa-score": "node scripts/test-pwa-score",
3334
"example-e2e": "yarn example-check-local && node ./tools/examples/run-example-e2e",

aio/scripts/build-artifacts.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,20 @@ source "`dirname $0`/../../scripts/ci/env.sh" print
66

77
readonly INPUT_DIR=dist/
88
readonly OUTPUT_FILE=$PROJECT_ROOT/$1
9+
readonly PR_NUMBER=$2
10+
readonly PR_LAST_SHA=$3
11+
readonly deployedUrl=https://pr${PR_NUMBER}-${PR_LAST_SHA:0:7}.ngbuilds.io/
12+
913
(
1014
cd $PROJECT_ROOT/aio
1115

1216
# Build and store the app
1317
yarn build
18+
19+
# Set deployedUrl as parameter in the opensearch description
20+
# deployedUrl must end with /
21+
yarn set-opensearch-url $deployedUrl
22+
1423
mkdir -p "`dirname $OUTPUT_FILE`"
1524
tar --create --gzip --directory "$INPUT_DIR" --file "$OUTPUT_FILE" .
1625
)

aio/scripts/deploy-to-firebase.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,10 @@ fi
9292
# Include any mode-specific files
9393
cp -rf src/extra-files/$deployEnv/. dist/
9494

95+
# Set deployedUrl as parameter in the opensearch description
96+
# deployedUrl must end with /
97+
yarn set-opensearch-url $deployedUrl
98+
9599
# Check payload size
96100
yarn payload-size
97101

aio/src/app/app.component.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -384,6 +384,7 @@ export class AppComponent implements OnInit {
384384

385385
hideSearchResults() {
386386
this.showSearchResults = false;
387+
this.locationService.setSearch('', {});
387388
}
388389

389390
focusSearchBox() {

aio/src/assets/opensearch.xml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/"
2+
xmlns:moz="http://www.mozilla.org/2006/browser/search/">
3+
<ShortName>Angular</ShortName>
4+
<Description>Search Angular</Description>
5+
<InputEncoding>UTF-8</InputEncoding>
6+
<Image width="16" height="16" type="image/x-icon">images/favicons/favicon-16x16.png</Image>
7+
<Url type="text/html" method="get" template="PLACEHOLDER_URL?search={searchTerms}"/>
8+
<moz:SearchForm>PLACEHOLDER_URL?search={searchTerms}</moz:SearchForm>
9+
</OpenSearchDescription>

aio/src/index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
<meta name="viewport" content="width=device-width, initial-scale=1">
99

10+
<link rel="search" type="application/opensearchdescription+xml" href="assets/opensearch.xml">
1011
<link rel="icon" type="image/x-icon" href="assets/images/favicons/favicon.ico">
1112
<link rel="icon" type="image/png" href="assets/images/favicons/favicon-32x32.png"
1213
sizes="32x32">

0 commit comments

Comments
 (0)