webapp: Prettify error display.

This commit is contained in:
Joey Hess 2012-12-02 15:02:49 -04:00
parent 3b8f56f435
commit c941523b63
4 changed files with 45 additions and 1 deletions

View file

@ -17,10 +17,13 @@ import Assistant.Pairing
import Assistant.Types.Buddies import Assistant.Types.Buddies
import Utility.NotificationBroadcaster import Utility.NotificationBroadcaster
import Utility.WebApp import Utility.WebApp
import Utility.Yesod
import Logs.Transfer import Logs.Transfer
import Build.SysConfig (packageversion)
import Yesod import Yesod
import Yesod.Static import Yesod.Static
import Text.Hamlet
import Data.Text (Text, pack, unpack) import Data.Text (Text, pack, unpack)
import Control.Concurrent.STM import Control.Concurrent.STM
@ -39,7 +42,7 @@ data WebApp = WebApp
} }
instance Yesod WebApp where 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 isAuthorized _ _ = checkAuthToken secretToken
{- Add the auth token to every url generated, except static subsite {- Add the auth token to every url generated, except static subsite
@ -52,6 +55,20 @@ instance Yesod WebApp where
makeSessionBackend = webAppSessionBackend makeSessionBackend = webAppSessionBackend
jsLoader _ = BottomOfHeadBlocking 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 instance RenderMessage WebApp FormMessage where
renderMessage _ _ = defaultFormMessage renderMessage _ _ = defaultFormMessage

1
debian/changelog vendored
View file

@ -15,6 +15,7 @@ git-annex (3.20121128) UNRELEASED; urgency=low
currently-supported AWS regions. currently-supported AWS regions.
* webdav: Avoid trying to set props, avoiding incompatability with * webdav: Avoid trying to set props, avoiding incompatability with
livedrive.com. Needs DAV version 0.3. livedrive.com. Needs DAV version 0.3.
* webapp: Prettify error display.
-- Joey Hess <joeyh@debian.org> Wed, 28 Nov 2012 13:31:07 -0400 -- Joey Hess <joeyh@debian.org> Wed, 28 Nov 2012 13:31:07 -0400

3
templates/error.cassius Normal file
View file

@ -0,0 +1,3 @@
body
padding-top: 60px
padding-bottom: 40px

23
templates/error.hamlet Normal file
View file

@ -0,0 +1,23 @@
<div .navbar .navbar-fixed-top>
<div .navbar-inner>
<div .container>
<a .brand>
git-annex
<ul .nav>
<li .active>
<a href="">
Error
<li>
<a href="" onclick="history.back(-1);return false">
Go Back
<li>
<a href="http://git-annex.branchable.com/bugs/">
File a Bug
<div .container-fluid>
<div .row-fluid>
<div .span3>
<div .span6>
<div .alert .alert-error .alert-block>
^{content}
<hr>
git-annex version #{packageversion}