markup-preview 0.2.0.2 → 0.2.2.0
raw patch · 3 files changed
+28/−11 lines, 3 filesdep +textdep ~MissingHdep ~basedep ~glib
Dependencies added: text
Dependency ranges changed: MissingH, base, glib, gtk, pandoc, temporary, webkit
Files
- Application/FileHandling.hs +14/−8
- Application/GUI.hs +1/−1
- markup-preview.cabal +13/−2
Application/FileHandling.hs view
@@ -15,6 +15,8 @@ import Data.List import Data.List.Utils import Data.Maybe+ import qualified Data.Text.IO as T (readFile)+ import Data.Text (Text) detectFiletype :: FilePath -> Maybe FileType@@ -24,13 +26,13 @@ , (ReStructuredText, [".rst", ".rest", ".restx"]) ] - readResource :: FilePath -> IO String+ readResource :: FilePath -> IO Text readResource filepath = #ifdef CABAL- getDataFileName filepath >>= \filepath' -> readFile filepath'+ getDataFileName filepath >>= \filepath' -> T.readFile filepath' #endif #ifndef CABAL- readFile filepath+ T.readFile filepath #endif @@ -42,8 +44,12 @@ writeHtmlFile content = do -- make this cross OS path style handling let tempDirectory = (++ "/") . join "/" . init . split "/" $ filepath- layout <- readResource "Resources/layout.html"- let htmlContent = renderTemplate [("htmlContent", writer $ reader content)] layout- (tempFilePath, tempHandle) <- openTempFile tempDirectory "markup-preview.html"- hPutStr tempHandle htmlContent >> hFlush tempHandle- return ("file://" ++ tempFilePath)+ contents <- readResource "Resources/layout.html"+ let layout = compileTemplate contents+ case layout of+ Left s -> putStrLn s >> return "" -- return error file+ Right t -> do+ let htmlContent = renderTemplate t $ varListToJSON [("htmlContent", writer $ reader content)]+ (tempFilePath, tempHandle) <- openTempFile tempDirectory "markup-preview.html"+ hPutStr tempHandle htmlContent >> hFlush tempHandle+ return ("file://" ++ tempFilePath)
Application/GUI.hs view
@@ -53,7 +53,7 @@ createToolbar loadNotifier = do toolbar <- toolbarNew toolbarSetStyle toolbar ToolbarIcons- openButton <- toolButtonNewFromStock "gtk-open"+ openButton <- toolButtonNewFromStock stockOpen void $ onToolButtonClicked openButton $ do openDialog <- createOpenDialog dialogResponse' <- dialogRun openDialog
markup-preview.cabal view
@@ -1,5 +1,5 @@ name: markup-preview-version: 0.2.0.2+version: 0.2.2.0 synopsis: A simple markup document preview (markdown, textile, reStructuredText) description: A GUI application that renders the markup documents (markdown, textile, reStructuredText) into@@ -33,4 +33,15 @@ Application.CommandLine, Application.GUI, Application.Types- build-depends: base == 4.*, gtk, webkit, pandoc == 1.10, directory, temporary, transformers, mtl, cmdargs, MissingH, glib+ build-depends: base >= 4.6 && <= 4.8,+ gtk == 0.13.*,+ webkit == 0.13.*,+ pandoc == 1.12.* || == 1.13.1,+ directory == 1.2.*,+ temporary == 1.1.* || == 1.2.*,+ transformers == 0.3.*,+ mtl == 2.1.*,+ cmdargs == 0.10.*,+ MissingH == 1.3.*,+ glib == 0.13.0.6,+ text == 1.1.*