Skip to content

Commit

Permalink
Sync up with master
Browse files Browse the repository at this point in the history
  • Loading branch information
NuSkooler committed Sep 3, 2023
2 parents cc42812 + b307e79 commit de4e3a1
Show file tree
Hide file tree
Showing 24 changed files with 203 additions and 68 deletions.
9 changes: 9 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
FROM library/node:lts-bookworm

ARG DEBIAN_FRONTEND=noninteractive
RUN apt update \
&& apt install -y --no-install-recommends sudo telnet \
&& apt autoremove -y \
&& rm -rf /var/lib/apt/lists/* \
&& echo "node ALL=(ALL) NOPASSWD: ALL" >/etc/sudoers.d/node \
&& chmod 0440 /etc/sudoers.d/node
32 changes: 32 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"name": "Basic Node.js",
"build": { "dockerfile": "Dockerfile" },
"remoteUser": "root",
"forwardPorts": [8888, 4000],
"postCreateCommand": "gem install jekyll bundler && /bin/rm -rf node_modules && npm install && cd docs && bundle install && cd ..",
"features": {
"ghcr.io/devcontainers/features/python:1": {
"installTools": true,
"version": "latest"
},
"ghcr.io/devcontainers-contrib/features/curl-apt-get:1": {},
"ghcr.io/jungaretti/features/ripgrep:1": {},
"ghcr.io/warrenbuckley/codespace-features/sqlite:1": {},
"ghcr.io/devcontainers/features/ruby:1": {
"version": "3.1"
}
},
"customizations": {
"vscode": {
"extensions": [
"ms-azuretools.vscode-docker",
"alexcvzz.vscode-sqlite",
"yzhang.markdown-all-in-one",
"DavidAnson.vscode-markdownlint",
"christian-kohler.npm-intellisense",
"dbaeumer.vscode-eslint",
"bierner.markdown-yaml-preamble"
]
}
}
}
10 changes: 10 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,13 @@
*.TXT eol=crlf
*.diz eol=crlf
*.DIZ eol=crlf

# Don't mess with shell script line endings
*.sh text eol=lf

# Same thing for optutil.js which functions as a shell script
optutil.js text eol=lf

# The devcontainer is also unix
.devcontainer/Dockerfile text eol=lf
.devcontainer/devcontainer.json text eol=lf
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,4 @@ logs/
mail/
node_modules/
docs/_site/
docs/.sass-cache/
.vscode/
docs/.sass-cache/
3 changes: 3 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"recommendations": ["ms-vscode-remote.remote-containers", "laktak.hjson"]
}
15 changes: 15 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Launch Program",
"skipFiles": ["<node_internals>/**"],
"program": "${workspaceFolder}/main.js"
}
]
}
26 changes: 26 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"version": "2.0.0",
"tasks": [
{
"label": "Start Jekyll (ENiGMA½ documentation server)",
"command": "cd docs && bundle exec jekyll serve",
"isBackground": true,
"type": "shell"
},
{
"label": "(re)build Jekyll bundles",
"command": "cd docs && bundle install",
"type": "shell"
},
{
"label": "(re)build node modules",
"command": "/bin/rm -rf node_modules && npm install",
"type": "shell"
},
{
"label": "ENiGMA½ new configuration",
"command": "./oputil.js config new",
"type": "shell"
}
]
}
1 change: 1 addition & 0 deletions WHATSNEW.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ This document attempts to track **major** changes and additions in ENiGMA½. For
* New `NewUserPrePersist` system event available to developers to 'hook' account creation and add their own properties/etc.
* The signature for `viewValidationListener`'s callback has changed: It is now `(err, newFocusId)`. To ignore a validation error, implementors can simply call the callback with a `null` error, else they should forward it on.
* The Menu Flag `popParent` has been removed and `noHistory` has been updated to work as expected. In general things should "Just Work", but do see [UPGRADE](UPGRADE.md) for additional details.
* Various New User Application (NUA) properties are now optional. If you would like to reduce the information users are required, remove optional fields from NUA artwork and collect less. These properties will be stored as "" (empty). Optional properties are as follows: Real name, Birth date, Sex, Location, Affiliations (Affils), Email, and Web address.
* Art handling has been changed to respect the art width contained in SAUCE when present in the case where the terminal width is greater than the art width. This fixes art files that assume wrapping at 80 columns on wide (mostly new utf8) terminals.

## 0.0.13-beta
Expand Down
6 changes: 3 additions & 3 deletions core/achievement.js
Original file line number Diff line number Diff line change
Expand Up @@ -505,9 +505,9 @@ class Achievements {
getFormatObject(info) {
return {
userName: info.user.username,
userRealName: info.user.properties[UserProps.RealName],
userLocation: info.user.properties[UserProps.Location],
userAffils: info.user.properties[UserProps.Affiliations],
userRealName: info.user.realName(false) || 'N/A',
userLocation: info.user.properties[UserProps.Location] || 'N/A',
userAffils: info.user.properties[UserProps.Affiliations] || 'N/A',
nodeId: info.client.node,
title: info.details.title,
//text : info.global ? info.details.globalText : info.details.text,
Expand Down
4 changes: 2 additions & 2 deletions core/ansi_escape_parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ function ANSIEscapeParser(options) {
this.graphicRendition = {};

this.parseState = {
re: /(?:\x1b\x5b)([?=;0-9]*?)([ABCDHJKfhlmnpsu])/g, // eslint-disable-line no-control-regex
re: /(?:\x1b\x5b)([?=;0-9]*?)([ABCDHJKfhlmnpsutEFGST])/g, // eslint-disable-line no-control-regex
};

options = miscUtil.valueWithDefault(options, {
Expand Down Expand Up @@ -231,7 +231,7 @@ function ANSIEscapeParser(options) {
self.parseState = {
// ignore anything past EOF marker, if any
buffer: input.split(String.fromCharCode(0x1a), 1)[0],
re: /(?:\x1b\x5b)([?=;0-9]*?)([ABCDHJKfhlmnpsu])/g, // eslint-disable-line no-control-regex
re: /(?:\x1b\x5b)([?=;0-9]*?)([ABCDHJKfhlmnpsutEFGST])/g, // eslint-disable-line no-control-regex
stop: false,
};
};
Expand Down
4 changes: 2 additions & 2 deletions core/art.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,13 @@ const SUPPORTED_ART_TYPES = {
};

function getFontNameFromSAUCE(sauce) {
if (sauce.Character) {
if (sauce && sauce.Character) {
return sauce.Character.fontName;
}
}

function getWidthFromSAUCE(sauce) {
if (sauce.Character) {
if (sauce && sauce.Character) {
let sauceWidth = _.toNumber(sauce.Character.characterWidth);
if (!_.isNaN(sauceWidth) && sauceWidth > 0) {
return sauceWidth;
Expand Down
2 changes: 1 addition & 1 deletion core/client_connections.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ function getActiveConnectionList(
//
entry.text = ac.user?.username || 'N/A';
entry.userName = ac.user?.username || 'N/A';
entry.realName = ac.user?.getProperty(UserProps.RealName) || 'N/A';
entry.realName = ac.user?.realName(false) || 'N/A';
entry.location = ac.user?.getProperty(UserProps.Location) || 'N/A';
entry.affils = entry.affiliation =
ac.user?.getProperty(UserProps.Affiliations) || 'N/A';
Expand Down
6 changes: 1 addition & 5 deletions core/fse.js
Original file line number Diff line number Diff line change
Expand Up @@ -1017,11 +1017,7 @@ exports.FullScreenEditorModule =
const area = getMessageAreaByTag(self.messageAreaTag);
if (fromView !== undefined) {
if (area && area.realNames) {
fromView.setText(
self.client.user.properties[
UserProps.RealName
] || self.client.user.username
);
fromView.setText(self.client.user.realName());
} else {
fromView.setText(self.client.user.username);
}
Expand Down
6 changes: 1 addition & 5 deletions core/my_messages.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
// ENiGMA½
const { MenuModule, MenuFlags } = require('./menu_module');
const Message = require('./message.js');
const UserProps = require('./user_property.js');
const { filterMessageListByReadACS } = require('./message_area.js');

exports.moduleInfo = {
Expand All @@ -21,10 +20,7 @@ exports.getModule = class MyMessagesModule extends MenuModule {

initSequence() {
const filter = {
toUserName: [
this.client.user.username,
this.client.user.getProperty(UserProps.RealName),
],
toUserName: [this.client.user.username, this.client.user.realName()],
sort: 'modTimestamp',
resultType: 'messageList',
limit: 1024 * 16, // we want some sort of limit...
Expand Down
15 changes: 8 additions & 7 deletions core/nua.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const UserProps = require('./user_property.js');

// deps
const _ = require('lodash');
const moment = require('moment');

exports.moduleInfo = {
name: 'NUA',
Expand Down Expand Up @@ -95,15 +96,15 @@ exports.getModule = class NewUserAppModule extends MenuModule {
areaTag = areaTag || '';

newUser.properties = {
[UserProps.RealName]: formData.value.realName,
[UserProps.RealName]: formData.value.realName || '',
[UserProps.Birthdate]: getISOTimestampString(
formData.value.birthdate
formData.value.birthdate || moment()
),
[UserProps.Sex]: formData.value.sex,
[UserProps.Location]: formData.value.location,
[UserProps.Affiliations]: formData.value.affils,
[UserProps.EmailAddress]: formData.value.email,
[UserProps.WebAddress]: formData.value.web,
[UserProps.Sex]: formData.value.sex || '',
[UserProps.Location]: formData.value.location || '',
[UserProps.Affiliations]: formData.value.affils || '',
[UserProps.EmailAddress]: formData.value.email || '',
[UserProps.WebAddress]: formData.value.web || '',
[UserProps.AccountCreated]: getISOTimestampString(),

[UserProps.MessageConfTag]: confTag,
Expand Down
27 changes: 19 additions & 8 deletions core/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,18 +128,29 @@ module.exports = class User {
return isMember;
}

getSanitizedName(type = 'username') {
let name;
switch (type) {
case 'real':
name = this.getProperty(UserProps.RealName) || this.username;
break;
default:
name = this.username;
realName(withUsernameFallback = true) {
const realName = this.getProperty(UserProps.RealName);
if (realName) {
return realName;
}
if (withUsernameFallback) {
return this.username;
}
}

getSanitizedName(type = 'username') {
const name = 'real' === type ? this.realName(true) : this.username;
return sanatizeFilename(name) || `user${this.userId.toString()}`;
}

emailAddress() {
const email = this.getProperty(UserProps.EmailAddress);
if (email) {
const realName = this.realName(false);
return realName ? `${realName} <${email}>` : email;
}
}

isAvailable() {
return (this.statusFlags & User.StatusFlags.NotAvailable) == 0;
}
Expand Down
4 changes: 1 addition & 3 deletions core/user_2fa_otp_web_register.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,7 @@ module.exports = class User2FA_OTPWebRegister {
}

const message = {
to: `${
user.getProperty(UserProps.RealName) || user.username
} <${user.getProperty(UserProps.EmailAddress)}>`,
to: user.emailAddress(),
// from will be filled in
subject: '2-Factor Authentication Registration',
text: textTemplate,
Expand Down
16 changes: 8 additions & 8 deletions core/user_config.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,15 +116,15 @@ exports.getModule = class UserConfigModule extends MenuModule {
formData = _.clone(formData);

const newProperties = {
[UserProps.RealName]: formData.value.realName,
[UserProps.RealName]: formData.value.realName || '',
[UserProps.Birthdate]: getISOTimestampString(
formData.value.birthdate
formData.value.birthdate || moment()
),
[UserProps.Sex]: formData.value.sex,
[UserProps.Location]: formData.value.location,
[UserProps.Affiliations]: formData.value.affils,
[UserProps.EmailAddress]: formData.value.email,
[UserProps.WebAddress]: formData.value.web,
[UserProps.Sex]: formData.value.sex || '',
[UserProps.Location]: formData.value.location || '',
[UserProps.Affiliations]: formData.value.affils || '',
[UserProps.EmailAddress]: formData.value.email || '',
[UserProps.WebAddress]: formData.value.web || '',
[UserProps.TermHeight]: formData.value.termHeight.toString(),
[UserProps.ThemeId]:
self.availThemeInfo[formData.value.theme].themeId,
Expand Down Expand Up @@ -237,7 +237,7 @@ exports.getModule = class UserConfigModule extends MenuModule {
self.setViewText(
'menu',
MciCodeIds.RealName,
user.properties[UserProps.RealName]
user.realName(false) || ''
);
self.setViewText(
'menu',
Expand Down
4 changes: 1 addition & 3 deletions core/web_password_reset.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,9 +146,7 @@ class WebPasswordReset {
}

const message = {
to: `${user.properties[UserProps.RealName] || user.username} <${
user.properties[UserProps.EmailAddress]
}>`,
to: user.emailAddress(),
// from will be filled in
subject: 'Forgot Password',
text: textTemplate,
Expand Down
4 changes: 1 addition & 3 deletions core/wfc.js
Original file line number Diff line number Diff line change
Expand Up @@ -506,9 +506,7 @@ exports.getModule = class WaitingForCallerModule extends MenuModule {

// Current
currentUserName: this.client.user.username,
currentUserRealName:
this.client.user.getProperty(UserProps.RealName) ||
this.client.user.username,
currentUserRealName: this.client.user.realName(false) || 'N/A',
availIndicator: availIndicator,
visIndicator: visIndicator,
lastLoginUserName: lastLoginStats.userName,
Expand Down
1 change: 1 addition & 0 deletions docs/Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,4 @@ end
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem "tzinfo-data", platforms: [:mingw, :mswin, :x64_mingw, :jruby]

gem "webrick"
Loading

0 comments on commit de4e3a1

Please sign in to comment.