Skip to content

Commit

Permalink
run prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastianbenz committed May 11, 2021
1 parent cd95865 commit 920b7b3
Show file tree
Hide file tree
Showing 18 changed files with 56 additions and 232 deletions.
7 changes: 5 additions & 2 deletions gulpfile.js/deploy.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,11 @@ const {join} = require('path');
const {sh} = require('@lib/utils/sh.js');
const mri = require('mri');
const {existsSync} = require('fs');
const {ROOT, THUMBOR_ROOT, PIXI_CLOUD_ROOT} =
require('@lib/utils/project').paths;
const {
ROOT,
THUMBOR_ROOT,
PIXI_CLOUD_ROOT,
} = require('@lib/utils/project').paths;

const PREFIX = 'amp-dev';
const PACKAGER_PREFIX = PREFIX + '-packager';
Expand Down
3 changes: 1 addition & 2 deletions gulpfile.js/import/importRoadmap.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@ const ROADMAP_DIRECTORY_PATH = utils.project.absolute('pages/shared/data');
const ALLOWED_ISSUE_TYPES = ['Type: Status Update', 'Status Update'];

// RegEx to extract date from issue title
const STATUS_UPDATE_REGEX =
/(\d\d\d\d)-(0?[1-9]|1[012])-(0?[1-9]|[12]\d|3[01])/;
const STATUS_UPDATE_REGEX = /(\d\d\d\d)-(0?[1-9]|1[012])-(0?[1-9]|[12]\d|3[01])/;
// Match any amp-component tag. Eg. <amp-img>
const AMP_COMPONENT_REGEX = /\s(<amp-\S*>)/g;
// Group markdown text into text blocks starting with h1 - h3
Expand Down
Original file line number Diff line number Diff line change
@@ -1,174 +0,0 @@
---
$title: Include third-party content
$order: 9
description: '페이지에서 써드 파티 컴포넌트를 가져오는 법에 대해서 다룹니다 ...'
formats:
- websites
components:
- iframe
- facebook
author: Meggin
contributors:
- pbakaus
- bpaduch
---

페이지에서 써드 파티 컴포넌트를 가져오는 법에 대해서 다룹니다.

## 트윗 가져오기

페이지에 트위터 트윗을 가져올 때 [`amp-twitter`](../../../../documentation/components/reference/amp-twitter.md) 요소를 사용합니다.

트위터를 페이지에 추가하고자 할 때, `<head>` 요소 안에 아래 스크립트를 먼저 가져와야 합니다.

[sourcecode:html]
<script async custom-element="amp-twitter"
src="https://cdn.ampproject.org/v0/amp-twitter-0.1.js"></script>
[/sourcecode]

현재 트윗은 자동으로 제공된 사이즈에 비례하여 크기가 조정되지만, 원하는 크기에 미치지 않을 수도 있습니다. 수동으로 width와 height를 제공하여 조정하거나, 스크린 width에 기반한 해상도를 선택하는 media 속성을 사용할 수 있습니다.

[example preview="inline" playground="true" imports="amp-twitter:0.1"]
```html
<amp-twitter width="500"
height="583"
layout="responsive"
data-tweetid="638793490521001985">
</amp-twitter>
```
[/example]

도움말: [AMP By Example],[`amp-twitter`](../../../../documentation/examples/documentation/amp-twitter.html).url.path}}) 예시를 확인하세요.

## 인스타그램 가져오기

페이지에 인스타그램을 가져올 때 [`amp-instagram`](../../../../documentation/components/reference/amp-instagram.md) 요소를 사용합니다.

인스타그램을 페이지에 추가하고자 할 때, `<head>` 요소 안에 아래 스크립트를 먼저 가져와야 합니다.

[sourcecode:html]
<script async custom-element="amp-instagram"
src="https://cdn.ampproject.org/v0/amp-instagram-0.1.js"></script>
[/sourcecode]

