Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

tweak to tutorial module

  • Loading branch information...
commit 16a517fc3c9aa9747075a63a0f7ccd051a3635b7 1 parent 131b81e
Mark Lentczner mzero authored

Showing 2 changed files with 19 additions and 10 deletions. Show diff stats Hide diff stats

  1. +12 5 seed/Source.hs
  2. +7 5 seed/lib/Tutorial.hs
17 seed/Source.hs
@@ -62,7 +62,7 @@ mkSrcPage path showPreview = do
62 62 srcPage :: SrcInfo -> String -> Bool -> Html
63 63 srcPage si contents showPreview = devpage ("Source of " ++ srcPath si)
64 64 content
65   - [ modFStat si, modActions si, modTutorial si, modSearch]
  65 + (modules si)
66 66 scriptSrcs
67 67 where
68 68 content = thediv ! [identifier "source-page"] <<
@@ -94,7 +94,7 @@ editor contents = thediv ! [identifier "editor", displayHidden] <<
94 94 identifier "txt-src", strAttr "readonly" "readonly" ]
95 95 << contents
96 96 hidden = input ! [thetype "hidden", name "preview", value "1"]
97   -
  97 +
98 98 preview :: Bool -> SrcInfo -> Html
99 99 preview showPreview = maybe noHtml build . previewPath
100 100 where
@@ -119,7 +119,14 @@ errors = thediv ! [ identifier "errors"
119 119 [ h1 << "Compilation Errors"
120 120 , pre ! [ theclass "panel-content", displayHidden ] << noHtml
121 121 ]
122   -
  122 +
  123 +modules :: SrcInfo -> [Html]
  124 +modules si = catMaybes
  125 + [ Just $ modFStat si
  126 + , Just $ modActions si
  127 + , modTutorial si
  128 + , Just modSearch]
  129 +
123 130 modFStat :: SrcInfo -> Html
124 131 modFStat si = (h2 << "File Info") +++
125 132 if srcExists si
@@ -136,8 +143,8 @@ modActions si = (h2 << "Actions") +++
136 143 , fileLink si
137 144 ])
138 145
139   -modTutorial :: SrcInfo -> Html
140   -modTutorial si = maybe noHtml (tutorialModule mkLink) $ previewPath si
  146 +modTutorial :: SrcInfo -> Maybe Html
  147 +modTutorial si = previewPath si >>= tutorialModule mkLink
141 148 where
142 149 mkLink = (++ ".hs") . ("source?file=" ++)
143 150 -- TODO: just adding .hs seems like a hack
12 seed/lib/Tutorial.hs
@@ -52,12 +52,14 @@ tutorialPrev = join . fmap fst . lookupIn pagePrevNext
52 52 tutorialNext :: String -> Maybe String
53 53 tutorialNext = join . fmap snd . lookupIn pagePrevNext
54 54
55   -tutorialModule :: (String -> String) -> String -> Html
56   -tutorialModule mkLink t = (h2 << "Tutorial") +++
57   - [ p << (toHtml "Prev: " +++ linkTo (tutorialPrev t))
58   - , p << (toHtml "Next: " +++ linkTo (tutorialNext t))
59   - ]
  55 +tutorialModule :: (String -> String) -> String -> Maybe Html
  56 +tutorialModule mkLink t =
  57 + if isTutorialPage t then Just modHtml else Nothing
60 58 where
  59 + modHtml = (h2 << "Tutorial") +++
  60 + [ p << (toHtml "Prev: " +++ linkTo (tutorialPrev t))
  61 + , p << (toHtml "Next: " +++ linkTo (tutorialNext t))
  62 + ]
61 63 linkTo = maybe (toHtml "--none--") asLink
62 64 asLink u = anchor ! [href $ mkLink u] << u
63 65

0 comments on commit 16a517f

Please sign in to comment.
Something went wrong with that request. Please try again.