-- | -- 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. -- The meaning of the command line parameters by the first modifier is the following: -- -- "f" -> name of the file where the text presented is written; -- -- "i" -> path to the image file to be used; -- -- "h" -> title and the main header; -- -- "a" -> author; -- -- "p" -> width of the textual div in percentage (no % sign needed); -- -- "d" -> width of the header container in percentage (no % sign needed); -- -- "s" -> font-size in percents for text; -- -- "o" -> opacity for the image; -- -- "w" -> width of the main container; -- -- "b" -> background-color; -- -- "c" -> color; 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) import Data.List (intercalate) 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 author = (\ts -> if null ts then "Автор" else ts) . mconcat . getB "a" $ 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 widthH = (\ts -> if null ts then "10" else ts) . mconcat . getB "d" $ argsB widthP = (\ts -> if null ts then "70" else ts) . mconcat . getB "p" $ 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 -> mconcat [" ", xs, "
", newLineEnding]) . lines $ text appendFile (header `mappend` ".html") . {- mconcat $ [intercalate newLineEnding ["", "", "", "", ""], header, intercalate newLineEnding ["", ""] , author, intercalate newLineEnding ["", "", "", "", "
", "
", "
", " ", "
", "
", "
", "
", "

"] , header, intercalate newLineEnding ["

", "

",""] , lineS, intercalate newLineEnding ["

", "
", "
", "
", "", "", ""]] -} helper1 newLineEnding [header,author,width,widthH,widthP,fontsize,backgroundcolor,color,opacity,image,header,lineS] $ [ ["", "", "", "", ""], ["", ""], ["", "", "", "", "
", "
", "
", " ","
", "
", "
", "
", "

"],["

", "

",""], ["

", "
", "
", "
", "", "", ""]] bSpecs = zip ["f","i","h","a","p","d","s","o","w","b","c"] . cycle $ [1] helper1 :: [a] -> [[a]] -> [[[a]]] -> [a] helper1 delim tss@(ys:yss) zsss@(zss:usss) = mconcat [intercalate delim zss, ys, helper1 delim yss usss] helper1 delim _ (zss:usss) = intercalate delim zss helper1 _ _ _ = []