I wouldn’t recommend that.
This would cause various issues. Let’s just leave that to one side for now.
I appreciate that ideally you’d want complete control over everything, however bear with me as I attempt to translate your needs into what might be feasible improvements to the current system. Keep in mind these are just suggestions and I don’t have control over what gets accepted by the Discourse team.
An embedded post in Discourse is essentially made up of two things
- “imported from” HTML (i.e. the link)
- HTML content from linked page, either full or truncated.
1. Control over the “imported from” html
Currently, this html is hardcoded as
"\n<hr>\n<small>#{I18n.t("embed.imported_from", link: "<a href='#{url}'>#{url}</a>")}</small>\n"
You’d like to customise this to be, for example, just the url so that it would onebox. I think a feasible improvement there would be a site setting that simply switches this to “url only”, so that you wouldn’t have to allow admins to enter html somewhere.
2. Control over the truncated HTML content
You can do this already. Just set the site setting allowed embed classnames
to a classname of an element you’ve used to wrap the excerpt you want on your site, e.g.
On discourse
Set these site settings:
embed truncate
to falseallowed embed classnames
to “discourse-excerpt”
On your blog page
<div class="discourse-excerpt">
We are thrilled to share the move of the Spiceworks community to Discourse! The Spiceworks team has worked closely with our migration team
</div>
3. Control over the order of the “import from” HTML, and the HTML Content
If I’m reading you correctly, you want the “imported from” part (e.g. just the URL) to come before the HTML content (or truncated content). Again, the simplest way to do this would be a boolean site setting, something like embed imported from above content
.
So, in short, if I’m reading you correctly, you could achieve this with the addition of two new boolean settings and some small tweaks to the TopicEmbed
class. You’ll note that all of these changes are to discourse/discourse
itself as the processing has to happen there.
As I mentioned above, these are just suggestions as to how I would achieve what you want to do. To get these, or something similar actioned, there would need to be by-in from the Discourse team.