Skip to content

Commit

Permalink
Update references public>liquid
Browse files Browse the repository at this point in the history
  • Loading branch information
kennsippell committed Feb 22, 2024
1 parent de53759 commit bc9121a
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 14 deletions.
6 changes: 3 additions & 3 deletions src/routes/add-place.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export default async function addPlace(fastify: FastifyInstance) {
contactTypes,
};

return resp.view('src/public/app/view.html', tmplData);
return resp.view('src/liquid/app/view.html', tmplData);
});

// you want to create a place? replace a contact? you'll have to go through me first
Expand All @@ -53,7 +53,7 @@ export default async function addPlace(fastify: FastifyInstance) {
const csvBuf = await fileData.toBuffer();
await PlaceFactory.createBulk(csvBuf, contactType, sessionCache, chtApi);
} catch (error) {
return fastify.view('src/public/place/bulk_create_form.html', {
return fastify.view('src/liquid/place/bulk_create_form.html', {
contactType,
errors: {
message: error,
Expand Down Expand Up @@ -94,7 +94,7 @@ export default async function addPlace(fastify: FastifyInstance) {
};

resp.header('HX-Push-Url', `/place/edit/${id}`);
return resp.view('src/public/app/view.html', tmplData);
return resp.view('src/liquid/app/view.html', tmplData);
});

fastify.post('/place/edit/:id', async (req, resp) => {
Expand Down
2 changes: 1 addition & 1 deletion src/routes/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export default async function sessionCache(fastify: FastifyInstance) {
op,
};

return resp.view('src/public/app/view.html', tmplData);
return resp.view('src/liquid/app/view.html', tmplData);
});

fastify.post('/app/remove-all', async (req) => {
Expand Down
4 changes: 2 additions & 2 deletions src/routes/authentication.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export default async function authentication(fastify: FastifyInstance) {
domains: Config.getDomains,
};

return resp.view('src/public/auth/view.html', tmplData);
return resp.view('src/liquid/auth/view.html', tmplData);
});

fastify.get('/logout', unauthenticatedOptions, async (req, resp) => {
Expand All @@ -35,7 +35,7 @@ export default async function authentication(fastify: FastifyInstance) {
try {
session = await ChtApi.createSession(authInfo, username, password);
} catch (e: any) {
return resp.view('src/public/auth/authentication_form.html', {
return resp.view('src/liquid/auth/authentication_form.html', {
domains: Config.getDomains,
errors: true,
});
Expand Down
2 changes: 1 addition & 1 deletion src/routes/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export default async function events(fastify: FastifyInstance) {
hierarchy: Config.getHierarchyWithReplacement(item, 'desc'),
};
});
return resp.view('src/public/place/list.html', {
return resp.view('src/liquid/place/list.html', {
contactTypes: placeData,
session: req.chtSession,
});
Expand Down
6 changes: 3 additions & 3 deletions src/routes/move.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export default async function sessionCache(fastify: FastifyInstance) {
...moveViewModel(contactType),
};

return resp.view('src/public/app/view.html', tmplData);
return resp.view('src/liquid/app/view.html', tmplData);
});

fastify.post('/move', async (req, resp) => {
Expand All @@ -35,7 +35,7 @@ export default async function sessionCache(fastify: FastifyInstance) {

try {
const tmplData = await MoveLib.move(formData, contactType, sessionCache, chtApi);
return resp.view('src/public/components/move_result.html', tmplData);
return resp.view('src/liquid/components/move_result.html', tmplData);
} catch (e: any) {
const tmplData = {
view: 'move',
Expand All @@ -48,7 +48,7 @@ export default async function sessionCache(fastify: FastifyInstance) {
error: e.toString(),
};

return resp.view('src/public/place/move_form.html', tmplData);
return resp.view('src/liquid/place/move_form.html', tmplData);
}
});
}
Expand Down
4 changes: 2 additions & 2 deletions src/routes/search.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export default async function place(fastify: FastifyInstance) {
}
const searchResults: RemotePlace[] = await SearchLib.search(contactType, data, dataPrefix, hierarchyLevel, chtApi, sessionCache);

return resp.view('src/public/components/search_results.html', {
return resp.view('src/liquid/components/search_results.html', {
op,
place,
prefix: dataPrefix,
Expand Down Expand Up @@ -89,6 +89,6 @@ export default async function place(fastify: FastifyInstance) {
tmplData.backend = `/move`;
}

return resp.view('src/public/app/form_switch.html', tmplData);
return resp.view('src/liquid/app/form_switch.html', tmplData);
});
}
9 changes: 7 additions & 2 deletions src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import autoload from '@fastify/autoload';
import cookie from '@fastify/cookie';
import formbody from '@fastify/formbody';
import multipart from '@fastify/multipart';
import fastifyStatic from '@fastify/static';
import view from '@fastify/view';
import { Liquid } from 'liquidjs';
import { FastifySSEPlugin } from 'fastify-sse-v2';
Expand All @@ -19,7 +20,7 @@ const build = (opts: FastifyServerOptions): FastifyInstance => {
fastify.register(cookie);
fastify.register(view, {
engine: {
liquid: new Liquid({ extname: '.html', root: 'src/public', jekyllInclude: true, dynamicPartials: true }),
liquid: new Liquid({ extname: '.html', root: 'src/liquid', jekyllInclude: true, dynamicPartials: true }),
},
});
fastify.register(autoload, {
Expand All @@ -28,11 +29,15 @@ const build = (opts: FastifyServerOptions): FastifyInstance => {
fastify.register(autoload, {
dir: path.join(__dirname, 'routes'),
});
fastify.register(fastifyStatic, {
root: path.join(__dirname, 'src/public'),
prefix: '/public/',
});

Auth.assertEnvironmentSetup();

fastify.addHook('preValidation', async (req: FastifyRequest, reply: FastifyReply) => {
if (req.unauthenticated) {
if (req.unauthenticated || req.routerPath === '/public/*') {
return;
}

Expand Down

0 comments on commit bc9121a

Please sign in to comment.