Digesting links in broadcast and injecting (still need to remove all other HTML)

This commit is contained in:
James Barnsley
2019-02-05 17:04:32 +13:00
parent bdc9935596
commit 31e62fdf81
7 changed files with 51 additions and 12 deletions

View File

@ -180,10 +180,23 @@ const UIMiddleware = (function(){
if (!suppressed_broadcasts.includes(broadcast.key)){
if (broadcast.message){
var content = broadcast.message;
// Digest raw content and drop in links where appropriate
if (broadcast.links){
for (var link_name in broadcast.links){
if (broadcast.links.hasOwnProperty(link_name)){
var link = broadcast.links[link_name];
var link_markup = '<a href="'+link.url+'"'+(link.new_window ? ' target="_blank" ' : '')+'>'+link.text+'</a>';
content = content.replace('$'+link_name, link_markup);
}
}
}
var data = {
key: (broadcast.key ? broadcast.key : null),
title: (broadcast.title ? broadcast.title : null),
content: broadcast.message,
content: content,
type: 'broadcast',
sticky: true
}