From 5ab710279751bbfc751d1921dc078d6ef1ee1a2a Mon Sep 17 00:00:00 2001 From: Steffen Jost Date: Wed, 22 Feb 2023 09:35:35 +0100 Subject: [PATCH 1/2] chore(lms): improve readability for lms passwords --- src/Handler/Utils/LMS.hs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Handler/Utils/LMS.hs b/src/Handler/Utils/LMS.hs index dcb92cdf0..3521d431a 100644 --- a/src/Handler/Utils/LMS.hs +++ b/src/Handler/Utils/LMS.hs @@ -127,7 +127,7 @@ maxLmsUserIdentRetries = 27 randomText :: MonadIO m => String -> Int -> m Text randomText extra n = fmap pack . evalRandTIO . replicateM n $ uniform range where - num_letters = ['0'..'9'] ++ ['a'..'z'] + num_letters = ['2'..'9'] ++ ['a'..'z'] \\ ['l'] range = extra ++ num_letters --TODO: consider using package elocrypt for user-friendly passwords here, licence requires mentioning of author, etc. though @@ -150,4 +150,4 @@ randomLMSIdentBut banList = untilJustMaxM maxLmsUserIdentRetries getIdentOk randomLMSpw :: MonadIO m => m Text randomLMSpw = randomText extra lengthPassword where - extra = "+*:=!?#&" -- you cannot distinguish ;: and ., in printed letters + extra = "+=!?" -- you cannot distinguish ;: and ., in printed letters From 33574b4554c44f827ec30bb099e60b30a5fe14a1 Mon Sep 17 00:00:00 2001 From: Steffen Jost Date: Wed, 22 Feb 2023 12:38:58 +0100 Subject: [PATCH 2/2] chore(letter): use DejaVu Sans Mono as tt font in letters for readability --- config/settings.yml | 4 ++-- nix/docker/default.nix | 2 +- shell.nix | 2 +- src/Utils/Form.hs | 13 ++++++++++++- templates/letter/din5008.latex | 8 +++++++- 5 files changed, 23 insertions(+), 6 deletions(-) diff --git a/config/settings.yml b/config/settings.yml index 2c7f0bcd5..5d0702621 100644 --- a/config/settings.yml +++ b/config/settings.yml @@ -25,8 +25,8 @@ mail-from: mail-object-domain: "_env:MAILOBJECT_DOMAIN:localhost" mail-use-replyto-instead-sender: "_env:MAIL_USES_REPLYTO:true" #mail-reroute-to: -# name: "_env:MAIL_REROUTE_TO_NAME:" -# email: "_env:MAIL_REROUTE_TO_EMAL:" +# name: "_env:MAIL_REROUTE_TO_NAME:Steffen Jost" +# email: "_env:MAIL_REROUTE_TO_EMAL:jost@tcs.ifi.lmu.de" #mail-verp: # separator: "_env:VERP_SEPARATOR:+" # prefix: "_env:VERP_PREFIX:bounce" diff --git a/nix/docker/default.nix b/nix/docker/default.nix index 23cbb919e..d452f8849 100644 --- a/nix/docker/default.nix +++ b/nix/docker/default.nix @@ -35,7 +35,7 @@ let (texlive.combine { inherit (texlive) scheme-basic babel-german babel-english booktabs textpos - enumitem eurosym koma-script parskip xcolor + enumitem eurosym koma-script parskip xcolor dejavu # required fro LuaTeX luatexbase lualatex-math unicode-math selnolig ; diff --git a/shell.nix b/shell.nix index 80b80297b..d381dcecb 100644 --- a/shell.nix +++ b/shell.nix @@ -87,7 +87,7 @@ in pkgs.mkShell { (texlive.combine { inherit (texlive) scheme-basic babel-german babel-english booktabs textpos - enumitem eurosym koma-script parskip xcolor + enumitem eurosym koma-script parskip xcolor dejavu # required fro LuaTeX luatexbase lualatex-math unicode-math selnolig ; diff --git a/src/Utils/Form.hs b/src/Utils/Form.hs index f5d8af0f3..23fe51aa4 100644 --- a/src/Utils/Form.hs +++ b/src/Utils/Form.hs @@ -848,13 +848,24 @@ cfCI :: (Functor m, CI.FoldCase s) => Field m s -> Field m (CI s) cfCI = convertField CI.mk CI.original cfCommaSeparatedSet :: (Functor m) => Field m Text -> Field m (Set Text) -cfCommaSeparatedSet = guardField (not . Set.null) . convertField (Set.fromList . mapMaybe (assertM' (not . T.null) . T.strip) . T.splitOn ",") (T.intercalate ", " . Set.toList) +cfCommaSeparatedSet = guardField (not . Set.null) . convertField (Set.fromList . mapMaybe (assertM' (not . T.null) . T.strip) . T.split (==',')) (T.intercalate ", " . Set.toList) cfAnySeparatedSet :: (Functor m) => Field m Text -> Field m (Set Text) cfAnySeparatedSet = guardField (not . Set.null) . convertField (Set.fromList . mapMaybe (assertM' (not . T.null) . T.strip) . T.split anySeparator) (T.intercalate ", " . Set.toList) where anySeparator :: Char -> Bool anySeparator c = C.isSeparator c || c == ',' || c == ';' +-- cfAnySeparatedSet :: (Functor m) => Field m Text -> Field m (Set Text) +-- cfAnySeparatedSet = guardField (not . Set.null) . convertField (Set.fromList . mapMaybe (assertM' (not . T.null) . T.strip) . splitConditionally) (T.intercalate "; " . Set.toList) +-- where splitConditionally :: Text -> [Text] +-- splitConditionally t +-- | ';' `telem` t = T.split (==';') t +-- | ',' `telem` t = T.split (==',') t +-- | otherwise = T.split C.isSeparator t +-- -- Our version of Data.Text does not yet support T.elem +-- telem :: Char -> Text -> Bool +-- telem c = T.any (==c) + -- -- TODO: consider using package ordered-containers? -- cfAnySeparatedList :: (Functor m) => Field m Text -> Field m [Text] -- cfAnySeparatedList = guardField (not . null) . convertField (mapMaybe (assertM' (not . T.null) . T.strip) . T.split anySeparator) (T.intercalate ", ") diff --git a/templates/letter/din5008.latex b/templates/letter/din5008.latex index 946e46b8d..9a418060d 100644 --- a/templates/letter/din5008.latex +++ b/templates/letter/din5008.latex @@ -61,7 +61,13 @@ $endif$ \usepackage[$if(fontenc)$$fontenc$$else$T1$endif$]{fontenc} \usepackage[utf8]{inputenc} \usepackage{textcomp} % provide euro and other symbols -\else % if luatex or xetex + \usepackage{DejaVuSansMono} % better monofont +\else + % if luatex or xetex + \usepackage{fontspec} + \setmonofont{DejaVu Sans Mono} +\fi + $if(mathspec)$ \ifXeTeX \usepackage{mathspec}