forked from ampproject/amp.dev
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'future' into migrate/rating
Showing
106 changed files
with
2,961 additions
and
1,222 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,103 @@ | ||
language: node_js | ||
node_js: | ||
- lts/* | ||
- lts/* | ||
git: | ||
depth: 3 | ||
addons: | ||
apt: | ||
packages: | ||
- expect-dev | ||
cache: | ||
- pip | ||
- npm | ||
install: | ||
- pip install grow==0.7.4 --user | ||
- grow --version | ||
- which grow | ||
- npm ci | ||
before_deploy: | ||
- npm run build:staging | ||
deploy: | ||
provider: gae | ||
keyfile: ".staging.key.json" | ||
project: amp-dev-staging | ||
skip_cleanup: true | ||
on: | ||
branch: future | ||
- pip | ||
- npm | ||
before_install: | ||
- openssl aes-256-cbc -K $encrypted_b44033ffb787_key -iv $encrypted_b44033ffb787_iv | ||
-in .prod.key.json.enc -out .prod.key.json -d | ||
- openssl aes-256-cbc -K $encrypted_d4a09416a845_key -iv $encrypted_d4a09416a845_iv | ||
-in .staging.key.json.enc -out .staging.key.json -d | ||
- gcloud auth activate-service-account --key-file=.staging.key.json | ||
install: | ||
- npm ci | ||
stages: | ||
- preparation | ||
- name: build | ||
if: branch = future | ||
- name: deploy | ||
if: branch = future | ||
jobs: | ||
include: | ||
- stage: preparation | ||
env: APP_ENV=staging | ||
name: Check code, import documents, build samples, playground & boilerplate | ||
before_script: | ||
- unbuffer gulp buildSamples | ||
- unbuffer gulp lintAll | ||
script: | ||
- if [ $TRAVIS_BRANCH == "future" ]; then unbuffer gulp buildPrepare; fi | ||
- stage: build | ||
env: APP_ENV=staging | ||
install: &1 | ||
- npm ci | ||
- pip install grow==0.7.4 --user | ||
name: Build Pages (EN) | ||
script: unbuffer gulp buildPages --locales en | ||
- stage: build | ||
env: APP_ENV=staging | ||
install: *1 | ||
name: Build Pages (FR) | ||
script: unbuffer gulp buildPages --locales fr | ||
- stage: build | ||
env: APP_ENV=staging | ||
install: *1 | ||
name: Build Pages (AR) | ||
script: unbuffer gulp buildPages --locales ar | ||
- stage: build | ||
env: APP_ENV=staging | ||
install: *1 | ||
name: Build Pages (ES) | ||
script: unbuffer gulp buildPages --locales es | ||
- stage: build | ||
env: APP_ENV=staging | ||
install: *1 | ||
name: Build Pages (IT) | ||
script: unbuffer gulp buildPages --locales it | ||
- stage: build | ||
env: APP_ENV=staging | ||
install: *1 | ||
name: Build Pages (ID) | ||
script: unbuffer gulp buildPages --locales id | ||
- stage: build | ||
env: APP_ENV=staging | ||
install: *1 | ||
name: Build Pages (JA) | ||
script: unbuffer gulp buildPages --locales ja | ||
- stage: build | ||
env: APP_ENV=staging | ||
install: *1 | ||
name: Build Pages (KO) | ||
script: unbuffer gulp buildPages --locales ko | ||
- stage: build | ||
env: APP_ENV=staging | ||
install: *1 | ||
name: Build Pages (BR) | ||
script: unbuffer gulp buildPages --locales pt_BR | ||
- stage: build | ||
env: APP_ENV=staging | ||
install: *1 | ||
name: Build Pages (RU) | ||
script: unbuffer gulp buildPages --locales ru | ||
- stage: build | ||
env: APP_ENV=staging | ||
install: *1 | ||
name: Build Pages (TR) | ||
script: unbuffer gulp buildPages --locales tr | ||
- stage: build | ||
env: APP_ENV=staging | ||
install: *1 | ||
name: Build Pages (CN) | ||
script: unbuffer gulp buildPages --locales zh_CN | ||
- stage: deploy | ||
env: APP_ENV=staging | ||
script: | ||
- unbuffer gulp buildFinalize | ||
- gcloud app deploy --project=amp-dev-staging --quiet |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
/** | ||
* Copyright 2019 The AMP HTML Authors. All Rights Reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS-IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
'use strict'; | ||
|
||
const express = require('express'); | ||
const multer = require('multer'); | ||
const upload = multer(); | ||
|
||
// eslint-disable-next-line new-cap | ||
const examples = express.Router(); | ||
const MAX_RESULT_SIZE = 4; | ||
const US_CAPITAL_CITIES = [ | ||
'Montgomery, Alabama', | ||
'Juneau, Alaska', | ||
'Phoenix, Arizona', | ||
'Little Rock, Arkansas', | ||
'Sacramento, California', | ||
'Denver, Colorado', | ||
'Hartford, Connecticut', | ||
'Dover, Delaware', | ||
'Tallahassee, Florida', | ||
'Atlanta, Georgia', | ||
'Honolulu, Hawaii', | ||
'Boise, Idaho', | ||
'Springfield, Illinois', | ||
'Indianapolis, Indiana', | ||
'Des Moines, Iowa', | ||
'Topeka, Kansas', | ||
'Frankfort, Kentucky', | ||
'Baton Rouge, Louisiana', | ||
'Augusta, Maine', | ||
'Annapolis, Maryland', | ||
'Boston, Massachusetts', | ||
'Lansing, Michigan', | ||
'Saint Paul, Minnesota', | ||
'Jackson, Mississippi', | ||
'Jefferson City, Missouri', | ||
'Helena, Montana', | ||
'Lincoln, Nebraska', | ||
'Carson City, Nevada', | ||
'Concord, New Hampshire', | ||
'Trenton, New Jersey', | ||
'Santa Fe, New Mexico', | ||
'Albany, New York', | ||
'Raleigh, North Carolina', | ||
'Bismarck, North Dakota', | ||
'Columbus, Ohio', | ||
'Oklahoma City, Oklahoma', | ||
'Salem, Oregon', | ||
'Harrisburg, Pennsylvania', | ||
'Providence, Rhode Island', | ||
'Columbia, South Carolina', | ||
'Pierre, South Dakota', | ||
'Nashville, Tennessee', | ||
'Austin, Texas', | ||
'Salt Lake City, Utah', | ||
'Montpelier, Vermont', | ||
'Richmond, Virginia', | ||
'Olympia, Washington', | ||
'Charleston, West Virginia', | ||
'Madison, Wisconsin', | ||
'Cheyenne, Wyoming', | ||
]; | ||
|
||
examples.get('/autosuggest/search_list', upload.none(), handleSearchRequest); | ||
examples.post('/autosuggest/address', upload.none(), handleAddressRequest); | ||
|
||
function handleSearchRequest(request, response) { | ||
const query = request.query ? request.query.q : ''; | ||
|
||
let results = US_CAPITAL_CITIES.filter((key) => { | ||
return key.toUpperCase().includes(query.toUpperCase()); | ||
}); | ||
|
||
if (results.length > MAX_RESULT_SIZE) { | ||
results = results.slice(0, MAX_RESULT_SIZE); | ||
} | ||
|
||
const items = ({ | ||
items: [ | ||
{ | ||
query, | ||
results, | ||
}, | ||
], | ||
}); | ||
|
||
response.json(items); | ||
}; | ||
|
||
function handleAddressRequest(request, response) { | ||
const city = request.body ? request.body.city : ''; | ||
let result; | ||
|
||
if (US_CAPITAL_CITIES.includes(city)) { | ||
result = `Success! Your package is on it's way to ${city}.`; | ||
} else { | ||
result = `Sorry! We don't ship to ${city}.`; | ||
} | ||
|
||
response.json({ | ||
result, | ||
}); | ||
}; | ||
|
||
module.exports = examples; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,8 @@ | |
preview: a4a | ||
skipValidation: 'true' | ||
width: 350 | ||
height: 70 | ||
---> | ||
|
||
|
Oops, something went wrong.