diff --git a/routes b/routes index 1a496001e..7bb7d7520 100644 --- a/routes +++ b/routes @@ -54,8 +54,8 @@ !/users/functionary-invite AdminFunctionaryInviteR GET POST !/users/add AdminUserAddR GET POST /admin AdminR GET -/admin/test AdminTestR GET POST -/admin/test/pdf AdminTestPdfR GET +/admin/test AdminTestR GET POST +/admin/test/pdf AdminTestPdfR GET /admin/errMsg AdminErrMsgR GET POST /admin/tokens AdminTokensR GET POST /admin/crontab AdminCrontabR GET diff --git a/src/Handler/Admin/Test.hs b/src/Handler/Admin/Test.hs index e24d7d305..636f3d598 100644 --- a/src/Handler/Admin/Test.hs +++ b/src/Handler/Admin/Test.hs @@ -15,8 +15,9 @@ import qualified Data.ByteString.Lazy as L import qualified Data.Set as Set import qualified Data.Map as Map -import qualified Text.Pandoc as P -import qualified Text.Pandoc.PDF as P +import qualified Text.Pandoc as P +import qualified Text.Pandoc.PDF as P +-- import qualified Text.Pandoc.Builder as P import Handler.Admin.Test.Download (testDownload) @@ -275,7 +276,7 @@ postAdminTestR = do getAdminTestPdfR :: Handler TypedContent getAdminTestPdfR = do - -- let typePDF = "application/pdf" :: ContentType + let -- typePDF = "application/pdf" :: ContentType -- typePDF = Settings.Mime.mimeLookup "pdfdemo.pdf" content <- liftIO . P.runIO $ do tmpl <- P.compileDefaultTemplate "latex" @@ -284,13 +285,12 @@ getAdminTestPdfR = do texopts = [] writeropts = def { P.writerTemplate = Just tmpl } doc <- P.readMarkdown def md - res <- P.makePDF "pdflatex" texopts P.writeLaTeX writeropts doc - case res of - Right bs -> return bs - Left err -> return err + P.makePDF "pdflatex" texopts P.writeLaTeX writeropts doc case content of - Right bs -> do - -- sendResponse (typePDF, toContent bs) -- works too + Right (Right bs) -> do + liftIO $ L.writeFile "generated.pdf" bs now <- liftIO getCurrentTime sendByteStringAsFile "demoPDF.pdf" (L.toStrict bs) now - Left err -> return $ toTypedContent $ tshow err \ No newline at end of file + -- sendResponse (typePDF, toContent bs) + Right (Left err) -> sendResponseStatus internalServerError500 $ tshow err + Left err -> sendResponseStatus internalServerError500 $ P.renderError err \ No newline at end of file diff --git a/templates/i18n/admin-test/de-de-formal.hamlet b/templates/i18n/admin-test/de-de-formal.hamlet index 0b81a7844..49a1a0a8d 100644 --- a/templates/i18n/admin-test/de-de-formal.hamlet +++ b/templates/i18n/admin-test/de-de-formal.hamlet @@ -64,3 +64,8 @@
  • ^{modal "Email-Test" (Right emailWidget')}
  • Some icons: ^{isVisible False} ^{hasComment True} + +
    +

    Download a generated PDF + Here is a + Download-Link \ No newline at end of file