indieweb / micropub-extensions

Issue tracking for Micropub extensions
https://indieweb.org/Micropub-extensions
10 stars 0 forks source link

Query for supported properties, for a supported post-type #33

Open jamietanna opened 4 years ago

jamietanna commented 4 years ago

As per my comment on #1, I would like an extension to configuration queries that would allow me to discover which properties are supported for a post-type.

My proposal from https://github.com/indieweb/micropub-extensions/issues/1#issuecomment-657046990 is to perform i.e. GET /q=post-types&post-type=note.

This would support Query for Supported Properties syntax, but be specific to the given post-type we want to interrogate.

jamietanna commented 4 years ago

Or as suggested by @manton off the back of this https://github.com/indieweb/micropub-extensions/issues/8#issuecomment-658813605

manton commented 4 years ago

I've implemented a version of this in Micro.blog to see how it would look. It returns the supported properties directly from q=config without needing any extra requests. My initial implementation looks like this, although it's probably missing some properties.

{
  "media-endpoint": "https://micro.blog/micropub/media",
  "destination": [
    {
      "uid": "https://manton.micro.blog/",
      "name": "www.manton.org"
    }
  ],
  "post-types": [
    {
      "type": "note",
      "name": "Post",
      "properties": [ "content", "published", "post-status", "category", "read-of", "mp-destination", "checkin", "location" ]
    },
    {
      "type": "article",
      "name": "Article",
      "properties": [ "name", "content", "published", "post-status", "category", "mp-channel", "mp-destination" ]
    },
    {
      "type": "photo",
      "name": "Photo",
      "properties": [ "name", "content", "published", "post-status", "category", "mp-destination", "photo", "mp-photo-alt" ]
    },
    {
      "type": "reply",
      "name": "Reply",
      "properties": [ "content", "in-reply-to" ]
    },
    {
      "type": "bookmark",
      "name": "Favorite",
      "properties": [ "bookmark-of" ]
    }
  ],
  "channels": [
    {
      "uid": "default",
      "name": "Posts"
    },
    {
      "uid": "pages",
      "name": "Pages"
    }
  ]
}
jamietanna commented 4 years ago

Looks good, @manton. I'm wondering about making some distinction between required/optional properties, as I'll have different handling for them internally, and it may be good for the client to be able to provide some feedback to the user if they're not provided. What do you think?

manton commented 4 years ago

Personally I'm having trouble seeing where required properties would be needed. As an example, technically name is required for an article, but if someone leaves it blank, it doesn't really matter. If a client really does need the concept of required properties, maybe that logic should be baked into the client instead of generalized for all servers.

jamietanna commented 4 years ago

I have implemented this, and have added the required-properties key to provide a hint to a client which of these should be validated:

{
    "syndicate-to": [
    ...
    ],
    "media-endpoint": "https://www-api.jvt.me/micropub/media",
    "q": [
        "post-types",
    ...
    ],
    "post-types": [
        {
            "type": "bookmark",
            "name": "Bookmark",
            "properties": [
                "bookmark-of",
                "name",
                "published",
                "category",
                "content",
                "syndication"
            ],
            "required-properties": [
                "bookmark-of",
                "name",
                "published"
            ]
        },
        {
            "type": "like",
            "name": "Like",
            "properties": [
                "like-of",
                "published",
                "category",
                "content",
                "name",
                "syndication"
            ],
            "required-properties": [
                "like-of",
                "published"
            ]
        },
        {
            "type": "reply",
            "name": "Reply",
            "properties": [
                "content",
                "in-reply-to",
                "published",
                "category",
                "name",
                "photo",
                "syndication"
            ],
            "required-properties": [
                "content",
                "in-reply-to",
                "published"
            ]
        },
        {
            "type": "repost",
            "name": "Repost",
            "properties": [
                "published",
                "repost-of",
                "content",
                "category",
                "syndication"
            ],
            "required-properties": [
                "published",
                "repost-of"
            ]
        },
        {
            "type": "rsvp",
            "name": "RSVP",
            "properties": [
                "in-reply-to",
                "published",
                "rsvp",
                "category",
                "content",
                "syndication"
            ],
            "required-properties": [
                "in-reply-to",
                "published",
                "rsvp"
            ]
        },
        {
            "type": "note",
            "name": "Note",
            "properties": [
                "content",
                "published",
                "category",
                "syndication"
            ],
            "required-properties": [
                "content",
                "published"
            ]
        },
        {
            "type": "photo",
            "name": "Photo",
            "properties": [
                "photo",
                "published",
                "category",
                "content",
                "syndication"
            ],
            "required-properties": [
                "photo",
                "published"
            ]
        },
        {
            "type": "step",
            "name": "Step Counts",
            "properties": [
                "unit",
                "num",
                "start",
                "end"
            ],
            "required-properties": [
                "unit",
                "num",
                "start",
                "end"
            ]
        },
        {
            "type": "event",
            "name": "Event",
            "properties": [
                "end",
                "name",
                "published",
                "start",
                "content",
                "url"
            ],
            "required-properties": [
                "end",
                "name",
                "published",
                "start"
            ]
        },
        {
            "type": "contact",
            "name": "Contact",
            "properties": [
                "name",
                "nickname",
                "url",
                "rel=twitter"
            ],
            "required-properties": [
                "name",
                "nickname",
                "url"
            ]
        }
    ]
}
jamietanna commented 4 years ago

I have updated my implementation to also expose an h property:

    {
      "type": "bookmark",
      "name": "Bookmark",
      "h": "entry",
      "properties": [
        "bookmark-of",
        "name",
        "published",
        "category",
        "content",
        "syndication"
      ],
      "required-properties": [
        "bookmark-of",
        "name",
        "published"
      ]
    }
barryf commented 4 years ago

@jamietanna I'm working on supporting this with Micropublish, including required-properties.

In your example above I wanted to query how you treat syndication. I have syndication and mp-syndicate-to as separate properties. When creating a post I don't want to specify syndication URLs, but I do want to choose targets via mp-syndicate-to. Does your syndication property refer to both use cases?

jamietanna commented 4 years ago

That's a good point - it's not one I'd considered. It's also uncovered a bug (or maybe a feature 🤷🏽‍♂️) where sending syndication does not get sanitised like mp-syndicate-to

(Originally published at: https://www.jvt.me/mf2/2020/10/lqei3/)

manton commented 2 years ago

Just reviewing this, it seems like it is close to being considered a stable extension. Maybe there aren't 3 clients yet, though?

jalcine commented 2 years ago

Hm, not yet. My website works as a Micropub client but I don't know if that actually counts here.