Merge branch 'feature/data-configuration'

This commit is contained in:
Martin Zimmermann 2013-11-06 17:47:14 +01:00
commit 616ec57de2
3 changed files with 30 additions and 4 deletions

View File

@ -132,6 +132,15 @@ You can configure the client (the JS part) via `data-` attributes:
<script data-isso="/isso" src="/path/to/embed.min.js"></script> <script data-isso="/isso" src="/path/to/embed.min.js"></script>
``` ```
* data-isso-css
Set to `false` prevents Isso from automatically appending the stylesheet.
Defaults to `true`.
```html
<script src="..." data-isso-css="false"></script>
```
### Webserver configuration ### Webserver configuration
* nginx configuration to run Isso on `/isso`: * nginx configuration to run Isso on `/isso`:

View File

@ -6,6 +6,9 @@ define(["q"], function(Q) {
Q.longStackSupport = true; Q.longStackSupport = true;
var salt = "Eech7co8Ohloopo9Ol6baimi", var salt = "Eech7co8Ohloopo9Ol6baimi",
config = {
"css": true
},
location = window.location.pathname; location = window.location.pathname;
var rules = { var rules = {
@ -45,6 +48,16 @@ define(["q"], function(Q) {
} else if (js[i].src.match("require\\.js$")) { } else if (js[i].src.match("require\\.js$")) {
endpoint = js[i].dataset.main.replace(/\/js\/(embed|count)$/, ""); endpoint = js[i].dataset.main.replace(/\/js\/(embed|count)$/, "");
} }
[].forEach.call(js[i].attributes, function(attr) {
if (/^data-isso-/.test(attr.name)) {
try {
config[attr.name.substring(10)] = JSON.parse(attr.value);
} catch (ex) {
config[attr.name.substring(10)] = attr.value;
}
}
});
} }
if (! endpoint) { if (! endpoint) {
@ -181,6 +194,7 @@ define(["q"], function(Q) {
return { return {
endpoint: endpoint, endpoint: endpoint,
salt: salt, salt: salt,
config: config,
remote_addr: remote_addr, remote_addr: remote_addr,

View File

@ -8,10 +8,13 @@ require(["ready", "app/api", "app/isso", "app/count", "app/dom", "app/markup", "
"use strict"; "use strict";
domready(function() { domready(function() {
if (api.config["css"]) {
var style = $.new("style"); var style = $.new("style");
style.type = "text/css"; style.type = "text/css";
style.textContent = css.inline; style.textContent = css.inline;
$("head").append(style); $("head").append(style);
}
count(); count();