<commit_before>/**
 * Show the default quota settings for users and collections.
 */
girder.views.largeImageConfig = girder.View.extend({
    events: {
        'submit #g-large-image-form': function (event) {
            event.preventDefault();
            this.$('#g-large-image-error-message').empty();
            this._saveSettings([{
                key: 'large_image.show_thumbnails',
                value: this.$('.g-large-image-thumbnails-show').prop('checked')
            }, {
                key: 'large_image.show_viewer',
                value: this.$('.g-large-image-viewer-show').prop('checked')
            },{
                key: 'large_image.use_memcached',
                value: this.$('.g-large-image-memcached').prop('checked')
            }, {
                key: 'large_image.default_viewer',
                value: this.$('.g-large-image-default-viewer').val()
            }]);
        }
    },
    initialize: function () {
        girder.views.largeImageConfig.getSettings(_.bind(
            function (settings) {
                this.settings = settings;
                this.render();
            }, this));
    },

    render: function () {
        this.$el.html(girder.templates.largeImageConfig({
            settings: this.settings,
            viewers: girder.views.largeImageConfig.viewers
        }));
        if (!this.breadcrumb) {
            this.breadcrumb = new girder.views.PluginConfigBreadcrumbWidget({
                pluginName: 'Large image',
                el: this.$('.g-config-breadcrumb-container'),
                parentView: this
            }).render();
        }

        return this;
    },

    _saveSettings: function (settings) {
        /* Now save the settings */
        girder.restRequest({
            type: 'PUT',
            path: 'system/setting',
            data: {
                list: JSON.stringify(settings)
            },
            error: null
        }).done(_.bind(function () {
            /* Clear the settings that may have been loaded. */
            girder.views.largeImageConfig.clearSettings();
            girder.events.trigger('g:alert', {
                icon: 'ok',
                text: 'Settings saved.',
                type: 'success',
                timeout: 4000
            });
        }, this)).error(_.bind(function (resp) {
            this.$('#g-large-image-error-message').text(
                resp.responseJSON.message
            );
        }, this));
    }
}, {
    /* Class methods and objects */

    /* The list of viewers is added as a property to the select widget view so
     * that it is also available to the settings page. */
    viewers: [
        {
            name: 'openseadragon',
            label: 'OpenSeaDragon',
            type: 'OpenseadragonImageViewerWidget'
        },
        {
            name: 'openlayers',
            label: 'OpenLayers',
            type: 'OpenlayersImageViewerWidget'
        },
        {
            name: 'leaflet',
            label: 'Leaflet',
            type: 'LeafletImageViewerWidget'
        },
        {
            name: 'geojs',
            label: 'GeoJS',
            type: 'GeojsImageViewerWidget'
        },
        {
            name: 'slideatlas',
            label: 'SlideAtlas',
            type: 'SlideAtlasImageViewerWidget'
        }
    ],

    /**
     * Get settings if we haven't yet done so.  Either way, call a callback
     * when we have settings.
     *
     * @param {function} callback a function to call after the settings are
     *      fetched.  If the settings are already present, this is called
     *      without any delay.
     */
    getSettings: function (callback) {
        if (!girder.views.largeImageConfig.settings) {
            girder.restRequest({
                type: 'GET',
                path: 'system/setting/large_image'
            }).done(function (resp) {
                girder.views.largeImageConfig.settings = resp;
                if (callback) {
                    callback(girder.views.largeImageConfig.settings);
                }
            });
        } else {
            if (callback) {
                callback(girder.views.largeImageConfig.settings);
            }
        }
    },

    /**
     * Clear the settings so that getSettings will refetch them.
     */
    clearSettings: function () {
        delete girder.views.largeImageConfig.settings;
    }
});

girder.router.route(
    'plugins/large_image/config', 'largeImageConfig', function () {
        girder.events.trigger('g:navigateTo',
                              girder.views.largeImageConfig);
    });

girder.exposePluginConfig('large_image', 'plugins/large_image/config');
<commit_msg>Revert "Added memcache selection to the plugin settings"<commit_after>/**
 * Show the default quota settings for users and collections.
 */
