diff options
Diffstat (limited to 'src/WWWStaticusPlugins.hs')
| -rw-r--r-- | src/WWWStaticusPlugins.hs | 48 |
1 files changed, 27 insertions, 21 deletions
diff --git a/src/WWWStaticusPlugins.hs b/src/WWWStaticusPlugins.hs index fe509f3..cc190a3 100644 --- a/src/WWWStaticusPlugins.hs +++ b/src/WWWStaticusPlugins.hs @@ -1,5 +1,6 @@ module WWWStaticusPlugins ( staticusPluginsDefault + ,staticusPluginTimestamp ,staticusPluginInit ,staticusPluginCfg ,staticusPluginCopy @@ -10,9 +11,12 @@ module WWWStaticusPlugins ) where import WWWStaticus +import System.Directory as D +import System.IO.Error +import Data.Time.Clock as C +import Data.Time.Calendar import qualified Data.Map.Strict as M import qualified Data.Text as T -import System.Directory import Control.Monad import Data.Maybe import Data.Either @@ -23,27 +27,16 @@ import Data.Tuple.Extra import Text.Pandoc import Text.Regex --- -- PLUGIN IDEAS -- --- timestamp plugin/ do not refresh if md did not change? dir timestamp? --- but check if depends on upstream stuff as git --- --- super `gallery and everythin` plugin, just throw images,videos, --- zips,tars,source files,mds etc inside a folder-> gen page! --- --- flexible layout, main pic, secondary pics, multiple templates 1 2 3 --- --- scale images --- --- asciinema, git, videos (generate both from single one) --- --- contact form? (use nginx log? save post request??) --- --- pdf plugin --- --- autotranslate/ multilang --- +-- * super `gallery and everythin` plugin, just throw images,videos, +-- zips,tars,source files,mds etc inside a folder-> gen page! +-- * flexible layout, main pic, secondary pics, multiple templates 1 2 3 +-- * scale images +-- * asciinema, git, videos (generate both from single one) +-- * contact form? (use nginx log? save post request??) +-- * pdf plugin +-- * autotranslate/ multilang -- |little helper to get values out of a map easily -- error if not found. @@ -61,6 +54,7 @@ par' k m = case M.lookup k m of -- Use now, Adapt later. staticusPluginsDefault::[StaticusPlugin] staticusPluginsDefault=[ staticusPluginInit + ,staticusPluginTimestamp ,staticusPluginCfg ,staticusPluginCopy [".jpg",".png",".zip",".css",".js",".ico",".mp4",".ogv",".hs",".glade"] ,staticusPluginCards @@ -69,13 +63,25 @@ staticusPluginsDefault=[ staticusPluginInit ,staticusPluginWrite ] +-- |Check if result is younger than source index.md, otherwise set "abort" +-- TODO: what if other things changed (some upstream files in worst case or even subdir added/removed) +staticusPluginTimestamp::StaticusPlugin +staticusPluginTimestamp = StaticusPlugin "init" id runIO + where runIO m = + do t1 <- catchIOError (D.getModificationTime $ par "path" m++"/"++"index.md") handler + t2 <- catchIOError (D.getModificationTime $ par "outdir" m++"/"++"index.html") handler + let abort = if(t1<t2) then [("abort","yes")] else [] + when (t1<t2) $ print "result is younger.. aborting!" + return $ M.union (M.fromList abort) m + handler e = return $ UTCTime (ModifiedJulianDay 0) 1 + -- |Creates target directory and sets basic params in map: -- TODO: cleanup! staticusPluginInit::StaticusPlugin staticusPluginInit = StaticusPlugin "init" id runIO where runIO m = do putStrLn $ "processing: " ++ par "path" m ++ " ..." - when (not isHome) (createDirectory outdir) + when (not isHome) (createDirectoryIfMissing False outdir) c <- getDirList (par "path" m) t <- getDirList (par "dir_in" m) |
