wip
This commit is contained in:
parent
0f62b038df
commit
536f0ed5e6
|
@ -1,3 +1,5 @@
|
|||
_cache/
|
||||
src/archive.org
|
||||
.direnv/
|
||||
_shake/
|
||||
.shake/
|
68
Shakefile.hs
68
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)
|
||||
|
|
|
@ -1,2 +0,0 @@
|
|||
*
|
||||
!.gitignore
|
|
@ -1,2 +0,0 @@
|
|||
*
|
||||
!.gitignore
|
|
@ -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,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
|
||||
];
|
||||
|
|
Loading…
Reference in New Issue