Skip to content
This repository was archived by the owner on Feb 6, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions infra/handler/app/Test.hs
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,8 @@ testPresDeploys = withQueueName $ withEnv $ \env -> withSQS env $ withS3 env $ d
, presentationOwner = someUserId
, presentationAttributes = HMS.empty
, presentationBackground = Nothing
, presentationHeader = Nothing
, presentationFooter = Nothing
, presentationDescription = ""
, presentationHeadExtra = Nothing
}
Expand Down
34 changes: 33 additions & 1 deletion infra/handler/src/DeckGo/Handler.hs
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,14 @@ newtype PresentationBackground = PresentationBackground { unPresentationBackgrou
deriving stock (Show, Eq)
deriving newtype (Aeson.FromJSON, Aeson.ToJSON)

newtype PresentationHeader = PresentationHeader { unPresentationHeader :: T.Text }
deriving stock (Show, Eq)
deriving newtype (Aeson.FromJSON, Aeson.ToJSON)

newtype PresentationFooter = PresentationFooter { unPresentationFooter :: T.Text }
deriving stock (Show, Eq)
deriving newtype (Aeson.FromJSON, Aeson.ToJSON)

-- SLIDES

instance ToSchema Slide where
Expand Down Expand Up @@ -312,6 +320,8 @@ data PresentationInfo = PresentationInfo
{ presentationName :: PresentationName
, presentationOwner :: UserId
, presentationBackground :: Maybe PresentationBackground
, presentationHeader :: Maybe PresentationHeader
, presentationFooter :: Maybe PresentationFooter
, presentationAttributes :: HMS.HashMap T.Text T.Text
, presentationSlides :: [Slide]
, presentationDescription :: T.Text
Expand All @@ -331,6 +341,8 @@ instance FromJSONObject PresentationInfo where
obj .: "name" <*>
obj .: "owner_id" <*>
obj .:? "background" <*>
obj .:? "header" <*>
obj .:? "footer" <*>
obj .:? "attributes" .!= HMS.empty <*>
obj .: "slides" <*>
obj .: "description" <*>
Expand Down Expand Up @@ -1325,11 +1337,17 @@ type Tag = TagSoup.Tag T.Text
processTags :: PresentationInfo -> [Tag] -> [Tag]
processTags presentationInfo = concatMap $ \case
TagSoup.TagOpen str (HMS.fromList -> attrs)
-- If the tag is 'deckgo-deck', we add the slides and the "background",
-- "header" and "footer" divs
| str == "deckgo-deck" -> do
[ TagSoup.TagOpen str (HMS.toList (presentationAttributes presentationInfo <> attrs)) ] <>
(concatMap slideTags (presentationSlides presentationInfo)) <>
(maybe [] presentationBackgroundTags
(presentationBackground presentationInfo))
(presentationBackground presentationInfo)) <>
(maybe [] presentationHeaderTags
(presentationHeader presentationInfo)) <>
(maybe [] presentationFooterTags
(presentationFooter presentationInfo))
t -> [t]

presentationBackgroundTags :: PresentationBackground -> [Tag]
Expand All @@ -1339,6 +1357,20 @@ presentationBackgroundTags (unPresentationBackground -> bg) =
[ TagSoup.TagClose "div"
]

presentationHeaderTags :: PresentationHeader -> [Tag]
presentationHeaderTags (unPresentationHeader -> bg) =
[ TagSoup.TagOpen "div" (HMS.toList $ HMS.singleton "slot" "header")
] <> TagSoup.parseTags bg <>
[ TagSoup.TagClose "div"
]

presentationFooterTags :: PresentationFooter -> [Tag]
presentationFooterTags (unPresentationFooter -> bg) =
[ TagSoup.TagOpen "div" (HMS.toList $ HMS.singleton "slot" "footer")
] <> TagSoup.parseTags bg <>
[ TagSoup.TagClose "div"
]

slideTags :: Slide -> [Tag]
slideTags slide =
[ TagSoup.TagOpen
Expand Down