<commit_before>define([
    'backbone',
    'views/category',
    'views/user',
    'views/account',
    'views/conversation-list',
    'views/messages',
    'models/user',
], function(Backbone, CategoryView, UserView, AccountView, ConversationListView, MessagesView, User) {
    var Router = Backbone.Router.extend({
        routes: {
            '':                                'index',
            'pods/new/':                       'newPod',
            'pods/:id/':                       'podById',
            'account/pods/favs/':              'podsByFav',
            'pods/categories/:id/':            'podsByCategory',
            'categories/':                     'categories',
            'categories/new/':                 'newCategory',
            'signin/':                         'signin',
            'signup/':                         'signup',
            'account/':                        'account',
            'about/':                          'about',
            'tags/':                           'tags',
            'tags/:tagName/':                  'tagByName',
            'account/tags/favs/':              'tagsByFav',
            'users/:username/':                'userByUsername',
            'conversations/':                  'conversations',
            'conversations/:param/':           'conversationByParam',
            'messages/':                       'messages'
        },
        execute: function(callback, args, name) {
            this.pauseAudio();
            this.collapseMobileNav();
            $('.view').hide();
            callback.apply(this, args);
        },
        afterExecute: function() {
            if (app.isMobile()) return;
            $('.view:visible').each(function() {
                $(this).find('input:first').focus();
            });
        },
        index: function() {
            $('#pods-view').show();
            app.loadInitialPods();
        },
        newPod: function() {
            $('#pod-form-view').show();
        },
        podById: function(id) {
            app.podDetailView.show(app.pods.get(id));
        },
        podsByFav: function() {
            if (!app.loggedIn) return;
            $('#pods-view').show();
            app.headerView.show({ name: 'My favorite pods', description: '' });
            $.get('/account/pods/favs/').then(function(data) {
                app.pods.reset(data);
            });
        },
        podsByCategory: function(name) {
            function f() {
                app.categories.each(function(cat) {
                    if (cat.get('name').toLowerCase() == name) {
                        app.headerView.show(cat.toJSON());
                        return false;
                    }
                });
            }

            if (app.categories.length) {
                f();
            } else {
                app.categories.fetch({
                    reset: true,
                    success: f
                });
            }
            $('#pods-view').show();
            $.get('/pods/categories/{name}/'.replace('{name}', name.toLowerCase())).then(function(data) {
                app.pods.reset(data);
            });
        },
        categories: function() {
            $('#categories-view').show();
            if (!app.categories.length) {
                app.categories.fetch({ reset: true });
            }
        },
        newCategory: function() {
            $('#category-view').show();
        },
        signin: function() {
            $('#signin-view').show();
        },
        signup: function() {
            $('#signup-view').show();
        },
        account: function() {
            if (!app.loggedIn) return;
            if (!app.accountView) {
                app.accountView = new AccountView();
            }
            app.accountView.show();
        },
        about: function() {
            $('#about-view').show();
        },
        tags: function() {
            $('#tags-view').show();
            $('#tags-view h3.title').html('Tags');
            app.tags.fetch({ reset: true });
        },
        tagByName: function(tagName) {
            $('#pods-view').show();
            $.get('/tags/{tagName}/'.replace('{tagName}', tagName)).then(function(data) {
                app.headerView.show({ name: data.name, description: data.description });
                app.pods.reset(data.pods);
            });
        },
        tagsByFav: function() {
            if (!app.loggedIn) return;
            $('#tags-view').show();
            $('#tags-view h3.title').html('My favorite tags');
            $.get('/account/tags/favs/').then(function(data) {
                app.tags.reset(data);
            });
        },
        userByUsername: function(username) {
            $.get('/users/{username}/'.replace('{username}', username)).then(function(data) {
                if (!app.userView) app.userView = new UserView();
                app.userView.show(new User(data));
            });
        },
        conversationByParam: function(param) {
            if (!app.loggedIn) return;
            if (!app.messagesView) {
                app.messagesView = new MessagesView();
            }
            app.messagesView.show();
            if (param.match(/\d+/)) {
                this.conversationById(param);
            } else {
                this.conversationByUsername(param);
            }
        },
        conversationById: function(id) {
            app.messagesView.showConversation(id);
        },
        conversationByUsername: function(username) {
            app.messagesView.showConversationOrStartNew(username);
        },
        messages: function() {<commit_msg>router bug fix<commit_after>define([
    'backbone',
    'views/category',
    'views/user',
    'views/account',
    'views/conversation-list',
    'views/messages',
    'models/user',
], function(Backbone, CategoryView, UserView, AccountView, ConversationListView, MessagesView, User) {
    var Router = Backbone.Router.extend({
        routes: {
            '':                                'index',
            'pods/new/':                       'newPod',
            'pods/:id/':                       'podById',
            'account/pods/favs/':              'podsByFav',
            'pods/categories/:id/':            'podsByCategory',
            'categories/':                     'categories',
            'categories/new/':                 'newCategory',
            'signin/':                         'signin',
            'signup/':                         'signup',
            'account/':                        'account',
            'about/':                          'about',
            'tags/':                           'tags',
            'tags/:tagName/':                  'tagByName',
            'account/tags/favs/':              'tagsByFav',
            'users/:username/':                'userByUsername',
            'conversations/':                  'conversations',
            'conversations/:param/':           'conversationByParam',
            'messages/':                       'messages'
        },
        execute: function(callback, args, name) {
            this.pauseAudio();
            this.collapseMobileNav();
            $('.view').hide();
            callback.apply(this, args);
        },
        afterExecute: function() {
            if (app.isMobile()) return;
            $('.view:visible').each(function() {
                $(this).find('input:first').focus();
            });
        },
        index: function() {
            $('#pods-view').show();
            app.loadInitialPods();
        },
        newPod: function() {
            $('#pod-form-view').show();
        },
        podById: function(id) {
            app.podDetailView.show(app.pods.get(id));
        },
        podsByFav: function() {
            if (!app.loggedIn) return;
            $('#pods-view').show();
            app.headerView.show({ name: 'My favorite pods', description: '' });
            $.get('/account/pods/favs/').then(function(data) {
                app.pods.reset(data);
            });
        },
        podsByCategory: function(name) {
            function f() {
                app.categories.each(function(cat) {
                    if (cat.get('name').toLowerCase() == name) {
                        app.headerView.show(cat.toJSON());
                        return false;
                    }
                });
            }

            if (app.categories.length) {
                f();
            } else {
                app.categories.fetch({
                    reset: true,
                    success: f
                });
            }
            $('#pods-view').show();
            $.get('/pods/categories/{name}/'.replace('{name}', name.toLowerCase())).then(function(data) {
                app.pods.reset(data);
            });
        },
        categories: function() {
            $('#categories-view').show();
            if (!app.categories.length) {
                app.categories.fetch({ reset: true });
            }
        },
        newCategory: function() {
            $('#category-view').show();
        },
        signin: function() {
            $('#signin-view').show();
        },
        signup: function() {
            $('#signup-view').show();
        },
        account: function() {
            if (!app.loggedIn) return;
            if (!app.accountView) {
                app.accountView = new AccountView();
            }
            app.accountView.show();
        },
        about: function() {
            $('#about-view').show();
        },
        tags: function() {
            $('#tags-view').show();
            $('#tags-view h3.title').html('Tags');
            app.tags.fetch({ reset: true });
        },
        tagByName: function(tagName) {
            $('#pods-view').show();
            $.get('/tags/{tagName}/'.replace('{tagName}', tagName)).then(function(data) {
                app.headerView.show({ name: data.name, description: data.description });
                app.pods.reset(data.pods);
            });
        },
        tagsByFav: function() {
            if (!app.loggedIn) return;
            $('#tags-view').show();
            $('#tags-view h3.title').html('My favorite tags');
            $.get('/account/tags/favs/').then(function(data) {
                app.tags.reset(data);
            });
        },
        userByUsername: function(username) {
            $.get('/users/{username}/'.replace('{username}', username)).then(function(data) {
                if (!app.userView) app.userView = new UserView();
                app.userView.show(new User(data));
            });
        },
        conversationByParam: function(param) {
            if (!app.loggedIn) return;
            if (!app.messagesView) {
                app.messagesView = new MessagesView();
            }
            app.messagesView.show();
            if (/^\d+$/.test(param)) {
                this.conversationById(param);
            } else {
                this.conversationByUsername(param);
            }
        },
        conversationById: function(id) {
            app.messagesView.showConversation(id);
        },
        conversationByUsername: function(username) {
            app.messagesView.showConversationOrStartNew(username);
        },
        messages: function() {
{'fraction_non_alphanumeric': 0.1578577699736611, 'fraction_numerical': 0.0003511852502194908, 'mean_word_length': 1.2578790882061448, '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': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6772671', 'n_tokens_mistral': 2968, 'n_tokens_neox': 2946, 'n_words': 432}