forked from glotcode/glot-www
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Learn.hs
52 lines (42 loc) · 1.65 KB
/
Learn.hs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
module Handler.Learn where
import Import
import Widget.Editor (editorWidget, footerWidget)
import Widget.Languages (languagesWidget)
import Util.Alert (successHtml)
import qualified Network.Wai as Wai
import qualified Text.Blaze as Blaze
import qualified Util.Handler as Handler
import qualified Util.Snippet as Snippet
import qualified Glot.Snippet
import qualified Data.Text.Encoding as Encoding
import qualified Database.Persist.Sql as Sql
import qualified Data.Aeson as Aeson
import qualified Data.Time.Clock.POSIX as PosixClock
import qualified Data.Time.Clock as Clock
import qualified Numeric
import qualified Data.List.NonEmpty as NonEmpty
import qualified Glot.Language as Language
import qualified Data.Text as Text
import Data.Function ((&))
import Prelude ((!!))
getLearnR :: Handler Html
getLearnR = do
defaultLayout $ do
App{..} <- getYesod
setTitle $ Handler.title "Learn programming - Choose language"
Handler.setCanonicalUrl LearnR
$(widgetFile "learn")
getLearnLanguageR :: Language.Id -> Handler Html
getLearnLanguageR langId = do
language <- Handler.getLanguage langId
defaultLayout $ do
setTitle (learnLanguageTitle language)
setDescription (learnLanguageDescription language)
Handler.setCanonicalUrl (LearnLanguageR langId)
$(widgetFile "learn-language")
learnLanguageTitle :: Language.Language -> Blaze.Markup
learnLanguageTitle language =
Handler.titleConcat ["Learn ", Language.name language]
learnLanguageDescription :: Language.Language -> Text
learnLanguageDescription language =
concat ["Best books for learning the ", Language.name language, " programming language."]