Skip to content

Commit

Permalink
CSS optimizations.
Browse files Browse the repository at this point in the history
  • Loading branch information
Kyle Marek-Spartz committed Dec 5, 2014
1 parent afb8cbb commit 802be82
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 10 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -12,3 +12,4 @@ presentations/*.html
.cabal-sandbox .cabal-sandbox
cabal.sandbox.config cabal.sandbox.config
dist dist
css/combined.css
1 change: 1 addition & 0 deletions build_css.sh
@@ -0,0 +1 @@
cat css/syntax.css css/markdown.css css/default.css > css/combined.css
1 change: 1 addition & 0 deletions css/default.css
@@ -1,3 +1,4 @@
/* default.css */
iframe { iframe {
border: none; border: none;
} }
Expand Down
17 changes: 11 additions & 6 deletions site.hs
Expand Up @@ -2,9 +2,10 @@
{-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE OverloadedStrings #-}
module Main where module Main where


import Data.Monoid ((<>)) import Control.Applicative ((<$>))
import Data.List (isPrefixOf, isSuffixOf) import Data.Monoid ((<>))
import System.FilePath (takeFileName) import Data.List (isPrefixOf, isSuffixOf)
import System.FilePath (takeFileName)


import Text.Pandoc.Options ( WriterOptions import Text.Pandoc.Options ( WriterOptions
, writerHTMLMathMethod , writerHTMLMathMethod
Expand Down Expand Up @@ -40,7 +41,7 @@ main = hakyllWith config $ do


match staticContent $ idR copyFileCompiler match staticContent $ idR copyFileCompiler


match "css/*" $ idR compressCssCompiler -- match "css/*" $ idR compressCssCompiler


match "posts/*" $ do match "posts/*" $ do
route $ setExtension "html" route $ setExtension "html"
Expand All @@ -55,7 +56,7 @@ main = hakyllWith config $ do
create ["posts/tags/index.html"] $ idR $ tagsCompiler tags create ["posts/tags/index.html"] $ idR $ tagsCompiler tags


create ["blog.html"] $ idR $ postsCompiler tags create ["blog.html"] $ idR $ postsCompiler tags

create ["index.html"] $ idR $ homeCompiler tags create ["index.html"] $ idR $ homeCompiler tags


create ["atom.xml"] $ idR $ feedCompiler tags create ["atom.xml"] $ idR $ feedCompiler tags
Expand All @@ -64,6 +65,7 @@ main = hakyllWith config $ do


match "templates/*" $ compile templateCompiler match "templates/*" $ compile templateCompiler


match "css/combined.css" $ compile cssTemplateCompiler


------------------------------------------------------------------------------- -------------------------------------------------------------------------------


Expand All @@ -75,6 +77,9 @@ defaultTemplateWith template ctx =
>>= loadAndApplyTemplate "templates/default.html" ctx >>= loadAndApplyTemplate "templates/default.html" ctx
>>= relativizeUrls >>= relativizeUrls


cssTemplateCompiler :: Compiler (Item Template)
cssTemplateCompiler = cached "Hakyll.Web.Template.cssTemplateCompiler" $
fmap (readTemplate . compressCss) <$> getResourceString


tagCompiler :: Tags -> String -> Pattern -> Compiler (Item String) tagCompiler :: Tags -> String -> Pattern -> Compiler (Item String)
tagCompiler tags tag pattern = do tagCompiler tags tag pattern = do
Expand Down Expand Up @@ -181,7 +186,7 @@ writerOptions = defaultHakyllWriterOptions
config :: Configuration config :: Configuration
config = defaultConfiguration config = defaultConfiguration
{ ignoreFile = ignoreFile' { ignoreFile = ignoreFile'
, deployCommand = "pushd presentations && ./build.sh && popd && ./build_cv.sh && ./build_sitemap.sh && pushd _site && widely push && popd" , deployCommand = "./build_css.sh && pushd presentations && ./build.sh && popd && ./build_cv.sh && ./build_sitemap.sh && pushd _site && widely push && popd"
} }
where where
ignoreFile' path ignoreFile' path
Expand Down
16 changes: 12 additions & 4 deletions templates/default.html
Expand Up @@ -7,10 +7,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="$if(description)$$description$$else$$title$ – kms$endif$"> <meta name="description" content="$if(description)$$description$$else$$title$ – kms$endif$">
<link rel="icon" href="/favicon.ico" type="image/x-icon"/> <link rel="icon" href="/favicon.ico" type="image/x-icon"/>
<link rel="stylesheet" type="text/css" href="/css/syntax.css"/> <style>$partial("css/combined.css")$</style>
<link rel="stylesheet" type="text/css" href="/css/markdown.css" />
<link href='http://fonts.googleapis.com/css?family=EB+Garamond|Inconsolata|Source+Sans+Pro:300,300italic' rel='stylesheet' type='text/css'>
<link rel="stylesheet" type="text/css" href="/css/default.css"/>
</head> </head>
<body> <body>
<header> <header>
Expand Down Expand Up @@ -52,6 +49,17 @@ <h1>
</script> </script>
<script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script> <script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
$endif$<script> $endif$<script>
var cb = function() {
var l = document.createElement('link'); l.rel = 'stylesheet'; l.type = 'text/css';
l.href = 'http://fonts.googleapis.com/css?family=EB+Garamond|Inconsolata|Source+Sans+Pro:300,300italic';
var h = document.getElementsByTagName('head')[0]; h.parentNode.insertBefore(l, h);
};
var raf = requestAnimationFrame || mozRequestAnimationFrame ||
webkitRequestAnimationFrame || msRequestAnimationFrame;
if (raf) raf(cb);
else window.addEventListener('load', cb);
</script>
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
Expand Down

0 comments on commit 802be82

Please sign in to comment.