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

Add embed entity #101

Merged
merged 2 commits into from Oct 5, 2018
Merged

Conversation

SuperTux88
Copy link
Member

Fixes #93

I did a few changes to the proposal:

  • I renamed link to url.
  • I added a nothing property for when nothing should be embedded and nothing should be scanned. I think this is better to be explicit in this case. When this is true the url property is optional, otherwise it is required.

cc @annando

Copy link

@annando annando left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just some copy&paste stuff. And some clarification would be great if Markdown is allowed in the description.

Additionally I would prefer to mention that the doesn't need to be present in the status message.


| Property | Type (Length) | Description |
| ------------- | ------------------------ | ------------------------------------------------------------------------ |
| `url` | [URL][url] (65535) | A string describing your location, e.g. a city name, a street name, etc. |
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

" A string describing your location"? Looks like some copy&paste ;-)

| Property | Type (Length) | Description |
| ------------- | ------------------------ | ------------------------------------------------------------------------ |
| `url` | [URL][url] (65535) | A string describing your location, e.g. a city name, a street name, etc. |
| `title` | [String][string] (255) | A string describing your location, e.g. a city name, a street name, etc. |
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above

| ------------- | ------------------------ | ------------------------------------------------------------------------ |
| `url` | [URL][url] (65535) | A string describing your location, e.g. a city name, a street name, etc. |
| `title` | [String][string] (255) | A string describing your location, e.g. a city name, a street name, etc. |
| `description` | [String][string] (65535) | The geographical latitude of your location. |
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dito

| `url` | [URL][url] (65535) | A string describing your location, e.g. a city name, a street name, etc. |
| `title` | [String][string] (255) | A string describing your location, e.g. a city name, a street name, etc. |
| `description` | [String][string] (65535) | The geographical latitude of your location. |
| `image` | [URL][url] (65535) | The geographical longitude of your location. |
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and again :-)

| `title` | [String][string] (255) | A string describing your location, e.g. a city name, a street name, etc. |
| `description` | [String][string] (65535) | The geographical latitude of your location. |
| `image` | [URL][url] (65535) | The geographical longitude of your location. |
| `nothing` | [Boolean][boolean] | The geographical longitude of your location. |
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And again ;-)

@SuperTux88
Copy link
Member Author

Oh yes, I forget to change the descriptions m( fixed that now.

Markdown is not allowed, it also wouldn't make any sense, because this is provided by websites for all sorts of use-cases and not only diaspora, so I don't think any website would provide markdown there.

The embed is in the optional section of the status_message entity, I think that is enough to show that it is optional.

@annando
Copy link

annando commented Apr 9, 2018

I would prefer having some "Markdown is not allowed" in the documentation, just to clarify this. And yes, if that hadn't been cleared, I had put it through our HTML to Markdown interpreter, since the fetched description sometimes contain HTML elements. BTW: Is only plaintext allowed or HTML elements?

With "optional" I meant that the "embed" could point to an address that doesn't exist in the status message at all. So you could include the links A, B and C in your post, but the "embed" points to the link "D". This is a little bit nitpicking to mention this, but one does never know how people are interpreting specifications.

@SuperTux88
Copy link
Member Author

Is only plaintext allowed or HTML elements?

Everything is "allowed" (websites can put what they want in that field), but only plaintext is rendered. It has the type String which allows just everything. We have many things that "doesn't allow" markdown, but we don't mention when something doesn't allow markdown, we mention when something explicitly allows Markdown.

With "optional" I meant that the "embed" could point to an address that doesn't exist in the status message at all.

While this is theoretically possible, I wouldn't recommend this so I don't think it is a good idea to mention that. When you link to a url that isn't in the status message at all, not everybody can see it (when not every software supports this entity, or old versions), so maybe people talk about a link in the comments, that not everybody can see. While when you include the link in the message too, some softwares maybe embed the wrong url or embed nothing at all (if they don't support embedding at all), but at least everybody can see all links. So I would always include the link in the message for accessibility reasons.

@SuperTux88
Copy link
Member Author

@annando I added a little paragraph about the second part now, I hope that it's clear know that the link should also be included in the text but doesn't need to match 1:1.

@annando
Copy link

annando commented Apr 9, 2018

I still am confused by:

Everything is "allowed" (websites can put what they want in that field), but only plaintext is rendered.

So how do I force a linefeed in the description? By doing some CR or with
?

@SuperTux88
Copy link
Member Author

SuperTux88 commented Apr 10, 2018

So how do I force a linefeed in the description?

The description is only plain text (see spec), there are no newlines or other formatting.

@SuperTux88
Copy link
Member Author

@annando are there any open points here or can you approve this PR?

Copy link
Member

@cmrd-senya cmrd-senya left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some minor things, otherwise looks good to me!

docs/_entities/embed.md Show resolved Hide resolved

## Optional Properties

All entities are "optional", but either `url` is required or `nothing` must be `true`.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All entities are
These are not entities, these are properties.

Nit: I'm not sure if we need to put "optional" in the quotes here. I think it looks better without quotes.

So it should be:

All properties are optional, but either `url` is required or `nothing` must be `true`.

| `title` | [String][string] (255) | The title of the embedded URL. |
| `description` | [String][string] (65535) | The description of the embedded URL. |
| `image` | [URL][url] (65535) | The image of the embedded URL. |
| `nothing` | [Boolean][boolean] | `true' if nothing should be embedded. |
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are inconsistent quotes around true here

def validate
super

raise ValidationError, "URL set and 'nothing' is 'true'" if url && nothing
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: These two lines can be replaced with one by using xor:

raise ValidationError, "Either URL must be set or 'nothing' must be 'true'" unless nothing ^ url

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, if we refer the properties' names then it is better to write them the same way, i.e. 'url' instead of URL, so that it matches 'nothing' in style. So: Either 'url' must be set or 'nothing' must be 'true'

@SuperTux88 SuperTux88 merged commit 12c1cd8 into diaspora:develop Oct 5, 2018
SuperTux88 added a commit that referenced this pull request Oct 5, 2018
@SuperTux88 SuperTux88 deleted the add-embed-entity branch October 5, 2018 19:48
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.

None yet

3 participants