Skip to content

Commit

Permalink
🔀 merged with future
Browse files Browse the repository at this point in the history
  • Loading branch information
keevkeev committed Apr 8, 2019
2 parents 870e217 + ae01c33 commit 5cfa997
Show file tree
Hide file tree
Showing 485 changed files with 4,770 additions and 1,172 deletions.
1 change: 1 addition & 0 deletions boilerplate/templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
<link rel="preload" href="/static/fonts/noto-sans-v7-latin-regular.woff2" as="font" crossorigin>
<link rel="preload" href="/static/fonts/noto-sans-v7-latin-700.woff2" as="font" crossorigin>
<link rel="preload" href="/static/fonts/poppins-v5-latin-700.woff2" as="font" crossorigin>
<link rel="preload" href="/static/fonts/fira-mono-v7-latin-500.woff2" as="font" crossorigin>
<script async src="https://cdn.ampproject.org/v0.js"></script>
<script async custom-element="amp-bind" src="https://cdn.ampproject.org/v0/amp-bind-0.1.js"></script>
<script async custom-element="amp-list" src="https://cdn.ampproject.org/v0/amp-list-0.1.js"></script>
Expand Down
91 changes: 91 additions & 0 deletions examples/api/cache.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
/**
* 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 URL = require('url').URL;
const {setImmutable} = require('@lib/utils/cacheHelpers');

// eslint-disable-next-line new-cap
const examples = express.Router();

examples.get('/query', (request, response) => {
setImmutable(response);
const queryString = JSON.stringify(request.query, null, 2);
/* eslint-disable max-len */
response.send(`<!doctype html>
<html âš¡ lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,minimum-scale=1">
<script async src="https://cdn.ampproject.org/v0.js"></script>
<style amp-boilerplate>body{-webkit-animation:-amp-start 8s steps(1,end) 0s 1 normal both;-moz-animation:-amp-start 8s steps(1,end) 0s 1 normal both;-ms-animation:-amp-start 8s steps(1,end) 0s 1 normal both;animation:-amp-start 8s steps(1,end) 0s 1 normal both}@-webkit-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-moz-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-ms-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-o-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}</style><noscript><style amp-boilerplate>body{-webkit-animation:none;-moz-animation:none;-ms-animation:none;animation:none}</style></noscript>
<link rel="canonical" href="${request.originalUrl}">
<title>AMP Cache Query Demo</title>
</head>
<body>
<h1>Hello World!</h1>
<pre>${queryString}</pre>
</body>
</html>
`);
/* eslint-enable max-len */
});

examples.get('/invalid-amp', (request, response) => {
setImmutable(response);
response.send(`<!doctype html>
<html âš¡ lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,minimum-scale=1">
<script async src="https://cdn.ampproject.org/v0.js"></script>
<title>Invalid AMP</title>
</head>
<body>
<h1>This page is not valid AMP</h1>
</body>
</html>
`);
});

examples.get('/not-found', (request, response) => {
setImmutable(response);
response.status(404).send('404 - Not found');
});

examples.get('/redirect', (request, response) => {
setImmutable(response);
if (!request.query.url) {
response.status().send('No url specified via <code>?url=https://example.com</code>');
return;
}
try {
new URL(request.url);
} catch (err) {
response.status().send('Invalid url specified');
return;
}
res.redirect(301, request.query.url);
});

examples.get('/server-error', (request, response) => {
setImmutable(response);
response.status(500).send('500 - Internal Server Error');
});

module.exports = examples;
54 changes: 54 additions & 0 deletions examples/source/0.introduction/AMPHTML_Ads_Hello_World.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<!---
preview: a4a
skipValidation: 'true'
--->

<!--
## Introduction
An introduction into how to create [AMPHTML ads]({{ g.doc('/content/amp-dev/documentation/guides-and-tutorials/learn/a4a_spec.md').url.path }}). AMPHTML ads are ads implemented using AMPHTML. The AMPHTML ads runtime is based on the AMP runtime and provides the same performance benefits. However, there are a few things that make them different from normal AMPHTML files.
Read on: The [AMPHTML Validator](https://validator.ampproject.org/#htmlFormat=AMP4ADS) features a special validation mode for AMPHTML ads.
-->

<!-- ## Markup -->
<!-- -->
<!-- Doctype declaration is required. -->
<!doctype html>
<!-- This tells everyone that this is an AMPHTML ads file. -->
<html âš¡4ads>
<!-- ### Head -->
<!-- -->
<head>
<!-- The charset definition must be the first child of the `<head>` tag. -->
<meta charset="utf-8">
<title> Hello World</title>
<!-- AMPHTML ads require a custom version of the AMP runtime.-->
<script async src="https://cdn.ampproject.org/amp4ads-v0.js"></script>
<meta name="viewport" content="width=device-width,minimum-scale=1,initial-scale=1">
<!--
The AMPHTML ads boilerplate which is shorter than the regular AMP boilerplate. -->
<style amp4ads-boilerplate>body{visibility:hidden}</style>
<!--
CSS must be embedded inline as well.
-->
<style amp-custom>
h1 {
color: red;
}
</style>
</head>
<!-- ## Body -->
<!-- -->
<body>
<!--
Inside the body, AMPHTML ads are only allowed to use a restricted set of HTML and AMPHTML elements as described in the [spec](https://github.com/ampproject/amphtml/blob/master/extensions/amp-a4a/amp-a4a-format.md).
-->
<h1>Hello World</h1>
<!--
Check out the other [AMPHTML ads samples](/documentation/examples.html?format=ads) to learn how to create more sophisticated AMPHTML ads.
-->
</body>
</html>
11 changes: 7 additions & 4 deletions examples/source/0.introduction/Banner_Ad.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
preview: a4a
adSlot: /30497360/amp_by_example/AMP_Banner_300x250
skipValidation: 'true'
width: 300
height: 250
--->

Expand Down Expand Up @@ -37,17 +39,18 @@
The anatonomy of banner ad is an image with a hyperlink to the advertiser's page. We display the image for the creative using [amp-img](/documentation/components/reference/amp-img.html).
-->
<a target="_blank"
href="<% hosts.platform %>/amp_ads/banner_ad/">
<amp-img src="/static/samples/img/amp-300x250.jpg"
href="<% canonical %>">
<amp-img src="<% hosts.platform %>/static/samples/img/amp-300x250.jpg"
width="300"
height="250"
layout="responsive"
alt="a4a image"></amp-img>
</a>

<!--
We include a tracking pixel to record that the ad was rendered using [amp-pixel](https://www.ampproject.org/docs/reference/components/amp-pixel).
We include a tracking pixel to record that the ad was rendered using [amp-pixel](/documentation/components/reference/amp-pixel.html).
<p>Alternatively one could make use of [amp-analytics](https://www.ampproject.org/docs/reference/extended/amp-analytics.html) to enable much more comprenhensive measure activity.</p>
Alternatively one could make use of [amp-analytics](/documentation/components/reference/amp-analytics.html) to enable much more comprenhensive measure activity.
-->
<amp-pixel src="https://foo.com/pixel?RANDOM"></amp-pixel>
</body>
Expand Down
6 changes: 0 additions & 6 deletions examples/source/1.components/amp-ad.html
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
<!---
draft: true
--->

<!--
## Introduction
Expand Down
116 changes: 116 additions & 0 deletions examples/source/1.components/amp-date-display.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
<!---
experiments:
- amp-date-display
preview: default
--->

<!--
## Introduction
The [amp-date-display](/documentation/components/reference/amp-date-display.html) component renders date information in various date formats and in different locales.
-->
<!-- -->
<!doctype html>
<html âš¡>
<head>
<meta charset="utf-8">
<!-- ## Setup -->
<!-- Include the `amp-date-display` component ... -->
<script async custom-element="amp-date-display" src="https://cdn.ampproject.org/v0/amp-date-display-0.1.js"></script>
<!-- ... and the `amp-mustache` component in the header -->
<script async custom-template="amp-mustache" src="https://cdn.ampproject.org/v0/amp-mustache-0.2.js"></script>
<meta name="viewport" content="width=device-width,minimum-scale=1,initial-scale=1">
<link rel="canonical" href="<% canonical %>">
<style amp-boilerplate>body{-webkit-animation:-amp-start 8s steps(1,end) 0s 1 normal both;-moz-animation:-amp-start 8s steps(1,end) 0s 1 normal both;-ms-animation:-amp-start 8s steps(1,end) 0s 1 normal both;animation:-amp-start 8s steps(1,end) 0s 1 normal both}@-webkit-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-moz-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-ms-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-o-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}</style><noscript><style amp-boilerplate>body{-webkit-animation:none;-moz-animation:none;-ms-animation:none;animation:none}</style></noscript>
<script async src="https://cdn.ampproject.org/v0.js"></script>
<style amp-custom></style>
</head>
<body>
<!--
## Basic usage
You must specify one of `datetime`, `timestamp-ms`, or `timestamp-seconds` attributes. This indicates the date and time to display.
The date information is rendered via an [amp-mustache template](https://www.ampproject.org/docs/reference/components/amp-mustache).
The day, hour, minutes and seconds values are bound to `{{day}}`, `{{hour}}`, `{{minute}}` and `{{second}}` respectively.
Double digit format variants (`{{dayTwoDigit}}`, `{{hourTwoDigit}}`, `{{minuteTwoDigit}}` and `{{secondTwoDigit}}`) display these values with zero-padding on single digit values. Other values like `{{iso}}` are also available
-->
<amp-date-display timestamp-seconds="2147483648" layout="fixed-height" height="20">
<template type="amp-mustache">
<a href="https://en.wikipedia.org/wiki/Year_2038_problem">Y2K38</a> will be at {{iso}}
</template>
</amp-date-display>

<!--
## Available variables
All the variables that can be displayed are in the template below.
-->
<amp-date-display datetime="now" layout="fixed" width="360" height="590">
<template type="amp-mustache">
<table>
<thead>
<tr><th>variable</th><th>value</th></tr>
</thead>
<tbody>
<tr><td>day</td><td>{{day}}</td></tr>
<tr><td>dayName</td><td>{{dayName}}</td></tr>
<tr><td>dayNameShort</td><td>{{dayNameShort}}</td></tr>
<tr><td>dayPeriod</td><td>{{dayPeriod}}</td></tr>
<tr><td>dayTwoDigit</td><td>{{dayTwoDigit}}</td></tr>
<tr><td>hour</td><td>{{hour}}</td></tr>
<tr><td>hour12</td><td>{{hour12}}</td></tr>
<tr><td>hour12TwoDigit</td><td>{{hour12TwoDigit}}</td></tr>
<tr><td>hourTwoDigit</td><td>{{hourTwoDigit}}</td></tr>
<tr><td>iso</td><td>{{iso}}</td></tr>
<tr><td>minute</td><td>{{minute}}</td></tr>
<tr><td>minuteTwoDigit</td><td>{{minuteTwoDigit}}</td></tr>
<tr><td>month</td><td>{{month}}</td></tr>
<tr><td>monthName</td><td>{{monthName}}</td></tr>
<tr><td>monthNameShort</td><td>{{monthNameShort}}</td></tr>
<tr><td>monthTwoDigit</td><td>{{monthTwoDigit}}</td></tr>
<tr><td>second</td><td>{{second}}</td></tr>
<tr><td>secondTwoDigit</td><td>{{secondTwoDigit}}</td></tr>
<tr><td>year</td><td>{{year}}</td></tr>
<tr><td>yearTwoDigit</td><td>{{yearTwoDigit}}</td></tr>
</tbody>
</table>
</template>
</amp-date-display>


<!--
## Locales
Internationalized month and weekday names can be configured by specifying a `locale` attribute.
For example, the `amp-date-display` components below show the same date information in German, French, Czech and English.
-->
<div>
<amp-date-display datetime="now" locale="de" layout="fixed" width="360" height="20">
<template type="amp-mustache">
<div>de: {{dayName}} {{day}} {{monthName}} {{year}}</div>
</template>
</amp-date-display>
<amp-date-display datetime="now" locale="fr" layout="fixed" width="360" height="20">
<template type="amp-mustache">
<div>fr: {{dayName}} {{day}} {{monthName}} {{year}}</div>
</template>
</amp-date-display>
<amp-date-display datetime="now" locale="cs" layout="fixed" width="360" height="20">
<template type="amp-mustache">
<div>cs: {{dayName}} {{day}} {{monthName}} {{year}}</div>
</template>
</amp-date-display>
<amp-date-display datetime="now" locale="en-GB" layout="fixed" width="360" height="20">
<template type="amp-mustache">
<div>en-GB: {{dayName}} {{day}} {{monthName}} {{year}}</div>
</template>
</amp-date-display>
</div>
</body>
</html>
6 changes: 0 additions & 6 deletions examples/source/1.components/amp-springboard-player.html
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
<!---
draft: true
--->

<!--
## Introduction
Expand Down
6 changes: 0 additions & 6 deletions examples/source/1.components/amp-web-push.html
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
<!---
draft: true
--->

<!--
## Introduction
Expand Down
4 changes: 2 additions & 2 deletions examples/source/2.guides/Internationalization.html
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
* 1 link tag with `rel=amphtml`
* And X link tags with `rel=alternate` and the `hreflang` attribute
<a href="/internationalization/basic/" class="ampstart-btn ampstart-btn-secondary caps text-decoration-none inline-block"> View the Example</a>
<a href="/static/samples/internationalization/basic/">View the Example</a>
## Example 2: Canonical + Alternate + AMP
The next example is an expanded version of the first example. This example includes
Expand All @@ -96,7 +96,7 @@
* Every alternate mobile document must have a link tag with `rel=alternate` and an
`hreflang` attribute for each alternative language version of the alternate mobile document.
<a href="/internationalization/alternate/" class="ampstart-btn ampstart-btn-secondary caps text-decoration-none inline-block"> View the Example</a>
<a href="/static/samples/internationalization/alternate/">View the Example</a>
-->
</body>
Expand Down
4 changes: 2 additions & 2 deletions examples/source/2.guides/Using_the_Google_AMP_Cache.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
<meta charset="utf-8">
<title>Using the Google AMP Cache</title>
<script async src="https://cdn.ampproject.org/v0.js"></script>
<script async custom-element="amp-iframe" src="https://cdn.ampproject.org/v0/amp-iframe-0.1.js"></script>
<link rel="canonical" href="<% canonical %>">
<script async custom-element="amp-iframe" src="https://cdn.ampproject.org/v0/amp-iframe-0.1.js"></script>
<meta name="viewport" content="width=device-width,minimum-scale=1,initial-scale=1">
<style amp-boilerplate>body{-webkit-animation:-amp-start 8s steps(1,end) 0s 1 normal both;-moz-animation:-amp-start 8s steps(1,end) 0s 1 normal both;-ms-animation:-amp-start 8s steps(1,end) 0s 1 normal both;animation:-amp-start 8s steps(1,end) 0s 1 normal both}@-webkit-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-moz-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-ms-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-o-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}</style><noscript><style amp-boilerplate>body{-webkit-animation:none;-moz-animation:none;-ms-animation:none;animation:none}</style></noscript>
</head>
Expand All @@ -32,7 +32,7 @@
Here is AMP Cache URL for `https://ampbyexample.com/components/amp-img`:
<amp-iframe title="Google AMP Cache tool" height="149" layout="fixed-height" sandbox="allow-scripts allow-same-origin allow-popups" src="https://amp-by-example-api.appspot.com/iframe/amp-url-converter.html?url=https://ampbyexample.com/components/amp-img"><div placeholder></div></amp-iframe>
<amp-iframe title="Google AMP Cache tool" height="149" layout="fixed-height" sandbox="allow-scripts allow-same-origin allow-popups" src="<% hosts.preview %>/files/amp-url-converter.html?url=https://amp.dev/index.amp.html"><div placeholder></div></amp-iframe>
The converted AMP Cache URL consists of the following parts:
Expand Down
Loading

0 comments on commit 5cfa997

Please sign in to comment.