인스타그램 사진 URL을 찾기 위해 인스타그램 data-shortcode를 추가해야합니다. 예를 들어, `https://instagram.com/p/fBwFP`에서 `fBwFP`가 data-shortcode 입니다. 또한 인스타그램은 반응형 레이아웃을 위한 고정 해상도를 사용하기 때문에, width와 height 값은 전역으로 사용해야합니다.

[example preview="inline" playground="true" imports="amp-instagram:0.1"]
```html
<amp-instagram data-shortcode="fBwFP"
width="320"
height="392"
layout="responsive">
</amp-instagram>
```
[/example]

도움말: [AMP By Example],[`amp-instagram`](../../../../documentation/examples/documentation/amp-instagram.html).url.path}}) 예시를 확인하세요.

## 페이스북 포스트나 비디오 보여주기

페이지에서 페이스북 포스트나 비디오를 보여줄 때는 [`amp-facebook`](../../../../documentation/components/reference/amp-facebook.md) 요소를 사용합니다.

아래 스크립트를 `<head>` 안에 추가해야합니다:

[sourcecode:html]
<script async custom-element="amp-facebook"
src="https://cdn.ampproject.org/v0/amp-facebook-0.1.js"></script>
[/sourcecode]

##### 예시 - 포스트 가져오기

출처:

```html
<amp-facebook width="486" height="657"
layout="responsive"
data-href="https://www.facebook.com/zuck/posts/10102593740125791">
</amp-facebook>
```

시사: <amp-facebook width="486" height="657" layout="responsive" data-href="https://www.facebook.com/zuck/posts/10102593740125791"> </amp-facebook>

##### 예시 - 비디오 가져오기

출처:

```html
<amp-facebook width="476" height="316"
layout="responsive"
data-embed-as="video"
data-href="https://www.facebook.com/nasaearth/videos/10155187938052139">
</amp-facebook>
```

시사: <amp-facebook width="476" height="316" layout="responsive" data-embed-as="video" data-href="https://www.facebook.com/nasaearth/videos/10155187938052139"> </amp-facebook>

도움말: [AMP By Example],[`amp-facebook`](../../../../documentation/examples/documentation/amp-facebook.html).url.path}}) 예시를 확인하세요.

## 유튜브 비디오 가져오기

페이지에 유튜브 비디오를 가져올 때는 [`amp-youtube`](../../../../documentation/components/reference/amp-youtube.md) 요소를 사용합니다

아래 스크립트를 `<head>` 안에 추가해야합니다:

[sourcecode:html]
<script async custom-element="amp-youtube"
src="https://cdn.ampproject.org/v0/amp-youtube-0.1.js"></script>
[/sourcecode]

유튜브 `data-videoid` 속성은 유튜브 비디오 페이지 URL을 찾게 해줍니다. 예를 들어, https://www.youtube.com/watch?v=Z1q71gFeRqM 에서 Z1q71gFeRqM가 video id입니다.

16:9 해상도 비디오의 정확한 레이아웃을 위해 `layout="responsive"`를 사용하길 바랍니다:

[example preview="inline" playground="true" imports="amp-youtube:0.1"]
```html
<amp-youtube data-videoid="lBTCB7yLs8Y"
layout="responsive"
width="560"
height="315">
</amp-youtube>
```
[/example]

도움말: [AMP By Example],[`amp-youtube`](../../../../documentation/examples/documentation/amp-youtube.html).url.path}}) 예시를 확인하세요.

## 광고 보여주기

페이지에서 광고를 보여줄 때는 [`amp-ad`](../../../../documentation/components/reference/amp-ad.md) 요소를 사용합니다. HTTPS로 제공한 광고만 지원합니다.

AMP 문서 내에서 자바스크립트로 제공하는 광고 네트워크는 허용하지 않습니다. 대신해 AMP 런타임은 다른 오리진(iframe sandbox)으로부터 iframe을 불러오며 해당 iframe sandbox 내에서 광고 네트워크 JS를 실행합니다.

