<commit_before>//= require tent-client
//= require ./boiler/core
//= require ./boiler/config
//= require_self
//= require_tree ./boiler/props
//= require_tree ./boiler/routers
//= require_tree ./boiler/views
//= require_tree ./boiler/collections
//= ./boiler/raven_config

(function () {

	Marbles.Utils.extend(Boiler, Marbles.Events, Marbles.Accessors, {
		Views: {},
		Models: {},
		Collections: {},
		Routers: {},
		Props: {},
		Helpers: {

			formatRelativeTime: function (milliseconds) {
				var time = moment(milliseconds);
				return time.fromNow();
			},

			formatDateTime: function (milliseconds) {
				var time = moment(milliseconds);
				return time.format();
			},

			fullPath: function (path) {
				prefix = Boiler.config.PATH_PREFIX || '/';
				return (prefix + '/').replace(/\/+$/, '') + path;
			}

		},

		run: function (options) {
			if (!Marbles.history || Marbles.history.started) {
				return;
			}

			if (!options) {
				options = {};
			}

			if (!this.config.container_el) {
				this.config.container_el = options.container_el || document.getElementById('main');
			}

			if (this.config.authenticated) {
				this.handleAuthenticated();
			}

			this.initAppNav();
			this.initAuthButton();

			Marbles.history.start(Marbles.Utils.extend({ root: (this.config.PATH_PREFIX || '') + '/', silent: true }, options.history || {}));

			if (this.config.authenticated || Marbles.history.path.match(/^[^a-z]*signin[^a-z]/)) {
				Marbles.history.loadURL();
			} else {
				Marbles.history.navigate(this.Helpers.fullPath('/signin'+ (Marbles.history.path ? '?redirect='+ Marbles.history.path : '')), { replace: true });
			}

			this.ready = true;
			this.trigger('ready');
		},

		handleAuthenticated: function () {
			this.set('current_entity', this.config.meta.content.entity);
			this.set('client', new TentClient(this.current_entity, {
				serverMetaPost: this.config.meta,
				credentials: this.config.credentials
			}));
			this.trigger('change:authenticated', true);
		},

		handleUnauthenticated: function () {
			this.set('current_entity', null);
			this.set('client', null);
			this.trigger('change:authenticated', false);
		},

		initAppNav: function () {
			var appNav = React.renderComponent(
				Boiler.Views.AppNav({
					authenticated: this.config.authenticated,
					navItems: this.config.nav.items,
				}),
				document.getElementById('main-nav')
			);

			this.on('change:authenticated', function (authenticated) {
				appNav.setProps({ authenticated: authenticated });
			});

			Marbles.history.on("handler:before", function (handler, path, params) {
				appNav.setState({
					activePath: path
				});
			});
		},

		initAuthButton: function () {
			if (!Boiler.config.SIGNOUT_URL) {
				return;
			}

			var authBtn = React.renderComponent(
				Boiler.Views.AuthButton({
					authenticated: this.config.authenticated,
					signoutURL: this.config.SIGNOUT_URL,
					handleSignout: function () {
						window.location.href = this.config.SIGNOUT_REDIRECT_URL;
					}.bind(this)
				}),
				document.getElementById('auth-button')
			);

			this.on('change:authenticated', function (authenticated) {
				authBtn.setProps({ authenticated: authenticated });
			});
		}
	});

	if (Boiler.config_ready) {
		Boiler.trigger('config:ready');
	}

})();<commit_msg>Allow overriding signout handler<commit_after>//= require tent-client
//= require ./boiler/core
//= require ./boiler/config
//= require_self
//= require_tree ./boiler/props
//= require_tree ./boiler/routers
//= require_tree ./boiler/views
//= require_tree ./boiler/collections
//= ./boiler/raven_config

(function () {

	Marbles.Utils.extend(Boiler, Marbles.Events, Marbles.Accessors, {
		Views: {},
		Models: {},
		Collections: {},
		Routers: {},
		Props: {},
		Helpers: {

			formatRelativeTime: function (milliseconds) {
				var time = moment(milliseconds);
				return time.fromNow();
			},

			formatDateTime: function (milliseconds) {
				var time = moment(milliseconds);
				return time.format();
			},

			fullPath: function (path) {
				prefix = Boiler.config.PATH_PREFIX || '/';
				return (prefix + '/').replace(/\/+$/, '') + path;
			}

		},

		run: function (options) {
			if (!Marbles.history || Marbles.history.started) {
				return;
			}

			if (!options) {
				options = {};
			}

			if (!this.config.container_el) {
				this.config.container_el = options.container_el || document.getElementById('main');
			}

			if (this.config.authenticated) {
				this.handleAuthenticated();
			}

			this.initAppNav();
			this.initAuthButton();

			Marbles.history.start(Marbles.Utils.extend({ root: (this.config.PATH_PREFIX || '') + '/', silent: true }, options.history || {}));

			if (this.config.authenticated || Marbles.history.path.match(/^[^a-z]*signin[^a-z]/)) {
				Marbles.history.loadURL();
			} else {
				Marbles.history.navigate(this.Helpers.fullPath('/signin'+ (Marbles.history.path ? '?redirect='+ Marbles.history.path : '')), { replace: true });
			}

			this.ready = true;
			this.trigger('ready');
		},

		handleAuthenticated: function () {
			this.set('current_entity', this.config.meta.content.entity);
			this.set('client', new TentClient(this.current_entity, {
				serverMetaPost: this.config.meta,
				credentials: this.config.credentials
			}));
			this.trigger('change:authenticated', true);
		},

		handleUnauthenticated: function () {
			this.set('current_entity', null);
			this.set('client', null);
			this.trigger('change:authenticated', false);
		},

		initAppNav: function () {
			var appNav = React.renderComponent(
				Boiler.Views.AppNav({
					authenticated: this.config.authenticated,
					navItems: this.config.nav.items,
				}),
				document.getElementById('main-nav')
			);

			this.on('change:authenticated', function (authenticated) {
				appNav.setProps({ authenticated: authenticated });
			});

			Marbles.history.on("handler:before", function (handler, path, params) {
				appNav.setState({
					activePath: path
				});
			});
		},

		initAuthButton: function () {
			if (!Boiler.config.SIGNOUT_URL) {
				return;
			}

			var authBtn = React.renderComponent(
				Boiler.Views.AuthButton({
					authenticated: this.config.authenticated,
					signoutURL: this.config.SIGNOUT_URL,
					handleSignout: Boiler.signoutHandler || Boiler.performSignoutRedirect
				}),
				document.getElementById('auth-button')
			);

			this.on('change:authenticated', function (authenticated) {
				authBtn.setProps({ authenticated: authenticated });
			});
		},

		performSignoutRedirect: function () {
			window.location.href = Boiler.config.SIGNOUT_REDIRECT_URL;
		}
	});

	if (Boiler.config_ready) {
		Boiler.trigger('config:ready');
	}

})();
{'fraction_non_alphanumeric': 0.16779127305443095, 'fraction_numerical': 0.0, 'mean_word_length': 3.4585561497326203, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '796995', 'n_tokens_mistral': 2623, 'n_tokens_neox': 2132, 'n_words': 337}