diff --git a/app.js b/app.js index c04e0cb4a..38ac3c003 100644 --- a/app.js +++ b/app.js @@ -34,6 +34,7 @@ app.use(helmet({ })); app.use(bodyParser.json()); app.use('/client', express.static(path.join(__dirname, 'dist'))); +app.get('/Coral.js', (req, res) => res.sendFile(path.join(__dirname, 'client/coral-embed-api/index.js'))); app.set('views', path.join(__dirname, 'views')); app.set('view engine', 'ejs'); diff --git a/client/coral-admin/src/containers/Configure/EmbedLink.js b/client/coral-admin/src/containers/Configure/EmbedLink.js index 105b531c5..32024bde2 100644 --- a/client/coral-admin/src/containers/Configure/EmbedLink.js +++ b/client/coral-admin/src/containers/Configure/EmbedLink.js @@ -25,8 +25,24 @@ class EmbedLink extends Component { } render () { - const embedText = `
`; - + const location = window.location; + const talkBaseUrl = [ + location.protocol, + '//', + location.hostname, + location.port ? (`:${ window.location.port}`) : '' + ].join(''); + const coralJsUrl = [talkBaseUrl, '/Coral.js'].join(''); + const nonce = String(Math.random()).slice(2); + const streamElementId = `coral_talk_${nonce}`; + const embedText = ` +
+ + `.trim(); return (

{this.props.title}

diff --git a/client/coral-embed-api/index.js b/client/coral-embed-api/index.js new file mode 100644 index 000000000..efc60ee75 --- /dev/null +++ b/client/coral-embed-api/index.js @@ -0,0 +1,164 @@ +/* eslint-disable no-var */ +/** + * @file Exposes the main 'window.Coral.Talk' API that developers can use to + * render Talk streams in their webpages + * @todo Currently implemented to be included directly via - - -