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
|
route idRoute
|
||||||
compile copyFileCompiler
|
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")
|
tags <- buildTags ("posts/**" .&&. hasNoVersion) (fromCapture "tags/*.html")
|
||||||
|
|
||||||
paginatedPosts <- buildPaginateWith
|
paginatedPosts <- buildPaginateWith
|
||||||
@ -175,6 +187,7 @@ main = do
|
|||||||
|
|
||||||
---------------------------------------------------------------------------------------------------------
|
---------------------------------------------------------------------------------------------------------
|
||||||
-- Default Version --------------------------------------------------------------------------------------
|
-- Default Version --------------------------------------------------------------------------------------
|
||||||
|
=======
|
||||||
-- Generate tag pages
|
-- Generate tag pages
|
||||||
paginateTagsRules tags
|
paginateTagsRules tags
|
||||||
|
|
||||||
@ -247,10 +260,28 @@ main = do
|
|||||||
>>= applyAsTemplate indexCtx
|
>>= applyAsTemplate indexCtx
|
||||||
>>= loadAndApplyTemplate "templates/default.html" indexCtx
|
>>= loadAndApplyTemplate "templates/default.html" indexCtx
|
||||||
|
|
||||||
---------------------------------------------------------------------------------------------------------
|
|
||||||
-- NOJS Version -----------------------------------------------------------------------------------------
|
-- NOJS Version -----------------------------------------------------------------------------------------
|
||||||
-- tagsNoJs <- buildTags ("posts/**" .&&. hasVersion "nojs") (fromCapture "nojs/tags/*.html")
|
tagsNoJs <- buildTags ("posts/**" .&&. hasVersion "nojs") (fromCapture "nojs/tags/*.html")
|
||||||
-- tagsRules tagsNoJs $ genTagRules tagsNoJs
|
|
||||||
|
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
|
create ["nojs/atom.xml"] $ do
|
||||||
route idRoute
|
route idRoute
|
||||||
@ -260,28 +291,28 @@ main = do
|
|||||||
>>= fmap (take 10) . recentFirst
|
>>= fmap (take 10) . recentFirst
|
||||||
renderAtom (feedConfiguration Nothing) feedCtx blogPosts
|
renderAtom (feedConfiguration Nothing) feedCtx blogPosts
|
||||||
|
|
||||||
create ["nojs/archive.html"] $ do
|
-- create ["nojs/archive.html"] $ do
|
||||||
route idRoute
|
-- route idRoute
|
||||||
compile $ do
|
-- compile $ do
|
||||||
-- Load all blog posts for archive
|
-- -- Load all blog posts for archive
|
||||||
posts <- recentFirst =<< loadAllSnapshots ("posts/*" .&&. hasVersion "nojs") "content"
|
-- posts <- recentFirst =<< loadAllSnapshots ("posts/*" .&&. hasVersion "nojs") "content"
|
||||||
|
|
||||||
-- Generate nav-bar from pages/*
|
-- -- Generate nav-bar from pages/*
|
||||||
pages <- sortByM pageWeight =<< loadAll ("pages/*" .&&. hasVersion "nav-gen")
|
-- pages <- sortByM pageWeight =<< loadAll ("pages/*" .&&. hasVersion "nav-gen")
|
||||||
|
|
||||||
let archiveCtx =
|
-- let archiveCtx =
|
||||||
listField "posts" postCtx (return posts) <>
|
-- listField "posts" postCtx (return posts) <>
|
||||||
constField "title" "Archives" <>
|
-- constField "title" "Archives" <>
|
||||||
defaultContext
|
-- defaultContext
|
||||||
indexCtx =
|
-- indexCtx =
|
||||||
listField "pagesFirst" pagesCtx (return pages) <>
|
-- listField "pagesFirst" pagesCtx (return pages) <>
|
||||||
listField "pagesLast" pagesCtx (return []) <>
|
-- listField "pagesLast" pagesCtx (return []) <>
|
||||||
defaultContext
|
-- defaultContext
|
||||||
|
|
||||||
makeItem ""
|
-- makeItem ""
|
||||||
>>= loadAndApplyTemplate "templates/archive.html" archiveCtx
|
-- >>= loadAndApplyTemplate "templates/archive.html" archiveCtx
|
||||||
>>= loadAndApplyTemplate "templates/default-nojs.html" indexCtx
|
-- >>= loadAndApplyTemplate "templates/default-nojs.html" indexCtx
|
||||||
>>= relativizeUrls
|
-- >>= relativizeUrls
|
||||||
|
|
||||||
match "posts/**" $ version "nojs" $ do
|
match "posts/**" $ version "nojs" $ do
|
||||||
route $ customRoute (\r -> "nojs" </> toFilePath r) `composeRoutes` setExtension "html"
|
route $ customRoute (\r -> "nojs" </> toFilePath r) `composeRoutes` setExtension "html"
|
||||||
@ -293,56 +324,64 @@ main = do
|
|||||||
curId <- getUnderlying
|
curId <- getUnderlying
|
||||||
|
|
||||||
let (pagesFirst, pagesLast') = flip span pages $ \x ->
|
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 []
|
pagesLast = if not . null $ pagesLast' then tail pagesLast' else []
|
||||||
postNojsCtx =
|
postNojsCtx =
|
||||||
listField "pagesFirst" pagesCtx (return pagesFirst) <>
|
listField "pagesFirst" pagesCtx (return pagesFirst) <>
|
||||||
listField "pagesLast" pagesCtx (return pagesLast) <>
|
listField "pageMid" pagesCtx (return pageMid) <>
|
||||||
|
listField "pagesLast" pagesCtx (return pagesLast) <>
|
||||||
defaultContext
|
defaultContext
|
||||||
|
|
||||||
pandocCompiler
|
pandocCompilerWith pandocReaderOptions pandocWriterOptions
|
||||||
>>= saveSnapshot "content"
|
>>= saveSnapshot "content"
|
||||||
>>= loadAndApplyTemplate "templates/partials/post-nojs.html" postCtx
|
>>= loadAndApplyTemplate "templates/partials/post.html" postCtx
|
||||||
>>= loadAndApplyTemplate "templates/default-nojs.html" postNojsCtx
|
>>= loadAndApplyTemplate "templates/default-nojs.html" postNojsCtx
|
||||||
>>= relativizeUrls
|
>>= relativizeUrls
|
||||||
|
|
||||||
-- This route is used for the initial pass of the pages (nav-gen) and the final nojs page output
|
match "pages/*" $ version "nav-gen" $ do
|
||||||
let pagesNoJsRoute = customRoute (\r -> if toFilePath r == "pages/home.markdown"
|
compile $ pandocCompiler
|
||||||
|
|
||||||
|
match "pages/*" $ version "nojs" $ do
|
||||||
|
route $ customRoute (\r -> if toFilePath r == "pages/home.markdown"
|
||||||
then "pages/index.markdown"
|
then "pages/index.markdown"
|
||||||
else toFilePath r) `composeRoutes`
|
else toFilePath r) `composeRoutes`
|
||||||
gsubRoute "pages" (const "nojs") `composeRoutes`
|
gsubRoute "pages" (const "nojs") `composeRoutes`
|
||||||
setExtension "html"
|
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
|
compile $ do
|
||||||
-- Show a slideshow of blog posts using js..limit to the 3 most recent posts
|
posts <- recentFirst =<< loadAllSnapshots ("posts/**" .&&. hasVersion "nojs") "content"
|
||||||
recentPosts <- loadAllSnapshots ("posts/**" .&&. hasVersion "nojs") "content"
|
|
||||||
>>= fmap (take 3) . recentFirst
|
|
||||||
|
|
||||||
-- Generate nav-bar from pages/*
|
-- Generate nav-bar from pages/*
|
||||||
pages <- sortByM pageWeight =<< loadAll ("pages/*" .&&. hasVersion "nav-gen")
|
pages <- sortByM pageWeight =<< loadAll ("pages/*" .&&. hasVersion "nav-gen")
|
||||||
|
|
||||||
|
-- Get the current page name
|
||||||
|
pageName <- takeBaseName . toFilePath <$> getUnderlying
|
||||||
|
|
||||||
-- Get the current Identifier
|
-- Get the current Identifier
|
||||||
curId <- getUnderlying
|
curId <- getUnderlying
|
||||||
|
|
||||||
let (pagesFirst, pagesLast') = flip span pages $ \x ->
|
let (pagesFirst, pagesLast') = flip span pages $ \x ->
|
||||||
toFilePath curId /= (toFilePath . itemIdentifier $ x)
|
toFilePath curId /= (toFilePath . itemIdentifier $ x)
|
||||||
pageMid = head pagesLast'
|
pageMid = [head pagesLast']
|
||||||
pagesLast = if not . null $ pagesLast' then tail pagesLast' else []
|
pagesLast = if not . null $ pagesLast' then tail pagesLast' else []
|
||||||
|
|
||||||
|
recentPosts = take 5 posts
|
||||||
|
pageTemplate = "templates/pages/" ++ pageName ++ ".html"
|
||||||
|
|
||||||
pagesNojsCtx =
|
pagesNojsCtx =
|
||||||
listField "recentPosts" postCtx (return recentPosts) <>
|
listField "recentPosts" (taggedPostCtx tagsNoJs) (return recentPosts) <>
|
||||||
listField "pagesFirst" pagesCtx (return pagesFirst) <>
|
listField "posts" (taggedPostCtx tagsNoJs) (return posts) <>
|
||||||
field "pageMid" (const $ return . itemBody $ pageMid) <>
|
tagCloudField "tagCloud" 65 135 tagsNoJs <>
|
||||||
listField "pagesLast" pagesCtx (return pagesLast) <>
|
listField "pagesFirst" pagesCtx (return pagesFirst) <>
|
||||||
|
listField "pageMid" pagesCtx (return pageMid) <>
|
||||||
|
listField "pagesLast" pagesCtx (return pagesLast) <>
|
||||||
defaultContext
|
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
|
>>= loadAndApplyTemplate "templates/default-nojs.html" pagesNojsCtx
|
||||||
>>= relativizeUrls
|
>>= relativizeUrls
|
||||||
|
|
||||||
|
@ -1,46 +1,37 @@
|
|||||||
<!DOCTYPE html>
|
<!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'>
|
<html class='en'>
|
||||||
<head>
|
<head>
|
||||||
<!-- Basic Page Needs -->
|
<!-- Basic Page Needs -->
|
||||||
<meta charset='utf-8'>
|
<meta charset='utf-8'>
|
||||||
<link href='lib/images/favicon.png' rel='shortcut icon'>
|
|
||||||
<title>RekahSoft</title>
|
<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'>
|
<meta content='Collin Doering' name='author'>
|
||||||
|
|
||||||
<!-- Mobile Specific Metas -->
|
<!-- Mobile Specific Metas -->
|
||||||
<meta content='width=device-width, initial-scale=1, maximum-scale=1' name='viewport'>
|
<meta content='width=device-width, initial-scale=1, maximum-scale=1' name='viewport'>
|
||||||
|
|
||||||
<!-- CSS -->
|
<!-- CSS -->
|
||||||
<link href='lib/css/base.css' rel='stylesheet'>
|
<link rel="stylesheet" href="/lib/css/normalize.css">
|
||||||
<link href='lib/css/skeleton.css' rel='stylesheet'>
|
<link rel="stylesheet" href="/lib/css/skeleton.css">
|
||||||
<link href='lib/css/layout.css' rel='stylesheet'>
|
|
||||||
<!-- Custom styles for this template -->
|
<!-- Custom styles for this template -->
|
||||||
<link href='default.css' rel='stylesheet'>
|
<link href='/default.css' rel='stylesheet'>
|
||||||
<!--[if lt IE 9]>
|
|
||||||
<script src='http://html5shim.googlecode.com/svn/trunk/html5.js'></script>
|
|
||||||
<![endif]-->
|
|
||||||
<!-- Favicons -->
|
<!-- Favicons -->
|
||||||
<link href='lib/images/favicon.ico' rel='shortcut icon'>
|
<link href='/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'>
|
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<p>
|
<p>
|
||||||
<img src="//analytics.rekahsoft.ca/piwik.php?idsite=1" style="border:0;" alt="" />
|
<img src="//analytics.rekahsoft.ca/piwik.php?idsite=1" style="border:0;" alt="" />
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<div class='container'>
|
$partial("templates/partials/logo-banner.html")$
|
||||||
$partial("templates/partials/logo-banner.html")$
|
$partial("templates/partials/nav-nojs.html")$
|
||||||
$partial("templates/partials/nav-nojs.html")$
|
|
||||||
$if(recentPosts)$
|
<div id="page-content">
|
||||||
$partial("templates/partials/recent-posts-nojs.html")$
|
|
||||||
$endif$
|
|
||||||
$body$
|
$body$
|
||||||
$partial("templates/partials/footer.html")$
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
$partial("templates/partials/footer.html")$
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
@ -1,19 +1,20 @@
|
|||||||
<div id='nav'>
|
<div id='nav'>
|
||||||
<ul id='nav-menu'>
|
<ul class="container" id='nav-menu'>
|
||||||
$for(pagesFirst)$
|
$for(pagesFirst)$
|
||||||
<li>
|
<li>
|
||||||
<a class='menuitem' href='$url$'>$title$</a>
|
<a class='menuitem' href='$url$'>$title$</a>
|
||||||
</li>
|
</li>
|
||||||
$endfor$
|
$endfor$
|
||||||
$if(pageMid)$
|
$for(pageMid)$
|
||||||
<li class='active'>
|
<li class='active'>
|
||||||
<a class='menuitem' href='$url$'>$title$</a>
|
<a class='menuitem' href='$url$'>$title$</a>
|
||||||
</li>
|
</li>
|
||||||
$endif$
|
$endfor$
|
||||||
$for(pagesLast)$
|
$for(pagesLast)$
|
||||||
<li>
|
<li>
|
||||||
<a class='menuitem' href='$url$'>$title$</a>
|
<a class='menuitem' href='$url$'>$title$</a>
|
||||||
</li>
|
</li>
|
||||||
$endfor$
|
$endfor$
|
||||||
|
<a class='rss-icon' href='atom.xml'></a>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
Reference in New Issue
Block a user