Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Christopher League
bookme
Commits
eba3190b
Commit
eba3190b
authored
May 24, 2018
by
Christopher League
Browse files
Test handler to list calendars
parent
224aba22
Changes
4
Hide whitespace changes
Inline
Side-by-side
config/routes
View file @
eba3190b
...
...
@@ -7,5 +7,6 @@
/robots.txt RobotsR GET
/ HomeR GET POST
/cals CalListR GET
/comments CommentR POST
package.yaml
View file @
eba3190b
...
...
@@ -17,6 +17,7 @@ dependencies:
-
containers
-
data-default
-
directory >=1.1 && <1.4
-
exceptions
-
fast-logger >=2.2 && <2.5
-
file-embed
-
foreign-store
...
...
src/Foundation.hs
View file @
eba3190b
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE OverloadedStrings #-}
...
...
@@ -9,9 +10,10 @@
module
Foundation
where
import
Import.NoFoundation
import
Import.NoFoundation
as
Pre
import
Control.Monad.Logger
(
LogSource
)
import
Text.Hamlet
(
hamletFile
)
import
qualified
Control.Monad.Catch
as
MC
import
Text.Jasmine
(
minifym
)
import
Yesod.Core.Types
(
Logger
)
import
Yesod.Default.Util
(
addStaticContentExternal
)
...
...
@@ -59,6 +61,9 @@ mkYesodData "App" $(parseRoutesFile "config/routes")
-- | A convenient synonym for creating forms.
type
Form
x
=
Html
->
MForm
(
HandlerFor
App
)
(
FormResult
x
,
Widget
)
instance
MC
.
MonadCatch
(
HandlerFor
App
)
where
catch
=
Pre
.
catch
-- Please see the documentation for the Yesod typeclass. There are a number
-- of settings which can be configured by overriding methods here.
instance
Yesod
App
where
...
...
src/Handler/Home.hs
View file @
eba3190b
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE QuasiQuotes #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE TypeFamilies #-}
module
Handler.Home
where
import
Import
import
Network.Google
(
LogLevel
(
Debug
),
newLogger
,
newEnvWith
,
envScopes
,
runGoogle
,
send
)
import
Network.Google.AppsCalendar
(
calendarScope
,
calendarListList
,
clItems
,
cleSummary
)
import
Control.Lens
((
<&>
),
(
.~
),
(
^.
))
import
Yesod.Form.Bootstrap3
(
BootstrapFormLayout
(
..
),
renderBootstrap3
)
import
Text.Julius
(
RawJS
(
..
))
...
...
@@ -65,3 +70,18 @@ sampleForm = renderBootstrap3 BootstrapBasicForm $ FileForm
commentIds
::
(
Text
,
Text
,
Text
)
commentIds
=
(
"js-commentForm"
,
"js-createCommentTextarea"
,
"js-commentList"
)
getCalListR
::
Handler
Html
getCalListR
=
do
App
{
..
}
<-
getYesod
lg
<-
newLogger
Debug
stdout
env
<-
newEnvWith
appGoogleCreds
lg
appHttpManager
<&>
envScopes
.~
calendarScope
xs
<-
runGoogle
env
$
send
calendarListList
defaultLayout
[
whamlet
|
<h2>Hello calendar
<ol>
$forall itemOpt <- xs ^. clItems
$maybe item <- itemOpt ^. cleSummary
<li>#{item}
|]
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment