<commit_before>import("helpers");
import("utils.*");

import("collab.collab_server");

import("editor.workspace");

import("pad.model");
import("pad.revisions");

jimport("collabode.Workspace");

jimport("java.lang.System");

const localhost = '0:0:0:0:0:0:0:1%0';

function render_acl() {
  var padId = workspace.accessAclPad();
  
  model.accessPadGlobal(padId, function(pad) {
    helpers.addClientVars({
      padId: padId,
      collab_client_vars: collab_server.getCollabClientVars(pad),
      initialRevisionList: revisions.getRevisionList(pad),
      serverTimestamp: +(new Date),
      initialOptions: pad.getPadOptionsObj(),
      userId: getSession().userId,
      userName: getSession().userName,
      opts: {}
    });
  });
  
  renderHtml("editor/acl.ejs", {
    projects: Workspace.listProjects()
  });
  return true;
}

function do_login(clazz, username, destination) {
  getSession().userId = clazz + '.' + username;
  getSession().userName = username;
  getSession().restricted = workspace.restricted(getSession().userId);
  response.redirect(destination);
}

function render_login(username, destination) {
  if (username != '') {
    do_login('r', username, destination);
  } else if (request.clientAddr == localhost) {
    do_login('u', 'admin', destination);
  } else {
    renderHtml("editor/login.ejs", { });
  }
  return true;
}

function login(destination) {
  var username = request.params.username.replace(/\s+/g, '').toLowerCase();
  do_login('r', username, destination);
  return true;
}

function logout() {
  delete getSession().userId;
  delete getSession().userName;
  delete getSession().restricted;
  response.redirect('/');
  return true;
}<commit_msg>More general localhost<commit_after>import("helpers");
import("utils.*");

import("collab.collab_server");

import("editor.workspace");

import("pad.model");
import("pad.revisions");

jimport("collabode.Workspace");

jimport("java.lang.System");

const localhost = /^0:0:0:0:0:0:0:1(%0)?$/;

function render_acl() {
  var padId = workspace.accessAclPad();
  
  model.accessPadGlobal(padId, function(pad) {
    helpers.addClientVars({
      padId: padId,
      collab_client_vars: collab_server.getCollabClientVars(pad),
      initialRevisionList: revisions.getRevisionList(pad),
      serverTimestamp: +(new Date),
      initialOptions: pad.getPadOptionsObj(),
      userId: getSession().userId,
      userName: getSession().userName,
      opts: {}
    });
  });
  
  renderHtml("editor/acl.ejs", {
    projects: Workspace.listProjects()
  });
  return true;
}

function do_login(clazz, username, destination) {
  getSession().userId = clazz + '.' + username;
  getSession().userName = username;
  getSession().restricted = workspace.restricted(getSession().userId);
  response.redirect(destination);
}

function render_login(username, destination) {
  if (username != '') {
    do_login('r', username, destination);
  } else if (request.clientAddr.match(localhost)) {
    do_login('u', 'admin', destination);
  } else {
    renderHtml("editor/login.ejs", { });
  }
  return true;
}

function login(destination) {
  var username = request.params.username.replace(/\s+/g, '').toLowerCase();
  do_login('r', username, destination);
  return true;
}

function logout() {
  delete getSession().userId;
  delete getSession().userName;
  delete getSession().restricted;
  response.redirect('/');
  return true;
}
{'fraction_non_alphanumeric': 0.16431095406360424, 'fraction_numerical': 0.00530035335689046, 'mean_word_length': 4.550653594771242, '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': '746369', 'n_tokens_mistral': 1099, 'n_tokens_neox': 1090, 'n_words': 187}