From e4fdf5ac751273bcea58beaafb7d7e98f3a93b85 Mon Sep 17 00:00:00 2001 From: Miguel Date: Sun, 17 Feb 2019 11:59:50 +0100 Subject: cleaning up in progress --- Makefile | 7 +++++-- src/WWWStaticus.hs | 3 ++- src/WWWStaticusPlugins.hs | 21 ++++++++++++++------- stack.yaml | 2 +- 4 files changed, 22 insertions(+), 11 deletions(-) diff --git a/Makefile b/Makefile index a74efd1..851c3cf 100644 --- a/Makefile +++ b/Makefile @@ -1,9 +1,12 @@ +INDIR=/home/miguel/git/idziorek_net +OUTDIR=/tmp/idziorek_net + run: build clean - stack run staticus-exe -- /home/miguel/git/staticus_www/INDEX /home/miguel/git/staticus_www/OUT + stack run staticus-exe -- ${INDIR} ${OUTDIR} build: stack build clean: - -rm /home/miguel/git/staticus_www/OUT/* -r + -rm ${OUTDIR}/* -r showdoc: stack haddock # firefox /home/miguel/git/staticus_www/staticus/.stack-work/install/x86_64-linux/lts-13.0/8.6.3/doc/index.html diff --git a/src/WWWStaticus.hs b/src/WWWStaticus.hs index 01485e4..cd9e454 100644 --- a/src/WWWStaticus.hs +++ b/src/WWWStaticus.hs @@ -17,6 +17,7 @@ import System.Directory import Control.Monad import Data.Tree import Data.Maybe +import Data.List -- |Runs WWWStaticus given an input and an output directory and a list of -- plugins. This traverses 'inp' recursively and runs all the plugins @@ -55,7 +56,7 @@ trvDirTree fp f = unfoldTreeM unf fp >>= sequence_ -- |get list of subdirectories getDirList :: FilePath -> IO [FilePath] -getDirList d = map ((d++"/")++) <$> listDirectory d +getDirList d = filter (not.isPrefixOf ".") <$> map ((d++"/")++) <$> listDirectory d >>= filterM doesDirectoryExist -- |run plugins in a single directory 'path'. diff --git a/src/WWWStaticusPlugins.hs b/src/WWWStaticusPlugins.hs index fe17583..a569ca9 100644 --- a/src/WWWStaticusPlugins.hs +++ b/src/WWWStaticusPlugins.hs @@ -59,12 +59,14 @@ staticusPluginsDefault=[ staticusPluginInit staticusPluginInit::StaticusPlugin staticusPluginInit = StaticusPlugin "init" id runIO where runIO m = - do when (not isHome) (createDirectory outdir) + do print $ par "path" m + print $ outdir + when (not isHome) (createDirectory outdir) c <- getDirList (par "path" m) t <- getDirList (par "dir_in" m) let menutop= concat $ map (\x->"
  • "++x++"
  • ") (menu t) let submenu= if isHome then "" else concat $ map (\x->"
  • "++x++"
  • ") (menu c) --- let breadcrumbs=concat brc + let breadcrumbs=concat $ map (\x->x) brc let breadcrumbs="" --TODO: check top dirs until file found! add ./config md <- readFile $ par "path" m++"/"++"index.md" @@ -83,7 +85,8 @@ staticusPluginInit = StaticusPlugin "init" id runIO isHome = par "path" m==par "dir_in" m -- |This plugin will simply copy files of given extension from source --- to the target directory. give it a list of extensions. +-- to the target directory. give it a list of file extensions. +-- example [".png",".zip",".css"] staticusPluginCopy::[String]->StaticusPlugin staticusPluginCopy ext = StaticusPlugin "copy by extension" id runIO where runIO m = do @@ -99,13 +102,16 @@ staticusPluginPandoc = StaticusPlugin "pandoc" run return writeHtml5String def doc in M.union (M.fromList [("content",T.unpack (fromRight (T.pack "err") f))]) m --- |Plugin for filling the 'template.html' value with 'content' --- and storing in 'final' +-- |Plugin for filling the 'template.html' value with 'content', 'menu', +-- etc and storing in 'final' staticusPluginFill::StaticusPlugin staticusPluginFill = StaticusPlugin "fill template" run return where run m = M.union (M.fromList [("final", - replace "###BREADCRUMBS###" (par "breadcrumbs" m) $ replace "###SUBMENU###" (par "submenu" m) $ replace "###MENU###" (par "menutop" m) (replace "###CONTENT###" (par "content" m) (par "template.html" m)))]) m - + replace "###BREADCRUMBS###" (par "breadcrumbs" m) $ + replace "###SUBMENU###" (par "submenu" m) $ + replace "###MENU###" (par "menutop" m) $ + replace "###CONTENT###" (par "content" m) $ + (par "template.html" m))]) m -- |write final index.html file staticusPluginWrite::StaticusPlugin @@ -113,3 +119,4 @@ staticusPluginWrite = StaticusPlugin "writer" id runIO where runIO m = do writeFile ((par "outdir" m)++"/index.html") (par "final" m) return m + diff --git a/stack.yaml b/stack.yaml index 1cc351e..d658bf4 100644 --- a/stack.yaml +++ b/stack.yaml @@ -17,7 +17,7 @@ # # resolver: ./custom-snapshot.yaml # resolver: https://example.com/snapshots/2018-01-01.yaml -resolver: lts-13.0 +resolver: lts-13.5 # User packages to be built. # Various formats can be used as shown in the example below. -- cgit v1.2.3