Adding Something to the "Create a New Topic" text box?

(Lanie) #1

Is it possible to add code in the “Create a New Topic” text box? I have coded a calendar sign-up that I was hoping to embed, so every person who posts a new topic can fill it out. Thanks so much!

(Tom Newsom) #2

Check out Topic Templates. They’re a per-category setting

(Lanie) #3

Thanks a lot for the response! Do you know how to have it take my code? It’s just takes it as text.

(Tom Newsom) #4

Ah, well if you want to actually embed code in a post then the other app needs to be supported by Onebox, which is outside my knowledge. Not so simple.

For now, you’d have to settle for a link.

(Lanie) #5

Sorry for the elementary question, but you mean just a hyperlink, right?

(Mittineague) #6

If you want to be able to post actual code and you aren’t concerned about the possibility of it being abused, you can “white-list” tags-attributes. eg.

Discourse.Markdown.whiteListTag("progress", "class", /d-prog/);
Discourse.Markdown.whiteListTag("progress", "max", /[0-9\.]+/);
Discourse.Markdown.whiteListTag("progress", "value", /[0-9\.]+/);

The regex is what attribute values are acceptable.

(Lanie) #7

Thanks so much for the reply! Could you explain that a little more, I’m not familiar with "white-list’ tags-attributes. The code I’m want to embed/add is a sort of calendar planner in HTML and Ruby.
Thanks again!

(Mittineague) #8

It’s a plugin. For example

You would need to add a line for every tag / attribute you want to whitelist.
And be careful with the regex, it can look deceptively easier than it is to craft a good one.

(Kane York) #9

Here, @LanieI would probably want to do this:

Discourse.Markdown.whiteListTag("iframe", "src", "");