Open kethomassen opened 11 years ago
Cool, didn't know about that little javascript library. Would you prefer this to happen on the client side instead of on the server side? I was originally planning to handle this sort of thing server-side.
@andrewhavens Client side would probably be the best way. There is https://github.com/tenderlove/rails_autolink, but it doesn't render images and doesn't have as much extensibility as the javascript implementation.
I was planning to store the message as both the original text and formatted html, that way I could allow custom formatted messages. Maybe this isn't a necessary feature though.
Storing the text unformatted, and sending the rendered version to the client when needed would probably be the best way. @andrewhavens
Send Message -> Store in database plain -> Send back rendered -> Display to clients
My original plan was to do something like this:
When someone enters a room or fetches old messages, the messages that are stored in the database already have the formatted HTML. So there's no additional processing that needs to be done. On the client side, when a message is received, it's appended to the chat room.
Example scenarios:
What do you think of that?
Autolink
All URL's in messages should be autolinked using autolink.js, and images displayed inline.
https://github.com/bryanwoods/autolink-js
Example implementation
Images
Have images display underneath the text, like HipChat, etc.