xournal-convert 0.1 → 0.1.0
raw patch · 3 files changed
+10/−29 lines, 3 files
Files
- lib/Application/XournalConvert/Job.hs +8/−27
- lib/Application/XournalConvert/ProgType.hs +1/−1
- xournal-convert.cabal +1/−1
lib/Application/XournalConvert/Job.hs view
@@ -10,7 +10,6 @@ import Text.Xournal.Parse import Text.StringTemplate--- import Text.StringTemplate.Helpers import System.Directory import System.FilePath@@ -36,27 +35,21 @@ startMakeSVG :: FilePath -> Maybe FilePath -> IO () startMakeSVG fname mdest = do xojcontent <- read_xournal fname + cdir <- getCurrentDirectory + let dest = maybe cdir id mdest - case mdest of - Nothing -> return ()- Just dest -> setCurrentDirectory dest+ -- setCurrentDirectory dest + let -- (fname_wo_ext,_fname_ext) = splitExtension fname + fnamebase = takeBaseName fname - let (fname_wo_ext,_fname_ext) = splitExtension fname let pages = xoj_pages xojcontent- names = map (svgFileName fname_wo_ext) [1..]- -- names = map (\x -> fname_wo_ext ++ show x ++ ".svg") [1..] + names = map (svgFileName fnamebase) [1..] namePages = zip names pages let Dim w h = page_dim (head pages)-- putStrLn $ " w = " ++ show w- putStrLn $ " h = " ++ show h -- let svgoutfn x = withSVGSurface (fst x) w h (\s -> renderWith s (cairoDrawPage (snd x)))+ let svgoutfn x = withSVGSurface (dest </> fst x) w h (\s -> renderWith s (cairoDrawPage (snd x))) mapM_ svgoutfn namePages-- makeHtmlJavascriptPage "index.html" $ zip [1..] (map fst namePages)- + makeHtmlJavascriptPage (dest </> "index.html") $ zip [1..] (map fst namePages) putStrLn "test ended" onePageTemplate :: String @@ -70,24 +63,12 @@ putStrLn $ "writing " ++ fname putStrLn $ show names templateDir <- getDataDir >>= return . (</> "template")- indexhtmlst <- readFile (templateDir </> "index.html.st")- -- (templates :: STGroup String) <- directoryGroup templateDir - - - let mkstr :: (Int,String) -> String mkstr (p,n) = flip render1 onePageTemplate [ ("filename", "." </> n) , ("page", show p) ] bodystr = intercalate onerule . map mkstr $ names- let str = flip render1 indexhtmlst [ ("body", bodystr) ] -- {- renderTemplateGroup - templates - [ ("body", bodystr) ] - "index.html" -}- withFile fname WriteMode $ \h -> do hPutStr h str
lib/Application/XournalConvert/ProgType.hs view
@@ -18,6 +18,6 @@ , dest = Nothing &= typ "DESTINATION" } -mode :: Xournal_convert + mode = modes [test, makeSVG]
xournal-convert.cabal view
@@ -1,5 +1,5 @@ Name: xournal-convert-Version: 0.1+Version: 0.1.0 Synopsis: convert utility for xoj files Description: convert xoj files into various formats (SVG,SVG+index.html..) Homepage: http://ianwookim.org/hxournal