Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
  • 3 commits
  • 4 files changed
  • 0 comments
  • 1 contributor
2  posts/2011-03-31-databases.lhs
@@ -4,7 +4,7 @@ tags: haskell,database,school
4 4 ---
5 5
6 6 The database used in this post can be fetched from
7   -[here](/static/employee.sql).
  7 +[here](/static/lib/employee.sql).
8 8
9 9 I recently had an school assignment to write a java method to list all
10 10 employees with their projects. The example output was given as:
61 site.hs
@@ -6,11 +6,12 @@ import Prelude hiding (id)
6 6 import Control.Category (id)
7 7 import Control.Arrow ((***), (>>>), arr)
8 8 import Data.Monoid
9   -import Data.List
  9 +import Data.List hiding (group)
10 10 import Hakyll.Main
11 11 import Hakyll.Core.Routes
12 12 import Hakyll.Core.Configuration (defaultHakyllConfiguration, deployCommand)
13 13 import Hakyll.Core.Util.Arrow
  14 +import Hakyll.Core.Identifier.Pattern (list, inGroup)
14 15 import Hakyll.Core.Rules
15 16 import Hakyll.Core.Compiler
16 17 import Hakyll.Core.Writable.CopyFile
@@ -26,76 +27,64 @@ import Text.HTML.TagSoup
26 27
27 28 main = hakyllWith config $ do
28 29 let defaultTemplate = "templates/rs19.html"
  30 + sidebarposts <- group "sidebarposts" $ do
  31 + match "posts/*" $ do
  32 + route $ setExtension "html"
  33 + compile $ pageCompiler
29 34 -- CSS
30 35 match "css/*" $ do
31 36 route idRoute
32 37 compile compressCssCompiler
33   - -- JS
34   - match "static/js/**" $ do
  38 + match "static/**/*" $ do
35 39 route idRoute
36 40 compile copyFileCompiler
37   - -- Data
38   - match "static/data/**" $ do
39   - route idRoute
40   - compile copyFileCompiler
41   - -- Images
42   - match "static/img/*" $ do
43   - route idRoute
44   - compile copyFileCompiler
45   - match "static/images/*" $ do
46   - route idRoute
47   - compile copyFileCompiler
48   - -- About
49   - match "contact.markdown" $ do
50   - route $ setExtension "html"
51   - compile $ pageCompiler
52   - >>> introCompiler
53   - >>> applyTemplateCompiler defaultTemplate
54   - >>> relativizeUrlsCompiler
55   - match "about.markdown" $ do
  41 + match "intro.markdown" $ compile pageCompiler
  42 + match (list ["contact.markdown", "about.markdown"]) $ do
56 43 route $ setExtension "html"
57 44 compile $ pageCompiler
58 45 >>> introCompiler
  46 + >>> sidebarCompiler sidebarposts
59 47 >>> applyTemplateCompiler defaultTemplate
60 48 >>> relativizeUrlsCompiler
61 49 -- Posts
62 50 match "posts/*" $ do
63 51 route $ setExtension "html"
64 52 compile $ pageCompiler
  53 + >>> sidebarCompiler sidebarposts
  54 + >>> introCompiler
65 55 >>> arr (renderDateField "date" "%B %e, %Y" "Date unknown")
66 56 >>> arr (renderDateField "month" "%B" "Date unknown")
67 57 >>> arr (renderDateField "day" "%d" "Date unknown")
68   - >>> introCompiler
69 58 >>> arr (copyBodyToField "description")
70 59 >>> arr (renderField "description" "excerpt" excerpt)
71 60 >>> applyTemplateCompiler "templates/rs19post.html"
72 61 >>> applyTemplateCompiler defaultTemplate
73 62 >>> relativizeUrlsCompiler
  63 + match (list ["index.html", "posts.html"]) $ route idRoute
74 64 -- Index
75   - match "intro.markdown" $ compile pageCompiler
76 65 match "index.html" $ route idRoute
77 66 create "index.html" $ constA mempty
78   - >>> arr (setField "title" "Home")
79   - >>> introCompiler
80 67 >>> top5 "templates/rs19teaser.html" "posts"
81   - >>> applyTemplateCompiler "templates/index.html"
82   - >>> applyTemplateCompiler defaultTemplate
83   - >>> relativizeUrlsCompiler
  68 + >>> arr (setField "title" "Home")
  69 + >>> postCompiler "templates/index.html" defaultTemplate sidebarposts
84 70 -- Posts list
85 71 match "posts.html" $ route idRoute
86 72 create "posts.html" $ constA mempty
  73 + >>> setFieldPageList (recentFirst) "templates/rs19teaser.html" "posts" ("posts/*" `mappend` inGroup Nothing)
87 74 >>> arr (setField "title" "Posts")
88   - >>> introCompiler
89   - >>> setFieldPageList (recentFirst) "templates/rs19teaser.html" "posts" "posts/*"
90   - >>> applyTemplateCompiler "templates/rs19posts.html"
91   - >>> applyTemplateCompiler defaultTemplate
92   - >>> relativizeUrlsCompiler
  75 + >>> postCompiler "templates/rs19posts.html" defaultTemplate sidebarposts
93 76 match "templates/*" $ compile templateCompiler
94 77 match "rss.xml" $ route idRoute
95   - create "rss.xml" $ requireAll_ "posts/*" >>> renderRss feedConfiguration
  78 + create "rss.xml" $ requireAll_ ("posts/*" `mappend` inGroup Nothing) >>> renderRss feedConfiguration
96 79 where
97   - top5 template key = setFieldPageList (take 5 . recentFirst) template key "posts/*"
  80 + top5 template key = setFieldPageList (take 5 . recentFirst) template key ("posts/*" `mappend` inGroup Nothing)
98 81 introCompiler = requireA "intro.markdown" (setFieldA "intro" $ arr pageBody)
  82 + sidebarCompiler sidebarposts = setFieldPageList (take 5 . recentFirst) "templates/postitem.html" "sidebar" sidebarposts
  83 + postCompiler tpl roottpl sidebarposts = introCompiler
  84 + >>> sidebarCompiler sidebarposts
  85 + >>> applyTemplateCompiler tpl
  86 + >>> applyTemplateCompiler roottpl
  87 + >>> relativizeUrlsCompiler
99 88 config = defaultHakyllConfiguration { deployCommand = "rsync --checksum --delete -avz -e ssh _site/ machra@linux.utu.fi:/www/users/m/machra/ --exclude ostoslista" }
100 89 feedConfiguration = FeedConfiguration {
101 90 feedTitle = "Masse's blog"
0  static/employee.sql → static/lib/employee.sql
File renamed without changes
6 templates/rs19.html
@@ -46,6 +46,11 @@ <h1 id="sitename">blog :: MasseR -> IO ($title$)</h1>
46 46 </div>
47 47 <div id="sidebar">
48 48 <div class="container">
  49 + <div class="latestposts">
  50 + <ul class="shadow">
  51 + $sidebar$
  52 + </ul>
  53 + </div>
49 54
50 55
51 56 </div>
@@ -56,6 +61,7 @@ <h1 id="sitename">blog :: MasseR -> IO ($title$)</h1>
56 61 </div>
57 62
58 63 <div id="footer">
  64 + <a href="/rss.xml"><img src="/static/img/feed-icon-14x14.png" title="RSS feed" /></a>
59 65 2009 - 2010 &copy; All Rights Reserved
60 66 <p>
61 67 <p id="credits">A

No commit comments for this range

Something went wrong with that request. Please try again.