<commit_before>girder.App = girder.View.extend({
    initialize: function () {
        girder.fetchCurrentUser()
            .done(_.bind(function (user) {
                girder.eventStream = new girder.EventStream({
                    timeout: girder.sseTimeout || null
                });

                this.headerView = new girder.views.LayoutHeaderView({
                    parentView: this
                });

                this.globalNavView = new girder.views.LayoutGlobalNavView({
                    parentView: this
                });

                this.footerView = new girder.views.LayoutFooterView({
                    parentView: this
                });

                this.progressListView = new girder.views.ProgressListView({
                    eventStream: girder.eventStream,
                    parentView: this
                });

                if (user) {
                    girder.currentUser = new girder.models.UserModel(user);
                    girder.eventStream.open();
                }

                this.layoutRenderMap = {};
                this.layoutRenderMap[girder.Layout.DEFAULT] = this._defaultLayout;
                this.layoutRenderMap[girder.Layout.EMPTY] = this._emptyLayout;
                this.render();

                // Once we've rendered the layout, we can start up the routing.
                Backbone.history.start({
                    pushState: false
                });
            }, this));

        girder.events.on('g:navigateTo', this.navigateTo, this);
        girder.events.on('g:loginUi', this.loginDialog, this);
        girder.events.on('g:registerUi', this.registerDialog, this);
        girder.events.on('g:resetPasswordUi', this.resetPasswordDialog, this);
        girder.events.on('g:alert', this.alert, this);
        girder.events.on('g:login', this.login, this);<commit_msg>Add configuration options for application startup<commit_after>girder.App = girder.View.extend({
    /**
     * @param {object} [settings]
     * @param {bool} [settings.start=true] Run start after initialization
     */
    initialize: function (settings) {
        this._started = false;
        settings = settings || {};
        if (settings.start === undefined || settings.start) {
            this.start();
        }
    },

    /**
     * Start the application with optional components.
     * @param {object} [settings]
     * @param {bool} [settings.fetch=true] Fetch the current user modal
     * @param {bool} [settings.render=true] Render the layout after starting
     * @param {bool} [settings.history=true] Start backbone's history api
     * @returns {$.Deferred} A promise-like object that resolves when the app is ready
     */
    start: function (settings) {
        // start is a noop if the app is already running
        var promise = new $.Deferred().resolve(null).promise();
        if (this._started) {
            return promise;
        }
        this._started = true;

        // set defaults
        settings = _.defaults(settings || {}, {
            fetch: true,
            render: true,
            history: true
        });

        // define a function to be run after fetching the user model
        var afterFetch = _.bind(function (user) {
            girder.eventStream = new girder.EventStream({
                timeout: girder.sseTimeout || null
            });

            this._createLayout();

            if (user) {
                girder.currentUser = new girder.models.UserModel(user);
                girder.eventStream.open();
            }

            if (settings.render) {
                this.render();
            }

            if (settings.history) {
                Backbone.history.start({
                    pushState: false
                });
            }
        }, this);

        // If fetching the user from the server then we return the jqxhr object
        // from the request, otherwise just call the callback.
        if (settings.fetch) {
            promise = girder.fetchCurrentUser()
                .done(afterFetch);
        } else {
            afterFetch(null);
        }

        this.bindGirderEvents();
        return promise;
    },

    /**
     * Bind the application to the global event object.
     */
    bindGirderEvents: function () {
        // Unbind any current handlers in case this happens to be called twice.
        girder.events.off(null, null, this);

        girder.events.on('g:navigateTo', this.navigateTo, this);
        girder.events.on('g:loginUi', this.loginDialog, this);
        girder.events.on('g:registerUi', this.registerDialog, this);
        girder.events.on('g:resetPasswordUi', this.resetPasswordDialog, this);
        girder.events.on('g:alert', this.alert, this);
        girder.events.on('g:login', this.login, this);
    },

    /**
     * Create the main layout views.
     * @private
     */
    _createLayout: function () {
        this.headerView = new girder.views.LayoutHeaderView({
            parentView: this
        });

        this.globalNavView = new girder.views.LayoutGlobalNavView({
            parentView: this
        });

        this.footerView = new girder.views.LayoutFooterView({
            parentView: this
        });

        this.progressListView = new girder.views.ProgressListView({
            eventStream: girder.eventStream,
            parentView: this
        });

        this.layoutRenderMap = {};
        this.layoutRenderMap[girder.Layout.DEFAULT] = this._defaultLayout;
        this.layoutRenderMap[girder.Layout.EMPTY] = this._emptyLayout;
{'fraction_non_alphanumeric': 0.1101953055008063, 'fraction_numerical': 0.0, 'mean_word_length': 1.7538233843117907, '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': '5287208', 'n_tokens_mistral': 1501, 'n_tokens_neox': 1452, 'n_words': 331}