Embedding links in textarea

Hi,

I’m building a small Sinatra app for a podcast and want to be able to add links in a textarea for the show notes.

I was looking for advice about how to best solve this. I have been looking into [wysihtml5][1] from xing but I can 't say I’m very much excited about this solution.

If anyone could point me in a better direction, much appreciation and many thanks will fly your way! :smiley:

Thanks!
[1]: GitHub - tiff/wysihtml5: Open source rich text editor based on HTML5 and the progressive-enhancement approach. Uses a sophisticated security concept and aims to generate fully valid HTML5 markup by preventing unmaintainable tag soups and inline styles.

I would make the show notes a list of links, so that you aren’t mixing content. Then you can render something like

<%- @podcast.shownotes.each do |show_note| %>
  <li><%= link_to show_note.text, show_note.link &></li>
<% end %>

Then every show note is a link. It might be a little less flexible, but it saves you from getting into complicated HTML content sanitization.

If you are dead-set on embedding the links in admin- or user-generated content, I’d recommend trying the Ace editor and using Liquid for content rendering and Loofah for HTML santiization.

1000.times do
  puts 'Thanks very much!'
end

I was thinking about looping through a link collection too but it doesn’t really fit my needs. Ace looks interesting, but maybe a bit overkill for my humble needs :wink:

Got a basic version working with WYSIHTML5 last night. Stripped out all the gobbledygook I don’t care about and load only extra JS files for the edit page. I can live with that for now and move on to bigger fish.

Thanks mate!

How about writing the notes in markdown and processing that? I find the WYSIWG editors quite poor.

1 Like

That sounds much simpler than what I had recommended, and quite flexible.

That sounds like the best solution. Since I only need the WYSIWYG for linking up a couple of show notes, I would like to get rid of the extra JS.

Could you point me in the right direction of how I would best implement writing markdown in my textarea input field?

Thanks a ton!

Here’s a Railscast on Redcarpet, which is a gem that can render Markdown: #272 Markdown with Redcarpet - RailsCasts

You can skip over the parts related to syntax highlighting.