diff --git a/.gitignore b/.gitignore index a1ade49..eb05c59 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,4 @@ _site _cache *.*~ src/site +.todo diff --git a/css/style.css b/css/style.css index 3381c01..050d614 100644 --- a/css/style.css +++ b/css/style.css @@ -2,10 +2,16 @@ body { background-color: #ffffff; color:black; - max-width: 60em; + max-width: 50em; margin: 0 auto; + font : 16.5px/1.5em "Georgia"; } +p + p { + text-indent:1em; + margin-top:0 } +blockquote { + margin:1.5em } a { color: #860111; @@ -15,18 +21,19 @@ a:visited { color: silver; } +h1, h2, h3, h4 { +font-weight: normal; +} + h1 { -/* margin-right: 25em; */ padding: 40px 0 30px; margin: 0; - font-size: 75px; - line-height: 1.2em; - font-weight: normal; - text-shadow: 0 2px 2px #000; - font-family: Georgia, serif; - + font-size: 218%; } +header h1 { + padding: 0 0 0 0; +} /*h2,h3,.history caption { font-face:impact; text-transform:uppercase; @@ -34,32 +41,28 @@ h1 { background-color: #860111; }*/ -h2, h3, .history caption { - color: #000000; - font-family: Arial, sans-serif; - text-shadow: 0 1px 1px #fff; + +h1 a, h2 a, h3 a, h4 a { + text-decoration : none; + font-weight : normal; } -h2 a, h3 a { - text-decoration : none; - color: #000000; - font-family: Arial, sans-serif; - text-shadow: 0 1px 1px #fff; -/* font-face:impact; - text-transform:uppercase; - color: silver; - background-color: #860111;*/ +h2 { + font-size : 164%; } -h4 a { - text-decoration : none; - font-weight : normal; +h3 { + font-size : 145%; +} + +h4 { + font-size : 118%; } -nav#main { +#site { display : block; position:absolute; - top : -0em; + top : 0; padding : 1em; clear : left; clear : right; @@ -70,14 +73,13 @@ header { margin-top : 4em; } -ul#navigation { +.navigation { display:block; list-style-type:none; } -ul#navigation li { +.navigation li { padding:0; - margin:0; display:inline; padding-right:1.2em; } @@ -123,7 +125,7 @@ footer { /* Navigation */ -nav#TOC { +#TOC { position: fixed; margin-left: 62em; top: 0; @@ -134,17 +136,17 @@ nav#TOC { width: 15em; } -nav#TOC > div li { +#TOC > div li { float: left; margin-right: 1px; } -nav#TOC > div li a, #top, #hide_menu { +#TOC > div li a, #top, #hide_menu { padding: 7px 10px 9px 10px; cursor: pointer; } -nav#TOC > div li.active a { +#TOC > div li.active a { border-top: 4px solid #0D2E4C; padding-top: 3px; color: #FFC76D; @@ -167,22 +169,22 @@ nav#TOC > div li.active a { float: left; } -nav#TOC li { +#TOC li { font-size: 16px; margin: 0px; list-style: none; } -nav#TOC > ul li:last-child a { +#TOC > ul li:last-child a { padding-bottom: 9px; } -nav#TOC > ul > li { +#TOC > ul > li { border-bottom: 1px solid #6E8294; } /* Sprite map for sidebar icons */ -nav#TOC li h1 a { +#TOC li h1 a { font-size: 15px; font-weight: bold; padding: 7px 20px 10px 32px; @@ -191,16 +193,16 @@ nav#TOC li h1 a { background-position: 3px 3px; } -nav#TOC li.nav_intro h1 a { background-image: none; padding-left: 20px; } -nav#TOC li.nav_object h1 a { background-position: 5px 3px; } -nav#TOC li.nav_function h1 a { background-position: 5px -60px; } -nav#TOC li.nav_array h1 a { background-position: 5px -28px; } -nav#TOC li.nav_types h1 a { background-position: 5px -92px; } -nav#TOC li.nav_core h1 a { background-position: 5px -124px; } -nav#TOC li.nav_other h1 a { background-position: 5px -156px; } -nav#TOC li.nav_appendix h1 a { background-position: 5px -188px; } +#TOC li.nav_intro h1 a { background-image: none; padding-left: 20px; } +#TOC li.nav_object h1 a { background-position: 5px 3px; } +#TOC li.nav_function h1 a { background-position: 5px -60px; } +#TOC li.nav_array h1 a { background-position: 5px -28px; } +#TOC li.nav_types h1 a { background-position: 5px -92px; } +#TOC li.nav_core h1 a { background-position: 5px -124px; } +#TOC li.nav_other h1 a { background-position: 5px -156px; } +#TOC li.nav_appendix h1 a { background-position: 5px -188px; } -nav#TOC a { +#TOC a { color: white; font-family: Arial, sans-serif; font-size: 13px; @@ -210,26 +212,26 @@ nav#TOC a { /* Background color for nav elements to animate */ -#nav_main, -nav#TOC a, -nav#TOC ul, -nav#TOC li { +#site, +#TOC a, +#TOC ul, +#TOC li { background-color: #556c81; } -nav#TOC a:hover, -nav#TOC li.active, -nav#TOC li.active a { +#TOC a:hover, +#TOC li.active, +#TOC li.active a { background-color: #344f68; } -nav#TOC li.active a:hover, -nav#TOC li a.active, -nav#TOC li a.active:hover { +#TOC li.active a:hover, +#TOC li a.active, +#TOC li a.active:hover { background-color: #0D2E4C; } -nav#TOC a:hover, nav ul.active a:hover, nav a, nav li { +#TOC a:hover, nav ul.active a:hover, nav a, nav li { -moz-transition-property: background-color, color; -moz-transition-duration: 0.3s; diff --git a/src/site.hs b/src/site.hs index 9f271f2..8558d01 100644 --- a/src/site.hs +++ b/src/site.hs @@ -9,10 +9,13 @@ import Text.Blaze.Html5 ((!),toValue) import qualified Text.Blaze.Html5 as H import qualified Text.Blaze.Html5.Attributes as A import Data.Monoid (mempty, mconcat, mempty, mappend) -import Data.List (elemIndex) +import Data.List (elemIndex, intercalate) import Data.Maybe (fromMaybe) +import Data.Time.Clock (UTCTime) +import Data.Time.Format (parseTime, formatTime) +import System.Locale (TimeLocale, defaultTimeLocale) import System.FilePath (combine, dropExtension, takeFileName) -import Text.Pandoc (bottomUp, defaultWriterOptions, Pandoc, WriterOptions(..), writeHtmlString, readMarkdown, defaultParserState) +import Text.Pandoc (bottomUp, defaultWriterOptions, Pandoc, WriterOptions(..), writeHtmlString, readMarkdown, defaultParserState, Block(Para), Inline(Link)) type Diff = [(DI, [String])] fileStore :: FileStore @@ -29,17 +32,21 @@ getDiff = unsafeCompiler $ \(page,rl) -> do return $ head diffs renderDiff :: (DI, [String]) -> String -renderDiff l = diffInd (fst l) ++ unlines (snd l) --renderHtml $ H.pre ! A.class_ (attrCls (fst l)) $ diffCnt l +renderDiff l = diffInd (fst l) ++ unlines (snd l) ++ diffInd (fst l) ++ nl (fst l) --renderHtml $ H.pre ! A.class_ (attrCls (fst l)) $ diffCnt l where attrCls c = toValue $ diffStr "diff" c diffCnt l' = H.toHtml $ diffInd (fst l') ++ unlines (snd l') diffStr a b = a ++ show b diffInd i = case i of - F -> "-" - S -> "+" + F -> "~~" -- strikeout + S -> "**" -- emphasis B -> "" + nl i = case i of + F -> "\n" + S -> "\n" + otherwise -> "" getFileDiff :: FilePath -> (Revision, Revision) -> IO Diff -getFileDiff f (a,b) = diff fileStore f (Just $ revId a) (Just $ revId b) +getFileDiff f (a,b) = diff fileStore f (Just $ revId b) (Just $ revId a) getRevisions :: FilePath -> IO [(Revision, Revision)] getRevisions f = do @@ -55,13 +62,18 @@ getListPrev i l = l !! checkBounds (fromMaybe 0 (i `elemIndex` l) +1 ) constructDiff :: String -> Diff -> Compiler () (Page String) constructDiff i d = constA mempty >>> addDefaultFields >>> arr applySelf +-- >>> pageCompiler (fromIdentifier $parseIdentifier i) >>> \res page -> do +-- return page >>> arr (setField "diff" (writeHtmlString options $ readMarkdown defaultParserState $ diff' d)) - -- >>> arr (setField "diff" (diff' d)) >>> arr (setField "title" ("Changes " ++ i)) + >>> renderTagsField "prettytags" (fromCapture "tags/*") >>> applyTemplateCompiler "templates/diff.html" >>> applyTemplateCompiler "templates/default.html" >>> relativizeUrlsCompiler - where diff' = concatMap renderDiff + where diff' = concatMap renderDiff + +applyDiffMarkup :: undefined +applyDiffMarkup = undefined makeRevisionCompiler :: Compiler (Page String) @@ -117,6 +129,10 @@ main = hakyll $ do match "files/*" $ do route idRoute compile copyFileCompiler + match "js/**" $ do + route idRoute + compile copyFileCompiler + -- apply unixFilter to compile coffeescript & minify js -- Compress CSS match "css/*" $ do route idRoute @@ -129,16 +145,17 @@ main = hakyll $ do >>> relativizeUrlsCompiler -- Render articles _ <- ($) match "articles/*" $ do - route $ setExtension ".html" + route routePage compile $ pageCompilerWith defaultHakyllParserState options >>> renderModificationTime "modified" "%B %e, %Y" + >>> arr(changeField "date" prettyPrintDate) -- >>> copyBodyFromField "date" >>> renderTagsField "prettytags" (fromCapture "tags/*") >>> addRevisionList >>> applyTemplateCompiler "templates/post.html" >>> applyTemplateCompiler "templates/default.html" >>> relativizeUrlsCompiler - group "diffs" $ match "articles/*" $ do + group "diffs" $ match "articles/*" $ metaCompileWith "diffs" $ requireAll_ "articles/*" >>> mapCompiler makeRevisionCompiler match "diffs/*" $ route $( gsubRoute "diffs/" (const "articles/diffs/") `composeRoutes` setExtension "html") @@ -147,6 +164,8 @@ main = hakyll $ do match "index.html" $ route idRoute create "index.html" $ constA mempty >>> arr (setField "title" "Andy Irving") + >>> arr (setField "description" "The personal website of Andy Irving") + >>> arr (setField "author" "Andy Irving") >>> requireA "tags" (setFieldA "tagcloud" renderTagCloud') >>> requireAllA "articles/*" (id *** arr (take 3 . reverse . sortByBaseName) >>> addPostList) >>> applyTemplateCompiler "templates/index.html" @@ -172,10 +191,19 @@ options :: WriterOptions options = defaultWriterOptions{ writerTableOfContents = True, writerTemplate = "$if(toc)$\n$toc$\n$endif$\n$body$", writerWrapText = True, - writerColumns = 80, + writerColumns = 72, writerTabStop = 4, writerStandalone = True, writerSectionDivs = True, - writerHtml5 = True + writerHtml5 = True, + writerReferenceLinks = False } + +prettyPrintDate :: String -> String +prettyPrintDate date = fromMaybe defaultValue $ do + let dateString = intercalate "-" $ take 3 $ splitAll "-" date + time <- parseTime defaultTimeLocale "%Y-%m-%d" dateString :: Maybe UTCTime + return $ formatTime defaultTimeLocale format time + where defaultValue = "Unknown" + format = "%B %e, %Y" diff --git a/templates/default.html b/templates/default.html index 9f9857c..81a5049 100644 --- a/templates/default.html +++ b/templates/default.html @@ -8,8 +8,8 @@ Blah - $title$ - - + + @@ -31,8 +31,8 @@

$title$

$body$ -