Skip to content

Commit 72660b9

Browse files
committed
update page
1 parent d156573 commit 72660b9

File tree

46 files changed

+16750
-97
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+16750
-97
lines changed

README.md

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ LiquidHaskell is a static verifier for Haskell, based on **Liquid Types**
44

55
See [about](about.md) for more details.
66

7-
## Build
7+
## Build
88

99
To add a new post:
1010

@@ -13,8 +13,10 @@ To add a new post:
1313

1414
## TODO
1515

16-
1. Posts
17-
2. Archive
18-
3. Disqus
19-
4. [Tags](https://javran.github.io/posts/2014-03-01-add-tags-to-your-hakyll-blog.html)
20-
5. [Teasers](https://jaspervdj.be/hakyll/tutorials/using-teasers-in-hakyll.html)
16+
+ Posts
17+
+ Index
18+
+ Archive
19+
+ Error
20+
- Disqus
21+
- [Teasers](https://jaspervdj.be/hakyll/tutorials/using-teasers-in-hakyll.html)
22+
- [Tags](https://javran.github.io/posts/2014-03-01-add-tags-to-your-hakyll-blog.html)

about.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ comments: false
44
sharing: true
55
footer: true
66
headerImg: sea.jpg
7+
demo: SimpleRefinements.hs
78
---
89

910
LiquidHaskell is a static verifier for Haskell, based on **Liquid Types**

blog.hs

Lines changed: 97 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
11
--------------------------------------------------------------------------------
22
{-# LANGUAGE OverloadedStrings #-}
3-
import Data.Monoid (mappend)
4-
import Hakyll
5-
import Text.Pandoc
3+
import Text.Pandoc
4+
import Data.Maybe (fromMaybe)
5+
import Data.Monoid (mappend)
6+
import Hakyll
7+
import System.FilePath ( (</>), (<.>)
8+
, splitExtension, splitFileName
9+
, takeDirectory )
10+
611

712
--------------------------------------------------------------------------------
813
main :: IO ()
@@ -11,40 +16,116 @@ main = hakyll $ do
1116
route idRoute
1217
compile copyFileCompiler
1318

14-
match (fromList tops) $ do
19+
match (fromList [{- "index.md", -} "about.md"]) $ do
1520
route $ setExtension "html"
1621
compile $ pandocCompiler
1722
>>= loadAndApplyTemplate "templates/page.html" siteCtx
1823
>>= loadAndApplyTemplate "templates/default.html" siteCtx
1924
>>= relativizeUrls
2025

26+
27+
-- create ["archive.html"] $ do
28+
-- route idRoute
29+
-- compile $ do
30+
-- posts <- recentFirst =<< loadAll "posts/*"
31+
-- let archiveCtx = listField "posts" postCtx (return posts) `mappend`
32+
-- constField "title" "Archives" `mappend`
33+
-- siteCtx
34+
35+
-- makeItem ""
36+
-- >>= loadAndApplyTemplate "templates/archive.html" archiveCtx
37+
-- >>= loadAndApplyTemplate "templates/default.html" archiveCtx
38+
-- >>= relativizeUrls
39+
40+
2141
match "posts/*" $ do
22-
route $ setExtension "html"
42+
route $ setExtension "html" `composeRoutes`
43+
dateFolders `composeRoutes`
44+
dropPostsPrefix `composeRoutes`
45+
-- prependCategory `composeRoutes`
46+
appendIndex
2347
compile $ pandocCompiler
24-
>>= loadAndApplyTemplate "templates/post.html" postCtx
25-
>>= loadAndApplyTemplate "templates/default.html" postCtx
26-
>>= relativizeUrls
48+
>>= loadAndApplyTemplate "templates/post.html" postCtx
49+
>>= loadAndApplyTemplate "templates/default.html" postCtx
50+
>>= relativizeUrls
2751

2852
create ["archive.html"] $ do
29-
route idRoute
53+
route appendIndex
3054
compile $ do
3155
posts <- recentFirst =<< loadAll "posts/*"
3256
let archiveCtx = listField "posts" postCtx (return posts) `mappend`
3357
constField "title" "Archives" `mappend`
58+
constField "demo" "SimpleRefinements.hs" `mappend`
59+
dropIndexHtml "url" `mappend`
3460
siteCtx
3561

3662
makeItem ""
37-
>>= loadAndApplyTemplate "templates/archive.html" archiveCtx
38-
>>= loadAndApplyTemplate "templates/default.html" archiveCtx
63+
>>= loadAndApplyTemplate "templates/archive.html" archiveCtx
64+
>>= loadAndApplyTemplate "templates/default.html" archiveCtx
65+
>>= relativizeUrls
66+
67+
match (fromList [{- "index.md", -} "about.md"]) $ do
68+
route $ setExtension "html"
69+
compile $ pandocCompiler
70+
>>= loadAndApplyTemplate "templates/page.html" siteCtx
71+
>>= loadAndApplyTemplate "templates/default.html" siteCtx
3972
>>= relativizeUrls
4073

74+
match "index.md" $ do
75+
route $ setExtension "html"
76+
compile $ do
77+
posts <- fmap (take 5) . recentFirst =<< loadAll "posts/*"
78+
let indexCtx = listField "posts" postCtx (return posts) `mappend`
79+
-- constField "title" "Home" `mappend`
80+
constField "demo" "SimpleRefinements.hs" `mappend`
81+
dropIndexHtml "url" `mappend`
82+
siteCtx
83+
84+
-- getResourceBody
85+
pandocCompiler
86+
>>= applyAsTemplate indexCtx
87+
>>= loadAndApplyTemplate "templates/index.html" indexCtx
88+
>>= loadAndApplyTemplate "templates/default.html" indexCtx
89+
>>= relativizeUrls
90+
4191
match "templates/*" $ compile templateCompiler
4292

93+
94+
95+
appendIndex :: Routes
96+
appendIndex = customRoute $ (\(p, e) -> p </> "index" <.> e) . splitExtension . toFilePath
97+
98+
transform :: String -> String
99+
transform url = case splitFileName url of
100+
(p, "index.html") -> takeDirectory p
101+
_ -> url
102+
103+
dropIndexHtml :: String -> Context a
104+
dropIndexHtml key = mapContext transform (urlField key)
105+
where
106+
transform url = case splitFileName url of
107+
(p, "index.html") -> takeDirectory p
108+
_ -> url
109+
110+
dateFolders :: Routes
111+
dateFolders =
112+
gsubRoute "/[0-9]{4}-[0-9]{2}-[0-9]{2}-" $ replaceAll "-" (const "/")
113+
114+
dropPostsPrefix :: Routes
115+
dropPostsPrefix = gsubRoute "posts/" $ const ""
116+
117+
-- prependCategory :: Routes
118+
-- prependCategory = metadataRoute $ \md -> customRoute $
119+
-- let mbCategory = lookupString "category" md
120+
-- category = fromMaybe (error "Posts: Post without category") mbCategory
121+
-- in (category </>) . toFilePath
122+
43123
--------------------------------------------------------------------------------
44124
postCtx :: Context String
45125
postCtx =
46-
dateField "date" "%B %e, %Y" `mappend`
47-
siteCtx
126+
dateField "date" "%b %e, %Y" `mappend`
127+
dropIndexHtml "url" `mappend`
128+
siteCtx
48129

49130

50131
-- http://goto.ucsd.edu:8090/index.html#?demo=ANF.hs
@@ -63,9 +144,8 @@ siteCtx =
63144
constField "github_username" "ucsd-progsys" `mappend`
64145
constField "google_username" "[email protected]" `mappend`
65146
constField "google_userid" "u/0/106612421534244742464" `mappend`
66-
constField "demo" "SimpleRefinements.hs" `mappend`
147+
-- constField "demo" "SimpleRefinements.hs" `mappend`
67148
constField "headerImg" "sea.jpg" `mappend`
149+
constField "summary" "todo" `mappend`
150+
constField "disqus_short_name" "liquidhaskell" `mappend`
68151
defaultContext
69-
70-
tops :: [Identifier]
71-
tops = [ "index.md" , "about.md" ]

0 commit comments

Comments
 (0)