Commit 5dc11f2f authored by Andrew Gibiansky's avatar Andrew Gibiansky

mostly working, it not being updated

parent 957de8ff
...@@ -43,6 +43,4 @@ chartData renderable format = do ...@@ -43,6 +43,4 @@ chartData renderable format = do
imgData <- readFile $ fpFromString filename imgData <- readFile $ fpFromString filename
return $ case format of return $ case format of
PNG -> png width height $ base64 imgData PNG -> png width height $ base64 imgData
SVG -> html $ makeSvgImg $ base64 imgData SVG -> svg $ Char.unpack imgData
where
makeSvgImg base64data = Char.unpack $ "<img src=\"data:image/svg+xml;base64," ++ base64data ++ "\"/>"
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -145,10 +145,8 @@ interpret allowedStdin action = runGhc (Just libdir) $ do ...@@ -145,10 +145,8 @@ interpret allowedStdin action = runGhc (Just libdir) $ do
initializeImports :: Interpreter () initializeImports :: Interpreter ()
initializeImports = do initializeImports = do
-- Load packages that start with ihaskell-*, aren't just IHaskell, -- Load packages that start with ihaskell-*, aren't just IHaskell,
-- and depend directly on the right version of the ihaskell library -- and depend directly on the right version of the ihaskell library.
-- -- Also verify that the packages we load are not broken.
-- XXX this will try to load broken packages, provided they depend
-- on the right ihaskell version
dflags <- getSessionDynFlags dflags <- getSessionDynFlags
broken <- liftIO getBrokenPackages broken <- liftIO getBrokenPackages
displayPackages <- liftIO $ do displayPackages <- liftIO $ do
...@@ -157,7 +155,8 @@ initializeImports = do ...@@ -157,7 +155,8 @@ initializeImports = do
packageNames = map (packageIdString . packageConfigId) db packageNames = map (packageIdString . packageConfigId) db
initStr = "ihaskell-" initStr = "ihaskell-"
-- "ihaskell-1.2.3.4"
-- Name of the ihaskell package, e.g. "ihaskell-1.2.3.4"
iHaskellPkgName = initStr ++ intercalate "." (map show (versionBranch version)) iHaskellPkgName = initStr ++ intercalate "." (map show (versionBranch version))
dependsOnRight pkg = not $ null $ do dependsOnRight pkg = not $ null $ do
...@@ -172,8 +171,8 @@ initializeImports = do ...@@ -172,8 +171,8 @@ initializeImports = do
-- ihaskell-0.2.0.5-ce34eadc18cf2b28c8d338d0f3755502 installed. -- ihaskell-0.2.0.5-ce34eadc18cf2b28c8d338d0f3755502 installed.
iHaskellPkg = case filter (== iHaskellPkgName) packageNames of iHaskellPkg = case filter (== iHaskellPkgName) packageNames of
[x] -> x [x] -> x
[] -> error ("cannot find required haskell library: "++iHaskellPkgName) [] -> error ("cannot find required haskell library: " ++ iHaskellPkgName)
_ -> error ("multiple haskell packages "++iHaskellPkgName++" found") _ -> error ("multiple haskell packages " ++ iHaskellPkgName ++ " found")
displayPkgs = [ pkgName displayPkgs = [ pkgName
| pkgName <- packageNames, | pkgName <- packageNames,
...@@ -194,8 +193,6 @@ initializeImports = do ...@@ -194,8 +193,6 @@ initializeImports = do
displayImports = map toImportStmt displayPackages displayImports = map toImportStmt displayPackages
liftIO $ print displayImports
-- Import implicit prelude. -- Import implicit prelude.
importDecl <- parseImportDecl "import Prelude" importDecl <- parseImportDecl "import Prelude"
let implicitPrelude = importDecl { ideclImplicit = True } let implicitPrelude = importDecl { ideclImplicit = True }
......
...@@ -21,11 +21,13 @@ import qualified Data.Map as Map ...@@ -21,11 +21,13 @@ import qualified Data.Map as Map
-- IHaskell imports. -- IHaskell imports.
import IHaskell.Eval.Completion (complete) import IHaskell.Eval.Completion (complete)
import IHaskell.Eval.Evaluate import IHaskell.Eval.Evaluate
import IHaskell.Display
import IHaskell.Eval.Info import IHaskell.Eval.Info
import IHaskell.Flags import IHaskell.Flags
import IHaskell.IPython import IHaskell.IPython
import IHaskell.Types import IHaskell.Types
import IPython.ZeroMQ import IPython.ZeroMQ
import IPython.Types
import qualified Data.ByteString.Char8 as Chars import qualified Data.ByteString.Char8 as Chars
import qualified IPython.Message.UUID as UUID import qualified IPython.Message.UUID as UUID
import qualified IPython.Stdin as Stdin import qualified IPython.Stdin as Stdin
...@@ -270,7 +272,11 @@ replyTo interface req@ExecuteRequest{ getCode = code } replyHeader state = do ...@@ -270,7 +272,11 @@ replyTo interface req@ExecuteRequest{ getCode = code } replyHeader state = do
sendOutput (ManyDisplay manyOuts) = mapM_ sendOutput manyOuts sendOutput (ManyDisplay manyOuts) = mapM_ sendOutput manyOuts
sendOutput (Display outs) = do sendOutput (Display outs) = do
header <- dupHeader replyHeader DisplayDataMessage header <- dupHeader replyHeader DisplayDataMessage
send $ PublishDisplayData header "haskell" outs send $ PublishDisplayData header "haskell" $ map convertSvgToHtml outs
convertSvgToHtml (DisplayData MimeSvg svg) = html $ makeSvgImg $ base64 svg
convertSvgToHtml x = x
makeSvgImg base64data = Chars.unpack $ "<img src=\"data:image/svg+xml;base64," ++ base64data ++ "\"/>"
publish :: EvaluationResult -> IO () publish :: EvaluationResult -> IO ()
publish result = do publish result = do
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment