-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Replace the URL template with a dictionary. #40
Conversation
index.html
Outdated
"params": { | ||
"title": "title", | ||
"text": "text", | ||
"url": "url" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe a minor thing, but as I was reading through this. I always find it helpful when examples differentiate constants vs variables that I can change. For instance here I have to read on to know if I change keys or values. Better might be to use a contrived example. Keeping in mind I'm no better at naming:
"title": "new_story_headline",
"text": "new_story_body",
"url": "new_story_link_url"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have changed the names.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for doing this. I have a bunch of comments (and in general, I think there is stuff removed that needs to stay, or be updated rather than deleted).
index.html
Outdated
the directory containing the manifest URL. | ||
The <a data-link-for="params">params</a> contain the names for a number | ||
of form fields that will be populated with the shared data when | ||
the target is <a>invoked</a> with a GET request. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Say that: The keys correspond to the key names in ShareData, while the values are arbitrary names that will be used as query parameters when the target is launched.
index.html
Outdated
</p> | ||
<p> | ||
When a share takes place, if the user selects this app as the share | ||
target, the user agent creates a form submission, and |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure we want it to exactly be a form submission (that has a number of bad quirks, like encoding). Let's say "like a form submission".
index.html
Outdated
window or tab and navigate to: | ||
</p> | ||
<pre> | ||
https://example.org/includinator/share.html?title=My%20News&text=&url=http%3A%2F%2Fexample.com%2Fnews |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would like to keep this example "finished" URL, to show that it just makes a GET request to a particular URL. Can you work that in?
index.html
Outdated
<p> | ||
When a share takes place, if the user selects this app as the share | ||
target, the user agent creates a form submission, and | ||
opens a new browsing context at the action URL. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
<code>action</code>
index.html
Outdated
}; | ||
|
||
partial dictionary WebAppManifest { | ||
ShareTarget share_target; | ||
}; | ||
</pre> | ||
<p> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this (and the below steps for post-processing the share_target) gone? It needs to be updated for the new format.
There are still some things that need to be performed / validated:
action
must be parsed and resolved against manifest URL.- (If the parsing is failure, the share target is invalid.)
action
must be within scope of scope URL.method
must be"GET"
.
That's all I can think of off the top of my head.
index.html
Outdated
"!WebShare#dom-sharedata"><code>ShareData</code></a> dictionary. | ||
After these placeholders are removed, it MUST form a <a data-cite= | ||
The <dfn>action</dfn> member specifies the URL for the web share | ||
target. It MUST be a <a data-cite= |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's actually wrong (and was originally) to say this MUST be a valid URL string.
"Valid URL string" refers to a 100% correct URL that would not trigger any validation error in the URL parser, which is way stricter than anything else is on the web. (Essentially, nothing ever requires a valid URL string, rather, URLs are run through the URL Parser and it is required to not fail.)
Just delete this sentence, and we will perform parsing in the pre-processing steps above.
(I realised that Web Share is also erroneous to say "Valid URL string" on its url
field, and have sent out a PR: w3c/web-share#76.)
index.html
Outdated
members. | ||
</p> | ||
<p> | ||
The <dfn>title</dfn> member specifies the name of the form field |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are fairly non-descript. We could perhaps use the same terminology as Web Share:
text
member- Arbitrary text that forms the body of the message being shared.
title
member- The title of the document being shared. May be ignored by the target.
url
member- A URL string referring to a resource being shared.
Or maybe literally link to Web Share's ShareData
dictionary, since these should always be kept up-to-date?
index.html
Outdated
dictionary ShareTarget { | ||
required USVString url_template; | ||
required USVString action; | ||
required ShareTargetParams params; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should have "method" here, for future-proofing.
I think we should have optional DOMString method = "GET"
, with processing steps that say its value MUST be "GET". Essentially, everyone can ignore it, BUT if it's anything other than "GET", the whole share target is ignored.
This way, if a site from the future says "method: POST", current browsers will ignore it instead of erroneously delivering a GET request.
<p> | ||
Any fields that are not present in the <a>url_template</a> will be |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This paragraph is still relevant.
index.html
Outdated
@@ -435,153 +355,6 @@ <h3> | |||
"!WebShare#dom-sharedata-url"><code>url</code></a> field. | |||
</p> | |||
</section> | |||
<section data-link-for="WebAppManifest"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This section needs to be rewritten (not deleted).
You should be able to delete the replace placeholders algorithm, and then update this to construct the URL from the action
and data.
An interesting question will be whether the query should be encoded with the application/x-www-form-urlencoded
scheme, or the new default encode set which I am currently working on adding to the URL standard (whatwg/url#369).
- The former:
- Is compatible with how HTML forms work. It uses arbitary encoding (though probably we'd lock it to UTF-8), encodes space as '
+
', and leaves-._*
un-encoded. - You would just call the application/x-www-form-urlencoded serializer.
- Is compatible with how HTML forms work. It uses arbitary encoding (though probably we'd lock it to UTF-8), encodes space as '
- The latter:
- Is compatible with how modern encoders work, like
encodeURIComponent
in JS. It uses UTF-8, encodes space as "%20
", and leaves-_.!~*'()
un-encoded. - It's compatible with how
registerProtocolHandler
works in practice (though it is not specified correctly; see Need an "unreserved" character set (and better define how to percent-encode arbitrary strings) whatwg/url#369). - This is how I currently define encoding in Web Share Target (see the bit at the bottom of replace placeholders).
- Is compatible with how modern encoders work, like
We should discuss this, and raise it at TAG review. The most important thing is whether space as '+' is commonly accepted by web servers. As far as I know, this is only used by HTML forms, and may not be expected by endpoints that are not form submission targets.
The new spec text for Launching the web share target is based on https://html.spec.whatwg.org/#concept-form-submit
index.html
Outdated
parameters when the target is launched. | ||
</p> | ||
<p> | ||
When a share takes place, if the user selects this app as the share |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Delete "app as the". We don't refer to share targets as apps (since the may not necessarily correspond to an app).
(I know this was in the previous text, but #whileyourehere.)
index.html
Outdated
</p> | ||
<p> | ||
When a share takes place, if the user selects this app as the share | ||
target, the user agent creates a GET request like a form submission, and |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a bit of a weird way to describe it, since opening the new browsing context is what creates the GET request. (It doesn't "create a GET request, then open a browsing context".)
How about, "opens a new browsing context at the action
URL, with query parameter values containing the shared data, just like an HTML form submission"?
index.html
Outdated
<li>If <var>URL template string</var> is <code>undefined</code>, | ||
<li>If <var>share | ||
target["<a href="#dom-sharetarget-method">method</a>"]</var> is not an | ||
ASCII case-insensitive match for the string <code>"GET"</code>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Link to https://infra.spec.whatwg.org/#ascii-case-insensitive
Note: Use the data-cite, not href. So this probably should look like:
<a data-cite="!INFRA#ascii-case-insensitive">
index.html
Outdated
"!URL#concept-url-fragment">fragment</a> parts of the URL template. | ||
Once the fields are replaced, it should be a URL that is relative to | ||
the directory containing the manifest URL. | ||
The <a href="#dom-sharetarget-params">params</a> keys correspond to the key |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Try to avoid using href, in favour of ReSpec's semantic linking options (use the existing code as a reference).
I think this should be:
<a data-link-for="ShareTarget">params</a>
(The current source file almost never uses "href", other than links to GitHub issues, and external sites, and I'd like to keep it that way.)
index.html
Outdated
Once the fields are replaced, it should be a URL that is relative to | ||
the directory containing the manifest URL. | ||
The <a href="#dom-sharetarget-params">params</a> keys correspond to the key | ||
names in <a href="https://wicg.github.io/web-share/#sharedata-dictionary">ShareData</a>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
<a data-cite="!WebShare#dom-sharedata">ShareData</a>
(Note: The "!" prefix makes it a normative reference; without a "!" it's informative. This is used to generate the bibliography at the bottom.)
Also, add "from [[!WebShare]]" (after "ShareData") since you are referring to a different spec.
index.html
Outdated
"url"</code>, | ||
<ul> | ||
<li> | ||
Let <var>name</var> be the value of <var>manifest[" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Deal with missing member from params.
index.html
Outdated
steps</a> on <var>final URL</var>, with empty <var>target</var> and | ||
empty <var>features</var>. | ||
<li> | ||
Let entry list be a new empty list of <a href= |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
<var>entry list</var>
index.html
Outdated
empty <var>features</var>. | ||
<li> | ||
Let entry list be a new empty list of <a href= | ||
"https://xhr.spec.whatwg.org/#concept-formdata-entry">entries</a>. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think it's worth referencing the XHR spec, given that the only thing that uses entry list is the application/x-www-form-urlencoded
serializer, which doesn't take a list of XHR entries, it takes a "list of name-value tuples".
So just say "Let entry list be a new empty list of name-value tuples."
index.html
Outdated
<li>If <var>template</var> contains U+007D (<code>}</code>), return | ||
failure (unmatched closing brace). | ||
<li> | ||
Set <var>parsed action</var>'s query component to <var>query</var>. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
index.html
Outdated
<li>If <var>end</var> < <var>start</var>, return failure | ||
(unmatched closing brace). | ||
<li> | ||
<a href="https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#append-an-entry"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't like the look of that "append an entry" algorithm. It mangles the data in ways that make sense for legacy form data processing, but doesn't properly preserve newlines, etc. Let's avoid using it.
If you want to link "append", just link here: https://infra.spec.whatwg.org/#list-append
Hmm, pr-preview hasn't updated to a76ba15. Maybe posting a comment will nudge it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm with a few formatting nits.
index.html
Outdated
<li>Let <var>parsed action</var> be the resulting URL record. | ||
<li>Let <var>action</var> be the result of | ||
<a data-cite="!URL#concept-url-parser">parsing</a> the | ||
<a data-cite="!URL#concept-url">URL</a> <var>share |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The closing </var>
should close at the end of "target", and not at the end of the bracket. Same applies later down below.
index.html
Outdated
<li> | ||
Let <var>parsed action</var> be the resulting URL record. | ||
Let <var>action</var> be <var>manifest["<a>share_target</a>"]["<a | ||
data-link-for="ShareTarget">action</a>"]</var>. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here (</var>
). I see this is actually already widespread in the doc, but I'll clean those up separately.
Replace <var>data[member]</var> with [200~<var>data</var>[<var>member</var>]. String literals such as "action" are not encoded in <var>
fixed |
Preview | Diff