Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
437cdb6
feat: Add JSX renderer
mrjvs Jun 19, 2025
f662fee
feat: port messages.ejs to JSX
mrjvs Jun 19, 2025
c4a5918
feat: add util to easily build render context for JSX
mrjvs Jun 19, 2025
e873262
feat: Implement new JSX view to messages list page
mrjvs Jun 19, 2025
04d92a3
fix: handle removal cancelation
mrjvs Jun 19, 2025
10ef12a
fix: add proper build steps
mrjvs Jun 21, 2025
99ebbea
Fix JSX bugs
mrjvs Jun 21, 2025
13fb320
chore: add jsx files to nodemon reloader
mrjvs Jun 21, 2025
8940478
fix: Add html doctype to JSX rendered pages
mrjvs Jun 21, 2025
092ae6f
fix: Remove duplicate endpoint
mrjvs Jun 21, 2025
faa023c
feat(web): Added audit logs for moderator action
CaramelKat Jun 21, 2025
b04a3d6
feat(web): Log actions in admin endpoints
CaramelKat Jun 21, 2025
ce7ccd7
fix(web): Recommended and shop page toggels not working in community …
CaramelKat Jun 21, 2025
f2b467d
fix(web): revert accidental push in database file
CaramelKat Jun 21, 2025
fa718fb
fix(web): typos in moderate user page
CaramelKat Jun 21, 2025
c71cce8
fix: Remove bad parameters in feed endpoint
ashquarky Jun 22, 2025
f74d07d
Merge pull request #133 from PretendoNetwork/fix/delete-prompt-misfire
ashquarky Jun 22, 2025
e91e43a
feat: add support for directory based rendering of JSX
mrjvs Jun 22, 2025
b464e7e
feat: Add JSX view for portal
mrjvs Jun 22, 2025
12e07ed
feat: Add support for omitting doctype on some rendered jsx pages
mrjvs Jun 22, 2025
7f79fac
feat: Add messages view to CTR
mrjvs Jun 22, 2025
c8f7cbe
fix: Fix express.d.ts types
mrjvs Jun 22, 2025
91e5f33
fix: Fix bugs when rendering portal version of jsx
mrjvs Jun 22, 2025
7823fec
Merge pull request #135 from PretendoNetwork/fix/global-feed-bug
mrjvs Jun 22, 2025
0ce37d6
fix(web): remove default enum value
CaramelKat Jun 22, 2025
98d1c75
chore(web): update user settings and community variables to be more c…
CaramelKat Jun 22, 2025
94603d1
chore(web): remove TODO that had already been resolved
CaramelKat Jun 22, 2025
40f86d8
Add SVG todos
mrjvs Jun 24, 2025
92cc451
Add typing to conversations in tsx view
mrjvs Jun 24, 2025
74e6c30
chore: update eslint config
mrjvs Jun 24, 2025
f4cda44
chore(web): increase audit log history to 20 items
CaramelKat Jun 24, 2025
4c5b57d
feat(web): make audit log strings easier to read
CaramelKat Jun 24, 2025
c42eb40
feat(web): keep track of fields that are changed in the audit log so …
CaramelKat Jun 24, 2025
2dd1123
feat(web): keep track of fields that are changed in the audit log so …
CaramelKat Jun 24, 2025
6c6c490
chore(web): remove endpoint that wasn't meant to be added
CaramelKat Jun 24, 2025
603c7a2
fix(web): set all fields to be required for the audit log schema
CaramelKat Jun 24, 2025
8c561b7
fix(web): schema validation fails when no changes were made to the us…
CaramelKat Jun 24, 2025
477c758
Merge pull request #132 from PretendoNetwork/feat/jsx
ashquarky Jun 25, 2025
b49df5e
Merge pull request #136 from PretendoNetwork/work/audit-log
ashquarky Jun 25, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,7 @@
},
"javascript.preferences.importModuleSpecifier": "non-relative",
"typescript.preferences.importModuleSpecifier": "non-relative",
"[typescriptreact]": {
"editor.defaultFormatter": "dbaeumer.vscode-eslint"
},
}
2 changes: 1 addition & 1 deletion apps/juxtaposition-ui/nodemon.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"watch": [
"src/"
],
"ext": "js,ts,ejs,json,css",
"ext": "js,ts,ejs,tsx,jsx,json,css",
"env": {
"NODE_ENV": "development"
}
Expand Down
8 changes: 7 additions & 1 deletion apps/juxtaposition-ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"@neato/config": "^3.0.0",
"@pretendonetwork/grpc": "^2.0.1",
"@repo/grpc-client": "^0.0.0",
"classnames": "^2.5.1",
"colors": "^1.4.0",
"connect-redis": "^8.0.1",
"cookie-parser": "^1.4.7",
Expand Down Expand Up @@ -46,14 +47,19 @@
"pjax": "^0.2.8",
"pngjs": "^7.0.0",
"prom-client": "^15.1.3",
"react": "^19.1.0",
"react-dom": "^19.1.0",
"redis": "^4.7.0",
"sharp": "^0.33.5",
"tga": "^1.0.7",
"tsx": "^4.19.3"
},
"devDependencies": {
"@pretendonetwork/eslint-config": "^0.0.8",
"@pretendonetwork/eslint-config": "^0.0.11",
"@types/hashmap": "^2.3.4",
"@types/node": "^22.13.8",
"@types/react": "^19.1.8",
"@types/react-dom": "^19.1.6",
"browserslist": "^4.24.5",
"browserslist-to-esbuild": "^2.1.1",
"ejs-lint": "^2.0.1",
Expand Down
9 changes: 8 additions & 1 deletion apps/juxtaposition-ui/src/database.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const { NOTIFICATION } = require('@/models/notifications');
const { POST } = require('@/models/post');
const { SETTINGS } = require('@/models/settings');
const { REPORT } = require('@/models/report');
const { LOGS } = require('@/models/logs');
const { logger } = require('@/logger');
const { config } = require('@/config');

Expand Down Expand Up @@ -506,6 +507,11 @@ async function getReportById(id) {
return REPORT.findById(id);
}

async function getLogsForTarget(targetPID, offset, limit) {
verifyConnected();
return LOGS.find({ target: targetPID }).sort({ timestamp: -1 }).skip(offset).limit(limit);
}

module.exports = {
connect,
getCommunities,
Expand Down Expand Up @@ -563,5 +569,6 @@ module.exports = {
getReportsByOffender,
getReportsByPost,
getDuplicateReports,
getReportById
getReportById,
getLogsForTarget
};
37 changes: 37 additions & 0 deletions apps/juxtaposition-ui/src/middleware/jsx.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import { renderToStaticMarkup } from 'react-dom/server';
import type { RequestHandler } from 'express';

const htmlDoctype = '<!DOCTYPE html>';

/**
* Render JSX as static markup. Only static! No state or event handlers are supported.
*/
export const jsxRenderer: RequestHandler = (request, response, next) => {
response.jsx = (el, addDoctype): typeof response => {
const prefix = addDoctype ? htmlDoctype + '\n' : '';
response.send(prefix + renderToStaticMarkup(el));
return response;
};

response.jsxForDirectory = (opt): typeof response => {
const disabledFor = opt.disableDoctypeFor ?? [];
const directory = request.directory;
if (directory === 'ctr' && opt.ctr) {
response.jsx(opt.ctr, !disabledFor.includes('ctr'));
return response;
}

if (directory === 'portal' && opt.portal) {
response.jsx(opt.portal, !disabledFor.includes('portal'));
return response;
}

if (directory === 'web' && opt.web) {
response.jsx(opt.web, !disabledFor.includes('web'));
return response;
}

throw new Error('Invalid directory to render JSX for');
};
next();
};
51 changes: 51 additions & 0 deletions apps/juxtaposition-ui/src/models/logs.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
const { Schema, model } = require('mongoose');

const actionEnum = [
'REMOVE_POST',
'IGNORE_REPORT',
'LIMIT_POSTING',
'TEMP_BAN',
'PERMA_BAN',
'UNBAN',
'UPDATE_USER',
'MAKE_COMMUNITY',
'UPDATE_COMMUNITY',
'DELETE_COMMUNITY'
];

const auditLogSchema = new Schema({
actor: {
type: Number,
required: true
},
action: {
type: String,
enum: actionEnum,
required: true
},
target: {
type: String,
required: true
},
context: {
type: String,
required: true
},
timestamp: {
type: Date,
default: Date.now,
required: true
},
changed_fields: {
type: [String],
default: [],
required: true
}
});

const LOGS = model('LOGS', auditLogSchema);

module.exports = {
auditLogSchema,
LOGS
};
2 changes: 2 additions & 0 deletions apps/juxtaposition-ui/src/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const { redisClient } = require('@/redisCache');
const juxt_web = require('@/services/juxt-web');
const { healthzRouter } = require('@/services/healthz');
const { config } = require('@/config');
const { jsxRenderer } = require('@/middleware/jsx');

process.title = 'Pretendo - Juxt-Web';
process.on('SIGTERM', () => {
Expand Down Expand Up @@ -49,6 +50,7 @@ app.get('/ip', (request, response) => response.send(request.ip));

// Create router
logger.info('Setting up Middleware');
app.use(jsxRenderer);
app.use(loggerHttp);
app.use(express.json());
app.use(healthzRouter);
Expand Down
Loading