diff --git a/config/settings.yml b/config/settings.yml index 974b2e7e2..aba8f93c3 100644 --- a/config/settings.yml +++ b/config/settings.yml @@ -29,7 +29,7 @@ notification-expiration: 259201 session-timeout: 7200 jwt-expiration: 604800 jwt-encoding: HS256 -maximum-content-length: 52428800 +maximum-content-length: 134217728 health-check-interval: "_env:HEALTHCHECK_INTERVAL:600" # or WATCHDOG_USEC/2, whichever is smaller health-check-http: "_env:HEALTHCHECK_HTTP:true" health-check-delay-notify: "_env:HEALTHCHECK_DELAY_NOTIFY:true" diff --git a/src/Handler/Corrections.hs b/src/Handler/Corrections.hs index 4ef07e77d..01af2b880 100644 --- a/src/Handler/Corrections.hs +++ b/src/Handler/Corrections.hs @@ -721,6 +721,7 @@ postCorrectionsUploadR = do , formEncoding = uploadEncoding } + maxUploadMB <- appMaximumContentLength <$> getsYesod appSettings' defaultLayout $ do let uploadInstruction = $(i18nWidgetFile "corrections-upload-instructions") diff --git a/src/Utils.hs b/src/Utils.hs index 4fee6e818..9b764fc12 100644 --- a/src/Utils.hs +++ b/src/Utils.hs @@ -262,6 +262,22 @@ textPercent x = lz <> pack (show rx) <> "%" textPercentInt :: Integral a => a -> a -> Text -- slow, maybe use Data.Double.Conversion.Text.toFixed instead? textPercentInt part whole = textPercent $ fromIntegral part % fromIntegral whole +-- | Convert number of bytes to human readable format +textBytes :: Integral a => a -> Text +textBytes x + | v < kb = rshow v <> "B" + | v < mb = rshow (v/kb) <> "KB" + | v < gb = rshow (v/mb) <> "MB" + | otherwise = rshow (v/gb) <> "GB" + where + v = fromIntegral x + kb = 1024 + mb = 1024 * kb + gb = 1024 * mb + rshow :: Double -> Text + rshow = tshow . floorToDigits 1 + + stepTextCounterCI :: CI Text -> CI Text -- find and increment rightmost-number, preserving leading zeroes stepTextCounterCI = CI.map stepTextCounter @@ -294,6 +310,13 @@ notUsedT = notUsed roundToNearestMultiple :: Int -> Int -> Int roundToNearestMultiple m n = (n `div` m + 1) * m +roundToDigits :: (RealFrac a, Integral b) => b -> a -> a +roundToDigits d x = fromInteger (round $ x * prec) / prec + where prec = 10^d + +floorToDigits :: (RealFrac a, Integral b) => b -> a -> a +floorToDigits d x = fromInteger (floor $ x * prec) / prec + where prec = 10^d diff --git a/templates/corrections-upload-instructions/de.hamlet b/templates/corrections-upload-instructions/de.hamlet index f21254519..44e5deb4d 100644 --- a/templates/corrections-upload-instructions/de.hamlet +++ b/templates/corrections-upload-instructions/de.hamlet @@ -21,7 +21,6 @@ Korrekturen des letzten Korrektors gelöscht werden, falls diese den Abgabenden nicht zur Verfügung gestellt werden sollen. -
-

- Achtung: - Das Limit für die Dateigröße beträgt momentan ungefähr 52MB \ No newline at end of file + $maybe maxUpload <- maxUploadMB +

+ Das Limit für die Dateigröße beträgt momentan #{textBytes maxUpload} \ No newline at end of file