diff options
author | Joey Hess <joey@kitenet.net> | 2012-07-29 00:08:14 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2012-07-29 00:08:14 -0400 |
commit | 376f8443c1786a1acbaaf24fc7c4f8a662f0ef38 (patch) | |
tree | dbe7b4c767814d417cc24251dabd3b2558ba8d4f | |
parent | a498be7f98927370ad29221a170530a6de01b928 (diff) |
add a separate page for noscript browsers
This may be customised differently than the main page later on, but
for now the important thing is that this constantly refreshed page does not
allocate a new NotificationHandle each time it's loaded.
-rw-r--r-- | Assistant/Threads/WebApp.hs | 18 | ||||
-rw-r--r-- | templates/metarefresh.hamlet | 2 |
2 files changed, 17 insertions, 3 deletions
diff --git a/Assistant/Threads/WebApp.hs b/Assistant/Threads/WebApp.hs index 4da48ae04..d9d98e1bf 100644 --- a/Assistant/Threads/WebApp.hs +++ b/Assistant/Threads/WebApp.hs @@ -50,6 +50,7 @@ staticFiles "static" mkYesod "WebApp" [parseRoutes| / HomeR GET +/noscript NoScriptR GET /transfers/#NotificationId TransfersR GET /config ConfigR GET /static StaticR Static getStatic @@ -101,7 +102,7 @@ instance Yesod WebApp where autoUpdate :: Text -> Route WebApp -> Route WebApp -> Int -> Int -> Int -> Widget autoUpdate ident gethtml home ms_delay ms_startdelay ms_refreshdelay = do {- Fallback refreshing is provided for non-javascript browsers. -} - let delayseconds = show $ ms_to_seconds ms_refreshdelay + let delayseconds = ms_to_seconds ms_refreshdelay toWidgetHead $(hamletFile $ hamletTemplate "metarefresh") {- Use long polling to update the transfers display. -} @@ -131,6 +132,9 @@ getNotificationBroadcaster :: WebApp -> IO NotificationBroadcaster getNotificationBroadcaster webapp = notificationBroadcaster <$> getDaemonStatus (daemonStatus webapp) +dashboard :: Widget +dashboard = transfersDisplay + getHomeR :: Handler RepHtml getHomeR = defaultLayout $ do {- Set up automatic updates for the transfers display. -} @@ -139,7 +143,17 @@ getHomeR = defaultLayout $ do (newNotificationHandle =<< getNotificationBroadcaster webapp) autoUpdate transfersDisplayIdent (TransfersR nid) HomeR (10 :: Int) (10 :: Int) (3000 :: Int) - transfersDisplay + + dashboard + +{- Same as HomeR, except with no javascript, so it doesn't allocate + - new resources each time the page is refreshed. -} +getNoScriptR :: Handler RepHtml +getNoScriptR = defaultLayout $ do + let ident = NoScriptR + let delayseconds = 3 :: Int + toWidgetHead $(hamletFile $ hamletTemplate "metarefresh") + dashboard {- Called by client to get a display of currently in process transfers. - diff --git a/templates/metarefresh.hamlet b/templates/metarefresh.hamlet index be22aa899..ddbd225fe 100644 --- a/templates/metarefresh.hamlet +++ b/templates/metarefresh.hamlet @@ -1,2 +1,2 @@ <noscript> - <meta http-equiv="refresh" content="#{delayseconds}; URL=@{home}"> + <meta http-equiv="refresh" content="#{show delayseconds}; URL=@{NoScriptR}"> |