<commit_before># Argumenta instance, User, Storage and Errors classes
argumenta = require '../app/argumenta'
Storage   = require '../lib/argumenta/storage'
Errors    = require '../lib/argumenta/errors'

# Users index
exports.index = (req, res) ->
  argumenta.storage.getAllUsers (err, users) ->
    return res.reply 'index', 'Error loading users.' if err
    return res.reply 'users/index', title: 'Users', users: users

# Create a user via POST
exports.create = (req, res) ->
  options = {
    username:  req.body.username
    password:  <PASSWORD>
    email:     req.body.email
    join_date: new Date()
    join_ip:   req.ip
  }

  argumenta.users.create options, (err, user) ->
    if err
      return res.failed '/join', err.message,
        status: Errors.statusFor err
    else
      req.session.username = user.username
      return res.created "/users/#{user.username}",
        "Welcome aboard, #{user.username}!",
        user: user

# Show a user as html or json
exports.show = (req, res) ->
  name = req.param 'name'
  unless name?
    return res.reply 'index', error: "Error getting user: Missing name."

  argumenta.storage.getUser name, (err, user) ->
    return res.notFound "User '#{name}' not found" if err
    return res.reply 'users/user', user: user

# Show public overview of a user, including repos
exports.public = (req, res) ->
  name = req.param 'name'
  unless name?<commit_msg>Show public user page after joining.<commit_after># Argumenta instance, User, Storage and Errors classes
argumenta = require '../app/argumenta'
Storage   = require '../lib/argumenta/storage'
Errors    = require '../lib/argumenta/errors'

# Users index
exports.index = (req, res) ->
  argumenta.storage.getAllUsers (err, users) ->
    return res.reply 'index', 'Error loading users.' if err
    return res.reply 'users/index', title: 'Users', users: users

# Create a user via POST
exports.create = (req, res) ->
  options = {
    username:  req.body.username
    password:  <PASSWORD>
    email:     req.body.email
    join_date: new Date()
    join_ip:   req.ip
  }

  argumenta.users.create options, (err, user) ->
    if err
      return res.failed '/join', err.message,
        status: Errors.statusFor err
    else
      req.session.username = user.username
      return res.created "/#{user.username}",
        "Welcome aboard, #{user.username}!",
        user: user

# Show a user as html or json
exports.show = (req, res) ->
  name = req.param 'name'
  unless name?
    return res.reply 'index', error: "Error getting user: Missing name."

  argumenta.storage.getUser name, (err, user) ->
    return res.notFound "User '#{name}' not found" if err
    return res.reply 'users/user', user: user

# Show public overview of a user, including repos
exports.public = (req, res) ->
  name = req.param 'name'
  unless name?
{'fraction_non_alphanumeric': 0.13078826440438318, 'fraction_numerical': 0.0, 'mean_word_length': 3.008498583569405, 'pattern_counts': {'":': 0, '<': 5, '<?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': '2838879', 'n_tokens_mistral': 876, 'n_tokens_neox': 864, 'n_words': 286}