From d15ab7dfece364f444353dd9f92b4d5a56a3de5d Mon Sep 17 00:00:00 2001 From: lxsang Date: Sun, 7 Jun 2020 19:46:59 +0200 Subject: [PATCH] support multi-user in info --- grs/ubuntu-regular.css | 16 ++++++++-------- info/controllers/IndexController.lua | 4 ++-- info/controllers/UserController.lua | 1 + info/router.lua | 8 +++++--- info/views/default/user/index.ls | 2 +- 5 files changed, 17 insertions(+), 14 deletions(-) diff --git a/grs/ubuntu-regular.css b/grs/ubuntu-regular.css index 5811a05..ca23e01 100755 --- a/grs/ubuntu-regular.css +++ b/grs/ubuntu-regular.css @@ -4,8 +4,8 @@ @font-face { font-family: 'Ubuntu'; - src: url('resources/themes/antos/fonts//ubuntu-regular-webfont.woff2') format('woff2'), - url('resources/themes/antos/fonts//ubuntu-regular-webfont.woff') format('woff'); + src: url('resources/themes/system/fonts//ubuntu-regular-webfont.woff2') format('woff2'), + url('resources/themes/system/fonts//ubuntu-regular-webfont.woff') format('woff'); font-weight: normal; font-style: normal; @@ -13,8 +13,8 @@ @font-face { font-family: 'Ubuntu'; - src: url('resources/themes/antos/fonts//ubuntu-bold-webfont.woff2') format('woff2'), - url('resources/themes/antos/fonts//ubuntu-bold-webfont.woff') format('woff'); + src: url('resources/themes/system/fonts//ubuntu-bold-webfont.woff2') format('woff2'), + url('resources/themes/system/fonts//ubuntu-bold-webfont.woff') format('woff'); font-weight: bold; font-style: normal; @@ -22,8 +22,8 @@ @font-face { font-family: 'Ubuntu'; - src: url('resources/themes/antos/fonts//ubuntu-bolditalic-webfont.woff2') format('woff2'), - url('resources/themes/antos/fonts//ubuntu-bolditalic-webfont.woff') format('woff'); + src: url('resources/themes/system/fonts//ubuntu-bolditalic-webfont.woff2') format('woff2'), + url('resources/themes/system/fonts//ubuntu-bolditalic-webfont.woff') format('woff'); font-weight: bold; font-style: italic; @@ -31,8 +31,8 @@ @font-face { font-family: 'Ubuntu'; - src: url('resources/themes/antos/fonts//ubuntu-italic-webfont.woff2') format('woff2'), - url('resources/themes/antos/fonts//ubuntu-italic-webfont.woff') format('woff'); + src: url('resources/themes/system/fonts//ubuntu-italic-webfont.woff2') format('woff2'), + url('resources/themes/system/fonts//ubuntu-italic-webfont.woff') format('woff'); font-weight: normal; font-style: italic; diff --git a/info/controllers/IndexController.lua b/info/controllers/IndexController.lua index aadf8c6..ff57fa0 100644 --- a/info/controllers/IndexController.lua +++ b/info/controllers/IndexController.lua @@ -52,8 +52,8 @@ function IndexController:actionnotfound(...) end function IndexController:pdf(...) - local tmp_file = WWW_ROOT.."/lxsang_cv.pdf" - local cmd = "wkhtmltopdf "..HTTP_ROOT.."/index/notoc "..tmp_file + local tmp_file = WWW_ROOT.."/cv_exported.pdf" + local cmd = "wkhtmltopdf "..HTTP_ROOT.."/"..self.registry.user.."/notoc "..tmp_file local r = os.execute(cmd) if r then local mime = std.mimeOf(tmp_file) diff --git a/info/controllers/UserController.lua b/info/controllers/UserController.lua index 77aab0b..82febaf 100644 --- a/info/controllers/UserController.lua +++ b/info/controllers/UserController.lua @@ -11,6 +11,7 @@ function UserController:index(...) if not data or not data[1] then self:error("Cannot fetch user info") end + data[1].user = self.registry.user self.template:set("data", data[1]) return true end diff --git a/info/router.lua b/info/router.lua index c25cae7..fcfa16c 100644 --- a/info/router.lua +++ b/info/router.lua @@ -26,7 +26,8 @@ require(BASE_FRW.."silk.api") local REGISTRY = {} -- set logging level REGISTRY.logger = Logger:new{ levels = {INFO = false, ERROR = true, DEBUG = false}} -REGISTRY.db = DBHelper:new{db="mrsang"} +REGISTRY.user = "mrsang" +REGISTRY.db = DBHelper:new{db=REGISTRY.user} REGISTRY.layout = 'default' REGISTRY.fileaccess = true @@ -60,9 +61,10 @@ BaseController:subclass("NotfoundController",{ registry = {}, models = {} }) function NotfoundController:index(...) local args = {...} local user = args[1]:gsub("Controller", ""):lower(); - REQUEST.r = "index" + REQUEST.r = "index/"..std.trim(REQUEST.r:gsub(user, ""), "/") if REGISTRY.db then REGISTRY.db:close() end - REGISTRY.db = DBHelper:new{db = user} + REGISTRY.user = user + REGISTRY.db = DBHelper:new{db=REGISTRY.user} REGISTRY.db:open() router:delegate() end diff --git a/info/views/default/user/index.ls b/info/views/default/user/index.ls index 43135f9..787b74e 100644 --- a/info/views/default/user/index.ls +++ b/info/views/default/user/index.ls @@ -15,7 +15,7 @@ if not preview then ?> - Download + Download