광고에 반드시 width, height, 광고 네트워크 타입을 정의해야합니다. `type` 식별자는 광고 네트워크의 템플릿입니다. 다른 광고 타입은 다른 `data-*` 속성을 필요로 합니다.

[example preview="inline" playground="true" imports="amp-ad:0.1"]
```html
<amp-ad width="300"
height="250"
type="a9"
data-amzn_assoc_ad_mode="auto"
data-divid="amzn-assoc-ad-fe746097-f142-4f8d-8dfb-45ec747632e5"
data-recomtype="async"
data-adinstanceid="fe746097-f142-4f8d-8dfb-45ec747632e5">
</amp-ad>
```
[/example]

만약 광고 네트워크가 지원한다면, `placeholder`를 넣어서 광고가 불가한 경우에 보여줄 수 있습니다:

[example preview="inline" playground="true" imports="amp-ad:0.1"]
```html
<amp-ad width="300"
height="250"
type="a9"
data-amzn_assoc_ad_mode="auto"
data-divid="amzn-assoc-ad-fe746097-f142-4f8d-8dfb-45ec747632e5"
data-recomtype="async"
data-adinstanceid="fe746097-f142-4f8d-8dfb-45ec747632e5">
<div placeholder>Have a great day!</div>
</amp-ad>
```
[/example]

