1
1
mirror of https://github.com/aelve/guide.git synced 2024-12-26 14:23:14 +03:00

Fix warnings about shadowed variables (#181)

This commit is contained in:
Jens Krause 2017-07-30 12:31:35 +02:00
parent b1d76d194a
commit 7f8ebb4cad
No known key found for this signature in database
GPG Key ID: 3B2FAFBCEFA5906D
4 changed files with 20 additions and 23 deletions

View File

@ -418,7 +418,7 @@ getLoggedInUser = do
sess <- readSession
case sess ^. sessionUserID of
Nothing -> return Nothing
Just uid -> dbQuery $ GetUser uid
Just uid' -> dbQuery $ GetUser uid'
itemToFeedEntry
:: (MonadIO m)

View File

@ -830,9 +830,9 @@ renderAdminLinks globalState = do
fullList <- liftIO $ forM allLinks $ \(lnk, location) -> do
resp <- if isURI (T.unpack lnk) then (do
request <- parseRequest $ T.unpack lnk
status <- responseStatus <$> httpNoBody request manager
print (lnk, status)
pure $ case status of
status' <- responseStatus <$> httpNoBody request manager
print (lnk, status')
pure $ case status' of
Status 200 _ -> OK
Status code err -> Broken (""+|code|+": "+||err||+"")
) `catch` (return . handleHttpException)
@ -883,7 +883,7 @@ renderAdminLinks globalState = do
sortLink (a, b, OK) = (\(x, y, z) -> ((a, b):x, y, z))
sortLink (a, b, Unparseable) = (\(x, y, z) -> (x, (a, b):y, z))
sortLink (a, b, Broken text) = (\(x, y, z) -> (x, y, (a, b, text):z))
sortLink (a, b, Broken text') = (\(x, y, z) -> (x, y, (a, b, text'):z))
allLinks :: [(Url, Text)]
allLinks = ordNub (findLinks globalState)

View File

@ -14,7 +14,6 @@ import Imports
import Text.Digestive
-- lucid
import Lucid hiding (for_)
import Guide.Views.Page
import Guide.Views.Utils
import Guide.Config
@ -34,18 +33,18 @@ loginForm = Login
-- | Render input elements for a 'Login'
-- Note: This does not include the 'Form' element.
--
-- Use 'Guide.Server.protectForm' to render the appropriate form element with CSRF protection.
-- Use 'Guide.Server.protectForm' to render the appropriate form element with CSRF protection.
loginFormView :: MonadIO m => View (HtmlT m ()) -> HtmlT m ()
loginFormView view = do
loginFormView view' = do
div_ $ do
errorList "email" view
label "email" view "Email: "
inputText "email" view
errorList "email" view'
label "email" view' "Email: "
inputText "email" view'
div_ $ do
errorList "password" view
label "password" view "Password: "
inputPassword "password" view
errorList "password" view'
label "password" view' "Password: "
inputPassword "password" view'
inputSubmit "Log in"
@ -54,11 +53,11 @@ loginView :: (MonadIO m) => User -> HtmlT m ()
loginView user = do
div_ $ do
-- TODO: Make nicer.
"You are registered and logged in as "
"You are registered and logged in as "
toHtml (user ^. userName)
renderLogin :: (MonadIO m, MonadReader Config m) => HtmlT m () -> HtmlT m ()
renderLogin content = do
renderPage $
renderPage $
pageDef & pageTitle .~ "Aelve Guide"
& pageContent .~ content

View File

@ -363,8 +363,8 @@ readWidget fp = liftIO $ do
readWidgets :: MonadIO m => m [(SectionType, Text)]
readWidgets = liftIO $ do
let isWidget = F.extension F.==? ".widget"
files <- F.find F.always isWidget "templates/"
concat <$> mapM readWidget files
files' <- F.find F.always isWidget "templates/"
concat <$> mapM readWidget files'
getJS :: MonadIO m => m Text
getJS = do
@ -382,7 +382,7 @@ getCSS = do
--
-- This sets the method (POST) of submission and includes a server-generated
-- token to help prevent cross-site request forgery (CSRF) attacks.
--
--
-- Briefly: this is necessary to prevent third party sites from impersonating
-- logged in users, because a POST to the right URL is not sufficient to
-- submit the form and perform an action. The CSRF token is only displayed
@ -392,9 +392,9 @@ protectForm :: MonadIO m
-> View (HtmlT m ())
-> GuideAction ctx (HtmlT m ())
protectForm render formView = do
(name, value) <- getCsrfTokenPair
(name', value) <- getCsrfTokenPair
return $ form formView "" [id_ "login-form"] $ do
input_ [ type_ "hidden", name_ name, value_ value ]
input_ [ type_ "hidden", name_ name', value_ value ]
render formView
getCsrfTokenPair :: GuideAction ctx (Text, Text)
@ -408,5 +408,3 @@ getCsrfHeader = do
csrfTokenName <- spc_csrfHeaderName <$> getSpockCfg
csrfTokenValue <- getCsrfToken
return (csrfTokenName, csrfTokenValue)