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

{Proposal] Specify a content type #229

Closed
annando opened this issue Oct 28, 2015 · 8 comments

Comments

Projects
None yet
4 participants
@annando
Copy link

commented Oct 28, 2015

The "content" element is expected to contain structured text (e.g. HTML) and plain text. Without specifying an explicit content type there will be a problem in the detection of the correct type. In plain text a linefeed is important - in HTML it doesn't matter. And there could be situations when a plain text contains something that looks like a HTML element but mustn't be interpreted as those.

So I would suggest that every element that can contain more than plain text must have an element that describes the explicit content type (in the format "text/html", "text/plain", ...)

I would suggest that content always has to be present in one the two formats "text/html" and "text/plain". These two are standardized and easily interpretable.

But: Diaspora internally is working with Markdown, Friendica is using its own interpretation of BBCode. To reduce conversion problems on the transport between same networks I would suggest that there could be an optional and additional content in a free definable content type like maybe "text/markdown" or "application/x-friendica-bbcode".

@jasnell

This comment has been minimized.

Copy link
Collaborator

commented Oct 28, 2015

@annando ... +1, but can you provide a quick example of how you'd like to see it serialized?

@jasnell jasnell added the proposal label Oct 28, 2015

@annando

This comment has been minimized.

Copy link
Author

commented Oct 28, 2015

What do you exactly mean? Do you mean where the content type would be attached to the object?

@jasnell

This comment has been minimized.

Copy link
Collaborator

commented Oct 28, 2015

Yes, sorry. Here's what I had in mind:

{
  "@context": "http://www.w3.org/ns/activitystreams#",
  "@type": "Note",
  "mediaType": "text/plain", 
  "content": "This is the plain text content"
}

When used in an object, the mediaType property would identify the content type of the content object only. Specifically, the summary and title properties would still be limited to HTML and displayName would still be plain text.

@jaywink

This comment has been minimized.

Copy link

commented Oct 28, 2015

must have an element that describes the explicit content type

I find "must" problematic. A simpler solution is what @jasnell proposed on the mailing list - ie allow mediaType and then encourage defaulting to HTML if not given.

@annando

This comment has been minimized.

Copy link
Author

commented Oct 28, 2015

Defaulting to HTML sounds okay for me. I only don't like guessing :-)

The mediaType could be valid for every text property in the current activity. For example:

{
  "@context": "http://www.w3.org/ns/activitystreams",
  "@type": "Add",
  "mediaType": "text/plain",
  "published": "2015-02-10T15:04:55Z",
  "actor": {
   "@type": "Person",
   "@id": "http://www.test.example/martin",
   "displayName": "Martin Smith",
   "url": "http://example.org/martin",
   "image": {
     "@type": "Link",
     "href": "http://example.org/martin/image.jpg",
     "mediaType": "image/jpeg"
   }
  },
  "object" : {
   "@context": "http://www.w3.org/ns/activitystreams",
   "@type": "Note",
   "title": "A simple note",
   "content": "This is a simple note"
  },
  "target" : {
   "@id": "http://example.org/blog/",
   "@type": "OrderedCollection",
   "displayName": "Martin's Blog"
  }

So all displayName, the title and content in the example would be "text/plain". This mixture of having one value interpreted that way and the other one in another way doesn't make sense to me.

But if you wanted to, you could place the mediaTypeinto the object. Then it would be valid for the title and the content but not for the displayName

@jasnell

This comment has been minimized.

Copy link
Collaborator

commented Oct 28, 2015

AS2 currently does not define any kind of inheritance across objects beyond the built in JSON-LD mechanisms. Introducing it now would be problematic. It's better just to have each object define it's own mediaType directly, even if it leads to a little bit of duplication.

displayName is always plain text. It has been since Activity Streams 1.0 for the simple fact that it is used in places that do not support markup in any way. title is the equivalent to displayName but it allows markup.

It's possible that mediaType could apply to title, summary and content but that just feels like overreaching a bit too me. I can live with it tho.

@annando

This comment has been minimized.

Copy link
Author

commented Oct 28, 2015

Okay, then no inheritance. I haven't had that deep look into it at the moment.

I really would like to have a definition for every element that is capable of more than plain text. And title, summary and content are all at the same level of the hierarchy. So a mediaTypeat the same level could easily be valid for all these elements.

@jasnell

This comment has been minimized.

Copy link
Collaborator

commented Nov 3, 2015

WG approved this change

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.