(function() { var Revelry; global.Rev = Revelry = (function() { function Revelry() {} Revelry.App = { Mixins: {}, Components: {}, Examples: {} }; Revelry.appObject = function(name, object) { return this.registerObject("App." + name, object); }; Revelry.registerObject = function(name, object) { var container, i, j, len, part, parts; parts = name.split('.'); container = this; for (i = j = 0, len = parts.length; j < len; i = ++j) { part = parts[i]; if (i === parts.length - 1) { if ((container[part] != null) && name !== "App.Components.Main") { console.warn("Object previously defined: " + name); } container[part] = object; } else { container[part] || (container[part] = {}); container = container[part]; } } return object; }; Revelry.appComponent = function(name, object) { name = "App.Components." + name; return this.registerObject(name, this.createReactClass(name, object)); }; Revelry.registerComponent = function(name, object) { name = "Components." + name; return this.registerObject(name, this.createReactClass("Rev." + name, object)); }; Revelry.createReactClass = function(displayName, object) { var j, len, mixin, ref; object.displayName = displayName; object.mixins || (object.mixins = []); ref = object.mixins; for (j = 0, len = ref.length; j < len; j++) { mixin = ref[j]; if (mixin == null) { console.warn("Attempted to include missing mixin."); } } object.mixins.unshift(this.Mixins.Core); if (typeof object === 'function') { return object; } else { return React.createClass(object); } }; Revelry.appMixin = function(name, object) { if (object == null) { throw "Missing mixin `" + name + "`"; } return this.registerObject("App.Mixins." + name, object); }; Revelry.registerMixin = function(name, object) { if (object == null) { throw "Missing mixin `" + name + "`"; } return this.registerObject("Mixins." + name, object); }; Revelry.registerExample = function(name, object) { name = "Examples." + name; return this.registerObject(name, this.createReactClass("Rev." + name, object)); }; Revelry.appExample = function(name, object) { name = "App.Examples." + name; return this.registerObject(name, this.createReactClass(name, object)); }; Revelry.registerModel = function(name, object) { return this.registerObject("Models." + name, object); }; Revelry.appModel = function(name, object) { return this.registerObject("App.Models." + name, object); }; Revelry.pullInto = function(context) { return (function(_this) { return function() { var componentName, i, results; results = []; for (i in arguments) { componentName = arguments[i]; results.push(context[componentName] = Rev.Components[componentName]); } return results; }; })(this); }; Revelry.ESCAPE_LOOKUP = { "&": "&", ">": ">", "<": "<", "\"": """, "'": "'" }; Revelry.ESCAPE_REGEX = /[&><"']/g; Revelry._escaper = function(match) { return Revelry.ESCAPE_LOOKUP[match]; }; Revelry.escapeTextForBrowser = function(text) { return ('' + text).replace(Revelry.ESCAPE_REGEX, Revelry._escaper); }; Revelry._resetUniqueId = function() { var idCounter; idCounter = 0; return _.uniqueId = function(prefix) { var id; id = ++idCounter + ''; if (prefix) { return prefix + id; } else { return id; } }; }; Revelry.hasView = function(path) { return this.Components.Main.hasView(path); }; Revelry.viewToString = function(path, options) { var e, json, props, tag; this._resetUniqueId(); props = { path: path, options: JSON.parse(options) }; json = this.escapeTextForBrowser(JSON.stringify(props)); tag = function(inner) { return "
" + inner + "
"; }; try { if (React.renderComponentToString != null) { return tag(React.renderComponentToString(this.App.Components.Main(props))); } else { return tag(React.renderToString(React.createElement(this.App.Components.Main, props))); } } catch (_error) { e = _error; return ("
" + path + "
") + "
" + ("" + (this.escapeTextForBrowser(e.stack))) + "
" + tag("") + ("
" + json + "
"); } }; Revelry.initExecjsRails = function() { global.execjs_rails_has_view = this.hasView.bind(this); return global.execjs_rails_handler = this.viewToString.bind(this); }; return Revelry; })(); global.App = Rev.App; }).call(this);