moose-team / rich-message

:moneybag: Turn a plain message into a rich HTML message
MIT License
21 stars 8 forks source link

img and/or open graph parsing #2

Open Flet opened 9 years ago

Flet commented 9 years ago

From @derekr on April 28, 2015 4:23

Understandably not a desired feature, but I appreciate link/og parsing found in apps like slack and hipchat. Happy to work on it, but looking for some feedback on if this is wanted before I spend some time on it.

Copied from original issue: moose-team/friends#29

Flet commented 9 years ago

From @maxogden on April 28, 2015 4:27

+1 to gifs/pngs/jpgs for starters

would be nice to have a 'embed-media' module that matched strings for media urls, then turned them into embed html. bonus points if it can verify they are valid images before rendering (e.g. render to invisible canvas and make sure it loads correctly)

Flet commented 9 years ago

From @maxogden on April 28, 2015 16:52

since we have markdown now all you need to do is transform .jpg, .png, .gif into ![meta](url)

Flet commented 9 years ago

From @derekr on April 28, 2015 16:54

Yeah I think that'll work for now. To provide a decent experience like slack (verifying a valid url and what not) message parsing would need be async and was more work than I could put in to it last night haha.

Flet commented 9 years ago

From @derekr on April 28, 2015 17:3

Thoughts from last night:

message = richMessage(message)

// parse <a> from rendered html
// check for first valid embed (or just grab the first url and if it doesn't work then ¯\_(ツ)_/¯
parseEmbeds(message, cb (err, embed) {
  // embed could share the same structure as a message { text: 'url', html: 'embed html' }
  message = richMessage.mergeMessages(message, embed)
  render()
})
Flet commented 9 years ago

From @beaugunderson on April 29, 2015 6:50

some node tools for oembed parsing/lists of oembed URLs: