From 5886090d5052f7f7f0f0abe43c02250b63d2f0f7 Mon Sep 17 00:00:00 2001 From: Sergej Date: Thu, 30 Aug 2018 18:32:32 +0200 Subject: [PATCH] feat(docs-infra): Add opensearch description (#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 #25479 --- .circleci/config.yml | 2 +- aio/package.json | 1 + aio/scripts/build-artifacts.sh | 9 +++++++++ aio/scripts/deploy-to-firebase.sh | 4 ++++ aio/src/app/app.component.ts | 1 + aio/src/assets/opensearch.xml | 9 +++++++++ aio/src/index.html | 1 + 7 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 aio/src/assets/opensearch.xml diff --git a/.circleci/config.yml b/.circleci/config.yml index d3ea5e4a9a..e20d9766c5 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -158,7 +158,7 @@ jobs: - restore_cache: key: *cache_key - run: yarn install --frozen-lockfile --non-interactive - - run: ./aio/scripts/build-artifacts.sh $AIO_SNAPSHOT_ARTIFACT_PATH + - run: ./aio/scripts/build-artifacts.sh $AIO_SNAPSHOT_ARTIFACT_PATH $CIRCLE_PR_NUMBER $CIRCLE_SHA1 - store_artifacts: path: *aio_preview_artifact_path # The `destination` needs to be kept in synch with the value of diff --git a/aio/package.json b/aio/package.json index 93a60e4751..9b7257ceaf 100644 --- a/aio/package.json +++ b/aio/package.json @@ -28,6 +28,7 @@ "presetup-local": "yarn presetup", "setup-local": "yarn aio-use-local && yarn example-use-local", "postsetup-local": "yarn postsetup", + "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');\"", "test-pwa-score-localhost": "concurrently --kill-others --success first \"http-server dist -p 4200 --silent\" \"yarn test-pwa-score http://localhost:4200 90\"", "test-pwa-score": "node scripts/test-pwa-score", "example-e2e": "yarn example-check-local && node ./tools/examples/run-example-e2e", diff --git a/aio/scripts/build-artifacts.sh b/aio/scripts/build-artifacts.sh index 2104db5908..45684f7cbe 100755 --- a/aio/scripts/build-artifacts.sh +++ b/aio/scripts/build-artifacts.sh @@ -6,11 +6,20 @@ source "`dirname $0`/../../scripts/ci/env.sh" print readonly INPUT_DIR=dist/ readonly OUTPUT_FILE=$PROJECT_ROOT/$1 +readonly PR_NUMBER=$2 +readonly PR_LAST_SHA=$3 +readonly deployedUrl=https://pr${PR_NUMBER}-${PR_LAST_SHA:0:7}.ngbuilds.io/ + ( cd $PROJECT_ROOT/aio # Build and store the app yarn build + + # Set deployedUrl as parameter in the opensearch description + # deployedUrl must end with / + yarn set-opensearch-url $deployedUrl + mkdir -p "`dirname $OUTPUT_FILE`" tar --create --gzip --directory "$INPUT_DIR" --file "$OUTPUT_FILE" . ) diff --git a/aio/scripts/deploy-to-firebase.sh b/aio/scripts/deploy-to-firebase.sh index f72aeb1c16..407dc5732a 100755 --- a/aio/scripts/deploy-to-firebase.sh +++ b/aio/scripts/deploy-to-firebase.sh @@ -92,6 +92,10 @@ fi # Include any mode-specific files cp -rf src/extra-files/$deployEnv/. dist/ + # Set deployedUrl as parameter in the opensearch description + # deployedUrl must end with / + yarn set-opensearch-url $deployedUrl + # Check payload size yarn payload-size diff --git a/aio/src/app/app.component.ts b/aio/src/app/app.component.ts index e587d25ad1..a15c4ca3fe 100644 --- a/aio/src/app/app.component.ts +++ b/aio/src/app/app.component.ts @@ -384,6 +384,7 @@ export class AppComponent implements OnInit { hideSearchResults() { this.showSearchResults = false; + this.locationService.setSearch('', {}); } focusSearchBox() { diff --git a/aio/src/assets/opensearch.xml b/aio/src/assets/opensearch.xml new file mode 100644 index 0000000000..b49855b9e0 --- /dev/null +++ b/aio/src/assets/opensearch.xml @@ -0,0 +1,9 @@ + +Angular +Search Angular +UTF-8 +images/favicons/favicon-16x16.png + +PLACEHOLDER_URL?search={searchTerms} + \ No newline at end of file diff --git a/aio/src/index.html b/aio/src/index.html index 994ccf05f5..1eb26655a7 100644 --- a/aio/src/index.html +++ b/aio/src/index.html @@ -7,6 +7,7 @@ +