diff options
| author | Miguel <m.i@gmx.at> | 2019-02-17 11:59:50 +0100 |
|---|---|---|
| committer | Miguel <m.i@gmx.at> | 2019-02-17 11:59:50 +0100 |
| commit | e4fdf5ac751273bcea58beaafb7d7e98f3a93b85 (patch) | |
| tree | bbbc36bf1c0304887d1a9f6a2b58b34cbaf03fad | |
| parent | d0a2a6ed5ed787fc613f73ba74439d1beba0d1c1 (diff) | |
cleaning up in progress
| -rw-r--r-- | Makefile | 7 | ||||
| -rw-r--r-- | src/WWWStaticus.hs | 3 | ||||
| -rw-r--r-- | src/WWWStaticusPlugins.hs | 21 | ||||
| -rw-r--r-- | stack.yaml | 2 |
4 files changed, 22 insertions, 11 deletions
@@ -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->"<li class=\"navitem\"><a class=\"nav-link\" href=\""++par "dir_out" m++"/"++x++"/index.html\">"++x++"</a></li>") (menu t) let submenu= if isHome then "" else concat $ map (\x->"<li><a href=\""++outdir++"/"++x++"/index.html\">"++x++"</a></li>") (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 + @@ -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. |
