diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index c4b3e1ec785175268eeb9d4251c7ad7095abb2b4..31dbd12b23258925665152ca81cfa6643bbcc7ee 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,4 +1,5 @@ -image: omalaspinas/pandoc_website:latest +image: omalaspinas/hakyll-bootstrap:latest +# image: omalaspinas/pandoc_website:latest variables: GIT_SUBMODULE_STRATEGY: recursive @@ -35,4 +36,7 @@ build_and_deploy: - rsync -avzz css ur1bg_malas@ur1bg.ftp.infomaniak.com:web/malaspinas/ - rsync -avzz figs ur1bg_malas@ur1bg.ftp.infomaniak.com:web/malaspinas/ - rsync -avzz index.html ur1bg_malas@ur1bg.ftp.infomaniak.com:web/malaspinas/ + - make build_revealjs -C hakyll-bootstrap + - make build -C hakyll-bootstrap + - make deploy -C hakyll-bootstrap # - blc https://malaspinas.academy -ro --exclude *.pdf --filter-level 3 diff --git a/hakyll-bootstrap/404.html b/hakyll-bootstrap/404.html new file mode 100644 index 0000000000000000000000000000000000000000..772f302ac44a96dcec9647165fc504c8ec77e315 --- /dev/null +++ b/hakyll-bootstrap/404.html @@ -0,0 +1,9 @@ +--- +title: Page not found +--- + +<h1>Error 404</h1> +<p> + The page you were looking for does not exist. You might want to + <a href="/">go back home</a>. +</p> diff --git a/hakyll-bootstrap/Main.hs b/hakyll-bootstrap/Main.hs index 59dbe7332e46603d167c26fd9a777f5867e4de62..2089df6a7a6e9f1dc48130f536f2d7a953d9a2a1 100644 --- a/hakyll-bootstrap/Main.hs +++ b/hakyll-bootstrap/Main.hs @@ -21,11 +21,12 @@ import Data.Maybe (isJust) import Hakyll.Images ( loadImage , scaleImageCompiler ) +import System.Exit (ExitCode) -------------------------------------------------------------------------------- -- | Entry point main :: IO () -main = hakyllWith cfg $ do +main = hakyllWith config $ do -- Resize images match "img/thumbnails/**.png" $ do route idRoute @@ -58,6 +59,12 @@ main = hakyllWith cfg $ do route idRoute compile $ copyFileCompiler + -- Render the 404 page, we don't relativize URL's here. + match "404.html" $ do + route idRoute + compile $ pandocCompiler + >>= loadAndApplyTemplate "templates/page.html" postCtx + -- Phys app posts match "cours/isc_physics/*.markdown" $ do route $ setExtension "html" @@ -337,25 +344,20 @@ pandocRevealCompiler = do -- makeItem $ TmpFile pdfPath -cfg :: Configuration -cfg = defaultConfiguration - --- main :: IO () --- main = hakyllWith cfg $ do --- pages --- posts --- cours_conc --- conc --- cours_mti --- mti --- cours_phys_app --- phys_app --- research --- bachelor --- index --- templates --- resizeThumbnails --- resizeLarge --- resizeHeads --- static - +-------------------------------------------------------------------------------- +config :: Configuration +config = defaultConfiguration + { deploySite = deploy + } + where + deploy :: Configuration -> IO ExitCode + deploy _c = do + branch <- Process.readProcess + "git" ["rev-parse", "--abbrev-ref", "HEAD"] "" + case words branch of + ["master"] -> Process.rawSystem "rsync" + [ "--checksum", "-avzz" + , "_site/", "ur1bg_malas@ur1bg.ftp.infomaniak.com:web/malaspinas/beta/" + ] + _ -> fail $ + "I don't know how to deploy the branch " ++ show branch diff --git a/hakyll-bootstrap/Makefile b/hakyll-bootstrap/Makefile index 1c0e0c971063ccc735fdb932b596487acb0cecdc..50b5909175c25d92eafaa3ade7cfb7e3eae5ef7e 100644 --- a/hakyll-bootstrap/Makefile +++ b/hakyll-bootstrap/Makefile @@ -1,10 +1,16 @@ -watch: Main.hs cours/math_tech_info/*.md cours/isc_physics/*.md +watch: build + stack exec blog -- watch + +deploy: build + stack exec blog -- deploy + +build: Main.hs cours/math_tech_info/*.md cours/isc_physics/*.md make hakyll_gen -C cours/math_tech_info make hakyll_gen -C cours/isc_physics make -C cours/math_tech_info make -C cours/isc_physics make markdown -C cours/prog_seq/slides - stack build && stack exec blog -- build && stack exec blog -- watch + stack build && stack exec blog -- build build_revealjs: cd reveal.js && npm install && npm run build && cd ..