snarfed / granary

💬 The social web translator
https://granary.io
Creative Commons Zero v1.0 Universal
443 stars 57 forks source link

convert between mf2 and form-encoded micropub #27

Open snarfed opened 9 years ago

snarfed commented 9 years ago

inspired by @tantek and @elf-pavlik: http://indiewebcamp.com/irc/2015-03-03#t1425429655537

micropub spec: http://micropub.net

elf-pavlik commented 9 years ago

:+1: once you have it i'll link it from https://www.w3.org/wiki/Socialwg/Social_syntax#Serialization

bcomnes commented 9 years ago

A conceptual example of this: https://github.com/bcomnes/mf2-to-form-urlencoded

It would require some actual logic to clean this up to work as a micropub post request, but this is how serializing would work.

aaronpk commented 9 years ago

What is the purpose of this? I don't understand what it would be used for.

snarfed commented 9 years ago

sounds like @elf-pavlik has a use case where he has AS 2.0 data that he'd like to publish via micropub: http://indiewebcamp.com/irc/2015-03-03#t1425429753753

aaronpk commented 9 years ago

I still don't understand. If he's publishing data, he would be publishing HTML with microformats.

elf-pavlik commented 9 years ago

@aaronpk imagine that my frontend app generates JSON object as in http://www.w3.org/TR/activitystreams-core/#fig-an-object-that-is-both-a-place-and-a-gr-location

{
  "@context": [
    "http://www.w3.org/ns/activitystreams",
    {
      "gr": "http://purl.org/goodrelations/v1#"
    }
  ],
  "@type": ["Place", "gr:Location"],
  "displayName": "Sally's Restaurant",
  "longitude": 12.34,
  "latitude": 56.78,
  "gr:category": "restaurants/french_restaurants"
}

I assume we'll find an algorithmic way to serialize AS2.0 JSON objects to Microformats HTML (otherwise I don't think we should keep Microformats HTML serialization mentioned in the spec!) SocialWG: ACTION-34

In optimistic scenario I'd get

<div class="h-geo">
  <div class="p-name">Sally's Restaurant</div>
  At
  Longitude: <span class="p-longitude">12.34</span>,
  Latitude: <span class="p-latitude">56.78</span>.
  <meta name="category" content="restaurants/french_restaurants" />
</div>

or improved Microformats HTML version Social WG: ACTION-26

Then if I want to post it to Micropub endpoint, which as for today doesn't accept application/json or text/html. I need to serialize it to application/x-www-form-urlencoded

aaronpk commented 9 years ago

If you've already generated the HTML, why would you want to post it to a Micropub endpoint? I am just having a really hard time imagining an actual case when you would want to do this. Feel free to give me an actual use case that demonstrates otherwise.

elf-pavlik commented 9 years ago

Actually AS2.0 JSON -> Microformats JSON -> Microformats form-urlencoded makes more sense. Then server I post it to uses template to generate HTML. Even if client (frontend) would generate AS2.0 JSON -> Microformats HTML, I would need to send it to the server (backend) somehow.

aaronpk commented 9 years ago

I'm hearing an awful lot of plumbing talk. What is it you are actually trying to do? Can you describe it without using the terms "AS 2.0", "JSON", or "Microformats"?

kylewm commented 9 years ago

Guys regardless, activitystreams-unofficial is not the right place to implement this functionality. It may be misleadingly named, but it's not a general purpose format A -> format B conversion tool... it just converts streams from social media silos to various usable formats.

elf-pavlik commented 9 years ago

e.g. I want to check in to that restaurant, but it dosn't have indie profile yet so i create one for this restaurant on my domain which they can later migrate to their own http://indiewebcamp.com/micropub#Nested_Microformat_Objects

we experiment with such Portable Linked Profiles in https://github.com/hackers4peace/plp-docs

you did something similar with: http://aaronparecki.com/events/2015/03/17/1/socialwg-2015

just no portability at this moment

aaronpk commented 9 years ago

This is what Micropub is for. If you've got your data in some other format, then what you really want to do is convert from that format to Micropub, I don't see any reason to go through Microformats as an intermediary step. Anyway @kylewm is right, this is probably not the right repo for this functionality.

snarfed commented 8 years ago

fwiw granary has become a "general purpose format A -> format B conversion tool," so this feature request is now appropriate for this repo after all.

i don't actually plan to do this myself anytime soon; just sayin'. i'd happily merge a PR though!