<commit_before># @file main.coffee
# @brief Defines the routes and javascript events for the gitorial app

window.gitorial = {}

# Session
gitorial.session =
    update: ->
        $.ajax
            dataType: 'json'
            type: 'GET'
            url: '/api/session/'
            headers:
                'x-csrftoken' : $.cookie 'csrftoken'
        .done (data) ->
            gitorial.session.username = data.username
            gitorial.session.loggedin = data.username isnt ""
            return
        .fail gitorial.routes.fail
        return
        
    username: null
    loggedin: false

# Templating
gitorial.templates =
    profile: Handlebars.compile $("#profile-template").html()
    edit: Handlebars.compile $("#edit-template").html()
    view: Handlebars.compile $("#view-template").html()
    home: Handlebars.compile $("#home-template").html()
    fail: Handlebars.compile $("#not-found-template").html()

# Routing
gitorial.routes =
    home: ->
        data =
            gitorial: gitorial
        $('#container').html gitorial.templates.home data
        return

    tutorialPane: true

    profile: (params) ->
        address = '/api/' + params[0] + '/'
        $.ajax
            dataType: 'json'
            url: address
            type: 'GET'
            headers:
                'x-csrftoken' : $.cookie 'csrftoken'
        .done (data) ->
            data.isowner = gitorial.session.username is params[0]
            data.tutorialPane = gitorial.routes.tutorialPane
            data.reposPane = not data.tutorialPane
            data.gitorial = gitorial
            $('#container').html gitorial.templates.profile data
            $ '.new-tutorial-button'

            # Event listeners
            .on 'click', (e) ->
                gitorial.routes.tutorialPane = not gitorial.routes.tutorialPane
                gitorial.router()
                return

            $ '.user-listing-title'
            .on 'hover', (e) -> $(this).text += ' +'
            .on 'click', (e) -> 
                gitorial.tutorials.utils.makeNew(e)
                return<commit_msg>Fixed error<commit_after># @file main.coffee
# @brief Defines the routes and javascript events for the gitorial app

window.gitorial = {}

# Session
gitorial.session =
    update: ->
        $.ajax
            dataType: 'json'
            type: 'GET'
            url: '/api/session/'
            headers:
                'x-csrftoken' : $.cookie 'csrftoken'
        .done (data) ->
            gitorial.session.username = data.username
            gitorial.session.loggedin = data.username isnt ""
            return
        .fail gitorial.routes.fail
        return
        
    username: null
    loggedin: false

# Templating
gitorial.templates =
    profile: Handlebars.compile $("#profile-template").html()
    edit: Handlebars.compile $("#edit-template").html()
    view: Handlebars.compile $("#view-template").html()
    home: Handlebars.compile $("#home-template").html()
    fail: Handlebars.compile $("#not-found-template").html()

# Routing
gitorial.routes =
    home: ->
        data =
            gitorial: gitorial
        $('#container').html gitorial.templates.home data
        return

    tutorialPane: true

    profile: (params) ->
        address = '/api/' + params[0] + '/'
        $.ajax
            dataType: 'json'
            url: address
            type: 'GET'
            headers:
                'x-csrftoken' : $.cookie 'csrftoken'
        .done (data) ->
            data.isowner = gitorial.session.username is params[0]
            data.tutorialPane = gitorial.routes.tutorialPane
            data.reposPane = not data.tutorialPane
            data.gitorial = gitorial
            $('#container').html gitorial.templates.profile data
            $ '.new-tutorial-button'

            # Event listeners
            .on 'click', (e) ->
                gitorial.routes.tutorialPane = not gitorial.routes.tutorialPane
                gitorial.router()
                return

            $ '.user-listing-title'
            .on 'hover', (e) -> $(this).text($(this).text() += ' +')
            .on 'click', (e) -> 
                gitorial.tutorials.utils.makeNew(e)
                return
{'fraction_non_alphanumeric': 0.12796208530805686, 'fraction_numerical': 0.0009478672985781991, 'mean_word_length': 1.7075048107761386, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 19, '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': '4410948', 'n_tokens_mistral': 1240, 'n_tokens_neox': 1209, 'n_words': 252}