diff --git a/.gitignore b/.gitignore index d9947d9..e3771aa 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ _cache/ src/archive.org .direnv/ +_shake/ +.shake/ \ No newline at end of file diff --git a/Shakefile.hs b/Shakefile.hs index 727b838..2a1b921 100644 --- a/Shakefile.hs +++ b/Shakefile.hs @@ -4,38 +4,58 @@ import Development.Shake import Development.Shake.Command import Development.Shake.FilePath import Development.Shake.Util -import Data.Text as T + +import Data.Default (Default(def)) +import qualified Data.Set as Set +import qualified Data.Text as T +import Text.Pandoc.Class (PandocPure) +import qualified Text.Pandoc.Class as Pandoc +import Text.Pandoc.Extensions (getDefaultExtensions) +import Text.Pandoc.Options (ReaderOptions(..),TrackChanges(RejectChanges)) +import qualified Text.Pandoc.Readers as Readers +import qualified Text.Pandoc.Writers as Writers main :: IO () main = do let shOpts = shakeOptions { shakeVerbosity = Chatty, shakeLintInside = ["\\"] } - shakeArgsForward shOpts buildRules + shakeArgs shOpts buildRules -buildRules :: Action () +buildRules :: Rules () buildRules = do - allPosts <- buildPosts - buildIndex allPosts - buildFeed allPosts - copyStaticFiles + phony "clean" $ do + putInfo "Cleaning files in _site and _optim" + removeFilesAfter "_site" ["//*"] + removeFilesAfter "_optim" ["//*"] --- | Find and build all posts -buildPosts :: Action [Post] -buildPosts = do - pPaths <- getDirectoryFiles "." ["site/posts//*.md"] - forP pPaths buildPost + "_site//*.html" %> buildPost +-- buildPosts +-- allPosts <- buildPosts +-- buildIndex allPosts +-- buildFeed allPosts +-- copyStaticFiles + +data Post = Post { postTitle :: T.Text + , postAuthor :: T.Text + , postDate :: T.Text + } + +defaultReaderOpts t = + def { readerExtensions = getDefaultExtensions t + , readerStandalone = True } + +orgToHTML :: T.Text -> PandocPure T.Text +orgToHTML txt = Readers.readOrg (defaultReaderOpts "org") txt + >>= Writers.writeHtml5String def -- | Load a post, process metadata, write it to output, then return the post object -- Detects changes to either post content or template -buildPost :: FilePath -> Action Post -buildPost srcPath = cacheAction ("build" :: T.Text, srcPath) $ do - liftIO . putStrLn $ "Rebuilding post: " <> srcPath - postContent <- readFile' srcPath +buildPost :: FilePath -> Action () +buildPost out = do + let org = "src/" <> (dropDirectory1 $ out -<.> "org") + liftIO . putStrLn $ "Rebuilding post: " <> out + postContent <- readFile' org -- load post content and metadata as JSON blob - postData <- markdownToHTML . T.pack $ postContent - let postUrl = T.pack . dropDirectory1 $ srcPath -<.> "html" - withPostUrl = _Object . at "url" ?~ String postUrl - -- Add additional metadata we've been able to compute - let fullPostData = withSiteMeta . withPostUrl $ postData - template <- compileTemplate' "site/templates/post.html" - writeFile' (outputFolder T.unpack postUrl) . T.unpack $ substitute template fullPostData - convert fullPostData + let pandocReturn = Pandoc.runPure $ orgToHTML . T.pack $ postContent + case pandocReturn of + Left _ -> putError "BAD" + Right outData -> writeFile' out (T.unpack outData) diff --git a/_optim/.gitignore b/_optim/.gitignore deleted file mode 100644 index d6b7ef3..0000000 --- a/_optim/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -* -!.gitignore diff --git a/_site/.gitignore b/_site/.gitignore deleted file mode 100644 index d6b7ef3..0000000 --- a/_site/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -* -!.gitignore diff --git a/_site/index.html b/_site/index.html new file mode 100644 index 0000000..a508e26 --- /dev/null +++ b/_site/index.html @@ -0,0 +1,84 @@ +

+

I'm a functional programmer, working remotely for Cisco.
I work in Clojure and use Haskell/Purescript during the weekends.

+ + + + + + + + + + + + +
email Yann Esposito <yann@esposito.host>
gpgCB420F8005F1A662
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
self-hostedweb
programsgitea.esy.fungithub/yogsototh
bookmarksespial.esy.funpinboard/u:yogsototh
microblogespial.esy.funtwitter/@yogsototh
keybase. . . . . . . .yogsototh
lobste.rs. . . . . . . ./u/yogsototh
reddit. . . . . . . ./u/yogsototh
stack overflow. . . . . . . .yogsototh
+

That website was created with the following constraints in mind by order of priority:

+
    +
  1. Respect Privacy; no tracker of any sort (no ads, no google analytics, no referrer for all external links, etc…)

  2. +
  3. Almost javascript free; no js at all except for a single exception, pages containing Math formulæ are displayed using mathjax.

  4. +
  5. Accessibility; should be easy to read on a text browser so people with disabilities could easily consume it.

  6. +
  7. RSS; you should be able to get informed when I add a new blog post.

  8. +
  9. Frugal; try to minimize the resources needed to visit my website; no javascript, no web-font, not too much CSS magic, not much images or really compressed one.
  10. +
+

If you are interested about technical details behind this website, take a look here.

\ No newline at end of file diff --git a/shell.nix b/shell.nix index 59add58..919089c 100644 --- a/shell.nix +++ b/shell.nix @@ -2,13 +2,15 @@ let haskellDeps = ps : with ps; [ shake + pandoc + data-default ]; pkgs1909 = import (fetchTarball https://github.com/NixOS/nixpkgs/archive/19.09.tar.gz) {}; ghc = pkgs.haskellPackages.ghcWithPackages haskellDeps; in pkgs.mkShell { buildInputs = with pkgs; - [cacert + [ cacert coreutils html-xml-utils zsh @@ -17,6 +19,8 @@ pkgs.mkShell { minify niv ghc + git + direnv pkgs1909.haskellPackages.sws haskellPackages.shake ];