~yoctocell/yoctocell.xyz

3d9f1423e8dad643d73d58b8e324bb17195e9301 — yoctocell 7 months ago cb3a161
Move things to src/
15 files changed, 41 insertions(+), 29 deletions(-)

M default.nix
D media/images/haskell-logo.png
M site.hs
R about.org => src/about.org
R contact.org => src/contact.org
R css/default.css => src/css/default.css
R index.org => src/index.org
R media/pgp.asc => src/media/pgp.asc
R posts/hello-world.org => src/posts/hello-world.org
R posts/nixos-on-btrfs-with-encrypted-root.org => src/posts/nixos-on-btrfs-with-encrypted-root.org
R templates/archive.html => src/templates/archive.html
R templates/default.html => src/templates/default.html
R templates/post-list.html => src/templates/post-list.html
R templates/post.html => src/templates/post.html
R templates/webring.html => src/templates/webring.html
M default.nix => default.nix +1 -1
@@ 14,7 14,7 @@ let

  updateServer = pkgs.writeScriptBin "update-server"
    ''
      ./result/bin/site rebuild && rsync -r _dist/* root@yoctocell.xyz:/var/www/yoctocell.xyz
      ./result/bin/site rebuild && rsync -r public/* root@yoctocell.xyz:/var/www/yoctocell.xyz
    '';
in
{

D media/images/haskell-logo.png => media/images/haskell-logo.png +0 -0
M site.hs => site.hs +37 -25
@@ 1,11 1,12 @@
--------------------------------------------------------------------------------
{-# LANGUAGE OverloadedStrings #-}
import           Data.Char             (toLower)
import           Data.Char             (toLower, toUpper)
import Data.Semigroup ((<>))
import           Data.List             (isPrefixOf)
import           Data.List.Split       (splitOn)
import           System.FilePath.Posix (joinPath, replaceExtension,
                                        splitDirectories, takeDirectory,
                                        splitPath,
                                        takeFileName, (</>))

import           Hakyll


@@ 14,7 15,7 @@ import           Hakyll

--------------------------------------------------------------------------------
config :: Configuration
config = defaultConfiguration { destinationDirectory = "_dist" }
config = defaultConfiguration { destinationDirectory = "public" }

feedConfiguration :: FeedConfiguration
feedConfiguration = FeedConfiguration { feedTitle = "yoctocell's blog"


@@ 27,53 28,53 @@ feedConfiguration = FeedConfiguration { feedTitle = "yoctocell's blog"

main :: IO ()
main = hakyllWith config $ do
    match "media/*" $ do
        route   idRoute
    match "src/media/*" $ do
        route   srcRoute
        compile copyFileCompiler

    match "css/*" $ do
        route   idRoute
    match "src/css/*" $ do
        route   srcRoute
        compile compressCssCompiler

    match (fromList ["about.org", "contact.org"]) $ do
        route   $ setExtension "html"
    match (fromList ["src/about.org", "src/contact.org"]) $ do
        route   $ setExtension' "html"
        compile $ pandocCompiler
            >>= loadAndApplyTemplate "templates/default.html" defaultContext
            >>= loadAndApplyTemplate "src/templates/default.html" defaultContext
            >>= relativizeUrls

    match "posts/*.org" $ do
    match "src/posts/*.org" $ do
      route tempRoute
      compile $ getResourceString >>= orgCompiler

    create ["archive.html"] $ do
        route idRoute
        compile $ do
            posts <- recentFirst =<< loadAll "_temp/posts/*"
            posts <- recentFirst =<< loadAll "_temp/src/posts/*"
            let archiveCtx =
                    listField "posts" postCtx (return posts) `mappend`
                    constField "title" "Archives"            `mappend`
                    defaultContext

            makeItem ""
                >>= loadAndApplyTemplate "templates/archive.html" archiveCtx
                >>= loadAndApplyTemplate "templates/default.html" archiveCtx
                >>= loadAndApplyTemplate "src/templates/archive.html" archiveCtx
                >>= loadAndApplyTemplate "src/templates/default.html" archiveCtx
                >>= relativizeUrls

    match "index.org" $ do
    match "src/index.org" $ do
      route tempRoute
      compile $ getResourceString >>= orgCompiler

    match "_temp/index.org" $ do
    match "_temp/src/index.org" $ do
        route $ cleanRouteFromTemp
        compile $ do
            posts <- recentFirst =<< loadAll "_temp/posts/*"
            posts <- recentFirst =<< loadAll "_temp/src/posts/*"
            let indexCtx =
                    listField "posts" postCtx (return posts) `mappend`
                    defaultContext

            pandocCompiler
                >>= applyAsTemplate indexCtx
                >>= loadAndApplyTemplate "templates/default.html" indexCtx
                >>= loadAndApplyTemplate "src/templates/default.html" indexCtx
                >>= relativizeUrls

    match blogPattern $ do


@@ 81,18 82,18 @@ main = hakyllWith config $ do
        compile $ do
            pandocCompiler
            >>= saveSnapshot "content"
            >>= loadAndApplyTemplate "templates/post.html"    postCtx
            >>= loadAndApplyTemplate "templates/default.html" postCtx
            >>= loadAndApplyTemplate "src/templates/post.html"    postCtx
            >>= loadAndApplyTemplate "src/templates/default.html" postCtx
            >>= relativizeUrls

    create ["rss.xml"] $ do
      route idRoute
      compile $ do
        posts <- fmap (take 10) . recentFirst =<<
              loadAllSnapshots "_temp/posts/*.org" "content"
              loadAllSnapshots "_temp/src/posts/*.org" "content"
        renderRss feedConfiguration feedCtx posts

    match "templates/*" $ compile templateBodyCompiler
    match "src/templates/*" $ compile templateBodyCompiler


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


@@ 124,19 125,30 @@ orgMetadatas = map (format . lower . clean) . takeWhile (/= "") . lines
metadatasToStr :: [String] -> String
metadatasToStr = ("----------\n" ++) . (++ "----------\n") . unlines

-- | Custom Routes
-- | srcRoute "src/index.org" == "public/index.org"
srcRoute :: Routes
srcRoute = customRoute srcRoute'
  where
    srcRoute' i = joinPath $ tail $ (splitPath $ toFilePath i)

setExtension' :: String -> Routes
setExtension' extension = customRoute $
    (`replaceExtension` extension) . joinPath . tail . splitPath . toFilePath


-- | Temp Route
tempRoute :: Routes
tempRoute = customRoute tempRoute'
  where
    tempRoute' i = ".." </> "_temp" </> takeDirectory p </> takeFileName p
        where p = toFilePath i
    tempRoute' i = ".." </> "_temp" </> toFilePath i

cleanRouteFromTemp :: Routes
cleanRouteFromTemp = customRoute createIndexRoute
  where
    createIndexRoute ident =
      joinPath . tail . splitDirectories . (flip replaceExtension "html") $ toFilePath ident
      joinPath . tail . tail . splitDirectories . (flip replaceExtension "html") $ toFilePath ident

blogPattern :: Pattern
blogPattern =
    "_temp/posts/*.org"
    "_temp/src/posts/*.org"

R about.org => src/about.org +0 -0
R contact.org => src/contact.org +0 -0
R css/default.css => src/css/default.css +0 -0
R index.org => src/index.org +2 -2
@@ 4,12 4,12 @@ Welcome to my website

** Posts
#+begin_export html
$partial("templates/post-list.html")$
$partial("src/templates/post-list.html")$
#+end_export

Subscribe using [[./rss.xml][RSS]].

** Source code & contributing
This website is generated from Org files using [[https://jaspervdj.be/hakyll][Hakyll]] and [[https://git.sr.ht/~brettgilio/org-webring/][org-webring]].
This website is generated from Org files using [[https://jaspervdj.be/hakyll][Hakyll]] and [[https://git.sr.ht/~sircmpwn/openring][openring]].
- Source: [[https://git.sr.ht/~yoctocell/yoctocell.xyz]]
- Bug reports: https://lists.sr.ht/~yoctocell/public-inbox

R media/pgp.asc => src/media/pgp.asc +0 -0
R posts/hello-world.org => src/posts/hello-world.org +0 -0
R posts/nixos-on-btrfs-with-encrypted-root.org => src/posts/nixos-on-btrfs-with-encrypted-root.org +0 -0
R templates/archive.html => src/templates/archive.html +1 -1
@@ 1,2 1,2 @@
Here you can find all my previous posts:
$partial("templates/post-list.html")$
$partial("src/templates/post-list.html")$

R templates/default.html => src/templates/default.html +0 -0
R templates/post-list.html => src/templates/post-list.html +0 -0
R templates/post.html => src/templates/post.html +0 -0
R templates/webring.html => src/templates/webring.html +0 -0