Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

style: Update title tags in HTML files for consistency and clarity #22

Merged
merged 2 commits into from
Nov 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ app.use(expressLayouts);

app.use(appLocalStateMiddleware);

reload({ app, watch: [{ path: './src/views/pages', extensions: ['.html'] }] });
reload({ app, watch: [{ path: './src/views', extensions: ['.html'] }] });

app.use(router);

Expand Down
18 changes: 18 additions & 0 deletions src/handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
export function getTermsOfServicePageHandler(req: Request, res: Response) {
res.render('terms-of-service.html', {
path: '/terms-of-service',
title: 'Terms of Service',
});
}

Expand All @@ -34,6 +35,7 @@

res.render('home.html', {
path: '/',
title: 'web 2.0 style notification systems for discord, email, and sms',
});
}

Expand Down Expand Up @@ -62,6 +64,7 @@
// GET /settings
export async function getSettingsPageHandler(req: Request, res: Response) {
return res.render('settings-account.html', {
title: 'Settings',
user: req.session?.user,
path: '/settings',
layout: '../layouts/settings.html',
Expand Down Expand Up @@ -152,6 +155,7 @@
.from('users');

return res.render('admin-users.html', {
title: 'Admin Users',
users,
path: '/admin/users',
layout: '../layouts/admin.html',
Expand All @@ -161,6 +165,7 @@
// GET /settings/account
export async function getSettingsAccountPageHandler(req: Request, res: Response) {
return res.render('settings-account.html', {
title: 'Account',
user: req.session?.user,
path: '/settings/account',
layout: '../layouts/settings.html',
Expand All @@ -170,6 +175,7 @@
// GET /settings/data
export async function getSettingsDataPageHandler(req: Request, res: Response) {
return res.render('settings-data.html', {
title: 'Data',
user: req.session?.user,
path: '/settings/data',
layout: '../layouts/settings.html',
Expand Down Expand Up @@ -248,6 +254,7 @@
// GET /settings/danger-zone
export async function getSettingsDangerZonePageHandler(req: Request, res: Response) {
return res.render('settings-danger-zone.html', {
title: 'Danger Zone',
user: req.session?.user,
path: '/settings/danger-zone',
layout: '../layouts/settings.html',
Expand Down Expand Up @@ -350,6 +357,7 @@
const path = `${basePath}?${queryParams.toString()}`;

return res.render('notifications.html', {
title: 'Notifications',
notifications,
pagination,
path,
Expand Down Expand Up @@ -401,6 +409,7 @@
const path = `${basePath}?${queryParams.toString()}`;

return res.render('apps.html', {
title: 'Apps',
apps,
filter,
path,
Expand Down Expand Up @@ -439,6 +448,7 @@
}

return res.render('apps-id.html', {
title: 'App',
app,
layout: '../layouts/app.html',
path: `/apps/${app.id}`,
Expand Down Expand Up @@ -512,6 +522,7 @@
.first();

return res.render('apps-id-edit.html', {
title: 'App Edit',
app,
layout: '../layouts/app.html',
path: `/apps/${app.id}`,
Expand Down Expand Up @@ -642,7 +653,7 @@
},
);
} catch (error) {
const message = ((error as AxiosError).response as any)?.data.message;

Check warning on line 656 in src/handler.ts

View workflow job for this annotation

GitHub Actions / ESLint (22.x)

Unexpected any. Specify a different type
return res.redirect(`/apps/${id}?toast=${message}`);
}

Expand Down Expand Up @@ -727,6 +738,7 @@
}

return res.render('apps-id-channels-id-edit.html', {
title: 'App Channel',
app,
channel,
config,
Expand Down Expand Up @@ -871,6 +883,7 @@
}

return res.render('apps-id-channels-import.html', {
title: 'App Channel Import',
app,
layout: '../layouts/app.html',
path: `/apps/${app.id}/channels`,
Expand Down Expand Up @@ -916,7 +929,7 @@
acc[key] = value;
}
return acc;
}, {} as any);

Check warning on line 932 in src/handler.ts

View workflow job for this annotation

GitHub Actions / ESLint (22.x)

Unexpected any. Specify a different type

await trx(`${channel_type_name}_configs`).insert({
app_channel_id: appChannel.id,
Expand Down Expand Up @@ -956,7 +969,7 @@
.first();

if (config) {
const { created_at, updated_at, app_channel_id, id, name, ...cleanedConfig } = config;

Check warning on line 972 in src/handler.ts

View workflow job for this annotation

GitHub Actions / ESLint (22.x)

'created_at' is assigned a value but never used. Allowed unused vars must match /^_/u

Check warning on line 972 in src/handler.ts

View workflow job for this annotation

GitHub Actions / ESLint (22.x)

'updated_at' is assigned a value but never used. Allowed unused vars must match /^_/u

Check warning on line 972 in src/handler.ts

View workflow job for this annotation

GitHub Actions / ESLint (22.x)

'app_channel_id' is assigned a value but never used. Allowed unused vars must match /^_/u

Check warning on line 972 in src/handler.ts

View workflow job for this annotation

GitHub Actions / ESLint (22.x)

'id' is assigned a value but never used. Allowed unused vars must match /^_/u

const decryptedConfig = Object.entries(cleanedConfig).reduce((acc, [key, value]) => {
if (typeof value === 'string') {
Expand All @@ -965,7 +978,7 @@
acc[key] = value;
}
return acc;
}, {} as any);

Check warning on line 981 in src/handler.ts

View workflow job for this annotation

GitHub Actions / ESLint (22.x)

Unexpected any. Specify a different type

decryptedConfig.name = name;
return { channel_type_name, config: decryptedConfig };
Expand Down Expand Up @@ -1077,6 +1090,7 @@
}

return res.render('apps-id-channels.html', {
title: 'App Channels',
app,
layout: '../layouts/app.html',
path: `/apps/${app.id}/channels`,
Expand All @@ -1096,6 +1110,7 @@
}

return res.render('apps-id-channels-create.html', {
title: 'App Channels Create',
app,
layout: '../layouts/app.html',
path: `/apps/${app.id}/channels/create`,
Expand Down Expand Up @@ -1222,6 +1237,7 @@
}

return res.render('apps-id-settings.html', {
title: 'App Settings',
app,
layout: '../layouts/app.html',
path: `/apps/${app.id}/settings`,
Expand Down Expand Up @@ -1271,6 +1287,7 @@
.paginate({ perPage, currentPage, isLengthAware: true });

return res.render('apps-id-notifications.html', {
title: 'App Notifications',
app: {
...app,
notifications: result.data,
Expand All @@ -1284,6 +1301,7 @@
// GET /apps/create
export async function getCreateNewAppPageHandler(req: Request, res: Response) {
return res.render('apps-create.html', {
title: 'App Create',
layout: '../layouts/auth.html',
path: '/apps/create',
});
Expand Down
36 changes: 24 additions & 12 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -300,13 +300,25 @@ export function reload({
const pollInterval = options.pollInterval || 50;
const quiet = options.quiet || false;
let changeDetected = false;
const lastContents = new Map<string, string>();

watch.forEach(({ path: dir, extensions }) => {
const extensionsSet = new Set(extensions);
fs.watch(dir, { recursive: true }, (_: fs.WatchEventType, filename: string | null) => {
if (filename && extensionsSet.has(filename.slice(filename.lastIndexOf('.')))) {
if (!quiet) logger.info('[reload] File changed: %s', filename);
changeDetected = true;
try {
const fullPath = path.join(dir, filename);
const content = fs.readFileSync(fullPath, 'utf8');

if (content !== lastContents.get(fullPath)) {
lastContents.set(fullPath, content);

if (!quiet) logger.info('[reload] File changed: %s', filename);
changeDetected = true;
}
} catch {
if (!quiet) logger.debug('[reload] Error reading file: %s', filename);
}
}
});
});
Expand All @@ -324,16 +336,16 @@ export function reload({
});

const clientScript = `
<script>
(async function poll() {
try {
await fetch('/wait-for-reload');
location.reload();
} catch {
location.reload();
}
})();
</script>\n\t`;
<script>
(async function poll() {
try {
await fetch('/wait-for-reload');
location.reload();
} catch {
location.reload();
}
})();
</script>\n\t`;

app.use((req: Request, res: Response, next: NextFunction) => {
const originalSend = res.send.bind(res);
Expand Down
2 changes: 1 addition & 1 deletion src/views/components/head.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Notify</title>
<title>Notify - <%= title %></title>
<meta name="description" content="web 2.0 style notification systems for discord, email, and sms" />
<meta name="keywords" content="notify, notifications, alerts, messaging, web service, discord, sms" />
<meta name="author" content="wajeht" />
Expand Down
Loading