|
1 | 1 | --- |
2 | 2 | title:Monetization <link> element |
3 | | -tableOfContents: |
4 | | -maxHeadingLevel:4 |
5 | 3 | --- |
6 | 4 |
|
7 | | -import {LinkOut,Hidden }from'@interledger/docs-design-system' |
| 5 | +import {Badge }from'@astrojs/starlight/components' |
| 6 | +importOverviewfrom"/src/partials/link-element-overview.mdx"; |
| 7 | +importPrereqsfrom"/src/partials/link-element-prereqs.mdx"; |
| 8 | +importSyntaxfrom"/src/partials/link-element-syntax.mdx"; |
| 9 | +importPlacementfrom"/src/partials/link-element-placement.mdx"; |
| 10 | +importMultiLinkfrom"/src/partials/link-element-multilink.mdx"; |
| 11 | +importIframesfrom"/src/partials/link-element-iframes.mdx"; |
| 12 | +importMediafrom"/src/partials/link-element-media.mdx"; |
| 13 | +importHowHtmlfrom"/src/partials/link-element-how-html.mdx"; |
| 14 | +importHowRelfrom"/src/partials/link-element-how-rel.mdx"; |
| 15 | +importHowAgentfrom"/src/partials/link-element-how-agent.mdx"; |
8 | 16 | importSpecificationfrom'/src/components/docs/Specification.astro' |
9 | | -importBrowserCompatfrom'/src/components/docs/BrowserCompat.astro' |
10 | | -importdatafrom'/src/data/browser-compat-data/link.json' |
11 | | -import {Steps,Tabs,TabItem,Badge }from'@astrojs/starlight/components' |
12 | 17 |
|
13 | 18 | <Badgetext='HTML DOM API'style='position: relative; top:-30px;' /> |
14 | 19 |
|
15 | | -From a creator/developer perspective, the monetization`<link>` element is one of the two key pieces to web monetizing a page. The second piece is a wallet address/payment pointer. |
| 20 | +<Overview /> |
16 | 21 |
|
17 | 22 | ##Prerequisites |
18 | 23 |
|
19 | | -To web monetize an HTML page: |
20 | | - |
21 | | -- You must have an account with a[compatible wallet provider](/wallets) |
22 | | -- You must have the wallet address, or payment pointer in <LinkOuthref="https://paymentpointers.org">URL format</LinkOut>, from your wallet provider |
23 | | -- Your document must be served over HTTPS |
| 24 | +<Prereqs /> |
24 | 25 |
|
25 | 26 | ##Monetization`<link>` element |
26 | 27 |
|
27 | | -The monetization`<link>` element is what indicates your HTML page supports Web Monetization. |
28 | | - |
29 | 28 | ###Syntax |
30 | 29 |
|
31 | | -```html |
32 | | -<linkrel="monetization"href="https://(paymentUrl)" /> |
33 | | -``` |
34 | | - |
35 | | -- The`rel` attribute is always`monetization` |
36 | | -- The`href` attribute equals your wallet address or your payment pointer in URL format |
37 | | - |
38 | | -For example: |
39 | | - |
40 | | -```html |
41 | | -<linkrel="monetization"href="https://wallet.example.com/alice" /> |
42 | | -``` |
| 30 | +<Syntax /> |
43 | 31 |
|
44 | 32 | ###Placement |
45 | 33 |
|
46 | | -A monetization`<link>` is`body-ok`, meaning it's allowed in your page's`<head>` and/or`<body>`. |
| 34 | +<Placement /> |
47 | 35 |
|
48 | 36 | ###Multiple monetization links |
49 | 37 |
|
50 | | -An HTML page can contain multiple monetization`<link>` elements; however, your site visitor’s[Web Monetization agent](#web-monetization-agent) could be designed to handle multiple links in a particular way. For example, an agent might: |
51 | | - |
52 | | -- Split payments evenly between all links |
53 | | -- Split payments between the first few links it finds |
54 | | -- Send the amount only to the first link it finds and ignore all others |
55 | | - |
56 | | -:::tip[Recommendation] |
57 | | -The Web Monetization agent built into the <LinkOuthref="https://github.com/interledger/web-monetization-extension">Interledger Foundation's extension</LinkOut> splits payments evenly between all links. We recommend other extension developers follow this approach. |
58 | | -::: |
| 38 | +<MultiLink /> |
59 | 39 |
|
60 | 40 | ###Iframes |
61 | 41 |
|
62 | | -Nested browsing contexts (iframes) can contain monetization`<link>` elements; however, your site visitor's[Web Monetization agent](#web-monetization-agent) determines how iframes are monetized. A few examples of how a Web Monetization agent can monetize iframes include: |
63 | | - |
64 | | -- Splitting payments evenly between all monetization links within both the parent and the iframe |
65 | | -- Splitting payments evenly between all monetization links in the parent and the first monetization link it finds in the iframe's`<head>`, while ignoring any other monetization links in the iframe |
66 | | - :::note |
67 | | - This is the approach used in the <LinkOuthref="https://github.com/interledger/web-monetization-extension">Interledger Foundation's extension</LinkOut>. |
68 | | - ::: |
69 | | -- Sending payments to the first monetization link it finds in the parent browsing context and ignoring all other monetization links in the parent and the iframe |
| 42 | +<Iframes /> |
70 | 43 |
|
71 | 44 | ###Audio, video, and picture elements |
72 | 45 |
|
73 | | -The following HTML elements can be web monetized by adding the`<link>` element between the open and close tags. |
74 | | - |
75 | | -<Tabs> |
76 | | - <TabItemlabel="<audio>"icon="seti:audio"> |
77 | | -```html |
78 | | - <audiosrc="music.mp3"> |
79 | | - <linkrel="monetization"href="https://wallet.example.com/bob"> |
80 | | - </audio> |
81 | | -``` |
82 | | - </TabItem> |
83 | | - <TabItemlabel="<video>"icon="seti:video"> |
84 | | -```html |
85 | | - <videosrc="myvideo"> |
86 | | - <linkrel="monetization"href="https://wallet.example.com/bob"> |
87 | | - </video> |
88 | | -``` |
89 | | - </TabItem> |
90 | | - <TabItemlabel="<picture>"icon="seti:image"> |
91 | | -```html |
92 | | - <picturesrcset="cat.jpeg"> |
93 | | - <linkrel="monetization"href="https://wallet.example.com/bob"> |
94 | | - </picture> |
95 | | -``` |
96 | | - </TabItem> |
97 | | -</Tabs> |
| 46 | +<Media /> |
98 | 47 |
|
99 | 48 | ##How it works |
100 | 49 |
|
101 | 50 | ###HTMLLinkElement |
102 | | - |
103 | | -The <LinkOuthref="https://developer.mozilla.org/en-US/docs/Web/API/HTML_DOM_API">HTML DOM API's</LinkOut>`HTMLLinkElement` interface defines how the`<link>` element functions. The`<link>` element is what allows you to link your HTML page to a resource. |
104 | | - |
105 | | -The two most recognizable`HTMLLinkElement` properties are`href` and`rel`. The`href` property defines the URL to the resource. The`rel` property indicates the type of link, or relationship, the resource has to the current page. |
| 51 | +<HowHtml /> |
106 | 52 |
|
107 | 53 | ###rel="monetization" link type |
108 | | - |
109 | | -Browsers already know how to interpret certain`rel` values because of web standards. One such standard is`stylesheet`. When a browser loads a page that contains`<link href="styles.css" rel="stylesheet">`, the browser automatically knows to import a style sheet from the given URL. |
110 | | - |
111 | | -The`monetization` link type, however, is not yet a standard. Major web browsers don't automatically know what to do when encountering this link type in a page. Until`monetization` becomes a standard, browsers must rely on a Web Monetization agent. |
| 54 | +<HowRel /> |
112 | 55 |
|
113 | 56 | ###Web Monetization agent |
| 57 | +<HowAgent /> |
114 | 58 |
|
115 | | -A Web Monetization agent is a non-user facing component of the <LinkOuthref="https://github.com/interledger/web-monetization-extension">Interledger Foundation's extension</LinkOut>. |
116 | | - |
117 | | -The purpose of the Web Monetization agent is to recognize when a page is web monetized and automatically carry out certain tasks. These tasks include: |
118 | | - |
119 | | -- Extending the HTML DOM API so that`monetization` is a valid link type |
120 | | -- Processing the monetization link or links within an HTML page |
121 | | -- Instrumenting payments by calling the[Open Payments APIs](/developers/about-receiving#a-deeper-dive-into-payments), which are APIs implemented by wallet providers |
122 | | -- Firing[`monetization`](/developers/events) events after an outgoing payment is created |
123 | | -- Processing`monetization` events sent to the browser window via the`onmonetization` event handler |
124 | | -- Enabling the CSP[`monetization-src`](/developers/csp) and Permissions Policy[`monetization`](/developers/permissions-policy) directives |
125 | | - |
126 | | -Until Web Monetization agents are natively built in to web browsers, an agent must be added to browsers in some other way. That's why the agent is included as part of the Interledger Foundation's extension. |
127 | | - |
128 | | -<Hidden> |
129 | | - |
130 | | -// ## Browser compatibility |
131 | | - |
132 | | -<BrowserCompatjson={data} /> |
133 | | - |
134 | | -</Hidden> |
135 | | - |
136 | | -##Specifications |
| 59 | +##Specification |
137 | 60 |
|
138 | | -<Specificationanchor='link-type-monetization' /> |
| 61 | +<Specificationanchor='link-type-monetization' /> |