mirror of
https://github.com/zadam/trilium.git
synced 2025-10-19 06:38:59 +02:00
chore(client/print): use different approach than custom route (WIP)
This commit is contained in:
parent
b0234a75f8
commit
49cd8b2a24
@ -20,14 +20,7 @@ type View = "desktop" | "mobile" | "print";
|
|||||||
|
|
||||||
function index(req: Request, res: Response) {
|
function index(req: Request, res: Response) {
|
||||||
const view = getView(req);
|
const view = getView(req);
|
||||||
renderView(req, res, view);
|
console.log("Got view ", view);
|
||||||
}
|
|
||||||
|
|
||||||
export function printIndex(req: Request, res: Response) {
|
|
||||||
renderView(req, res, "print");
|
|
||||||
}
|
|
||||||
|
|
||||||
function renderView(req: Request, res: Response, view: View) {
|
|
||||||
const options = optionService.getOptionMap();
|
const options = optionService.getOptionMap();
|
||||||
|
|
||||||
//'overwrite' set to false (default) => the existing token will be re-used and validated
|
//'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(),
|
isProtectedSessionAvailable: protectedSessionService.isProtectedSessionAvailable(),
|
||||||
maxContentWidth: Math.max(640, parseInt(options.maxContentWidth)),
|
maxContentWidth: Math.max(640, parseInt(options.maxContentWidth)),
|
||||||
triliumVersion: packageJson.version,
|
triliumVersion: packageJson.version,
|
||||||
assetPath: view !== "print" ? assetPath : "../" + assetPath,
|
assetPath,
|
||||||
appPath: view !== "print" ? appPath : "../" + appPath,
|
appPath,
|
||||||
baseApiUrl: view !== "print" ? 'api/' : "../api/",
|
baseApiUrl: 'api/',
|
||||||
currentLocale: getCurrentLocale()
|
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.
|
// Electron always uses the desktop view.
|
||||||
if (isElectron) {
|
if (isElectron) {
|
||||||
return "desktop";
|
return "desktop";
|
||||||
@ -133,6 +132,5 @@ function getAppCssNoteIds() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
index,
|
index
|
||||||
printIndex
|
|
||||||
};
|
};
|
||||||
|
@ -81,7 +81,6 @@ const GET = "get",
|
|||||||
|
|
||||||
function register(app: express.Application) {
|
function register(app: express.Application) {
|
||||||
route(GET, "/", [auth.checkAuth, csrfMiddleware], indexRoute.index);
|
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, "/login", [auth.checkAppInitialized, auth.checkPasswordSet], loginRoute.loginPage);
|
||||||
route(GET, "/set-password", [auth.checkAppInitialized, auth.checkPasswordNotSet], loginRoute.setPasswordPage);
|
route(GET, "/set-password", [auth.checkAppInitialized, auth.checkPasswordNotSet], loginRoute.setPasswordPage);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user