Embeds an upcoming events widget on the current page through a combination of:
<div id="chq" />
and the following JavaScript snippet:
<script>
+function (c, h, q) {
(q = document.createElement("script")).type = "text/javascript";
q.src = "https://assets.culturehq.com/widget.js";
q.onload = function () { CHQ(c, h) };
document.getElementsByTagName("head")[0].appendChild(q);
}("#chq" /* your selector */, "token" /* your API token */)
</script>
Note that in order for this to be embedded on a page, the following additions to the hosting webpage's CSP will need to be made:
style-src 'unsafe-inline';
script-src 'unsafe-inline' https://assets.culturehq.com;
connect-src https://api.culturehq.com;
img-src https://uploads.culturehq.com;
Ensure you have node
and yarn
installed. Run yarn install
in the root of the repository to get the dependencies. Edit index.html
and src/config.js
as appropriate to get it to point to your local API using a valid bot token. Then, run yarn start
to start the local server. You can view the widget at http://localhost:8081
.
To run this against the local server, you need to add this snippet in the App.js
file, before the class App extends...
import { configure, skipPreflightChecks } from "@culturehq/client";
switch (process.env.NODE_ENV) { // eslint-disable-line default-case
case "development":
configure({
apiHost: "http://localhost:3000",
awsAccessKeyId: "access-key-id",
signerURL: "http://localhost:3001",
uploadBucket: "http://localhost:3001"
});
break;
case "test":
configure({
apiHost: "http://localhost:8080",
awsAccessKeyId: "access-key-id",
signerURL: "http://localhost:8081",
uploadBucket: "http://localhost:8082"
});
break;
case "production":
skipPreflightChecks();
break;
}
Bug reports and pull requests are welcome on GitHub at https://github.com/CultureHQ/widget.
The code is available as open source under the terms of the MIT License.