diff --git a/blog.cabal b/blog.cabal index e0f37d9aed130057001f440e87c63db26ba928a8..7dfe258da266b3d20265b5ab193cef53b9b190f0 100644 --- a/blog.cabal +++ b/blog.cabal @@ -31,9 +31,11 @@ executable server default-language: Haskell2010 ghc-options: -threaded build-depends: base == 4.*, + safe == 0.3.*, text, bytestring == 0.10.*, warp == 3.*, + warp-tls == 3.*, wai == 3.*, wai-extra <= 3.0.14, wai-app-static == 3.* diff --git a/css/app.css b/css/app.css index 93cf1869d52674e8959c6dc9d36cbf913dc343a9..ecad21973b3ed965387be400526fdbd387d525d4 100644 --- a/css/app.css +++ b/css/app.css @@ -5129,6 +5129,9 @@ figcaption { figcaption::before { content: 'fig. '; } +.wf-loading h1, .wf-loading p { + visibility: hidden; } + @media screen and (min-width: 40em) { .masonry { -webkit-column-count: 3; diff --git a/images/posts/POODLE.png b/images/posts/POODLE.png new file mode 100644 index 0000000000000000000000000000000000000000..f9ece24e41bd20b25d92c4d33b751d30a3e25e37 Binary files /dev/null and b/images/posts/POODLE.png differ diff --git a/images/posts/ensure-logo.png b/images/posts/ensure-logo.png new file mode 100644 index 0000000000000000000000000000000000000000..a22db232f82b53cd89d6f94e39977c7db95a6d0d Binary files /dev/null and b/images/posts/ensure-logo.png differ diff --git a/images/posts/foundation-checkbox.png b/images/posts/foundation-checkbox.png new file mode 100644 index 0000000000000000000000000000000000000000..c2cb462018a33e0e512334fcf4072ca791c8e2e4 Binary files /dev/null and b/images/posts/foundation-checkbox.png differ diff --git a/images/posts/hypercube.png b/images/posts/hypercube.png new file mode 100644 index 0000000000000000000000000000000000000000..010d3c0d861e714f34ccb1381b4f6bb34a1849b6 Binary files /dev/null and b/images/posts/hypercube.png differ diff --git a/images/posts/legit-logo.png b/images/posts/legit-logo.png new file mode 100644 index 0000000000000000000000000000000000000000..88f2b7ba68f1c9b8ac6b0113a541b822369686ba Binary files /dev/null and b/images/posts/legit-logo.png differ diff --git a/images/posts/snake2.png b/images/posts/snake2.png new file mode 100644 index 0000000000000000000000000000000000000000..7540a57b5d929220797052bd72ced5e6137611a2 Binary files /dev/null and b/images/posts/snake2.png differ diff --git a/images/posts/snake3.png b/images/posts/snake3.png new file mode 100644 index 0000000000000000000000000000000000000000..10a0b2c52b86197326c95bc2901b9414ce37c314 Binary files /dev/null and b/images/posts/snake3.png differ diff --git a/images/schwarzwald/2014-05-01_00001.jpg b/images/schwarzwald/2014-05-01_00001.jpg new file mode 100644 index 0000000000000000000000000000000000000000..9da87cc23af8c66619076821e0c085b53cdffdde Binary files /dev/null and b/images/schwarzwald/2014-05-01_00001.jpg differ diff --git a/images/schwarzwald/2014-05-01_00002.jpg b/images/schwarzwald/2014-05-01_00002.jpg new file mode 100644 index 0000000000000000000000000000000000000000..68a16746ee1249d907c60a0cd0fa4c9b4608aade Binary files /dev/null and b/images/schwarzwald/2014-05-01_00002.jpg differ diff --git a/images/schwarzwald/2014-05-01_00003.jpg b/images/schwarzwald/2014-05-01_00003.jpg new file mode 100644 index 0000000000000000000000000000000000000000..435a019eba1a6b4b216c136775bb3e2b4cc540dd Binary files /dev/null and b/images/schwarzwald/2014-05-01_00003.jpg differ diff --git a/images/schwarzwald/2014-05-01_00004.jpg b/images/schwarzwald/2014-05-01_00004.jpg new file mode 100644 index 0000000000000000000000000000000000000000..af99642be0e39d1aa5c952f78f64e18f7420c7d0 Binary files /dev/null and b/images/schwarzwald/2014-05-01_00004.jpg differ diff --git a/images/schwarzwald/2014-05-01_00005.jpg b/images/schwarzwald/2014-05-01_00005.jpg new file mode 100644 index 0000000000000000000000000000000000000000..df98b2695f085475340af4fe9cd7ed53aa7140c1 Binary files /dev/null and b/images/schwarzwald/2014-05-01_00005.jpg differ diff --git a/images/schwarzwald/2014-05-01_00006.jpg b/images/schwarzwald/2014-05-01_00006.jpg new file mode 100644 index 0000000000000000000000000000000000000000..1f9d92325b4b95603c1f3509875b7ee3937cebd1 Binary files /dev/null and b/images/schwarzwald/2014-05-01_00006.jpg differ diff --git a/images/schwarzwald/2014-05-01_00007.jpg b/images/schwarzwald/2014-05-01_00007.jpg new file mode 100644 index 0000000000000000000000000000000000000000..538d4d142c20db28fb63f20599428479590c9a88 Binary files /dev/null and b/images/schwarzwald/2014-05-01_00007.jpg differ diff --git a/images/schwarzwald/2014-05-01_00008.jpg b/images/schwarzwald/2014-05-01_00008.jpg new file mode 100644 index 0000000000000000000000000000000000000000..3f83ce15ec37c39cc5d7f125d37ad35d02d6bc80 Binary files /dev/null and b/images/schwarzwald/2014-05-01_00008.jpg differ diff --git a/images/schwarzwald/2014-05-01_00009.jpg b/images/schwarzwald/2014-05-01_00009.jpg new file mode 100644 index 0000000000000000000000000000000000000000..8f894ad48248372e58fcc0a4a9a669323453c1ae Binary files /dev/null and b/images/schwarzwald/2014-05-01_00009.jpg differ diff --git a/images/schwarzwald/2014-05-01_00010.jpg b/images/schwarzwald/2014-05-01_00010.jpg new file mode 100644 index 0000000000000000000000000000000000000000..4e120a688bea57a992506e460d00f5892bb618d1 Binary files /dev/null and b/images/schwarzwald/2014-05-01_00010.jpg differ diff --git a/images/schwarzwald/2014-05-01_00011.jpg b/images/schwarzwald/2014-05-01_00011.jpg new file mode 100644 index 0000000000000000000000000000000000000000..5e7e360f9ad435b557b947347c5d0b1ff3d9ca06 Binary files /dev/null and b/images/schwarzwald/2014-05-01_00011.jpg differ diff --git a/images/schwarzwald/2014-05-01_00012.jpg b/images/schwarzwald/2014-05-01_00012.jpg new file mode 100644 index 0000000000000000000000000000000000000000..17a9bab56f50bcfbc3df167f46e45c530aae33b9 Binary files /dev/null and b/images/schwarzwald/2014-05-01_00012.jpg differ diff --git a/images/schwarzwald/2014-05-01_00013.jpg b/images/schwarzwald/2014-05-01_00013.jpg new file mode 100644 index 0000000000000000000000000000000000000000..d647d47eb7efd5c1e174863d961a44980196a22c Binary files /dev/null and b/images/schwarzwald/2014-05-01_00013.jpg differ diff --git a/images/schwarzwald/2014-05-01_00014.jpg b/images/schwarzwald/2014-05-01_00014.jpg new file mode 100644 index 0000000000000000000000000000000000000000..0332f1d97f7d4d1a32b10cbf1c1c3d55c3048102 Binary files /dev/null and b/images/schwarzwald/2014-05-01_00014.jpg differ diff --git a/images/schwarzwald/2014-05-01_00015.jpg b/images/schwarzwald/2014-05-01_00015.jpg new file mode 100644 index 0000000000000000000000000000000000000000..73bbf58c237aa9d7b2fce770d30516400f91e3cc Binary files /dev/null and b/images/schwarzwald/2014-05-01_00015.jpg differ diff --git a/images/schwarzwald/2014-05-01_00016.jpg b/images/schwarzwald/2014-05-01_00016.jpg new file mode 100644 index 0000000000000000000000000000000000000000..754dd60e5190aeeda853112c6df25cd1b1bc3743 Binary files /dev/null and b/images/schwarzwald/2014-05-01_00016.jpg differ diff --git a/images/tumblr/background.png b/images/tumblr/background.png new file mode 100644 index 0000000000000000000000000000000000000000..d26a914c5a8f5ba89dab6985ca260bdc4a4352c0 Binary files /dev/null and b/images/tumblr/background.png differ diff --git a/images/tumblr/colorbar.png b/images/tumblr/colorbar.png new file mode 100644 index 0000000000000000000000000000000000000000..4aaf2cbab3f526d8c337bd57171e2b918a51cf9a Binary files /dev/null and b/images/tumblr/colorbar.png differ diff --git a/images/tumblr/logo.png b/images/tumblr/logo.png new file mode 100644 index 0000000000000000000000000000000000000000..c3c225c28f793ed27cd566e4c11d813b9edadcd9 Binary files /dev/null and b/images/tumblr/logo.png differ diff --git a/images/tumblr/style.css b/images/tumblr/style.css new file mode 100644 index 0000000000000000000000000000000000000000..0a08e45af0ebd9b7eb82f59523f431db45a04f9c --- /dev/null +++ b/images/tumblr/style.css @@ -0,0 +1,22 @@ +body { + background-image: url('background.png'); + background-repeat: no-repeat; + background-position: center top; + background-color: #1A1A1A; + background-size: 1920px; +} + +.logo { + width: 250px; + height: 90px; + background-image: url('logo.png'); + background-size: 250px 90px; + display: block; + margin-bottom: 20px; +} + +#color_bar { + background-color: #ABC837; + background-image: url('colorbar.png'); + background-size: 300px; +} diff --git a/posts/2014-03-08-php-is-not-dead.md b/posts/2014-03-08-php-is-not-dead.md index d8a77f1035c8020b1cd6990fb42145a8200c3bca..4a29ebfa5ae56f3709f4e93fda64378ce6b9fc32 100644 --- a/posts/2014-03-08-php-is-not-dead.md +++ b/posts/2014-03-08-php-is-not-dead.md @@ -19,7 +19,7 @@ Sadly, __the general consensus in some cases still seems to be that applications In addition to the regular need to improve software, this situation has pushed the PHP community to improve their practices and have a modern development workflow. Sort of like a __?We can do modern development too?__, which shows that the community is resilient and that it is open to major changes. <blockquote class="twitter-tweet" lang="en"><p>Chris Spruck (<a href="https://twitter.com/cspruck">@cspruck</a>) delivers the announcements to a packed house at <a href="https://twitter.com/AtlantaPHP">@AtlantaPHP</a> earlier tonight. <a href="http://t.co/yleFZQwh9u">pic.twitter.com/yleFZQwh9u</a></p>— Ben Ramsey (@ramsey) <a href="https://twitter.com/ramsey/statuses/441803542891081729">March 7, 2014</a></blockquote> -<script async src="//platform.twitter.com/widgets.js" charset="utf-8"></script> +<script async src="https://platform.twitter.com/widgets.js" charset="utf-8"></script> A few days ago I attended an [AtlantaPHP](http://atlantaphp.org) talk on modern PHP development, by [Ben Ramsey (@ramsey)](https://twitter.com/ramsey), and some of the ideas that got my attention were that the PHP community is very good at ?borrowing? concepts and including them into the language and frameworks, and that PHP development is not only about the language itself, but the tools around it and they way applications are built. @@ -33,7 +33,7 @@ Additionally, just because somebody writes an application in PHP it doesn't mean ## A modern PHP framework - + The other big thing in PHP right now are frameworks. There are a bunch of them, and thanks to standards and Composer they are all cooperating together. My favorite one so far is Laravel. diff --git a/posts/2014-06-07-ensurejs.md b/posts/2014-06-07-ensurejs.md index d41c8dc95ac938386179e2ba868172617cc9d27b..42161d77672352abe13ceef24bfa0dbcedccc99d 100644 --- a/posts/2014-06-07-ensurejs.md +++ b/posts/2014-06-07-ensurejs.md @@ -5,7 +5,7 @@ uuid: 3dc96fbd-5409-4d5b-926b-b1daa3ed3809 legacy: ensurejs-simple-type-checking-on-javascript --- - + ## From type-safe to type-unsafe? Coming from a world of Object Oriented languages and starting to work on JavaScript projects can be a little bit frustrating some times. You try to think in terms of classes, inheritance, interfaces, namespaces, etc. diff --git a/posts/2014-09-18-two-problems-from-ai-class.md b/posts/2014-09-18-two-problems-from-ai-class.md index ea280d00e4af972b0d270fe9b1bc025420e17ca0..8549e6c6cdae11cdb0ec0844ea36599b13151055 100644 --- a/posts/2014-09-18-two-problems-from-ai-class.md +++ b/posts/2014-09-18-two-problems-from-ai-class.md @@ -13,7 +13,7 @@ The Snake-in-the-box problem begins with a n dimensional hypercube. It consists Example 4-dimensional hypercube: - + A nice property about each node in a n-dimension cube is that they can be represented in n-digit binary numbers, and the difference between neighbors is one bit flip (In a 4-dimension hypercube, `0000` and `0001` are neighbors). @@ -55,7 +55,7 @@ This does not necessarily yield the correct solution, but it allows us to take a As a nice added extra, I was able to use a Symfony component for displaying information about the progress of the program, including an estimate of how much time it will take to go through all the iterations: - + ## Find the zebra diff --git a/posts/2014-10-17-poodle-nodejs.md b/posts/2014-10-17-poodle-nodejs.md index de1750ae2e4d8ee0bcbdd8616d033695cb98d9d0..91c4773629be200b1ee306fd3edf9d8d80087f45 100644 --- a/posts/2014-10-17-poodle-nodejs.md +++ b/posts/2014-10-17-poodle-nodejs.md @@ -5,7 +5,7 @@ uuid: bfa447a6-0b2b-44e2-b693-b042f209d8cf legacy: poodle-and-nodejs --- - + Earlier this week Google released details on a new security flaw that some of their researchers found in SSL version 3.0. diff --git a/posts/2014-10-18-foundation-checkboxes.md b/posts/2014-10-18-foundation-checkboxes.md index aa0c19aefaab8cb8b2bbe85e97a4956f0be48b09..89bad9948124b2c78f4d8c1dd1794001c138b7fb 100644 --- a/posts/2014-10-18-foundation-checkboxes.md +++ b/posts/2014-10-18-foundation-checkboxes.md @@ -15,4 +15,4 @@ I use the following SCSS to style checkbox input elements. The original code was The final result should look something like this: -<img src="http://assets.chromabits.com/posts/foundation-checkbox.png" style="max-width: 200px; margin-left: auto; margin-right: auto"> +<img src="/images/posts/foundation-checkbox.png" style="max-width: 200px; margin-left: auto; margin-right: auto"> diff --git a/posts/2014-11-05-modernphp-slides.md b/posts/2014-11-05-modernphp-slides.md index f4b2f2a9247555ca952b33405fce276b5949fe44..48131934470907333c5f7d4638fc060758f47892 100644 --- a/posts/2014-11-05-modernphp-slides.md +++ b/posts/2014-11-05-modernphp-slides.md @@ -8,6 +8,6 @@ legacy: modern-php-talk-slides Here are the slides for my presentation on Modern PHP development with Laravel and Symfony from November 4th: -<iframe src="//www.slideshare.net/slideshow/embed_code/41134082" +<iframe src="https://www.slideshare.net/slideshow/embed_code/41134082" width="476" height="400" frameborder="0" marginwidth="0" marginheight="0" scrolling="no"></iframe> diff --git a/posts/2014-11-08-ensurejs-documentation-shields.md b/posts/2014-11-08-ensurejs-documentation-shields.md index e6a40283d54784ace4c88877935171dd5b319276..a439cd2755019211f94eb91f92d57a8bf38ecd9f 100644 --- a/posts/2014-11-08-ensurejs-documentation-shields.md +++ b/posts/2014-11-08-ensurejs-documentation-shields.md @@ -11,7 +11,7 @@ It's been a while since I worked on Ensure.js, but I finally got around polishin ## New documentation - + Most of the library is now documented using JSdoc. Most functions should have explanations of their behavior and some of them have usage examples. diff --git a/posts/2014-12-04-minecraft-bot-nodejs.md b/posts/2014-12-04-minecraft-bot-nodejs.md index e07ed8d90c77aef70ce5b7741810d241a9698e7a..1e43abcec9f1a7caa6f86860e2ed92774a77c131 100644 --- a/posts/2014-12-04-minecraft-bot-nodejs.md +++ b/posts/2014-12-04-minecraft-bot-nodejs.md @@ -20,7 +20,7 @@ The final goal is to have the bot build a simple column it can climb at night so ### Demo: -<iframe width="480" height="360" src="//www.youtube.com/embed/6Fk0kv0LM3g?rel=0" frameborder="0" allowfullscreen></iframe> +<iframe width="480" height="360" src="https://www.youtube.com/embed/6Fk0kv0LM3g?rel=0" frameborder="0" allowfullscreen></iframe> ### Source code diff --git a/posts/2015-02-18-phabricator-bot.md b/posts/2015-02-18-phabricator-bot.md index 5133c1d7b9b267d732d3a9f2a9912445466fbc76..c00430a3c6ac59a2f605b0652c98ad637f243d3e 100644 --- a/posts/2015-02-18-phabricator-bot.md +++ b/posts/2015-02-18-phabricator-bot.md @@ -8,7 +8,7 @@ author: Eduardo Trujillo As the result of a short hacking session, I built a simple Node.js bot that forwards items from the Phabricator news feed into a Slack channel: - + Phabricator supports calling POST endpoints whenever there is a new feed item (setup through the `feed.http-hooks`). However, we can't just forward these directly to Slack. The main task of the bot is to take these requests from Phabricator, fetch some extra information using Conduit and the calling another webhook to deliver the message to a Slack channel. diff --git a/posts/2015-05-10-heapster-deis.md b/posts/2015-05-10-heapster-deis.md index 90a36ab5fcaa0648e454457a7b5091d7e37695bd..f1778a70f597d8dc2beca44cefce3d85f63c2d7c 100644 --- a/posts/2015-05-10-heapster-deis.md +++ b/posts/2015-05-10-heapster-deis.md @@ -6,7 +6,7 @@ legacy: heapster-and-deis-so-hip author: Eduardo Trujillo --- - + I've been playing with Deis, a Docker orchestration platform on AWS for the past few days. In fact, I got some services running on it. I have found it to be very diff --git a/scss/app.scss b/scss/app.scss index f7b71e6f5e05e8856b1048e81232d05f1efcfcb5..cfa75d3b99037d700a8cecbab126d26a4c4ada18 100644 --- a/scss/app.scss +++ b/scss/app.scss @@ -100,6 +100,10 @@ figcaption { } } +.wf-loading h1, .wf-loading p { + visibility: hidden; +} + @include breakpoint(medium) { .masonry { column-count: 3; diff --git a/server.hs b/server.hs index b7d3f1b52a9b22a3a30c1e61fc8846723aca6ade..16fed357a518a027bd4efbd3e41cd1c0dcf4b894 100644 --- a/server.hs +++ b/server.hs @@ -1,42 +1,49 @@ {-# LANGUAGE OverloadedStrings #-} +import Control.Concurrent (forkIO) +import Data.Monoid ((<>)) import qualified Data.ByteString as BS (ByteString, pack) import Data.String (fromString) import qualified Data.Text as T (Text, concat, pack) import qualified Data.Text.Encoding as TE (encodeUtf8) import Data.Maybe (mapMaybe, fromMaybe) +import Safe (lastMay) import System.Environment (lookupEnv) import Network.Wai (Application, Middleware, pathInfo) -import Network.Wai.Handler.Warp (run) +import Network.Wai.Handler.Warp (run, defaultSettings, setPort) +import Network.Wai.Handler.WarpTLS (runTLS, tlsSettingsChain) import Network.Wai.Application.Static (staticApp , defaultWebAppSettings , ssIndices , ssRedirectToIndex , ssAddTrailingSlash , ss404Handler + , ssMaxAge ) -import WaiAppStatic.Types (toPiece) +import WaiAppStatic.Types (toPiece, MaxAge(MaxAgeSeconds)) import Network.Wai.Middleware.RequestLogger (logStdout) import Network.Wai.Middleware.Gzip (gzip, def) import Network.Wai.Middleware.ForceSSL (forceSSL) import Network.Wai.Middleware.ForceDomain (forceDomain) import Network.Wai.Middleware.Vhost (redirectTo) +import Network.Wai.Middleware.AddHeaders (addHeaders) -- | The core application. -- It serves files from `_site` whic is where Hakyll will place the generated -- site. -staticSite :: Application -staticSite = staticApp - (defaultWebAppSettings $ fromString "_site") +staticSite :: Maybe String -> Application +staticSite path = staticApp + (defaultWebAppSettings $ fromString $ fromMaybe "_site" path) { ssIndices = mapMaybe (toPiece . T.pack) ["index.html"] , ssRedirectToIndex = False , ssAddTrailingSlash = True , ss404Handler = Just redirectApp + , ssMaxAge = MaxAgeSeconds 3600 } -- | 404 handler. --- We will redirect users back to the homepage if the reosurce they are looking --- for is not found. +-- We will redirect users to a 404 page if we can't locate the resource they +-- are looking for. redirectApp :: Application redirectApp req sendResponse = sendResponse $ redirectTo "/" @@ -55,16 +62,55 @@ domainMiddleware = forceDomain "chromabits.com" -> Nothing _ -> Just "chromabits.com") +-- | Common headers middleware. +headersMiddleware :: Middleware +headersMiddleware = addHeaders + [ ("Strict-Transport-Security", "max-age=31536000; includeSubdomains") + , ("X-Frame-Options", "SAMEORIGIN") + , ("X-XSS-Protection", "1; mode=block") + , ("X-Content-Type-Options", "nosniff") + ] + +cspHeadersMiddleware :: Middleware +cspHeadersMiddleware = addHeaders + [("Content-Security-Policy", TE.encodeUtf8 $ glue policies)] + where + glue :: [T.Text] -> T.Text + glue [] = "default-src 'none'" + glue [x] = x + glue xs = T.concat $ map (\x -> T.concat [x, "; "]) (init xs) ++ [last xs] + + policies :: [T.Text] + policies = [ "default-src 'self'" + , "script-src 'self' 'unsafe-inline' https://use.typekit.net" + <> " https://cdn.mathjax.org https://connect.facebook.net" + <> " https://*.twitter.com https://cdn.syndication.twimg.com" + <> " https://gist.github.com" + <> " https://*.google-analytics.com/ga.js" + , "img-src 'self' https: data: platform.twitter.com" + , "font-src 'self' data: https://use.typekit.net" + <> " https://cdn.mathjax.org" + , "style-src 'self' 'unsafe-inline' https://use.typekit.net" + <> " platform.twitter.com https://assets-cdn.github.com" + , "frame-src https://www.youtube.com https://www.slideshare.net" + <> " staticxx.facebook.com www.facebook.com" + ] + -- | De-indefify middleware. -- Redirects any path ending in `/index.html` to just `/`. deindexifyMiddleware :: Middleware deindexifyMiddleware app req sendResponse = - if maybeLast (pathInfo req) == Just "index.html" + if lastMay (pathInfo req) == Just "index.html" then sendResponse $ redirectTo newPath else app req sendResponse where newPath :: BS.ByteString - newPath = TE.encodeUtf8 $ T.concat (map prefixSlash oldPath) + newPath = TE.encodeUtf8 $ processPath oldPath + + processPath :: [T.Text] -> T.Text + processPath xs = case xs of + [] -> "/" + _ -> T.concat $ map prefixSlash xs oldPath :: [T.Text] oldPath = init $ pathInfo req @@ -72,11 +118,6 @@ deindexifyMiddleware app req sendResponse = prefixSlash :: T.Text -> T.Text prefixSlash x = T.concat ["/", x] -maybeLast :: [a] -> Maybe a -maybeLast xs = case xs of - [] -> Nothing - _ -> Just (last xs) - -- | Serves a WAI Application on the specified port. -- The target port is printed to stdout before hand, which can be useful for -- debugging purposes. @@ -87,22 +128,54 @@ listen port app = do -- Serve the WAI app using Warp run port app +-- | Serves a WAI Application on the specified port. +-- The target port is printed to stdout before hand, which can be useful for +-- debugging purposes. +listenTLS :: Int -> Application -> IO () +listenTLS port app = do + certPath <- lookupEnv "BLOG_TLS_CERT" + chainPath <- lookupEnv "BLOG_TLS_CHAIN" + keyPath <- lookupEnv "BLOG_TLS_KEY" + + let tlsSettings = tlsSettingsChain + (fromMaybe "cert.pem" certPath) + [fromMaybe "fullchain.pem" chainPath] + (fromMaybe "privkey.pem" keyPath) + let settings = setPort port defaultSettings + + -- Inform which port we will be listening on. + putStrLn $ "Listening on port " ++ show port ++ " (TLS)..." + -- Serve the WAI app using Warp + runTLS tlsSettings settings app + -- | The entry point of the server application. main :: IO () main = do stage <- lookupEnv "BLOG_STAGE" + path <- lookupEnv "BLOG_PATH" + + let liveMiddleware = logStdout + $ cspHeadersMiddleware + $ headersMiddleware + $ domainMiddleware + $ deindexifyMiddleware + $ gzipMiddleware + $ staticSite path -- Depending on the stage we will choose a different set of middleware to -- apply to the application. case fromMaybe "dev" stage of -- "Production" - "live" -> listen 80 (logStdout - $ domainMiddleware - $ deindexifyMiddleware - $ gzipMiddleware staticSite - ) + "live" -> do + forkIO $ listenTLS 443 liveMiddleware + listen 80 liveMiddleware + "staging" -> do + forkIO $ listenTLS 8443 liveMiddleware + listen 8080 liveMiddleware -- "Development" - _ -> listen 9090 (logStdout - $ deindexifyMiddleware - $ gzipMiddleware staticSite + _ -> listen 9090 (logStdout + $ headersMiddleware + $ deindexifyMiddleware + $ gzipMiddleware + $ staticSite path ) diff --git a/site.hs b/site.hs index 90390c1935a8e3fef074727e28784d223a2f428e..b207f5cf9342cb278993076fddfd851d9ccc9d76 100644 --- a/site.hs +++ b/site.hs @@ -63,6 +63,10 @@ main = hakyllWith hakyllConf $ do match "images/posts/*" $ do route idRoute compile copyFileCompiler + + match "images/tumblr/*" $ do + route idRoute + compile copyFileCompiler match "css/app.css" $ do route $ setExtension "css" diff --git a/templates/default.html b/templates/default.html index c3efe8f6f6e16716cd61ce87adbea5fb1cc5b0a2..a2d9ebb17e5a4dba5e165ea93934ed40daeaa7fe 100644 --- a/templates/default.html +++ b/templates/default.html @@ -12,8 +12,7 @@ $endif$ <link rel="stylesheet" type="text/css" href="/css/app.css" /> - <script src="https://use.typekit.net/voy2fek.js"></script> - <script>try{Typekit.load({ async: true });}catch(e){}</script> + <script>document.documentElement.className += ' wf-loading';</script> <meta property="fb:admins" content="etcinit"/> </head> @@ -24,7 +23,7 @@ var js, fjs = d.getElementsByTagName(s)[0]; if (d.getElementById(id)) return; js = d.createElement(s); js.id = id; - js.src = "//connect.facebook.net/en_US/sdk.js#xfbml=1&version=v2.5&appId=332765426823646"; + js.src = "https://connect.facebook.net/en_US/sdk.js#xfbml=1&version=v2.5&appId=332765426823646"; fjs.parentNode.insertBefore(js, fjs); }(document, 'script', 'facebook-jssdk')); </script> @@ -66,19 +65,21 @@ </div> </div> + <script src="https://use.typekit.net/voy2fek.js"></script> + <script>try{Typekit.load({ async: true });}catch(e){}</script> + + <script async type="text/javascript" + src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"> + </script> + <script> var _gaq=[['_setAccount','$gaId$'],['_trackPageview']]; (function(d,t){ var g=d.createElement(t), s=d.getElementsByTagName(t)[0]; - g.src=('https:'==location.protocol?'//ssl':'//www')+ - '.google-analytics.com/ga.js'; + g.src='https://ssl.google-analytics.com/ga.js'; s.parentNode.insertBefore(g,s) }(document,'script')); </script> - - <script type="text/javascript" - src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"> - </script> </body> </html> diff --git a/templates/twitter.html b/templates/twitter.html index 3ae983bdda7e83451f5f988be0100273f37b50cc..83a3c5d8f54b571ea6e91c70eee1022ef64697d5 100644 --- a/templates/twitter.html +++ b/templates/twitter.html @@ -5,13 +5,13 @@ <script> !function(d,s,id) { var js, - fjs = d.getElementsByTagName(s)[0], - p = /^http:/.test(d.location) ? 'http' : 'https'; + fjs = d.getElementsByTagName(s)[0]; if (!d.getElementById(id)) { js = d.createElement(s); js.id = id; - js.src = p + "://platform.twitter.com/widgets.js"; + js.async = true; + js.src = "https://platform.twitter.com/widgets.js"; fjs.parentNode.insertBefore(js,fjs); }