-- | -- Module : Main -- Copyright : (c) OleksandrZhabenko 2022 -- License : MIT -- Stability : Experimental -- Maintainer : olexandr543@yahoo.com -- -- Simple tool to create html presentation for text. The html and css template is taken from different tutorials -- in the Internet (with changes). The idea is to post some text on the background partially transparent image. module Main where import Data.Lists.FLines (newLineEnding) import System.Environment (getArgs) import CLI.Arguments import CLI.Arguments.Parsing import CLI.Arguments.Get import Data.Monoid (mconcat,mappend) main :: IO () main = do args <- getArgs let argsB = fst . takeBsR bSpecs $ args file = mconcat . getB "f" $ argsB image = mconcat . getB "i" $ argsB header = (\ts -> if null ts then "Заголовок" else ts) . mconcat . getB "h" $ argsB top = (\ts -> if null ts then "20" else ts) . mconcat . getB "t" $ argsB right = (\ts -> if null ts then "20" else ts) . mconcat . getB "r" $ argsB paddingleftright = (\ts -> if null ts then "15" else ts) . mconcat . getB "p" $ argsB fontsize = (\ts -> if null ts then "100" else ts) . mconcat . getB "s" $ argsB opacity = (\ts -> if null ts then "0.5" else ts) . mconcat . getB "o" $ argsB width = (\ts -> if null ts then "1080" else ts) . mconcat . getB "w" $ argsB maxwidth = (\ts -> if null ts then "100" else ts) . mconcat . getB "m" $ argsB backgroundcolor = (\ts -> if null ts then "#025abb" else ts) . mconcat . getB "b" $ argsB color = (\ts -> if null ts then "#fed501" else ts) . mconcat . getB "c" $ argsB text <- readFile file let lineS = concatMap (\xs -> " " `mappend` xs `mappend` "
" `mappend` newLineEnding) . lines $ text appendFile (header ++ ".html") $ mconcat ["", newLineEnding, "", newLineEnding, "", newLineEnding, "", newLineEnding, "", newLineEnding, "", newLineEnding, "", newLineEnding, "", newLineEnding, "

", header, "

", newLineEnding, "
", newLineEnding, " ,
    show header, ", newLineEnding, "
", newLineEnding, "

", header, "

", newLineEnding, "

", newLineEnding] `mappend` lineS `mappend` mconcat ["

", newLineEnding, "
", newLineEnding, "
", newLineEnding, "", newLineEnding, "", newLineEnding, "", newLineEnding] bSpecs = zip ["f","i","h","t","r","p","s","o","w","m","b","c"] . cycle $ [1]