on master help sign in
Migrated rssblog example to feedblog.
commite358894df10ce2106acf3df560ce94ac03e03e5f authorJasper Van der Jeugt <jaspervdj@gmail.com> dateMon 15 Mar 2010, 19:07 (17 years ago) parent4758616
15 files changed+46−34
examples/rssblog/css/default.css → examples/feedblog/css/default.css examples/feedblog/hakyll.hs+46 examples/rssblog/index.html → examples/feedblog/index.html examples/rssblog/posts.html → examples/feedblog/posts.html examples/rssblog/posts/2009-11-05-a-first-post.markdown → examples/feedblog/posts/2009-11-05-a-first-post.markdown examples/rssblog/posts/2009-11-10-another-post.markdown → examples/feedblog/posts/2009-11-10-another-post.markdown examples/rssblog/posts/2009-11-28-a-third-post.markdown → examples/feedblog/posts/2009-11-28-a-third-post.markdown examples/rssblog/posts/2009-12-04-this-blog-aint-dead.markdown → examples/feedblog/posts/2009-12-04-this-blog-aint-dead.markdown examples/rssblog/posts/2009-12-23-almost-christmas.markdown → examples/feedblog/posts/2009-12-23-almost-christmas.markdown examples/rssblog/templates/default.html → examples/feedblog/templates/default.html examples/rssblog/templates/post.html → examples/feedblog/templates/post.html examples/rssblog/templates/postitem.html → examples/feedblog/templates/postitem.html examples/rssblog/templates/rss.xml → examples/feedblog/templates/rss.xml examples/rssblog/templates/rssitem.xml → examples/feedblog/templates/rssitem.xml examples/rssblog/hakyll.hs−34
examples/rssblog/css/default.css → examples/feedblog/css/default.cssrenamed

The content is the same.

examples/feedblog/hakyll.hsnew file+46
@@ -0,0 +1,46 @@
1+module Main where
2+
3+import Control.Arrow ((>>>))
4+import Text.Hakyll (hakyll)
5+import Text.Hakyll.Render
6+import Text.Hakyll.Context
7+import Text.Hakyll.File (getRecursiveContents, directory)
8+import Text.Hakyll.CreateContext (createPage, createCustomPage, createListing)
9+import Text.Hakyll.ContextManipulations (copyValue)
10+import Text.Hakyll.Feed (FeedConfiguration (..), renderRss)
11+import Data.List (sort)
12+import Control.Monad (mapM_, liftM)
13+import Control.Monad.Reader (liftIO)
14+import Data.Either (Either(..))
15+
16+main = hakyll "http://example.com" $ do
17+ -- Static directory.
18+ directory css "css"
19+
20+ -- Find all post paths.
21+ postPaths <- liftM (reverse . sort) $ getRecursiveContents "posts"
22+ let postPages = map createPage postPaths
23+
24+ -- Render index, including recent posts.
25+ let index = createListing "index.html" ["templates/postitem.html"] (take 3 postPages) [("title", Left "Home")]
26+ renderChain ["index.html", "templates/default.html"] index
27+
28+ -- Render all posts list.
29+ let posts = createListing "posts.html" ["templates/postitem.html"] postPages [("title", Left "All posts")]
30+ renderChain ["posts.html", "templates/default.html"] posts
31+
32+ -- Render all posts.
33+ liftIO $ putStrLn "Generating posts..."
34+ mapM_ (renderChain ["templates/post.html", "templates/default.html"]) postPages
35+
36+ -- Render RSS feed.
37+ let
38+ renderRss myFeedConfiguration $
39+ map (>>> copyValue "body" "description") (take 3 postPages)
40+
41+myFeedConfiguration = FeedConfiguration
42+ { feedUrl = "rss.xml"
43+ , feedTitle = "SimpleBlog RSS feed."
44+ , feedDescription = "A simple demo of an RSS feed created with Hakyll."
45+ , feedAuthorName = "Jasper Van der Jeugt"
46+ }
examples/rssblog/index.html → examples/feedblog/index.htmlrenamed

The content is the same.

examples/rssblog/posts.html → examples/feedblog/posts.htmlrenamed

The content is the same.

examples/rssblog/posts/2009-11-05-a-first-post.markdown → examples/feedblog/posts/2009-11-05-a-first-post.markdownrenamed

The content is the same.

examples/rssblog/posts/2009-11-10-another-post.markdown → examples/feedblog/posts/2009-11-10-another-post.markdownrenamed

The content is the same.

examples/rssblog/posts/2009-11-28-a-third-post.markdown → examples/feedblog/posts/2009-11-28-a-third-post.markdownrenamed

The content is the same.

examples/rssblog/posts/2009-12-04-this-blog-aint-dead.markdown → examples/feedblog/posts/2009-12-04-this-blog-aint-dead.markdownrenamed

The content is the same.

examples/rssblog/posts/2009-12-23-almost-christmas.markdown → examples/feedblog/posts/2009-12-23-almost-christmas.markdownrenamed

The content is the same.

examples/rssblog/templates/default.html → examples/feedblog/templates/default.htmlrenamed

The content is the same.

examples/rssblog/templates/post.html → examples/feedblog/templates/post.htmlrenamed

The content is the same.

examples/rssblog/templates/postitem.html → examples/feedblog/templates/postitem.htmlrenamed

The content is the same.

examples/rssblog/templates/rss.xml → examples/feedblog/templates/rss.xmlrenamed

The content is the same.

examples/rssblog/templates/rssitem.xml → examples/feedblog/templates/rssitem.xmlrenamed

The content is the same.

examples/rssblog/hakyll.hsdeleted−34
@@ -1,34 +0,0 @@
1−module Main where
2−
3−import Control.Monad.Reader (liftIO)
4−import Text.Hakyll (hakyll)
5−import Text.Hakyll.Render (renderAndConcat, renderChain, css)
6−import Text.Hakyll.File (getRecursiveContents, directory)
7−import Text.Hakyll.Renderables (createPagePath, createCustomPage, createListing)
8−import Data.List (sort)
9−import Control.Monad (mapM_, liftM)
10−import Data.Either (Either(..))
11−
12−main = hakyll $ do
13− -- Static directory.
14− directory css "css"
15−
16− -- Find all post paths.
17− postPaths <- liftM (reverse . sort) $ getRecursiveContents "posts"
18− let renderablePosts = map createPagePath postPaths
19−
20− -- Render index, including recent posts.
21− let index = createListing "index.html" "templates/postitem.html" (take 3 renderablePosts) [("title", "Home")]
22− renderChain ["index.html", "templates/default.html"] index
23−
24− -- Render all posts list.
25− let posts = createListing "posts.html" "templates/postitem.html" renderablePosts [("title", "All posts")]
26− renderChain ["posts.html", "templates/default.html"] posts
27−
28− -- Render all posts.
29− liftIO $ putStrLn "Generating posts..."
30− mapM_ (renderChain ["templates/post.html", "templates/default.html"]) renderablePosts
31−
32− -- Render rss feed
33− let rss = createListing "rss.xml" "templates/rssitem.xml" (take 3 renderablePosts) []
34− renderChain ["templates/rss.xml"] rss