wip
This commit is contained in:
parent
0f62b038df
commit
536f0ed5e6
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -1,3 +1,5 @@
|
||||||
_cache/
|
_cache/
|
||||||
src/archive.org
|
src/archive.org
|
||||||
.direnv/
|
.direnv/
|
||||||
|
_shake/
|
||||||
|
.shake/
|
68
Shakefile.hs
68
Shakefile.hs
|
@ -4,38 +4,58 @@ import Development.Shake
|
||||||
import Development.Shake.Command
|
import Development.Shake.Command
|
||||||
import Development.Shake.FilePath
|
import Development.Shake.FilePath
|
||||||
import Development.Shake.Util
|
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 :: IO ()
|
||||||
main = do
|
main = do
|
||||||
let shOpts = shakeOptions { shakeVerbosity = Chatty, shakeLintInside = ["\\"] }
|
let shOpts = shakeOptions { shakeVerbosity = Chatty, shakeLintInside = ["\\"] }
|
||||||
shakeArgsForward shOpts buildRules
|
shakeArgs shOpts buildRules
|
||||||
|
|
||||||
buildRules :: Action ()
|
buildRules :: Rules ()
|
||||||
buildRules = do
|
buildRules = do
|
||||||
allPosts <- buildPosts
|
phony "clean" $ do
|
||||||
buildIndex allPosts
|
putInfo "Cleaning files in _site and _optim"
|
||||||
buildFeed allPosts
|
removeFilesAfter "_site" ["//*"]
|
||||||
copyStaticFiles
|
removeFilesAfter "_optim" ["//*"]
|
||||||
|
|
||||||
-- | Find and build all posts
|
"_site//*.html" %> buildPost
|
||||||
buildPosts :: Action [Post]
|
-- buildPosts
|
||||||
buildPosts = do
|
-- allPosts <- buildPosts
|
||||||
pPaths <- getDirectoryFiles "." ["site/posts//*.md"]
|
-- buildIndex allPosts
|
||||||
forP pPaths buildPost
|
-- 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
|
-- | Load a post, process metadata, write it to output, then return the post object
|
||||||
-- Detects changes to either post content or template
|
-- Detects changes to either post content or template
|
||||||
buildPost :: FilePath -> Action Post
|
buildPost :: FilePath -> Action ()
|
||||||
buildPost srcPath = cacheAction ("build" :: T.Text, srcPath) $ do
|
buildPost out = do
|
||||||
liftIO . putStrLn $ "Rebuilding post: " <> srcPath
|
let org = "src/" <> (dropDirectory1 $ out -<.> "org")
|
||||||
postContent <- readFile' srcPath
|
liftIO . putStrLn $ "Rebuilding post: " <> out
|
||||||
|
postContent <- readFile' org
|
||||||
-- load post content and metadata as JSON blob
|
-- load post content and metadata as JSON blob
|
||||||
postData <- markdownToHTML . T.pack $ postContent
|
let pandocReturn = Pandoc.runPure $ orgToHTML . T.pack $ postContent
|
||||||
let postUrl = T.pack . dropDirectory1 $ srcPath -<.> "html"
|
case pandocReturn of
|
||||||
withPostUrl = _Object . at "url" ?~ String postUrl
|
Left _ -> putError "BAD"
|
||||||
-- Add additional metadata we've been able to compute
|
Right outData -> writeFile' out (T.unpack outData)
|
||||||
let fullPostData = withSiteMeta . withPostUrl $ postData
|
|
||||||
template <- compileTemplate' "site/templates/post.html"
|
|
||||||
writeFile' (outputFolder </> T.unpack postUrl) . T.unpack $ substitute template fullPostData
|
|
||||||
convert fullPostData
|
|
||||||
|
|
2
_optim/.gitignore
vendored
2
_optim/.gitignore
vendored
|
@ -1,2 +0,0 @@
|
||||||
*
|
|
||||||
!.gitignore
|
|
2
_site/.gitignore
vendored
2
_site/.gitignore
vendored
|
@ -1,2 +0,0 @@
|
||||||
*
|
|
||||||
!.gitignore
|
|
84
_site/index.html
Normal file
84
_site/index.html
Normal file
|
@ -0,0 +1,84 @@
|
||||||
|
<p><nav>
|
||||||
|
<a href="/index.html">Home</a> |
|
||||||
|
<a href="/archive.html">Posts</a> |
|
||||||
|
<a href="/slides.html">Slides</a> |
|
||||||
|
<a href="/about-me.html">About</a>
|
||||||
|
<span class="details">
|
||||||
|
(<a href="https://gitea.esy.fun/yogsototh">code</a>
|
||||||
|
<a href="https://espial.esy.fun/u:yogsototh">bookmarks</a>
|
||||||
|
<a href="https://espial.esy.fun/u:yogsototh/notes">notes</a>)
|
||||||
|
</span>
|
||||||
|
</nav></p>
|
||||||
|
<p>I'm a functional programmer, working remotely for Cisco.<br/> I work in Clojure and use Haskell/Purescript during the weekends.</p>
|
||||||
|
<ul>
|
||||||
|
<li><a href="https://gitea.esy.fun/yogsototh">I write softwares</a> (<a href="https://github.com/yogsototh">backuped on github</a>),</li>
|
||||||
|
<li><a href="archive.org">I blog</a> (you can follow new articles via <a href="https://her.esy.fun/rss.xml">RSS</a>),</li>
|
||||||
|
<li><a href="slides.org">I sometime make some presentations</a></li>
|
||||||
|
</ul>
|
||||||
|
<table>
|
||||||
|
<tbody>
|
||||||
|
<tr class="odd">
|
||||||
|
<td>email</td>
|
||||||
|
<td> <a href="mailto:yann@esposito.host">Yann Esposito <yann@esposito.host></a></td>
|
||||||
|
</tr>
|
||||||
|
<tr class="even">
|
||||||
|
<td>gpg</td>
|
||||||
|
<td><a href="files/publickey.txt">CB420F8005F1A662</a></td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
<table>
|
||||||
|
<thead>
|
||||||
|
<tr class="header">
|
||||||
|
<th></th>
|
||||||
|
<th>self-hosted</th>
|
||||||
|
<th>web</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<tr class="odd">
|
||||||
|
<td>programs</td>
|
||||||
|
<td><a href="https://gitea.esy.fun/yogsototh">gitea.esy.fun</a></td>
|
||||||
|
<td><a href="https://github.com/yogsototh">github/yogsototh</a></td>
|
||||||
|
</tr>
|
||||||
|
<tr class="even">
|
||||||
|
<td>bookmarks</td>
|
||||||
|
<td><a href="https://espial.esy.fun/u:yogsototh">espial.esy.fun</a></td>
|
||||||
|
<td><a href="https://pinboard.in/u:yogsototh">pinboard/u:yogsototh</a></td>
|
||||||
|
</tr>
|
||||||
|
<tr class="odd">
|
||||||
|
<td>microblog</td>
|
||||||
|
<td><a href="https://espial.esy.fun/u:yogsototh/notes">espial.esy.fun</a></td>
|
||||||
|
<td><a href="https://twitter.com/yogsototh">twitter/<span class="citation" data-cites="yogsototh">@yogsototh</span></a></td>
|
||||||
|
</tr>
|
||||||
|
<tr class="even">
|
||||||
|
<td>keybase</td>
|
||||||
|
<td>. . . . . . . .</td>
|
||||||
|
<td><a href="https://keybase.io/yogsototh">yogsototh</a></td>
|
||||||
|
</tr>
|
||||||
|
<tr class="odd">
|
||||||
|
<td>lobste.rs</td>
|
||||||
|
<td>. . . . . . . .</td>
|
||||||
|
<td><a href="https://lobste.rs/u/yogsototh">/u/yogsototh</a></td>
|
||||||
|
</tr>
|
||||||
|
<tr class="even">
|
||||||
|
<td>reddit</td>
|
||||||
|
<td>. . . . . . . .</td>
|
||||||
|
<td><a href="https://reddit.com/u/yogsototh">/u/yogsototh</a></td>
|
||||||
|
</tr>
|
||||||
|
<tr class="odd">
|
||||||
|
<td>stack overflow</td>
|
||||||
|
<td>. . . . . . . .</td>
|
||||||
|
<td><a href="https://stackoverflow.com/users/40569/yogsototh">yogsototh</a></td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
<p>That website was created with the following constraints in mind by order of priority:</p>
|
||||||
|
<ol>
|
||||||
|
<li><strong>Respect Privacy</strong>; no tracker of any sort (no ads, no google analytics, no referrer for all external links, etc…) <br/> <br/></li>
|
||||||
|
<li><strong>Almost javascript free</strong>; no js at all except for a single exception, pages containing Math formulæ are displayed using mathjax. <br/> <br/></li>
|
||||||
|
<li><strong>Accessibility</strong>; should be easy to read on a text browser so people with disabilities could easily consume it. <br/> <br/></li>
|
||||||
|
<li><strong>RSS</strong>; you should be able to get informed when I add a new blog post. <br/> <br/></li>
|
||||||
|
<li><strong>Frugal</strong>; 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.</li>
|
||||||
|
</ol>
|
||||||
|
<p>If you are interested about technical details behind this website, take a look <a href="./posts/new-blog.org">here</a>.</p>
|
|
@ -2,6 +2,8 @@
|
||||||
let
|
let
|
||||||
haskellDeps = ps : with ps; [
|
haskellDeps = ps : with ps; [
|
||||||
shake
|
shake
|
||||||
|
pandoc
|
||||||
|
data-default
|
||||||
];
|
];
|
||||||
pkgs1909 = import (fetchTarball https://github.com/NixOS/nixpkgs/archive/19.09.tar.gz) {};
|
pkgs1909 = import (fetchTarball https://github.com/NixOS/nixpkgs/archive/19.09.tar.gz) {};
|
||||||
ghc = pkgs.haskellPackages.ghcWithPackages haskellDeps;
|
ghc = pkgs.haskellPackages.ghcWithPackages haskellDeps;
|
||||||
|
@ -17,6 +19,8 @@ pkgs.mkShell {
|
||||||
minify
|
minify
|
||||||
niv
|
niv
|
||||||
ghc
|
ghc
|
||||||
|
git
|
||||||
|
direnv
|
||||||
pkgs1909.haskellPackages.sws
|
pkgs1909.haskellPackages.sws
|
||||||
haskellPackages.shake
|
haskellPackages.shake
|
||||||
];
|
];
|
||||||
|
|
Loading…
Reference in a new issue