AMP는 광범위한 광고 네트워크를 지원합니다. [reference for a full list](../../../../documentation/components/reference/amp-ad.md#supported-ad-networks)를 참고하시길 바랍니다.

읽어보기: [AMP에 광고 게재](../../../../documentation/guides-and-tutorials/develop/monetization/index.md) 가이드에서 광고에 관해 자세히 알아보세요.
4 changes: 2 additions & 2 deletions pixi/backend/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ const cheerio = require('cheerio');
const log = require('@lib/utils/log')('Pixi API');
const fetch = require('node-fetch');
const RateLimitedFetch = require('@lib/utils/rateLimitedFetch');
const GA_TRACKING_ID =
require('../../platform/config/shared.json').gaTrackingId;
const GA_TRACKING_ID = require('../../platform/config/shared.json')
.gaTrackingId;
const {API_ENDPOINT_TOOLBOX_PAGE_EXPERIENCE} = require('../config').production;

const rateLimitedFetch = new RateLimitedFetch({
Expand Down
18 changes: 11 additions & 7 deletions pixi/src/Cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,17 @@ export default class PageExperienceCli {

const recommendations = await recommendationsPromise;

const [{pageExperience}, linter, mobileFriendliness, safeBrowsing] =
await Promise.all([
pageExperiencePromise,
linterPromise,
mobileFriendlinessPromise,
safeBrowsingPromise,
]);
const [
{pageExperience},
linter,
mobileFriendliness,
safeBrowsing,
] = await Promise.all([
pageExperiencePromise,
linterPromise,
mobileFriendlinessPromise,
safeBrowsingPromise,
]);

const hasPageExperience = pageExperience !== undefined;
const hasFieldData =
Expand Down
3 changes: 1 addition & 2 deletions pixi/src/ui/InputBar.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@
import i18n from './I18n.js';

/* eslint-disable max-len */
const URL_VALIDATION_REGEX =
/^(?:https?:\/\/)?[\w.-]+(?:\.[\w.-]+)+[\w._~:/?#\[\]@!$%&'()*+,;=-]+$/gm;
const URL_VALIDATION_REGEX = /^(?:https?:\/\/)?[\w.-]+(?:\.[\w.-]+)+[\w._~:/?#\[\]@!$%&'()*+,;=-]+$/gm;

export default class InputBar {
constructor(doc, callback) {
Expand Down
18 changes: 11 additions & 7 deletions pixi/src/utils/issueUrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,17 @@ export default async function getIssueUrl(
mobileFriendlinessPromise,
safeBrowsingPromise
) {
const [{pageExperience}, linter, mobileFriendliness, safeBrowsing] =
await Promise.all([
pageExperiencePromise,
linterPromise,
mobileFriendlinessPromise,
safeBrowsingPromise,
]);
const [
{pageExperience},
linter,
mobileFriendliness,
safeBrowsing,
] = await Promise.all([
pageExperiencePromise,
linterPromise,
mobileFriendlinessPromise,
safeBrowsingPromise,
]);
const hasPageExperience = pageExperience !== undefined;
const hasFieldData =
hasPageExperience && pageExperience.source === 'fieldData';
Expand Down
3 changes: 1 addition & 2 deletions platform/lib/common/samples.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@ const EXAMPLE_SITEMAP_PATH = path.join(
project.paths.STATICS_DEST,
'/samples/samples.json'
);
const EXAMPLE_COMPONENT_PATTERN =
/^(?:https?:\/\/[^/]+)?(?:\/[^/]+)?\/documentation\/examples\/components\/(amp-[^/]+)\/?/;
const EXAMPLE_COMPONENT_PATTERN = /^(?:https?:\/\/[^/]+)?(?:\/[^/]+)?\/documentation\/examples\/components\/(amp-[^/]+)\/?/;

function getExamplePreviewUrl(exampleUrl) {
let path = url.parse(exampleUrl).pathname;
Expand Down
6 changes: 2 additions & 4 deletions platform/lib/format-transform/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,14 +107,12 @@ describe('formatTransform', () => {
});

it('removes @formats', () => {
const input =
s(`<html ⚡><head><style amp-custom>body{color:red}</style></head>
const input = s(`<html ⚡><head><style amp-custom>body{color:red}</style></head>
<!-- comment @formats(websites) -->
<body>
</body>
</html>`);
const want =
s(`<html ⚡><head><style amp-custom>body{color:red}</style></head>
const want = s(`<html ⚡><head><style amp-custom>body{color:red}</style></head>
<!-- comment -->
<body>
</body>
Expand Down
12 changes: 4 additions & 8 deletions platform/lib/pipeline/markdownDocument.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,10 @@ const SlugGenerator = require('@lib/utils/slugGenerator');
const TOC_MARKER = '[TOC]';

// This expression matches a {% raw %}...{% endraw %} block
const JINJA2_RAW_BLOCK =
/\{%\s*raw\s*%\}(?:(?!\{%\s*endraw\s*%\})[\s\S])*\{%\s*endraw\s*%\}/;
const JINJA2_RAW_BLOCK = /\{%\s*raw\s*%\}(?:(?!\{%\s*endraw\s*%\})[\s\S])*\{%\s*endraw\s*%\}/;

// This expression matches source code blocks. fenced blocks are converted to this syntax
const SOURCECODE_BLOCK =
/\[\s*sourcecode[^\]]*\][\s\S]*?\[\s*\/\s*sourcecode\s*\]/;
const SOURCECODE_BLOCK = /\[\s*sourcecode[^\]]*\][\s\S]*?\[\s*\/\s*sourcecode\s*\]/;

// we search for ALL code blocks, and at the same time for raw blocks
// to ensure we do not match something that belongs to different code blocks
Expand Down Expand Up @@ -76,8 +74,7 @@ const RELATIVE_LINK_PATTERN = new RegExp(
);

// This pattern will find the text for markdown titles skipping explicit anchors.
const TITLE_ANCHOR_PATTERN =
/^(#+)[ \t]+(.*?)(<a[ \t]+name=[^>]*><\/a>)?((?:.(?!<a[ \t]+name))*?)$/gm;
const TITLE_ANCHOR_PATTERN = /^(#+)[ \t]+(.*?)(<a[ \t]+name=[^>]*><\/a>)?((?:.(?!<a[ \t]+name))*?)$/gm;

// Matches a block of frontmatter delimited by ---
const FRONTMATTER_PATTERN = /^---\r?\n.*\r?\n---\r?\n/ms;
Expand Down Expand Up @@ -330,8 +327,7 @@ class MarkdownDocument {
* @return {String} The rewritten input
*/
static rewriteCalloutToTip(contents) {
const CALLOUT_PATTERN =
/{% call callout\('.*?', type='(.*?)'\) %}(.*?){% endcall %}/gs;
const CALLOUT_PATTERN = /{% call callout\('.*?', type='(.*?)'\) %}(.*?){% endcall %}/gs;
const AVAILABLE_CALLOUT_TYPES = {
'note': 'note',
'read': 'read-on',
Expand Down
3 changes: 1 addition & 2 deletions platform/lib/routers/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@ const RESPONSE_MAX_AGE = {
autosuggest: 86400, // 24 hours
};

const COMPONENT_REFERENCE_DOC_PATTERN =
/^(?:https?:\/\/[^/]+)?(?:\/[^/]+)?\/documentation\/components\/(amp-[^/]+)/;
const COMPONENT_REFERENCE_DOC_PATTERN = /^(?:https?:\/\/[^/]+)?(?:\/[^/]+)?\/documentation\/components\/(amp-[^/]+)/;

// use the twitter title if available since it does not contain the site name
const TITLE_META_TAG = 'twitter:title';
Expand Down
3 changes: 1 addition & 2 deletions platform/lib/samples/CodeSection.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@ renderer.paragraph = function (text) {
return '<p class="mb2 px1">' + text + '</p>';
};

const encodedTemplateRegexp =
/\[\[\s*<.*?>([A-Za-z]*?)\s*(<.*?>)?(\.[A-Za-z]*)?\s*<\/span>\s*\]\]/g;
const encodedTemplateRegexp = /\[\[\s*<.*?>([A-Za-z]*?)\s*(<.*?>)?(\.[A-Za-z]*)?\s*<\/span>\s*\]\]/g;

const hintStartPlaceholder = 'START_HINT';
const hintStartRegexp = new RegExp(
Expand Down
10 changes: 2 additions & 8 deletions platform/lib/samples/DocumentParser.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -161,14 +161,8 @@ describe('DocumentParser', () => {
});

it('marks sections in body', () => {
const sections = parse(
HEAD,
HEAD_END,
BODY,
COMMENT,
TAG,
BODY_END
).sections;
const sections = parse(HEAD, HEAD_END, BODY, COMMENT, TAG, BODY_END)
.sections;
expect(sections[0].inBody).toBe(false);
expect(sections[1].inBody).toBe(true);
});
Expand Down
5 changes: 3 additions & 2 deletions platform/lib/tools/componentReferenceLinker.js
Original file line number Diff line number Diff line change
Expand Up @@ -224,8 +224,9 @@ class ComponentReferenceLinker {
_createTablePlaceholder(component) {
const placeholder = `<!--${this._hash(component)}-->`;
if (!this._tablePlaceholders[placeholder]) {
this._tablePlaceholders[placeholder] =
this._tableComponentPath(component);
this._tablePlaceholders[placeholder] = this._tableComponentPath(
component
);
}
return placeholder;
}
Expand Down
3 changes: 1 addition & 2 deletions platform/lib/tools/growReferenceChecker.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,7 @@ const LOOKUP_TABLE = {
};
/* eslint-enable max-len */
// The following paths are skipped when checked for existance
const IGNORED_PATH_PATTERNS =
/\/content\/amp-dev\/documentation\/components\/reference\/.*?|\/boilerplate|\/content\/amp-dev\/community\/working-groups\/.*?/g;
const IGNORED_PATH_PATTERNS = /\/content\/amp-dev\/documentation\/components\/reference\/.*?|\/boilerplate|\/content\/amp-dev\/community\/working-groups\/.*?/g;

// The list of imported docs. Here we do not check anchors.
const IMPORTED_DOCS = require(__dirname +
Expand Down
Loading

0 comments on commit 920b7b3

Please sign in to comment.