Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
chore(client/print): use different approach than custom route (WIP)
Elian Doran49cd8b2a240b
diff --git a/apps/server/src/routes/index.ts b/apps/server/src/routes/index.tsindex 0d968ce09f..d5183cbbe3 100644--- a/apps/server/src/routes/index.ts+++ b/apps/server/src/routes/index.ts@@ -20,14 +20,7 @@ type View = "desktop" | "mobile" | "print";function index(req: Request, res: Response) {const view = getView(req);- renderView(req, res, view);-}--export function printIndex(req: Request, res: Response) {- renderView(req, res, "print");-}--function renderView(req: Request, res: Response, view: View) {+ console.log("Got view ", view);const options = optionService.getOptionMap();//'overwrite' set to false (default) => the existing token will be re-used and validated@@ -67,14 +60,20 @@ function renderView(req: Request, res: Response, view: View) {isProtectedSessionAvailable: protectedSessionService.isProtectedSessionAvailable(),maxContentWidth: Math.max(640, parseInt(options.maxContentWidth)),triliumVersion: packageJson.version,- assetPath: view !== "print" ? assetPath : "../" + assetPath,- appPath: view !== "print" ? appPath : "../" + appPath,- baseApiUrl: view !== "print" ? 'api/' : "../api/",+ assetPath,+ appPath,+ baseApiUrl: 'api/',currentLocale: getCurrentLocale()});}-function getView(req: Request): "desktop" | "mobile" {+function getView(req: Request): View {+ console.log("Got ", req.query);+ // Special override for printing.+ if ("print" in req.query) {+ return "print";+ }+// Electron always uses the desktop view.if (isElectron) {return "desktop";@@ -133,6 +132,5 @@ function getAppCssNoteIds() {}export default {- index,- printIndex+ index};diff --git a/apps/server/src/routes/routes.ts b/apps/server/src/routes/routes.tsindex 30758b36e4..9ba6b686cc 100644--- a/apps/server/src/routes/routes.ts+++ b/apps/server/src/routes/routes.ts@@ -81,7 +81,6 @@ const GET = "get",function register(app: express.Application) {route(GET, "/", [auth.checkAuth, csrfMiddleware], indexRoute.index);- route(GET, "/print/:noteId", [ auth.checkAuth ], indexRoute.printIndex);route(GET, "/login", [auth.checkAppInitialized, auth.checkPasswordSet], loginRoute.loginPage);route(GET, "/set-password", [auth.checkAppInitialized, auth.checkPasswordNotSet], loginRoute.setPasswordPage);