Skip to content
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

Merged
merged 6 commits into from
Jun 27, 2018

Conversation

ewilligers
Copy link
Collaborator

@ewilligers ewilligers commented Jun 4, 2018

index.html Outdated
"params": {
"title": "title",
"text": "text",
"url": "url"
Copy link

@comp615 comp615 Jun 4, 2018

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"

Copy link
Collaborator Author

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.

Copy link
Collaborator

@mgiuca mgiuca left a 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.
Copy link
Collaborator

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
Copy link
Collaborator

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&amp;text=&amp;url=http%3A%2F%2Fexample.com%2Fnews
Copy link
Collaborator

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.
Copy link
Collaborator

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>
Copy link
Collaborator

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=
Copy link
Collaborator

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
Copy link
Collaborator

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;
Copy link
Collaborator

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
Copy link
Collaborator

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">
Copy link
Collaborator

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).

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.

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
Copy link
Collaborator

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
Copy link
Collaborator

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>,
Copy link
Collaborator

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
Copy link
Collaborator

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>,
Copy link
Collaborator

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["
Copy link
Collaborator

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=
Copy link
Collaborator

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>.
Copy link
Collaborator

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>.
Copy link
Collaborator

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> &lt; <var>start</var>, return failure
(unmatched closing brace).
<li>
<a href="https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#append-an-entry">
Copy link
Collaborator

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

@mgiuca
Copy link
Collaborator

mgiuca commented Jun 27, 2018

Hmm, pr-preview hasn't updated to a76ba15.

Maybe posting a comment will nudge it.

Copy link
Collaborator

@mgiuca mgiuca left a 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
Copy link
Collaborator

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>.
Copy link
Collaborator

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>
@ewilligers
Copy link
Collaborator Author

The closing </var> should close at the end of "target", and not at the end of the bracket.

fixed

@ewilligers ewilligers merged commit d556237 into w3c:master Jun 27, 2018
@ewilligers ewilligers deleted the ShareTargetParams branch June 27, 2018 03:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants