Permalink
Browse files

pretty print date field from markdown metadata. template tweaks and s…

…tyle changes
  • Loading branch information...
1 parent 99cf5af commit dca936b12c20db7fa79c770aff4cc2a7403c8512 Andy Irving committed Oct 2, 2011
Showing with 105 additions and 74 deletions.
  1. +1 −0 .gitignore
  2. +59 −57 css/style.css
  3. +40 −12 src/site.hs
  4. +5 −5 templates/default.html
View
@@ -8,3 +8,4 @@ _site
_cache
*.*~
src/site
+.todo
View
@@ -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,51 +21,48 @@ 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;
color: silver;
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;
View
@@ -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"
View
@@ -8,8 +8,8 @@
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>Blah - $title$</title>
- <meta name="description" content="">
- <meta name="author" content="">
+ <meta name="description" content="$description$">
+ <meta name="author" content="$author$">
<meta name="viewport" content="width=device-width,initial-scale=1">
@@ -31,8 +31,8 @@
$body$
</div>
-<nav id="main">
- <ul id="navigation">
+<nav id="site">
+ <ul class="navigation">
<li><a href="/about/">About</a></li>
<li><a href="/photos/">Photos</a></li>
<li><a href="/writings/">Writings</a></li>
@@ -41,7 +41,7 @@
<footer>
<p>All contents &copy; 1999-2011 Andy Irving</p>
</footer>
-<script src="//ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>
+<script src="//ajax.googleapis.com/ajax/libs/jquery/1.6/jquery.min.js"></script>
<script>window.jQuery || document.write('<script src="/js/libs/jquery-1.6.2.min.js"><\/script>')</script>
<!-- scripts concatenated and minified via ant build script-->

0 comments on commit dca936b

Please sign in to comment.