girder.views.largeImageConfig = girder.View.extend({
    events: {
        'submit #g-large-image-form': function (event) {
            event.preventDefault();
            this.$('#g-large-image-error-message').empty();
            this._saveSettings([{
                key: 'large_image.show_thumbnails',
                value: this.$('.g-large-image-thumbnails-show').prop('checked')
            }, {
                key: 'large_image.show_viewer',
                value: this.$('.g-large-image-viewer-show').prop('checked')
            }, {
                key: 'large_image.default_viewer',
                value: this.$('.g-large-image-default-viewer').val()
            }]);
        }
    },
    initialize: function () {
        girder.views.largeImageConfig.getSettings(_.bind(
            function (settings) {
                this.settings = settings;
                this.render();
            }, this));
    },

    render: function () {
        this.$el.html(girder.templates.largeImageConfig({
            settings: this.settings,
            viewers: girder.views.largeImageConfig.viewers
        }));
        if (!this.breadcrumb) {
            this.breadcrumb = new girder.views.PluginConfigBreadcrumbWidget({
                pluginName: 'Large image',
                el: this.$('.g-config-breadcrumb-container'),
                parentView: this
            }).render();
        }

        return this;
    },

    _saveSettings: function (settings) {
        /* Now save the settings */
        girder.restRequest({
            type: 'PUT',
            path: 'system/setting',
            data: {
                list: JSON.stringify(settings)
            },
            error: null
        }).done(_.bind(function () {
            /* Clear the settings that may have been loaded. */
            girder.views.largeImageConfig.clearSettings();
            girder.events.trigger('g:alert', {
                icon: 'ok',
                text: 'Settings saved.',
                type: 'success',
                timeout: 4000
            });
        }, this)).error(_.bind(function (resp) {
            this.$('#g-large-image-error-message').text(
                resp.responseJSON.message
            );
        }, this));
    }
}, {
    /* Class methods and objects */

    /* The list of viewers is added as a property to the select widget view so
     * that it is also available to the settings page. */
    viewers: [
        {
            name: 'openseadragon',
            label: 'OpenSeaDragon',
            type: 'OpenseadragonImageViewerWidget'
        },
        {
            name: 'openlayers',
            label: 'OpenLayers',
            type: 'OpenlayersImageViewerWidget'
        },
        {
            name: 'leaflet',
            label: 'Leaflet',
            type: 'LeafletImageViewerWidget'
        },
        {
            name: 'geojs',
            label: 'GeoJS',
            type: 'GeojsImageViewerWidget'
        },
        {
            name: 'slideatlas',
            label: 'SlideAtlas',
            type: 'SlideAtlasImageViewerWidget'
        }
    ],

    /**
     * Get settings if we haven't yet done so.  Either way, call a callback
     * when we have settings.
     *
     * @param {function} callback a function to call after the settings are
     *      fetched.  If the settings are already present, this is called
     *      without any delay.
     */
    getSettings: function (callback) {
        if (!girder.views.largeImageConfig.settings) {
            girder.restRequest({
                type: 'GET',
                path: 'system/setting/large_image'
            }).done(function (resp) {
                girder.views.largeImageConfig.settings = resp;
                if (callback) {
                    callback(girder.views.largeImageConfig.settings);
                }
            });
        } else {
            if (callback) {
                callback(girder.views.largeImageConfig.settings);
            }
        }
    },

    /**
     * Clear the settings so that getSettings will refetch them.
     */
    clearSettings: function () {
        delete girder.views.largeImageConfig.settings;
    }
});

girder.router.route(
    'plugins/large_image/config', 'largeImageConfig', function () {
        girder.events.trigger('g:navigateTo',
                              girder.views.largeImageConfig);
    });

girder.exposePluginConfig('large_image', 'plugins/large_image/config');

{'fraction_non_alphanumeric': 0.12183833817673016, 'fraction_numerical': 0.0008610483263373157, 'mean_word_length': 1.5583700440528634, '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': '4710804', 'n_tokens_mistral': 2529, 'n_tokens_neox': 2465, 'n_words': 505}