From c941523b63473e2d4d6f9b8baf3b723b87530e61 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Sun, 2 Dec 2012 15:02:49 -0400 Subject: [PATCH] webapp: Prettify error display. --- Assistant/WebApp/Types.hs | 19 ++++++++++++++++++- debian/changelog | 1 + templates/error.cassius | 3 +++ templates/error.hamlet | 23 +++++++++++++++++++++++ 4 files changed, 45 insertions(+), 1 deletion(-) create mode 100644 templates/error.cassius create mode 100644 templates/error.hamlet diff --git a/Assistant/WebApp/Types.hs b/Assistant/WebApp/Types.hs index 320438b333..71fcb6f246 100644 --- a/Assistant/WebApp/Types.hs +++ b/Assistant/WebApp/Types.hs @@ -17,10 +17,13 @@ import Assistant.Pairing import Assistant.Types.Buddies import Utility.NotificationBroadcaster import Utility.WebApp +import Utility.Yesod import Logs.Transfer +import Build.SysConfig (packageversion) import Yesod import Yesod.Static +import Text.Hamlet import Data.Text (Text, pack, unpack) import Control.Concurrent.STM @@ -39,7 +42,7 @@ data WebApp = WebApp } instance Yesod WebApp where - {- Require an auth token be set when accessing any (non-static route) -} + {- Require an auth token be set when accessing any (non-static) route -} isAuthorized _ _ = checkAuthToken secretToken {- Add the auth token to every url generated, except static subsite @@ -52,6 +55,20 @@ instance Yesod WebApp where makeSessionBackend = webAppSessionBackend jsLoader _ = BottomOfHeadBlocking + {- The webapp does not use defaultLayout, so this is only used + - for error pages or any other built-in yesod page. + - + - This can use static routes, but should use no other routes, + - as that would expose the auth token. + -} + defaultLayout content = do + webapp <- getYesod + pageinfo <- widgetToPageContent $ do + addStylesheet $ StaticR css_bootstrap_css + addStylesheet $ StaticR css_bootstrap_responsive_css + $(widgetFile "error") + hamletToRepHtml $(hamletFile $ hamletTemplate "bootstrap") + instance RenderMessage WebApp FormMessage where renderMessage _ _ = defaultFormMessage diff --git a/debian/changelog b/debian/changelog index 1491154b81..60a812687e 100644 --- a/debian/changelog +++ b/debian/changelog @@ -15,6 +15,7 @@ git-annex (3.20121128) UNRELEASED; urgency=low currently-supported AWS regions. * webdav: Avoid trying to set props, avoiding incompatability with livedrive.com. Needs DAV version 0.3. + * webapp: Prettify error display. -- Joey Hess Wed, 28 Nov 2012 13:31:07 -0400 diff --git a/templates/error.cassius b/templates/error.cassius new file mode 100644 index 0000000000..e05a73e7a1 --- /dev/null +++ b/templates/error.cassius @@ -0,0 +1,3 @@ +body + padding-top: 60px + padding-bottom: 40px diff --git a/templates/error.hamlet b/templates/error.hamlet new file mode 100644 index 0000000000..3f226e0305 --- /dev/null +++ b/templates/error.hamlet @@ -0,0 +1,23 @@ +
+
+
+ + git-annex +