Partly working NoJs site
Updated nojs site as the code became stale over time as a comment. Nojs site now mostly works, excluding the following issues: * Navigation links have no href. * Tags do not seem to work; the tagcloud that is displayed on the nojs homepage references the tags for the main site and tags aren't displayed in posts. The cause for this is not yet known. * Unused templates that are nojs specific can be removed: * templates/archive.html * templates/partials/post-nojs.html * templates/partials/recent-posts-nojs.html Signed-off-by: Collin J. Doering <collin.doering@rekahsoft.ca>
This commit is contained in:
parent
8997f122b5
commit
d8c7e54aaa
131
src/site.hs
131
src/site.hs
@ -109,6 +109,18 @@ main = do
|
||||
route idRoute
|
||||
compile copyFileCompiler
|
||||
|
||||
match "css/**" $ do
|
||||
route idRoute
|
||||
compile compressCssCompiler
|
||||
|
||||
match "lib/Skeleton/*.css" $ do
|
||||
route $ gsubRoute "Skeleton" (const "css")
|
||||
compile compressCssCompiler
|
||||
|
||||
match "templates/**" $ compile $ getResourceBody >>= saveSnapshot "original"
|
||||
>> templateCompiler
|
||||
|
||||
-- Default Version --------------------------------------------------------------------------------------
|
||||
tags <- buildTags ("posts/**" .&&. hasNoVersion) (fromCapture "tags/*.html")
|
||||
|
||||
paginatedPosts <- buildPaginateWith
|
||||
@ -175,6 +187,7 @@ main = do
|
||||
|
||||
---------------------------------------------------------------------------------------------------------
|
||||
-- Default Version --------------------------------------------------------------------------------------
|
||||
=======
|
||||
-- Generate tag pages
|
||||
paginateTagsRules tags
|
||||
|
||||
@ -247,10 +260,28 @@ main = do
|
||||
>>= applyAsTemplate indexCtx
|
||||
>>= loadAndApplyTemplate "templates/default.html" indexCtx
|
||||
|
||||
---------------------------------------------------------------------------------------------------------
|
||||
-- NOJS Version -----------------------------------------------------------------------------------------
|
||||
-- tagsNoJs <- buildTags ("posts/**" .&&. hasVersion "nojs") (fromCapture "nojs/tags/*.html")
|
||||
-- tagsRules tagsNoJs $ genTagRules tagsNoJs
|
||||
tagsNoJs <- buildTags ("posts/**" .&&. hasVersion "nojs") (fromCapture "nojs/tags/*.html")
|
||||
|
||||
paginatedPostsNoJs <- buildPaginateWith
|
||||
(fmap (paginateEvery numPaginatePages) . sortRecentFirst)
|
||||
("posts/**" .&&. hasVersion "nojs")
|
||||
(\n -> fromCapture "nojs/blog*.html" (show n))
|
||||
|
||||
-- Generate nojs tag pages
|
||||
paginateTagsRules tagsNoJs
|
||||
|
||||
paginateRules paginatedPostsNoJs $ \pageNum pattern -> do
|
||||
route idRoute
|
||||
compile $ do
|
||||
posts <- recentFirst =<< loadAllSnapshots pattern "content"
|
||||
let ctx = taggedPostCtx tagsNoJs <>
|
||||
paginateContext paginatedPostsNoJs pageNum <>
|
||||
virtualPaginateContext paginatedPostsNoJs pageNum <>
|
||||
constField "weight" "0" <>
|
||||
listField "posts" (taggedPostCtx tagsNoJs) (return posts)
|
||||
makeItem ""
|
||||
>>= loadAndApplyTemplate "templates/pages/blog.html" ctx
|
||||
|
||||
create ["nojs/atom.xml"] $ do
|
||||
route idRoute
|
||||
@ -260,28 +291,28 @@ main = do
|
||||
>>= fmap (take 10) . recentFirst
|
||||
renderAtom (feedConfiguration Nothing) feedCtx blogPosts
|
||||
|
||||
create ["nojs/archive.html"] $ do
|
||||
route idRoute
|
||||
compile $ do
|
||||
-- Load all blog posts for archive
|
||||
posts <- recentFirst =<< loadAllSnapshots ("posts/*" .&&. hasVersion "nojs") "content"
|
||||
-- create ["nojs/archive.html"] $ do
|
||||
-- route idRoute
|
||||
-- compile $ do
|
||||
-- -- Load all blog posts for archive
|
||||
-- posts <- recentFirst =<< loadAllSnapshots ("posts/*" .&&. hasVersion "nojs") "content"
|
||||
|
||||
-- Generate nav-bar from pages/*
|
||||
pages <- sortByM pageWeight =<< loadAll ("pages/*" .&&. hasVersion "nav-gen")
|
||||
-- -- Generate nav-bar from pages/*
|
||||
-- pages <- sortByM pageWeight =<< loadAll ("pages/*" .&&. hasVersion "nav-gen")
|
||||
|
||||
let archiveCtx =
|
||||
listField "posts" postCtx (return posts) <>
|
||||
constField "title" "Archives" <>
|
||||
defaultContext
|
||||
indexCtx =
|
||||
listField "pagesFirst" pagesCtx (return pages) <>
|
||||
listField "pagesLast" pagesCtx (return []) <>
|
||||
defaultContext
|
||||
-- let archiveCtx =
|
||||
-- listField "posts" postCtx (return posts) <>
|
||||
-- constField "title" "Archives" <>
|
||||
-- defaultContext
|
||||
-- indexCtx =
|
||||
-- listField "pagesFirst" pagesCtx (return pages) <>
|
||||
-- listField "pagesLast" pagesCtx (return []) <>
|
||||
-- defaultContext
|
||||
|
||||
makeItem ""
|
||||
>>= loadAndApplyTemplate "templates/archive.html" archiveCtx
|
||||
>>= loadAndApplyTemplate "templates/default-nojs.html" indexCtx
|
||||
>>= relativizeUrls
|
||||
-- makeItem ""
|
||||
-- >>= loadAndApplyTemplate "templates/archive.html" archiveCtx
|
||||
-- >>= loadAndApplyTemplate "templates/default-nojs.html" indexCtx
|
||||
-- >>= relativizeUrls
|
||||
|
||||
match "posts/**" $ version "nojs" $ do
|
||||
route $ customRoute (\r -> "nojs" </> toFilePath r) `composeRoutes` setExtension "html"
|
||||
@ -293,56 +324,64 @@ main = do
|
||||
curId <- getUnderlying
|
||||
|
||||
let (pagesFirst, pagesLast') = flip span pages $ \x ->
|
||||
toFilePath curId /= (toFilePath . itemIdentifier $ x)
|
||||
(toFilePath . itemIdentifier $ x) /= "pages/blog.markdown"
|
||||
pageMid = [head pagesLast']
|
||||
pagesLast = if not . null $ pagesLast' then tail pagesLast' else []
|
||||
postNojsCtx =
|
||||
listField "pagesFirst" pagesCtx (return pagesFirst) <>
|
||||
listField "pagesLast" pagesCtx (return pagesLast) <>
|
||||
listField "pagesFirst" pagesCtx (return pagesFirst) <>
|
||||
listField "pageMid" pagesCtx (return pageMid) <>
|
||||
listField "pagesLast" pagesCtx (return pagesLast) <>
|
||||
defaultContext
|
||||
|
||||
pandocCompiler
|
||||
pandocCompilerWith pandocReaderOptions pandocWriterOptions
|
||||
>>= saveSnapshot "content"
|
||||
>>= loadAndApplyTemplate "templates/partials/post-nojs.html" postCtx
|
||||
>>= loadAndApplyTemplate "templates/partials/post.html" postCtx
|
||||
>>= loadAndApplyTemplate "templates/default-nojs.html" postNojsCtx
|
||||
>>= relativizeUrls
|
||||
|
||||
-- This route is used for the initial pass of the pages (nav-gen) and the final nojs page output
|
||||
let pagesNoJsRoute = customRoute (\r -> if toFilePath r == "pages/home.markdown"
|
||||
match "pages/*" $ version "nav-gen" $ do
|
||||
compile $ pandocCompiler
|
||||
|
||||
match "pages/*" $ version "nojs" $ do
|
||||
route $ customRoute (\r -> if toFilePath r == "pages/home.markdown"
|
||||
then "pages/index.markdown"
|
||||
else toFilePath r) `composeRoutes`
|
||||
gsubRoute "pages" (const "nojs") `composeRoutes`
|
||||
setExtension "html"
|
||||
|
||||
match "pages/*" $ version "nav-gen" $ do
|
||||
route $ pagesNoJsRoute
|
||||
compile $ pandocCompiler
|
||||
>>= loadAndApplyTemplate "templates/page.html" defaultContext
|
||||
|
||||
match "pages/*" $ version "nojs" $ do
|
||||
route $ pagesNoJsRoute
|
||||
compile $ do
|
||||
-- Show a slideshow of blog posts using js..limit to the 3 most recent posts
|
||||
recentPosts <- loadAllSnapshots ("posts/**" .&&. hasVersion "nojs") "content"
|
||||
>>= fmap (take 3) . recentFirst
|
||||
posts <- recentFirst =<< loadAllSnapshots ("posts/**" .&&. hasVersion "nojs") "content"
|
||||
|
||||
-- Generate nav-bar from pages/*
|
||||
pages <- sortByM pageWeight =<< loadAll ("pages/*" .&&. hasVersion "nav-gen")
|
||||
|
||||
-- Get the current page name
|
||||
pageName <- takeBaseName . toFilePath <$> getUnderlying
|
||||
|
||||
-- Get the current Identifier
|
||||
curId <- getUnderlying
|
||||
|
||||
let (pagesFirst, pagesLast') = flip span pages $ \x ->
|
||||
toFilePath curId /= (toFilePath . itemIdentifier $ x)
|
||||
pageMid = head pagesLast'
|
||||
pageMid = [head pagesLast']
|
||||
pagesLast = if not . null $ pagesLast' then tail pagesLast' else []
|
||||
|
||||
recentPosts = take 5 posts
|
||||
pageTemplate = "templates/pages/" ++ pageName ++ ".html"
|
||||
|
||||
pagesNojsCtx =
|
||||
listField "recentPosts" postCtx (return recentPosts) <>
|
||||
listField "pagesFirst" pagesCtx (return pagesFirst) <>
|
||||
field "pageMid" (const $ return . itemBody $ pageMid) <>
|
||||
listField "pagesLast" pagesCtx (return pagesLast) <>
|
||||
listField "recentPosts" (taggedPostCtx tagsNoJs) (return recentPosts) <>
|
||||
listField "posts" (taggedPostCtx tagsNoJs) (return posts) <>
|
||||
tagCloudField "tagCloud" 65 135 tagsNoJs <>
|
||||
listField "pagesFirst" pagesCtx (return pagesFirst) <>
|
||||
listField "pageMid" pagesCtx (return pageMid) <>
|
||||
listField "pagesLast" pagesCtx (return pagesLast) <>
|
||||
defaultContext
|
||||
|
||||
loadVersion "nav-gen" curId
|
||||
sectionCtx <- getResourceBody >>= genSectionContext
|
||||
pg <- loadSnapshot (fromFilePath pageTemplate) "original"
|
||||
>>= applyAsTemplate (sectionCtx <> pagesNojsCtx)
|
||||
|
||||
(makeItem . itemBody) pg
|
||||
>>= loadAndApplyTemplate "templates/default-nojs.html" pagesNojsCtx
|
||||
>>= relativizeUrls
|
||||
|
||||
|
@ -1,46 +1,37 @@
|
||||
<!DOCTYPE html>
|
||||
<!--[if lt IE 7]> <html class="ie ie6" lang="en"> <![endif]-->
|
||||
<!--[if IE 7]> <html class="ie ie7" lang="en" <![endif]-->
|
||||
<!--[if IE 8]> <html class="ie ie8" lang="en"> <![endif]-->
|
||||
<!-- [if (gte IE 9)|!(IE)]><!-->
|
||||
<html class='en'>
|
||||
<head>
|
||||
<!-- Basic Page Needs -->
|
||||
<meta charset='utf-8'>
|
||||
<link href='lib/images/favicon.png' rel='shortcut icon'>
|
||||
<title>RekahSoft</title>
|
||||
<meta content='Custom soltuions to unique problems' name='description'>
|
||||
<meta content='The technical musings of a minimalist' name='description'>
|
||||
<meta content='Collin Doering' name='author'>
|
||||
|
||||
<!-- Mobile Specific Metas -->
|
||||
<meta content='width=device-width, initial-scale=1, maximum-scale=1' name='viewport'>
|
||||
|
||||
<!-- CSS -->
|
||||
<link href='lib/css/base.css' rel='stylesheet'>
|
||||
<link href='lib/css/skeleton.css' rel='stylesheet'>
|
||||
<link href='lib/css/layout.css' rel='stylesheet'>
|
||||
<link rel="stylesheet" href="/lib/css/normalize.css">
|
||||
<link rel="stylesheet" href="/lib/css/skeleton.css">
|
||||
|
||||
<!-- Custom styles for this template -->
|
||||
<link href='default.css' rel='stylesheet'>
|
||||
<!--[if lt IE 9]>
|
||||
<script src='http://html5shim.googlecode.com/svn/trunk/html5.js'></script>
|
||||
<![endif]-->
|
||||
<link href='/default.css' rel='stylesheet'>
|
||||
|
||||
<!-- Favicons -->
|
||||
<link href='lib/images/favicon.ico' rel='shortcut icon'>
|
||||
<link href='lib/images/apple-touch-icon.png' rel='apple-touch-icon'>
|
||||
<link href='lib/images/apple-touch-icon-72x72.png' rel='apple-touch-icon' sizes='72x72'>
|
||||
<link href='lib/images/apple-touch-icon-114x114.png' rel='apple-touch-icon' sizes='114x114'>
|
||||
<link href='/images/favicon.ico' rel='shortcut icon'>
|
||||
</head>
|
||||
<body>
|
||||
<p>
|
||||
<img src="//analytics.rekahsoft.ca/piwik.php?idsite=1" style="border:0;" alt="" />
|
||||
</p>
|
||||
|
||||
<div class='container'>
|
||||
$partial("templates/partials/logo-banner.html")$
|
||||
$partial("templates/partials/nav-nojs.html")$
|
||||
$if(recentPosts)$
|
||||
$partial("templates/partials/recent-posts-nojs.html")$
|
||||
$endif$
|
||||
$partial("templates/partials/logo-banner.html")$
|
||||
$partial("templates/partials/nav-nojs.html")$
|
||||
|
||||
<div id="page-content">
|
||||
$body$
|
||||
$partial("templates/partials/footer.html")$
|
||||
</div>
|
||||
|
||||
$partial("templates/partials/footer.html")$
|
||||
</body>
|
||||
</html>
|
||||
|
@ -1,19 +1,20 @@
|
||||
<div id='nav'>
|
||||
<ul id='nav-menu'>
|
||||
<ul class="container" id='nav-menu'>
|
||||
$for(pagesFirst)$
|
||||
<li>
|
||||
<a class='menuitem' href='$url$'>$title$</a>
|
||||
</li>
|
||||
$endfor$
|
||||
$if(pageMid)$
|
||||
$for(pageMid)$
|
||||
<li class='active'>
|
||||
<a class='menuitem' href='$url$'>$title$</a>
|
||||
</li>
|
||||
$endif$
|
||||
$endfor$
|
||||
$for(pagesLast)$
|
||||
<li>
|
||||
<a class='menuitem' href='$url$'>$title$</a>
|
||||
</li>
|
||||
$endfor$
|
||||
<a class='rss-icon' href='atom.xml'></a>
|
||||
</ul>
|
||||
</div>
|
||||
|
Loading…
Reference in New Issue
Block a user